homebridge-edomoticz icon indicating copy to clipboard operation
homebridge-edomoticz copied to clipboard

dimmer setting on and value 0

Open akamming opened this issue 2 years ago • 6 comments

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.

  • In domoticz: brightness changes to 10 --> in homekit: The brightness goes to 10 (correct!)
  • In domoticz: brightness changes to 0 (while leaving the light on) --> in homekit: light remains on, but also brightness remains 10 (incorrect!)

Can this be fixed?

akamming avatar Dec 19 '22 07:12 akamming

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 avatar Dec 19 '22 11:12 PatchworkBoy

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.

PatchworkBoy avatar Dec 19 '22 11:12 PatchworkBoy

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....

akamming avatar Dec 19 '22 12:12 akamming

Modifications required around...

  • https://github.com/PatchworkBoy/homebridge-edomoticz/blob/9e08e09e93204da05aa8c2df7ba30eaf1be13982/lib/domoticz_accessory.js#L290
  • https://github.com/PatchworkBoy/homebridge-edomoticz/blob/9e08e09e93204da05aa8c2df7ba30eaf1be13982/lib/domoticz_accessory.js#L1089
  • https://github.com/PatchworkBoy/homebridge-edomoticz/blob/9e08e09e93204da05aa8c2df7ba30eaf1be13982/lib/domoticz_accessory.js#L1758 (fan speed % uses same handler, as does anything that sets by % such as volume...)
  • and probably a few other places that those all lead on to!

PatchworkBoy avatar Dec 19 '22 13:12 PatchworkBoy

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

akamming avatar Dec 20 '22 09:12 akamming

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%".

akamming avatar Dec 27 '22 07:12 akamming