Closed
Description
The problem
A user reported seeing this error on the OEM Forum.
On checking they discovered that one of the Feeds had a Null value. When removed the error stopped.
Tested myself to confirm.
The code should check for a valid value before converting.
Environment
- Home Assistant Core release with the issue: 0.112.4
- Last working Home Assistant Core release (if known):
- Operating environment (OS/Container/Supervised/Core): Supervised
- Integration causing this issue: Emoncms
- Link to integration documentation on our website: https://www.home-assistant.io/integrations/emoncms/
Problem-relevant configuration.yaml
sensor:
platform: emoncms
api_key: API_KEY
url: 192.168.1.10
id: 1Traceback/Error logs
File "/usr/src/homeassistant/homeassistant/components/emoncms/sensor.py", line 160, in __init__
self._state = round(float(elem["value"]), DECIMALS)
TypeError: float() argument must be a string or a number, not 'NoneType'Additional information
core/homeassistant/components/emoncms/sensor.py
Lines 159 to 160 in 6ea5c8a
A check is needed to ensure the elem["value"] is valid and set sensor as unavailable if not.
My Python is not good enough to know what should be done to avoid this error being generated.