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

Save light state changes when light is off #40

Closed
ebaauw opened this issue Jan 6, 2017 · 4 comments
Closed

Save light state changes when light is off #40

ebaauw opened this issue Jan 6, 2017 · 4 comments

Comments

@ebaauw
Copy link
Owner

ebaauw commented Jan 6, 2017

Folks, I'm thinking about changing the way homebridge-hue behaves when lights are off. I would like to hear your thoughts on this.
Note: by "off" or "on", I mean turning the light off or on through the Hue bridge, while the light remains connected to the mains power.

Current Behaviour
The Hue bridge does not accept changes to a light state (brightness, colour) when that light is off. Currently, homebridge-hue propagates each change to a light state from HomeKit to the Hue bridge, regardless whether the light is on or off. This could result in an error, e.g. when changing brightness while the light is off:

[1/7/2017, 10:30:59 AM] [Hue] philipshue: hue bridge error 201: parameter, bri, is not modifiable. Device is set to off.

Note that the v2 (square) Hue bridge silently ignores this limitation when exposing lights to HomeKit. HomeKit shows the new value, but the light state isn't changed on the Hue bridge (nor in the light).

The Hue bridge treats the light state as a single object, enabling changes to power, brightness, colour in a single command. HomeKit treats each attribute as a separate characteristic, notifying homebridge-hue one change at a time. Currently, homebridge-hue propagates these changes 1:1 to the Hue bridge, using a separate command for each characteristic.

In particular, a HomeKit scene turning a light on at a particular brightness and colour results in four characteristic changes in HomeKit (colour is actually two characteristics, hue and saturation), and four commands from homebridge-hue to the Hue bridge. The could lead to strange behaviour, e.g. when the colour change is received by homebridge-hue before the power change, the colour will not be set (because the light is still off); when the power change is received first, the colour will be set (because now the light is already on).

When only instructed to turn on (without specifying any brightness nor colour), most lights turn on using their previous brightness and colour from when they were turned off. Most lights, the exception being the innr lightstrips under my kitchen cabinets and the pucks in my bedroom Ikea wardrobes - these turn on at full brightness.

Proposed New Behaviour
When receiving HomeKit changes to brightness or colour, while a light is off, homebridge-hue could save these changes. Then, when the light is turned on from HomeKit, homebridge-hue would send a command to the Hue bridge to turn the light on with the saved brightness and colour, instead of leaving it up to the light to use its previous state.

@ebaauw ebaauw changed the title Safe light state changes when light is off Save light state changes when light is off Jan 7, 2017
@ebaauw ebaauw mentioned this issue Feb 7, 2017
@ebaauw
Copy link
Owner Author

ebaauw commented Feb 13, 2017

Eve v6.2 turns a light on automatically when changing brightness, colour, or colour temperature while the light is off.

@Bowerz
Copy link

Bowerz commented Mar 11, 2017

Interesting concept. Would this solve the issue I am facing where I would turn off a light (my setup is a v2 hub and 1 Osram Lightify bulb, currently), then in 1-5 minutes the light would turn it's self back on. Looking in the log history
Mar 11 10:43:06 raspberrypi homebridge[413]: [3/11/2017, 10:43:06 AM] [Hue] Top light: homekit power changed from 0 to 1
Mar 11 10:43:09 raspberrypi homebridge[413]: [3/11/2017, 10:43:09 AM] [Hue] Top light: homekit brightness changed from 100% to 66%
Mar 11 10:43:09 raspberrypi homebridge[413]: [3/11/2017, 10:43:09 AM] [Hue] Top light: homekit brightness changed from 66% to 54%
Mar 11 10:43:10 raspberrypi homebridge[413]: [3/11/2017, 10:43:10 AM] [Hue] Top light: homekit brightness changed from 54% to 44%
Mar 11 10:43:10 raspberrypi homebridge[413]: [3/11/2017, 10:43:10 AM] [Hue] Top light: homekit brightness changed from 44% to 39%
Mar 11 10:43:13 raspberrypi homebridge[413]: [3/11/2017, 10:43:13 AM] [Hue] Top light: homekit power changed from 1 to 0
Mar 11 10:46:05 raspberrypi homebridge[413]: [3/11/2017, 10:46:05 AM] [Hue] Top light: set homekit power from 0 to 1
Mar 11 10:46:05 raspberrypi homebridge[413]: [3/11/2017, 10:46:05 AM] [Hue] Top light: set homekit brightness from 39% to 100%

Those commands at 10:46:05 I did not issue, my phone was on standby. It only seems to be when I turn the light off (via HomeKit) when it has been dimmed.

Perhaps this isn't related and requires a new issue to be raised?

@ebaauw
Copy link
Owner Author

ebaauw commented Mar 11, 2017

This proposal might provide a workaround, but it wouldn't solve it (take away the cause).

I would seem some-one or something set the light power on and the light brightness to 100% on the Hue bridge at 10:46:05. The homekit ... changed from ... to ... messages indicate changes from HomeKit that homebridge-hue forwards to the Hue bridge. The set homekit ... from ... to ... messages indicate changes to HomeKit issued by homebridge-hue, because it detected a change in the Hue bridge. If you start homebridge -D, homebridge-hue issues debug messages for every interaction with the Hue bridge.

This some-one or something could be:

  • A rule on the Hue bridge, triggered by a Hue dimmer switch, a Hue tap, a Hue motion sensor, or from some other conditions (e.g. a routine in the official Philips Hue app);
  • A schedule on the Hue bridge;
  • A request from an app connected to the Hue bridge;
  • A request from the MeetHue portal;
  • A request from IFTTT.

The change on the Hue bridge could also be caused by a power cycle of the light. What version of homebridge-hue are you running? The more recent versions map the reachable attribute on the Hue bridge to homekit status fault, so you can tell from the log if the light is (dis)connected from/to power. Note however, that it takes the Hue bridge some time (minutes?) to mark the light as (un)reachable after the power is (dis)connected, so a quick power cycle will likely go unnoticed by homebridge-hue.

@ebaauw
Copy link
Owner Author

ebaauw commented Apr 20, 2017

I'm closing this issue as I won't be implementing this. It seems no longer needed, with HomeKit apps only allowing changes when the light is on, or turning on the light automatically.

@ebaauw ebaauw closed this as completed Apr 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants