Emoncms Home Assistant

A post was merged into an existing topic: Home Assistant emonSD

Quick update the emoncms_history component for home assistant got accepted and is due to release in ha 0.31 (normally this weekend, guessing saturday)

Nice :thumbsup:

How does the Emoncms history component work in HA?

You specify the write api key, base url (like https://emoncms.org or your local installation), an input node id, optional scan interval and whitelisted entities in the config. Entities are like sensors for example temprature power meters etc

What it does then is every “Scan interval” seconds it will gather all whitelisted entities states (values) and try to convert it to a numeric value place it all in the json format like {entitiy1:entity1value,entitiy2:entity2value,…} and use http post using the data parameter (input api) to send the data to emoncms on the chosen input node id in the config.

That’s basically all it does and how it works.

The default scan interval is set at 30 seconds so every 30 seconds it would send data to emoncms but users can lower this value or make multiple emoncms_history sensor config’s each with their own scan interval (for example one with whitelisted entities that don’t change much with a higher scan interval and another with one that changes a lot with lower scan itnerval).

This makes it possible to send every (current) number value from components like sensors etc to emoncms to create feeds, graphs, dashboards etc for it afterwards.

So if somone has a zwave power reading outlet and uses home assistant to read its value they can send the power value to emoncms using this component. But it’s not just for power values any numeric value can be send and dashboards can be created for it or the data can be kept in feeds for historical data etc.

there currently is a bug in home assistant with the wemo insights so that it does not update the power value when it changes (it’s reported) but if that’s fixed you can create a template sensor that gets this power value and then you can add the (template) sensor to the whitelisted entities in emoncms_history component so then you can send power values from wemo insights to emoncms and don’t need any self made code to send the values to emoncms (like i did in the past).

or send the temprature data from open weather map to emoncms anything you can think of basically as long as home assistant supports it and it’s a numeric value it can be send to emoncms

1 Like

I am trying to bring in emonpi.local data in to my Home Assistant / hassio dashboard, which is running on a separate Raspberry Pi. I have been following the guide on Emoncms - Home Assistant but I keep getting an error. The Feed id of 106 is what I see when I hover over the Feed (Office Temp) within my emonpi.local

The error log states

Log Details (ERROR)
Mon Dec 09 2019 13:17:54 GMT+0000 (GMT)
HTTPConnectionPool(host='emonpi.local', port=80): Max retries exceeded with url: /feed/list.json?apikey=*my emonpi.local read API is redacted here* (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7f86639e10>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

Does anyone know what I should use in place of http://emonpi.local which I think is what the issue is?

TIA, Julian

PS: This is what my config.yaml looks like …

sensor:
  - platform: emoncms
    api_key: *my emonpi.local read API is redacted here*
    url: http://emonpi.local
    scan_interval: 300
    id: 1
    unit_of_measurement: "ºC"
    include_only_feed_id:
      - 106

.

Mmmm, never found this component before and I use HA quite a lot!!!

HA has moved on a lot since this was created so it is very possible it is now broken.

Try the IP address?

I currently post everything from EmonCMS to an ‘output’ MQTT topic which I pick up in HA.

I’m about to (over Christmas) move my HA install to a new 4Gb RPi 4 with an HDD. I’ll have a play with the node then.

Just tried it, works fine with an IP such as http://192.168.1.10

Thanks @borpin ; I have finally managed to get it to work - and for the possible benefit of others following in the future, this is what I needed to include…

sensor:
  - platform: emoncms
    api_key: XXmyAPI_read_key_redactedXX
    url: http://192.168.1.150/emoncms
    id: 1
    unit_of_measurement: "C"
    include_only_feed_id:
      - 106

For me, the inclusion of the trailing /emoncms made all the difference.

Yee Gads, this is all very exciting when I get it to work :grinning:

1 Like

There have been some changes in the Apache config so yes, sometimes you need the trailing emoncms, depends on when the install was done. It is the same for the HTTP interfacer in emonhub.

1 Like


Since January i cannot write to my emoncms
I can send by other devices but not with home assistant.
what can i do to debug?

@joyrider3774

nice one, how would you send to multiple nodes?

emoncms_history:
  api_key: 
  url: 
  scan_interval: 10
  inputnode: 2
  whitelist:
    - sensor.bedroom_bo_battery_level
emoncms_history:
  api_key: 
  url: 
  scan_interval: 10
  inputnode: 1
  whitelist:
    - sensor.openweathermap_temperature
    - sensor.openweathermap_pressure
    - sensor.openweathermap_humidity

it only send to the last node, if i swith them arround it will send to node 2

it was only made for 1 config so that explains it

@joyrider3774 any chance you will revisit it as some point?

@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