basschipper / homeassistant-generic-hygrostat

Generic Hygrostat for Home Assistant
78 stars 20 forks source link

Error doing job: Exception in callback async_track_point_in_utc_time.<locals>.run_action(<Job HassJobT...ffff764fcd30>>) at /usr/src/homeassistant/homeassistant/helpers/event.py:129 #39

Closed buhito81 closed 2 years ago

buhito81 commented 2 years ago

Running the HACS addon gives the following error on HA 2022.9.7:

This error originated from a custom integration.

Logger: homeassistant
Source: custom_components/generic_hygrostat/binary_sensor.py:188
Integration: generic_hygrostat (documentation)
First occurred: 13:39:32 (1 occurrences)
Last logged: 13:39:32

Error doing job: Exception in callback async_track_point_in_utc_time.<locals>.run_action(<Job HassJobT...ffff764fcd30>>) at /usr/src/homeassistant/homeassistant/helpers/event.py:1297
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/asyncio/events.py", line 80, in _run
    self._context.run(self._callback, *self._args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1312, in run_action
    hass.async_run_hass_job(job, utc_point_in_time)
  File "/usr/src/homeassistant/homeassistant/core.py", line 567, in async_run_hass_job
    hassjob.target(*args)
  File "/usr/src/homeassistant/homeassistant/helpers/event.py", line 1373, in interval_listener
    hass.async_run_hass_job(job, now)
  File "/usr/src/homeassistant/homeassistant/core.py", line 567, in async_run_hass_job
    hassjob.target(*args)
  File "/config/custom_components/generic_hygrostat/binary_sensor.py", line 148, in _async_update
    self.update_humidity()
  File "/config/custom_components/generic_hygrostat/binary_sensor.py", line 188, in update_humidity
    self.sensor_humidity = float(sensor.attributes[self.sensor_attribute])
KeyError: 'humidity'
basschipper commented 2 years ago
perryodk commented 2 years ago

@buhito81 Experienced the same error which is logged to the Home Assistant logging every x seconds as per the configured sample interval. I fixed it by commenting out the line: attribute: humidity # Optional use sensor attribute instead of state.

My humidity sensor doesn't contain an attribute for humidity however the state of the sensor itself contains the humidity in %.

basschipper commented 2 years ago

So it was just a configuration mistake?

buhito81 commented 2 years ago

So it was just a configuration mistake?

No, I think this indicates that the addon can't take a sensor that has the forementioned attribute humidity. So actually I think its a bug (or a lack of documentation saying that the sensor can't have the humidity attribute)

basschipper commented 2 years ago

So because your sensor doesn't have an attribute humidity but you configured it anyway and the addon throws an error (to inform you about that) it's therefore a bug?

Sorry but this is all basic Home Assisstant stuff, sensors have a state and can have attributes.

Configuring an attribute as source sensor was added as a (optional) feature https://github.com/basschipper/homeassistant-generic-hygrostat/pull/27 so you no longer needed a template https://www.home-assistant.io/docs/configuration/templating/ to use a sensors attribute.

Anyway, you can always file a PR if you want to add improvements of course, it's open source... :)