Emoncms Home Assistant

@boelle no chanse of revisiting, i stopped using emoncms. However having only one input node is not a problem, as you normally create feeds out of certain inputnode’s data inside emoncms anyway or at least should. So you can just put everything in a single inputnode and then create feeds from it inside emoncms

that would be one way yes

i’m just an old fart that is used to keep everything seperate all the way

@joyrider3774, did you switch to something else or stop monitoring altogether?

stopped monitoring. I can not use a system that hooks into the fuse box well those special cables with clamps, don’t know what they are called as i live in a rental appartment and don’t have any outlet near the fuse box nor have access to the cables where the clamps would need to go. So i had put all kind of smart energy monitoring plugs in the outlets in the wall like wemo insight and such but i found it too finicky and had to intervene too much to my liking to fix things, so stopped doing it all togheter. Also wemo insights as far as i’m aware are not sold anymore.

i know the pain with rental, i also gave up on that part (electricity) and soon after the electricity company provided daily online readouts, i could pay for hourly but found out it was updated daily so was a waste of money. soon after the districtheating was added to the same system

but getting my own house i would like to add things as i settle in. sending it all as one node is one way yes

but still i would like to keep it all seperate from the source

oh well

i found out it can be done with rest command and automations
got a working setup and just need to dublicate for each node

Has anyone managed to get the EMON interfaced into the new Energy Monitor in Home assistant can’t seem to get it to pick up a consumption input, has anyone had any luck

1 Like

Yes. This should probably be a new topic, but:

You need energy feeds in emoncms which you can access in homeassistant somehow. I’m using the emoncms component like this:

sensor:
  - platform: emoncms
    url: http://localhost/emoncms
    id: 1
    api_key: !secret emoncms

with the api key in secrets.yaml, obviously. I have quite an old HA installation so I’m still using configuration.yaml. I suspect adding the emoncms component through the GUI is trivial.

Then use the template component to create sensors with the right state_class and device_class.

template:                                                                                                                                                                                     
  # Home Energy sensors for HAEnergy                                                                                                                                                          
  - sensor:                                                                                                                                                                                   
      - name: Energy Consumption                                                                                                                                                              
        state: "{{ states('sensor.emoncms_import_kwh') | float(none) | round(3) }}"                                                                                                                 
        unit_of_measurement: "kWh"                                                                                                                                                            
        state_class: measurement                                                                                                                                                              
        device_class: energy                                                                                                                                                                  
      - name: Energy Return to Grid                                                                                                                                                           
        state: "{{ states('sensor.emoncms_export_kwh') | float(none) | round(3) }}"                                                                                                                 
        unit_of_measurement: "kWh"                                                                                                                                                            
        state_class: measurement                                                                                                                                                              
        device_class: energy                                                                                                                                                                  
      - name: Energy Solar Production                                                                                                                                                         
        state: "{{ states('sensor.emoncms_solar_energy') | float(none) | round(3) }}"                                                                                                               
        unit_of_measurement: "kWh"                                                                                                                                                            
        state_class: measurement                                                                                                                                                              
        device_class: energy                                                                                                                                                                  

At first you had to mess with last_reset_value attributes or something. It’s possible that I did something with those that makes it all work now, but I believe that requirement was removed in the latest HA, so you shouldn’t need to worry about it.

For reference, here are the feeds I have set up on my power1 input (that’s connected to the grid circuit):

Then in HA you need to tell it to use the new feeds:

I always had a solar_energy feed so I just told it to use that.

Anyway, I hope that helps. If you want actual help you’ll have to share your setup, the configuration settings and the errors you’re seeing.

Bruce

[edited by MOD] - added in float default value none required from HA version 2021.12.x

Thanks Bruce for your prompt very helpful response, I do have emoncms configured, in my configuration.yaml as follows
platform: emoncms
api_key:87608760876806086
url: https://emoncms.org
id: 1
I use MQTT to to create the entities via the emonpi MQTT output.

I will add the consumption entry you suggest above and see if that works.

I have added the config has not made any difference when trying to add the Energy consumption Energy Grid under ADD Consumption it states " No matching statistics found"
he new sensor is created though, and the entity is there with the correct information.

