ebaauw / homebridge-hue

Homebridge plugin for Philips Hue
Apache License 2.0
898 stars 91 forks source link

Transition time not set #965

Closed boehser-enkel closed 3 years ago

boehser-enkel commented 3 years ago

Hey there,

as i mentioned in discord i am not able to use transition time. Value is ignored. The bulb is turned to 100% instantly. 2 scenes (1 with Osram bulb, 1 with tradfri):

Debug Log:

Osram: [12/04/2021, 06:54:47] [Deconz] Zigbee-GW: request 34: 200 OK [12/04/2021, 06:54:47] [Deconz] Zigbee-GW: homekit transition time changed from 0.4s to 158.2s [12/04/2021, 06:54:47] [Deconz] Helles Licht: homekit on changed from false to true [12/04/2021, 06:54:47] [Deconz] Zigbee-GW: request 35: PUT /lights/17/state {"on":true,"transitiontime":1582} [12/04/2021, 06:54:47] [Deconz] Zigbee-GW: request 35: 200 OK [12/04/2021, 06:54:47] [Deconz] Helles Licht: state changed event: {"alert":null,"bri":254,"on":true,"reachable":true} [12/04/2021, 06:54:47] [Deconz] Zigbee-GW: reset homekit transition time from 158.2s to 0.4s

Tradfri:

[12/04/2021, 07:00:12] [Deconz] Zigbee-GW: request 23: PUT /lights/10/state {"on":true,"bri":254,"transitiontime":0} [12/04/2021, 07:00:12] [Deconz] Zigbee-GW: request 23: 200 OK [12/04/2021, 07:00:12] [Deconz] Diele 1: state changed event: {"alert":null,"bri":254,"on":true,"reachable":true} [12/04/2021, 07:00:12] [Deconz] Diele 1: state changed event: {"alert":null,"bri":2,"on":true,"reachable":true} [12/04/2021, 07:00:12] [Deconz] Diele 1: light bri changed from 254 to 2 [12/04/2021, 07:00:12] [Deconz] Diele 1: recently updated - ignore changed bri [12/04/2021, 07:00:12] [Deconz] Zigbee-GW: request 24: GET /sensors [12/04/2021, 07:00:12] [Deconz] Zigbee-GW: request 24: 200 OK [12/04/2021, 07:00:12] [Deconz] Zigbee-GW: request 25: GET /lights [12/04/2021, 07:00:12] [Deconz] Zigbee-GW: request 25: 200 OK [12/04/2021, 07:00:12] [Deconz] Diele 1: light bri changed from 254 to 2 [12/04/2021, 07:00:12] [Deconz] Diele 1: recently updated - ignore changed bri [12/04/2021, 07:00:17] [Deconz] Zigbee-GW: request 26: GET /sensors [12/04/2021, 07:00:17] [Deconz] Zigbee-GW: request 26: 200 OK [12/04/2021, 07:00:17] [Deconz] Zigbee-GW: request 27: GET /lights [12/04/2021, 07:00:17] [Deconz] Zigbee-GW: request 27: 200 OK

Everything on neweset public version.

greetz boehser enkel

ebaauw commented 3 years ago

Please attach the debug dump file, and capture and attach a debug log file, from the start of Homebridge, up to and including recalling the scenes.

boehser-enkel commented 3 years ago

Here's both

Timestamps: Osram 06:47:33 Tradfri 6:47:56

Both scenes with:

homebridge.log homebridge-hue.json.gz

ebaauw commented 3 years ago

Thanks. As I suspected, the OSRAM and IKEA case are different. In case of the OSRAM, the light is already at 100% brightness, and the HomeKit scene doesn't change the brightness, so there's no transition. In case of the IKEA, the workaround for the firmware bug kicks in, overwriting the requested transition time. I don't think it should in this case (with only on and bri), but I need to check if I can address that.

Osram 06:47:33

Homebridge Hue sends the transitiontime alright, but recalling the HomeKit scene doesn't result in a changed value for Brightness. Consequently, Homebridge Hue doesn't include bri in the command it sends to deCONZ. Like the Hue bridge, deCONZ ignores transitiontime in combination with (only) "on": true, see https://github.com/dresden-elektronik/deconz-rest-plugin/issues/1111#issuecomment-456464872.

I'm not sure if HomeKit only sends changed characteristics, or if Homebridge Hue silently ignores the unchanged Brightness. In the latter case, I'm not sure I should change that. The issue is that a HomeKit accessory (incl. any Homebridge plugin) has no clue about HomeKit scenes, and doesn't know that a scene is being recalled. So if I would change this, it would change all occurrences.

[14/04/2021, 06:47:33] [Deconz] Helles Licht: homekit on changed from false to true
[14/04/2021, 06:47:33] [Deconz] Zigbee-GW: homekit transition time changed from 0.4s to 362.1s

So HomeKit changes the On and Transition Time characteristics when recalling the scene. Only one light? Apparently, HomeKit thinks the light is already at the right Brightness and doesn't change that value.

[14/04/2021, 06:47:33] [Deconz] Zigbee-GW: request 11: PUT /lights/17/state {"on":true,"transitiontime":3621}

Homebridge Hue sends the command to deCONZ. Unfortunately, transitiontime doesn't do anything in combination with only on; the light simply turns on at its previous brightness level.

[14/04/2021, 06:47:33] [Deconz] Zigbee-GW: request 11: 200 OK
[14/04/2021, 06:47:33] [Deconz] Helles Licht: state changed event: {"alert":null,"bri":254,"on":true,"reachable":true}

deCONZ has accepted the command sent by Homebridge Hue and sends a notification for the changed light state. You seem to have websocketnofityall set, so I cannot tell which attributes have changed, but I'd guess it's only on.

