fmartinou / tydom2mqtt

Deltadore Tydom to MQTT Bridge
https://fmartinou.github.io/tydom2mqtt/
MIT License
86 stars 49 forks source link

fix unknown sensor class #52

Closed CyrilP closed 1 year ago

CyrilP commented 1 year ago

door status doesn't work anymore in Home Assistant because of an unknown device class. list of available classes : https://www.home-assistant.io/integrations/sensor/

fmartinou commented 1 year ago

Hi,

Hi @CyrilP, thank you very much for contributing 👍 .

As I'm always thrilling when I have to remove some code (and I don't own the required hardware to test by myself)... can you provide some additional details/context to your changes, please?

Is this bug present from the beginning of the project? Or is this a bug that appeared from a particular version of tydom2mqtt or home-assistant? What is the behavior before the fix? What users are concerned? What will be the behavior after the fix?

Thank you very much!

CyrilP commented 1 year ago

The problem appeared recently (a few weeks ago). probably with the update to the latest HA version. (I'm using HA 2022.10.5)

the sensor went to the 'unavailable' state and HA logs show the following error :

 Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'name': 'openState_tydom__Porte_1', 'unique_id': 'openState_tydom_1604473848_1604473848', 'device_class': 'door', 'device': {'manufacturer': 'Delta Dore', 'model': 'Sensor', 'name': 'openState_tydom__Porte_1', 'identifiers': '1604473848_1604473848_sensors'}, 'state_topic': 'sensor/tydom/openState_tydom_1604473848_1604473848/state', 'platform': 'mqtt'},) Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/mqtt/mixins.py", line 315, in async_discover config = 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 SensorDeviceClass or one of 
 'apparent_power', 'aqi', 'battery', 'carbon_monoxide', 'carbon_dioxide', 'current', 'date', 'distance', 'duration', 'energy', 'frequency', 'gas', 
 'humidity', 'illuminance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'pm1', 'pm10', 'pm25', 'power_factor', 
 'power', 'pressure', 'reactive_power', 'signal_strength', 'speed', 'sulphur_dioxide', 'temperature', 'timestamp', 'volatile_organic_compounds', 
 'voltage', 'volume', 'weight' for dictionary value @ data['device_class'] 
fmartinou commented 1 year ago

Thanks for the precisions 👍

fmartinou commented 1 year ago

Released with 2.6.2