EmonCms feed sensors component

Hi guys,

Last night i created a new component for home assistant that reads the feed values from emoncms using the feed api. I only tested it against my local version of emoncms and did not try it against the cloud based version. If the feed api did not change it should work.

i’ve uploaded the sensor component as well as a few quick examples to github and created a Pull request

It was already possible to use the feed api directly using a rest sensor but this sensor component can get all feeds as a sensor by just suppling the emon cms read api key as well as the url (for their local or cloud based) emoncms.

It’s also possible to display all feeds with exclusions as well as only display sensors based on a feed id list (this last option is probably the best to go if you have many feeds as i did).

By default the unit_of_measurement is set to “W” and all sensors have funky names but you can change them individually using the customize section.

It’s also possible to reference the same emoncms instance multiple times .for example if they use diffrent measurement unit, then you can combine all feeds that use the same unit in one entry in your configuration.

i only tested it rather quickly with me locally though as i did it overnight, did not sleep and had to go to work :wink:


I was thinking about doing this. You beat me to it.
I will test it out with my emoncms install and let you know how it goes.

It seems the scan_interval setting does not work as it should as it’s updating the sensors more then it should.

I’ve added some code changes already but i can only commit once i’m home. it should not interfere with the workings though, it just that it might poll a bit too much at the moment with the current version

I think that we should include your sensor platform into Home Assistant. Have you though about to open PR? Of course there is still a little bit of work needed but there is already documentation and code works :slight_smile:

Just a couple of quick comments:

  • Line 45: would be simpler to just use string formatting
  • Line 69: if you call data.update() you can make sure that the URL and the API key are valid through catching the exception. If they are not, make the setup of the platform fail.
  • Line 60 - 67: can be removed. voluptuous is taking care that apikey and url are present
  • Line 191: looks like a debug output
  • Line 193: add a timeout (I guess that 5 seconds are enough) to the request

Hi @fabaff it is indeed my intention to create a PR but as i did not test it a lot and i’m still making changes to it i did not do so immediatly. I also posted on the emoncms forums in the hope that somone uses home assistant as well there to test. But i guess @tinglis1 can also test.

I just did another commit these are the changes:

  • fixed scan interval not working properly by switching to “track_point_in_utc_time” system and set default interval to 60 seconds
  • use new naming scheme for the sensors. They will be named emoncms[sensorid]_feedid_[emoncmsfeedid] to better recognize them
  • added option to specify customn names for the sensors using the “include_feed_id_names” list when “include_feed_id” is used. The list may contain less values then include_feed_id, the remaining values will use the above mentioned naming scheme then

i’ll check your remarks and see if i can fix them but it could be you’ll have new remarks based on my last push.

edit: just fixed your remarks

I have set this up with my emoncms install which is running under a docker install.

I am only pulling one feed id using the include feature and it seems to be working correctly for me.

Hi tinglis,

Thats great, thanks for testing… May i know which version of emoncms you are currently running ?

I know the latest at the moment is Emoncms 9.7.2 | 2016.07.04 , my local install is still running 9.3 | 2015.12.30.

When i get home tonight i’ll try the cloud version by creating an account for testing purposes.

I’ve also ran out of idea’s on things to add so when i address one more issue (bug dealing with the new include_feed_id_names feature) in the code then i’ll start an Pull request.

I am running 9.7.2 under a docker install.
It is pretty much stock standard except that the url and port differ to what most people use for emoncms.

I have used emoncms for a while now for capturing inputs from sensors that I build myself such as pulse counting on my power meter. I would like to get it going with my water meter and gas meter but have yet to find a reliable way to capture the pulses for my meters.

I used to use openhab and push the data for my sensors (zwave power etc.) out to emoncms for charting and long term storage. I haven’t done that with HA yet but given there is little or no long term sensor data in HA I am thinking this may be my next step in this area. Not sure if that is something that could be added to this component or a separate one.

Nice so the feed api has not changed in latest version good to know :slight_smile:

i’m affraid i don’t really understand what you’d like to be added in this (or a new) component…

One thing i was thinking on that i could add was also displaying sensors for the input’s (instead of only feeds) but i’m not certain if that’s a good idea, since it’s just the unprocessed raw data so i thought feeds would be a better idea, not sure what you think about having input’s as sensors as well in home assistant ?

I’m using emoncms to capture my electricty use from appliances using wemo insight switches and some other obscure energy meter plugs. What i did was created an intermediatry program (Wemo_Insight_Emoncms ) for my wemo insights and modified one (plugctl) for my other (aldi) plugs . The program reads the values from the plugs on some way and then pushes the data using input api to my emoncms installation. it’s been working well like this for months. I have multiple dashboards for each plug giving me the costs / watt usuage / kwh/d etc

I also used to use it to capture my intel nuc cpu / ram / disk info again by using an extra program that gets the data and sends it to emoncms using input api. But home assistant’s system monitor is better for that.

Lastly i own a few wirelesstags and created a kumo app (it’s a javascript based) on their cloud server and send all the tags information to my emoncms using input api. But the wireless tags don’t seem reliable since yesterday my pir sensor can’t seem to communicate with the tag manager anymore and it’s less then a year old !

I had created a temp logger as well as a pir sensor myselve that works using Adafruit HUZZAH ESP8266 Breakout but my main problem always is that it used to much power so running on batteries wont work that long, problem might also be using the huzzah that in itselve draws some power even in deep sleep and i never tried a non breakout version of the ESP8266. Don’t know much about electronics i only experimented a little bit with it though but then i found those wirelesstags which have great battery life but it’s all cloud based unfortunatly. using a raspberry pi hooked up to a power outlet is not something i want to do just for a pir or temp sensor

just tested against the cloud based version (url=https://emoncms.org) and it also works. Won’t be long for the PR then

As reference: