seime / openhab-esphome

ESPHome native API implementation for openHAB binding
MIT License
26 stars 6 forks source link

UVI unit not supported #30

Open marcusb opened 2 months ago

marcusb commented 2 months ago

I have a device with a LTR-390 ambient light and UV sensor, and the binding it emits this warning every few seconds:

2024-09-01 21:44:17.986 [WARN ] [ernal.message.AbstractMessageHandler] - Unit 'UVI' unknown to openHAB, returning DecimalType for state '0.0' on channel 'esphome:device:mtr1:ltr390_uv_index'

I would guess it should be treated as a Number.

seime commented 2 months ago

UVI is not listed as a valid unit here: (which is linked from esphome doc): https://www.home-assistant.io/integrations/sensor/#device-class

Solution: In your esphome config, set device_class and unit to valid values. Ie setting device_class to generic_number and unit to None or empty would treat the values as pure numbers (Number) without any quanity information.

marcusb commented 2 months ago

Ok but this device (Apollo MTR-1) is built for HomeAssistant so it definitely works there. Perhaps it's sensible to default to Number for unknown units?

It would also be helpful to only warn on this once, not every few seconds.

seime commented 1 month ago

Yes the defaulting could be better. It was initially designed to make it easy to spot misconfiguration, but I guess it is too noisy ;)