Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switching on by setLevel #221

Closed
superjunky opened this issue Aug 24, 2020 · 2 comments
Closed

Switching on by setLevel #221

superjunky opened this issue Aug 24, 2020 · 2 comments

Comments

@superjunky
Copy link

Hi,

Occasionally there is a problem with dimmers, when they are switched on by setting a new level. 50% of the time they jump back to the level when last active.

I tested the following scenario:

  • In Homekit, I switch 'off' a device with current level 50.
  • Next, when opening the device (currently 'off') and selecting a new dim value, IE level 10:
  • It results in the device switching 'on', and jumping back to the initial level 50.

This does not occur 100% of the time. If it's not reproduced the first time, repeat the above steps a couple of times to reveal the issue.

I attached a GIF to demo the issue:
Switch is 'on' at level 83.
Switch set to 'off'.
Open switch, set level 26.
Results in switch set to 'on', and level jumps to 83.

This behaviour is tested with:

Domoticz: 2020.2
Homebridge: 1.1.2
Edomoticz: 2.1.37

RPReplay_Final1598271801

@superjunky
Copy link
Author

While I think of it,
Chances are it's caused by the way Domoticz returns it's OUT-MQTT messages. The order in which the callbacks are received by Edomoticz can result in this behaviour. (The order may differ on busy moments).

Perhaps Edomoticz should filter out the callback message upon "switching on by setLevel"?

@sander1988
Copy link
Contributor

I was able to reproduce the issue. This is what causes the issue...

  1. Homekit sends the dim level.
  2. Homekit sends a power on command.

Both of these commands are send to Domoticz through this plugin. But the "set level" API call of Domoticz will also trigger a power on inside the Domoticz API. Now get's bit random (due to timing) which of the two power on commands if processed through MQTT. Sometimes it's the the one triggered by Domoticz and sometimes the on trigger by HomeKit. If the power on command from Homekit is first then Domoticz uses the old dim level in it's MQTT message as the "set level" API call isn't yet processed. I think loop protection prevents the final "set level" command from being send back to HomeBridge (through MQTT) which results in this issue.

I applied a small fix to just ignore the power on command (for 500ms) from Homekit when the device was just turned on by a dimmer command: sander1988@4ee6936

Can you test it? It now works fine in my setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants