Closed JoniR closed 2 weeks ago
Thanks for feedback. I will check & fix. After the summer holidays.
In hadiscovery.py
changed elif d["unit_of_measurement"] == "V": d["device_class"] = "V" To elif d["unit_of_measurement"] == "V": d["device_class"] = "VOLTAGE" And the issue is fixed, the entities also show up in HA now
v4.0.1
Description: Home Assistant's auto-discovery feature does not accept 'device_class': 'V' for voltage sensors. The correct device class for voltage should be 'voltage' as per the Home Assistant documentation. This discrepancy prevents voltage sensors from being automatically discovered.
Steps to Reproduce:
Configure an MQTT sensor with the following parameters:
Publish the MQTT discovery message to the topic homeassistant/sensor/dsmr/V1/config.
Observe the error in the Home Assistant logs.
Expected Behavior: The voltage sensor should be automatically discovered and added to Home Assistant without any errors.
Actual Behavior: An error is logged, and the voltage sensor is not discovered.
Error Log:
Error 'expected SensorDeviceClass or one of 'date', 'enum', 'timestamp', 'apparent_power', 'aqi', 'atmospheric_pressure', 'battery', 'carbon_monoxide', 'carbon_dioxide', 'conductivity', 'current', 'data_rate', 'data_size', 'distance', 'duration', 'energy', 'energy_storage', 'frequency', 'gas', 'humidity', 'illuminance', 'irradiance', 'moisture', 'monetary', 'nitrogen_dioxide', 'nitrogen_monoxide', 'nitrous_oxide', 'ozone', 'ph', 'pm1', 'pm10', 'pm25', 'power_factor', 'power', 'precipitation', 'precipitation_intensity', 'pressure', 'reactive_power', 'signal_strength', 'sound_pressure', 'speed', 'sulphur_dioxide', 'temperature', 'volatile_organic_compounds', 'volatile_organic_compounds_parts', 'voltage', 'volume', 'volume_storage', 'volume_flow_rate', 'water', 'weight', 'wind_speed' for dictionary value @ data['device_class']' when processing MQTT discovery message topic: 'homeassistant/sensor/dsmr/V1/config', message: '{'unique_id': 'V1', 'state_topic': 'dsmr/el', 'unit_of_measurement': 'V', 'value_template': '{{ value_json.V1 }}', 'device_class': 'V', 'icon': 'mdi:gauge', 'device': {'identifiers': ['dsmr']}, 'name': 'Voltage L1', 'platform': 'mqtt'}'