[14/04/2021, 06:47:33] [Deconz] Zigbee-GW: reset homekit transition time from 362.1s to 0.4s
[14/04/2021, 06:47:33] [Deconz] Helles Licht: attr changed event: {"id":"17","lastannounced":"2021-01-29T12:55:56Z","lastseen":"2021-04-14T04:47Z","manufacturername":"OSRAM","modelid":"Classic A60 W clear - LIGHTIFY","name":"Helles Licht","swversion":"V1.04.12","type":"Dimmable light","uniqueid":"7c:b0:3e:aa:0a:04:52:07-03"}

Homebridge Hue resets Transition Time and deCONZ sends an event that lastseen has been updated.

Tradfri 6:47:56

Homebridge Hue changes transitiontime to 0 to workaround the IKEA firmware bug. I'm not sure it should do so in this case, when only specifying on and bri (and no colour nor colour temperature). Also I don't see a message that _TransitionTime is reset here?!

[14/04/2021, 06:47:56] [Deconz] Diele 1: homekit brightness changed from 47% to 100%
[14/04/2021, 06:47:56] [Deconz] Diele 1: homekit on changed from false to true
[14/04/2021, 06:47:56] [Deconz] Zigbee-GW: homekit transition time changed from 0.4s to 207.4s

Here, HomeKit changes On, Brightness, and TransitionTime.

[14/04/2021, 06:47:56] [Deconz] Zigbee-GW: request 22: PUT /lights/10/state {"bri":254,"on":true,"transitiontime":0}

But Homebridge Hue overwrites transitiontime with 0, as a workaround for the IKEA firmware bug. That would make sense if the scene contained both brightness and colour (temperature), but I don't think it should do so in this case.

[14/04/2021, 06:47:56] [Deconz] Zigbee-GW: request 22: 200 OK
[14/04/2021, 06:47:56] [Deconz] Diele 1: state changed event: {"alert":null,"bri":254,"on":true,"reachable":true}

deCONZ has accepted the command and updates the (cached!) API state from API call.

[14/04/2021, 06:47:56] [Deconz] Diele 1: attr changed event: {"id":"10","lastannounced":"2021-02-15T15:43:07Z","lastseen":"2021-04-14T04:47Z","manufacturername":"IKEA of Sweden","modelid":"TRADFRI bulb E27 WW clear 250lm","name":"Diele 1","swversion":"2.1.022","type":"Dimmable light","uniqueid":"ec:1b:bd:ff:fe:9c:e8:45-01"}
[14/04/2021, 06:47:56] [Deconz] Diele 1: state changed event: {"alert":null,"bri":2,"on":true,"reachable":true}
[14/04/2021, 06:47:56] [Deconz] Diele 1: light bri changed from 254 to 2
[14/04/2021, 06:47:56] [Deconz] Diele 1: recently updated - ignore changed bri

I think the Trådfri light sends an attribute report after handling the Move to Level (with On/Off) (2, 0), causing deCONZ to send the corresponding websocket notification. Homebridge Hue ignores this to "debounce" the brightness in HomeKit.

[14/04/2021, 06:48:00] [Deconz] Zigbee-GW: request 24: GET /lights
[14/04/2021, 06:48:00] [Deconz] Zigbee-GW: request 24: 200 OK
[14/04/2021, 06:48:00] [Deconz] Diele 1: light bri changed from 254 to 2
[14/04/2021, 06:48:00] [Deconz] Diele 1: set homekit brightness from 100% to 1%

I would expect deCONZ to send the Move to Level (254, 0) (the workaround-adjusted transitiontime) right after the Move to Level (with On/Off), but when Homebridge Hue next polls the light, deCONZ still reports bri 2, so now Homebridge Hue updates the Brightness in HomeKit.

[14/04/2021, 06:48:01] [Deconz] Diele 1: state changed event: {"alert":null,"bri":254,"on":true,"reachable":true}
[14/04/2021, 06:48:01] [Deconz] Diele 1: light bri changed from 2 to 254
[14/04/2021, 06:48:01] [Deconz] Diele 1: set homekit brightness from 1% to 100%

The light now sends an attribute report for brightness 254, deCONZ sends the corresponding web socket event, and Homebridge Hue updates HomeKit.

boehser-enkel commented 3 years ago

Thanks for that deep analyze. Maybe you can work around this conditions. This would make it easier to set up dimming over time.

There's only one thing left that bothers me:

So the transition time is always set to 0,4 so that the light don't turn on instantly. Whats the difference when i just turn on the light. There is no change in brightness but the 0,4 seconds are used anyways. In my opinion thats the desired behaviour (off should behave as 0% so turning on would consider any transition time)

ebaauw commented 3 years ago

Transitiontime isn’t used for turning lights on or off. For brightness and colour, it’s a parameter to the Zigbee command. The commands to turn a light on or off don’t have that parameter. There are some attributes on the On/Off cluster to change the behaviour, but not all lights support these (Hue don’t) and I don’t understand how they’re supposed to work (different light models/vendors seem to handle them differently). The Hue bridge works around these by using Move to Level (with On/Off) instead of On and Off with Effect instead of Off. Of course, not all light models/vendors support these, and those that do don’t handle these commands the same way.

It’s really a jungle out there. If you want consistent behaviour, stick to lights from one vendor. Even then, different Hue models support different colour ranges.

ebaauw commented 3 years ago

@boehser-enkel Could you try beta v0.13.6-0. It should fix both the issue with the OSRAM as well as with the IKEA.

ebaauw commented 3 years ago

Published v0.13.6.