#How to set the unit for an MQTT illuminance sensor that cannot be converted to lx?

1 messages · Page 1 of 1 (latest)

silver summit
#

My light sensor is DIY-built using cheap electronic components and lacks a reference, so I cannot convert the electrical units to lx. I tried using ⁨⁨%⁩⁩ as the unit, but I received the following error:
⁨⁨```
Error 'The unit of measurement % is not valid together with device class illuminance' when processing MQTT discovery message topic: 'homeassistant/sensor/bedroom_light_sensor/config', message: '{'state_topic': 'homeassistant/sensor/bedroom_light_sensor/state', 'unique_id': 'bedroom_light_sensor_light', 'device_class': 'illuminance', 'unit_of_measurement': '%', 'value_template': '{{ value }}', 'device': {'identifiers': ['bedroom_light_sensor'], 'model': 'ESP8266 AO Sensor', 'name': '卧室光传感器'}, 'name': '卧室光传感器'}'

If I don't set unit, I will get a warning.
⁨⁨```
Entity sensor.wo_shi_guang_liang_chuan_gan_qi (<class 'homeassistant.components.mqtt.sensor.MqttSensor'>) is using native unit of measurement 'None' which is not a valid unit for the device class ('illuminance') it is using; expected one of ['lx']; Please update your configuration if your entity is manually configured, otherwise create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+mqtt%22
```⁩⁩
Is there a way to set a physically meaningful unit without triggering errors or warnings?
tropic seal
#

Yes, don’t use a device class. If you set device class to illuminance, the units must be lx or you will get errors.