Skip to content

Emoncms Integration - Null value causes error #38016

Closed
@borpin

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: 1

Traceback/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

else:
self._state = round(float(elem["value"]), DECIMALS)

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.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions