# Emoncms Home Assistant

**URL:** <https://community.openenergymonitor.org/t/emoncms-home-assistant/1667>\
**Category:** Integrations\
**Tags:** homeassistant\
**Created:** [11 September 2016 12:04 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667 "2016-09-11T12:04:47Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![joyrider3774](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@joyrider3774](https://community.openenergymonitor.org/u/joyrider3774)\
**Post date:** [7 September 2021 10:42 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/23 "2021-09-07T10:42:20Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![boelle](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/boelle/32/19850_2.png) [@boelle](https://community.openenergymonitor.org/u/boelle)\
**Post date:** [8 September 2021 06:33 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/24 "2021-09-08T06:33:47Z")

</div>

that would be one way yes

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

---

<div class="post-metadata">

**Author:** ![Bill.Thomson](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/bill.thomson/32/1834_2.png) [@Bill.Thomson](https://community.openenergymonitor.org/u/Bill.Thomson)\
**Post date:** [8 September 2021 18:46 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/25 "2021-09-08T18:46:43Z")

</div>

> [@joyrider3774](#):
>
> i stopped using emoncms.

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

---

<div class="post-metadata">

**Author:** ![joyrider3774](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/j/a87d85/32.png) [@joyrider3774](https://community.openenergymonitor.org/u/joyrider3774)\
**Post date:** [9 September 2021 03:34 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/26 "2021-09-09T03:34:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![boelle](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/boelle/32/19850_2.png) [@boelle](https://community.openenergymonitor.org/u/boelle)\
**Post date:** [9 September 2021 07:58 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/27 "2021-09-09T07:58:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![boelle](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/boelle/32/19850_2.png) [@boelle](https://community.openenergymonitor.org/u/boelle)\
**Post date:** [11 September 2021 08:31 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/28 "2021-09-11T08:31:59Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![foxlees](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@foxlees](https://community.openenergymonitor.org/u/foxlees)\
**Post date:** [30 September 2021 09:12 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/29 "2021-09-30T09:12:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bwduncan](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bwduncan](https://community.openenergymonitor.org/u/bwduncan)\
**Post date:** [30 September 2021 17:55 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/30 "2021-09-30T17:55:05Z")

</div>

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:

```auto
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`.

```auto
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):

 ![image](https://community.openenergymonitor.org/uploads/default/original/3X/b/d/bd365da5fc817f923e8ea0be59b311bbde1a2467.png)

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

 ![image](https://community.openenergymonitor.org/uploads/default/original/3X/8/0/8005496ca4c30bae29176dd0e5e40c6d0c5e778f.png)

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

---

<div class="post-metadata">

**Author:** ![foxlees](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@foxlees](https://community.openenergymonitor.org/u/foxlees)\
**Post date:** [30 September 2021 19:22 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/31 "2021-09-30T19:22:55Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![foxlees](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@foxlees](https://community.openenergymonitor.org/u/foxlees)\
**Post date:** [30 September 2021 20:25 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/32 "2021-09-30T20:25:34Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![bwduncan](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bwduncan](https://community.openenergymonitor.org/u/bwduncan)\
**Post date:** [30 September 2021 21:58 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/33 "2021-09-30T21:58:38Z")

</div>

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](https://community.home-assistant.io/t/mqtt-sensor-how-to-define-last-reset-value-template/327175/13)

---

<div class="post-metadata">

**Author:** ![foxlees](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@foxlees](https://community.openenergymonitor.org/u/foxlees)\
**Post date:** [2 October 2021 19:19 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/34 "2021-10-02T19:19:43Z")

</div>

Hi Bruce here is. copy of the developer attributes:  
[sensor.energy\_consumption](http://192.168.1.158:8123/developer-tools/state#)

```auto
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

---

<div class="post-metadata">

**Author:** ![foxlees](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/f/59ef9b/32.png) [@foxlees](https://community.openenergymonitor.org/u/foxlees)\
**Post date:** [2 October 2021 19:53 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/35 "2021-10-02T19:53:32Z")

</div>

This is my configuration.yaml. entry

```auto
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

```

---

<div class="post-metadata">

**Author:** ![bwduncan](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bwduncan](https://community.openenergymonitor.org/u/bwduncan)\
**Post date:** [8 October 2021 22:33 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/36 "2021-10-08T22:33:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![TheMiddle36uug](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/t/a87d85/32.png) [@TheMiddle36uug](https://community.openenergymonitor.org/u/TheMiddle36uug)\
**Post date:** [25 November 2021 20:50 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/37 "2021-11-25T20:50:16Z")

</div>

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:

```auto
# 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:

```auto
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!

```auto
[{"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

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [25 November 2021 21:17 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/38 "2021-11-25T21:17:54Z")

</div>

> [@TheMiddle36uug](#):
>
> `url: http://192.168.9.204/emoncms`

Try the URL without `emoncms` - that works for me.

---

<div class="post-metadata">

**Author:** ![TheMiddle36uug](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/t/a87d85/32.png) [@TheMiddle36uug](https://community.openenergymonitor.org/u/TheMiddle36uug)\
**Post date:** [26 November 2021 12:34 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/39 "2021-11-26T12:34:43Z")

</div>

> [@bwduncan](#):
>
> ```auto
> template:                                                                                                                                                                                     
> # Home Energy sensors for HAEnergy                                                                                                                                                          
> - sensor:                                                                                                                                                                                   
> - name: Energy Consumption                                                                                                                                                              
> state: "{{ states('sensor.emoncms_import_kwh') | float | round(3) }}"                                                                                                                 
> unit_of_measurement: "kWh"                                                                                                                                                            
> state_class: measurement                                                                                                                                                              
> device_class: energy    
> 
> ```

That’s the one! Cheers

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [27 November 2021 08:22 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/40 "2021-11-27T08:22:01Z")

</div>

> [@TheMiddle36uug](#):
>
> That’s the one! Cheers

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

> [@bwduncan](#):
>
> `state: "{{ states('sensor.emoncms_import_kwh') | float | round(3) }}"`

`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](https://community.home-assistant.io/t/updating-templates-with-the-new-default-values-in-2021-10-x/346198))

---

<div class="post-metadata">

**Author:** ![bwduncan](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bwduncan](https://community.openenergymonitor.org/u/bwduncan)\
**Post date:** [27 November 2021 22:34 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/41 "2021-11-27T22:34:28Z")

</div>

> [@borpin](#):
>
> HA will complain after 2121.12.x.

I think I will risk waiting until nearer the time… 😆

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. 😃

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [27 November 2021 22:43 UTC](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667/42 "2021-11-27T22:43:57Z")

</div>

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).

[Previous page](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667.md?page=1)

[Next page](https://community.openenergymonitor.org/t/emoncms-home-assistant/1667.md?page=3)