Haha no worries. Promptness was just your good luck that I happened to visit this forum.

Can you look at the developer tools->states and find the attributes of your consumption entity? it should have things like state_class: total_increasing and device_class: energy. Paste a screenshot here if you can.

Hmm, if it’s MQTT then that sounds a bit like the last_reset_value_template problem. I presume you’re using the latest HA release?

Also perhaps try here: MQTT Sensor : how to define last_reset_value_template - #13 by Mariusthvdb - Configuration - Home Assistant Community

Hi Bruce here is. copy of the developer attributes:
sensor.energy_consumption

Energy Consumption 5066.1
 state_class: measurement
 unit_of_measurement: kWh
 friendly_name: Energy Consumption device_class: energy

yes latest version
I will have a look at the reset value as you suggested

This is my configuration.yaml. entry

sensor:
  platform: emoncms
  api_key: 77d93eecdedc9333865b03f882e1cce0
  url: https://emoncms.org
  id: 1
  
template:                                                                                                                                                                                     
  # Home Energy sensors for HAEnergy                                                                                                                                                          
  - sensor:                                                                                                                                                                                   
      - name: Energy Consumption                                                                                                                                                              
        state: "{{ states('sensor.castlehill_main_power_feed') | float | round(3) }}"                                                                                                                 
        unit_of_measurement: "kWh"                                                                                                                                                            
        state_class: measurement                                                                                                                                                              
        device_class: energy

Oh that’s interesting. Mine look similar, however I’ve just noticed that the 2021.10.0 release of home assistant improves the emoncms integration to hopefully make this a bit simpler. Could you upgrade and try again?

Hi, banging my head against the wall here.

Fresh install of Home Assistant this evening, but unable to get the EmonCMS integration to work.

To my configuration.yaml I have added:

# Energy Monitoring from EmonCMS
sensor:
  - platform: emoncms
    api_key: my_read_api_key
    url: http://192.168.9.204/emoncms
    id: 1

Although I can access my emonPi at the IP above in my browser I see in the logs:

HTTPConnectionPool(host='192.168.9.204', port=80): Max retries exceeded with url: /emoncms/feed/list.json?apikey=**hidden_API_key** (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x70ea3e98>: Failed to establish a new connection: [Errno 113] Host is unreachable'))

Annoyingly, when I access the URL that HomeAssistant is trying to access, complained about in the log, I return the JSON data without issue!

[{"id":"1","userid":"1","name":"power1","datatype":"1","tag":"emonpi","public":"0","size":"121840","engine":"5","processList":"","unit":"","value":447,"time":1637873509,"start_time":1613473130,"interval":10},{"id":"2","userid":"1","name":"power_kwh","datatype":"1","tag":"emonpi","public":"0","size":"121836","engine":"5","processList":"","unit":"kWh","time":1637873509,"value":6154.873788256,"start_time":1613473140,"interval":10},{"id":"3","userid":"1","name":"Cost","datatype":"1","tag":"Virtual","public":"0","size":"0","engine":"7","processList":"53:1,2:0.0001567","unit":"\u00a3","time":1637873514,"value":0.0700449,"start_time":0,"interval":1}]

Can anyone tell me where I’ve gone wrong?

Thanks,
Nick

Try the URL without emoncms - that works for me.

That’s the one! Cheers

1 Like

Ah, it wasn’t that the integration wasn’t working, but that the data was not appearing in the Energy dashboard.

float will shortly require a default value - e.g. float(0). HA will complain after 2121.12.x.

Just to note that the docs do not currently reflect this requirement (Discussion here Updating Templates with the new default values in 2021.10.x - Configuration - Home Assistant Community)

I think I will risk waiting until nearer the time… :laughing:

But you are right, it is important to use float(default=none) or else you might end up with horrible spikes to zero if the sensor is unavailable. It looks like I can’t edit my post, presumably because it’s too old. Feel free to do it for me Mr Admin. :smiley:

1 Like

You probably know this, but for others, you can just use float(none).

If the calculation fails, you just get a none returned (rather than a zero).

1 Like