thejeffreystone / hassio_addons

Apache License 2.0
48 stars 29 forks source link

MQTT discovery error on latest - Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt #44

Open convicte opened 1 year ago

convicte commented 1 year ago

Hi @thejeffreystone

If I am not mistaken, you may have added ['expire_after'] to this add-on (from the Accurate version) that has no call in the config, but is reported as an error:

Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'name': 'Bresser 7in1 43807 uv', 'unit_of_measurement': 'UV Index', 'value_template': '{{ value|int }}', 'state_topic': 'rtl_433/Bresser-7in1/43807/0/uv', 'unique_id': 'rtl433sensor43807uv', 'availability_topic': 'rtl_433/status', 'expire_after': 'null', 'last_reset': 'homeassistant.util.dt.utc_from_timestamp(0)', 'state_class': 'measurement', 'device': {'identifiers': '43807', 'name': '43807', 'model': '7in1', 'manufacturer': 'Bresser'}, 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 331, in async_discover config: DiscoveryInfoType = discovery_schema(discovery_payload) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 232, in call return self._exec((Schema(val) for val in self.validators), v) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 355, in _exec raise e if self.msg is None else AllInvalid(self.msg, path=path) File "/usr/local/lib/python3.10/site-packages/voluptuous/validators.py", line 351, in _exec v = func(v) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in call return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 818, in validate_callable return schema(data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 272, in call return self._compiled([], data) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 595, in validate_dict return base_validate(path, iteritems(data), out) File "/usr/local/lib/python3.10/site-packages/voluptuous/schema_builder.py", line 433, in validate_mapping raise er.MultipleInvalid(errors) voluptuous.error.MultipleInvalid: expected int for dictionary value @ data['expire_after']

image

Could you advise what to do in this situation? I was trying to add it manual in yaml config, to see if it's going to be a workaround for the moment, but this didn't work.

Thank you in advance!!

convicte commented 1 year ago

image

convicte commented 1 year ago

Going back to ver. 0.1.15b clears the problem entirely so the above seems to be specifically related to the update. This said, it didn't trigger as an issue for me until I restarted my HA, and it was attempting a fresh discovery in MQTT.

thejeffreystone commented 1 year ago

roof, that restart must have been why I didn't catch it in my dev box.

Pushing fix now.

convicte commented 1 year ago

Just installed ver.0.1.17b and the issue of the MQTT messages causing an error has been resolved.

Is this to be used in the same way as in the accurite2mqtt, where the config calls for: Option: expire_after This is an integer value that will set an individual sensor entity to unknown if no payload is received within the specified seconds. The default value of 0 disables this feature.

In other words, if I set it to 30 and no payloads are received for an entity for 30 seconds, it will go unavailable? At this time, I am using the last seen as the proof of life to reboot the add-on and SDR every time it dies.

Thank you for all your efforts on this - it's a great thing to have!

thejeffreystone commented 1 year ago

Right yeah, that is so you could set a value and the sensor will to unknown after a set period. 0 disables it.

I'll get it added to the config. Just too trying to go too fast.