Mqtt discovery throws exception

I am experiencing an issue with MQTT discovery - and would like some help in identifying what the issue might be.

I publish an MQTT auto-discovery message and HA throws the following exception. It works for other entities I am adding, so I am a little puzzled. Any hints or as to what is wrong - or how I can uncover the issue would be great!

Thanks

Exception in async_discover when dispatching 'mqtt_discovery_new_sensor_mqtt': ({'name': 'Spotprice Level', 'state_topic': 'energyassistant/dk2/spotprice', 'json_attributes_topic': 'energyassistant/dk2/spotprice', 'schema': 'json', 'unique_id': 'EnergyAssistant_dk2_Spotprice Level', 'device_class': 'None', 'unit_of_measurement': '', 'value_template': '{{ value_json.level }}', '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']

Can’t send null device class. Remove that key:value.

Yes, I just saw that, thanks! It was easier to read here, than in HA :slight_smile:

1 Like