ilcato / homebridge-Fibaro-HC2

Homebridge plugin for Fibaro Home Center 2 (and Home Center Lite ...)
Apache License 2.0
65 stars 27 forks source link

Adjusting light brightness - causes multiple turnOn commands #15

Closed dgburtonbv closed 8 years ago

dgburtonbv commented 8 years ago

In iOS 10, using the new Apple Home app, when adjusting the brightness of a Dimmer via Homekit the plugin appears to be sending sending "brighten to XX%" and "turnOn" messages to HC2.

The result is the brightness jumps around a lot as the HC2 fights the conflicting messages to 1) brighten the dimmer to XX% and 2) "turnOn" the dimmer (which sets the dimmer to it's last value).

I think the solution is to just not have the plugin send the turnOn command...

Here's a screenshot of the log:

screen shot 2016-07-10 at 19 03 04
ilcato commented 8 years ago

It is the Home app that send both a turnOn command and a set value. This is not a problem. The reason why you see several seValues on the log (this is visible also on iOs 9 and from other apps) is that I'm passing directly the command from the apps to the Home Center that reacts slowly to such a request. I will try to skip some setValue commands if they are coming too fast.

ryanmaxwell commented 8 years ago

@ilcato I agree it would be useful to coalesce the brightness adjustments - dragging the slider up and down really causes a lag as the home center takes a while to respond... and then it keeps adjusting a couple of seconds after you stop interacting. The % can also jump around after you let go, as the commands may be received out of order. If you just sent the command say every second or so (and the final measurement), I think the adjustments may be smoother and not create a backed up queue of commands.

In any case I'm so thankful for your work on this project!

dgburtonbv commented 8 years ago

Thanks @ilcato - really appreciate your work on this project.

Let me know if you'd like anything tested!

ilcato commented 8 years ago

@dgburton , @ryanmaxwell , I made some optimization:

thefirst setValue is passed through
each new setValue requested in a 0,5s time frame is skipped
at the end of the 0,5s timeframe the last value is set

are you available to test the fix ?

dgburtonbv commented 8 years ago

@ilcato so I don't think this version has changed things too much - I can see that there's no longer the unnecessary "turnOn/Off" commands coming through, but if I slowly drag the brightness up and down in the iOS 10 Home app, a whole bunch of setValue commands are still sent which results in a backlog building up such that when you stop adjusting the brightness in the Home app the commands are still queued and the brightness still changes for a few seconds until the HC2 catches up.

It doesn't feel like that 0.5s timeout is working to me...

screen shot 2016-07-19 at 21 09 31

ilcato commented 8 years ago

The only real commands sent to Home Center are the one with the "Command: setValue, value: " label. If you drag the slider with a speed shown in the log (9 seconds to go from 94 to 53) and with a timeout window of half a second there's no way to filter the command. I will set the timeout window as a parameter in order for you to experiment an optimum value for it.

ilcato commented 8 years ago

I made some refactoring and removed the timeout filtering and tested on iOs 10 Beta 3. For it's working pretty well now. Can you confirm it?

dgburtonbv commented 8 years ago

Thanks @ilcato - will test and confirm shortly (I'm also on Beta 3)

dgburtonbv commented 8 years ago

Hi @ilcato - it's weird....

In terms of what is in Homebridge's log it looks better - no unnecessary turnOn events, and there seems to be the correct lag between the brightness commands.... however in Home in iOS 10 the brightness slider continues to slide up and down even after the log entries in Homebridge have stopped.

It's difficult to explain so I took this video to demonstrate it:

https://cl.ly/3t443x1j3t3S

ilcato commented 8 years ago

Does it happen also with another Homekit app?

dgburtonbv commented 8 years ago

Nope - only happens in the stock Apple iOS 10 Home app, but then that is the only Homekit app that sends commands as you're dragging the slider.

The Selfcoded "Home" app (http://selfcoded.com/home/) for example only sends the command when the slider is released...

ilcato commented 8 years ago

Try with the MyHome app

dgburtonbv commented 8 years ago

The link in your comment didn't work but assuming you mean this app - http://new.vicinno.com/ - then the behaviour there is the same as the stock Apple iOS 10 Home app - i.e. the brightness continues changing around even after you've stopped controlling it...

ilcato commented 8 years ago

Let's wait final version of iOS 10.

ilcato commented 8 years ago

@dgburton did you experiment with the latest beta of iOS 10? It seems better.

dgburtonbv commented 8 years ago

Hi - yes, it's certainly better on the latest iOS 10 beta!

ilcato commented 8 years ago

How is the result with iOs 10 production version?