icanos / hassio-plejd

Hass.io add-on for Plejd home automation devices
Apache License 2.0
126 stars 37 forks source link

Min brightness not handled correctly #255

Open SweVictor opened 1 year ago

SweVictor commented 1 year ago

For the longest time, I've had issues with lamps misbehave when using transitioning.

After a long session of debugging, I've realized that the core issue is that representation of minimum brightness differs between HA and Plejd.

HA treats brightness = 0 as "off" whereas Plejd treats brightness = 0 as "on, minimum brightness".

The issue seen when transitioning (to 0) in my case shows up when previous brightness was "minimum". Instead of transitioning from "minumum" to "0" the end result currently is that transitioning happens from "full brightness" (ON without any brightness value) and "0".

A side note when debugging this is that all (of my) 0-100% Lovelace sliders send the minimum brightness=3, not 1 as could be expected. The reason for this is that the same logic is applied HA-side: 0% = off, 1% => round(255*1/100) = 3. Quite annoying to be honest, but something to solve on the HA side.

I'm working on an update that simply replaces 0 <=> 1 when translating between Plejd <=> HA. Since the precision is only 0..255 / 1..255 I don't think scaling the values is a good idea.