Community
OpenEnergyMonitor

OpenEnergyMonitor Community

Home Assistant integration not working

For some reason my emonCMS integration in to Home Assistant has stopped working, and I can’t work out why.

In the HA instructions it says to use a url of http://x.x.x.x/emoncms if using a self hosted EmonCMS (which I do). But if I type http://192.168.2.50/emoncms into my browser I get an error

## 406 Not Acceptable

URI not acceptable. **Emoncms** cannot respond to **""**.

Try another link from the menu.

No emon sensor devices / entities show up in HA. I have treble checked my config.yaml and secrets.yaml files, and am using the correct Write API.

Any thoughts?

TIA

sensor:

    - platform: emoncms
      api_key: !secret emoncmsapi
      url: http://192.168.2.50
      id: 1
emoncmsapi: 7901...REDACTED....d9e135

Hi,

this is what I have in config.yaml I did not put anything in secrets.yaml
note HA does not like blank lines in the file

sensor:
  platform: emoncms
  api_key: "redacted"
  url: http://192.168.1.19/emoncms
  id: 1

John

[edited by Mod]
@JJC
For future reference, when posting code or bash output, please put in 3 ‘backticks’ (found at the top left of the keyboard normally) on a line on their own, then the code, then 3 more backticks on a line following the code.

    ```
    code
    ```

If it is something like php you can add a language identifier that after the first 3 backticks so ```php

Thanks @JJC ; it is still not working, but looking in /config/home-assistant.log there are a load of issues which all look more involved than I am comfortable with.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/emoncms/sensor.py", line 112, in setup_platform
    EmonCmsSensor(
  File "/usr/src/homeassistant/homeassistant/components/emoncms/sensor.py", line 157, in __init__
    self._state = round(float(elem["value"]), DECIMALS)
TypeError: float() argument must be a string or a number, not 'NoneType'

I deleted all reference to emoncms and re-started HA, and the above errors were not present. But re-entering the emoncms details and back the error came. No idea why …

Even nuking my HA completely, and starting with a vanilla installation, when I add emoncms I get this error in the logs.

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 205, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/components/emoncms/sensor.py", line 112, in setup_platform
    EmonCmsSensor(
  File "/usr/src/homeassistant/homeassistant/components/emoncms/sensor.py", line 157, in __init__
    self._state = round(float(elem["value"]), DECIMALS)
TypeError: float() argument must be a string or a number, not 'NoneType'

So I don’t think it is me or a conflict with another component.

Hi,

did you copy my text in exactly with no blank lines and no leading - before the platform.
I found if it was not exactly correct it would not work though did not show any error during boot up.

John

Is HA fully up to date?

To be fair, I do say ‘may’ in the instructions :grinning:

Try just the IP (with HTTP).

The code is expecting a numeric value and it seems it isn’t getting one. It has already checked that the value is not none so this shouldn’t happen.

Try specifying a specific Feed to see if that cures it.

  include_only_feed_id:
    - 75
    - 97

Many thanks all; replying to several points raised …

  • Yes, I did enter exactly that text (changing IP address, and no surrounding the Read API with “”; I think I need to put a leading - character in from of the platform line (and re-indent the following lines) as I also have other sensors under sensor
  • HA is fully up to date (well, 2021.4.5 actually, but about to update to 2021.4.6)
  • http://192.168.2.50 and http://192.168.2.50/emoncms work (but to be fair the latter did work a couple of weeks ago).
  • Where do I find a feed_id? Can I use a feed name (ie O2-Office for example)? I don’t see where my feeds have numbers.

My emonCMS integration did work, so either I or HA has broken something somewhere …

TIA

In Emoncms, mouse over the feed name and you will get the ID.

Interesting - could easily be an HA change.

It does depend if you split up your yaml into separate files. If you have a sensor file, you do not need the sensor line, but the indenting changes. You do need the ‘dash’ in from of platform - suprised you did not get an error when you did a check config in HA.

Actually I think the ‘minimal’ config in the HA docs is wrong.

1 Like

Hmmm, going the whole hog and throwing in lots of lines, and it works!

sensor:
  platform: emoncms
  api_key: 79REDACTED135
  url: http://192.168.2.50/emoncms
  id: 1
  unit_of_measurement: "kW"
  include_only_feed_id:
    - 209
    - 305

I will now play around with tweaking it as in an ideal world I won’t have to list each and every feed_id as I have so many - but will if necessary.

Many thanks - one happy bunny! :+1:

If you specify the Unit in Emoncms for each feed, then the HA integration will pick it up from there.

1 Like