PatchworkBoy / homebridge-edomoticz

Domoticz Homebridge-Plugin
Other
118 stars 43 forks source link

dimmer setting on and value 0 #252

Open akamming opened 1 year ago

akamming commented 1 year ago

Hi,

1st of all: tx for this great peace of software. I am a very happy user...

I just found one issue, which was present in domoticz as well, but is now fixed in domoticz. But still present in thi homebridge plugin:

A dimmer should be able to be have a state "on", but with brightness value "0". In domoticz this works, but in this plugin, when the brightness is set to 0, it ignores this value and leaves it on the latest brightness setting.

e.g. dimmer is on, with brightness value 27.

Can this be fixed?

PatchworkBoy commented 1 year ago

I don't have ANY dimmers in Domoticz that I can set brightness to 0% without them tallying automatically over to "Off"... unless this is a behaviour change in the latest version of Domoticz (which I'm yet to update to).

PatchworkBoy commented 1 year ago

Righty... yes, domoticz allows in latest version.

Not a simple fix and will require a rework of all the dimming features in homebridge-edomoticz... which has a knock on effect on anything else that can set a percentage level. This will only be fixed if someone else undertakes the work.

akamming commented 1 year ago

This will only be fixed if someone else undertakes the work.

can you point me a bit in the right direction? i'm not a very experienced programmer, bit I can take a look....

PatchworkBoy commented 1 year ago

Modifications required around...

akamming commented 1 year ago

i will take a look,. might take some time with my programming skills ;)

akamming commented 1 year ago

hmm... gonna need some more help, cause i don't understand the program logic.

I started with these corrections (make sure brightness is still set to 0 when value = 0 in the cachedVariables):

290c290
<             // if (value > 0) {
---
>             if (value > 0) {
292c292
<             // }
---
>             }
1114c1114
<                             // if (level > 0) {
---
>                             if (level > 0) {
1119c1119
<                             // }
---
> 

but now dimmer goes to 100% in homekit when set to zero. So probably cached vars are presented to homekit somewhere in the code and there there's some conversion as well (i assume, but i want to check). Where can i find that code?

EDIT: Did some more investigation: i think the issue is in homekit. Cause in homebridge an dimmer with value on and brightness 0 is presented as just "on" (no brightness shown in the ui). In homekit it is changed to "100%".