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

Adaptive lighting on iOS14 #766

Closed
timwegenerDE opened this issue Sep 17, 2020 · 83 comments
Closed

Adaptive lighting on iOS14 #766

timwegenerDE opened this issue Sep 17, 2020 · 83 comments
Labels

Comments

@timwegenerDE
Copy link

Hi there,

is there anything to to in homebridge-hue for supporting adaptive lightning in iOS14?
If so, I would love this feature :)

Kind regards,
Tim

@peter99330
Copy link

Also very interested in this. It looks like Apple hasn’t updated their Specification yet though. (At least the non-commercial one.)

@kaeferfreund
Copy link

Same here

@ebaauw
Copy link
Owner

ebaauw commented Sep 17, 2020

Don’t know yet. We’ll have to see how this will work natively with the Hue bridge. I understand Apple defined some new characteristics for that, but they’re TLV8, so we’ll have to reverse engineer the encoding of the schedule. My guess/hope is the schedule will translate to some rules or schedules on the Hue bridge, which Homebridge Hue should be able to do as well.

@kaeferfreund
Copy link

I have everything here - anything I can help you with? A Wireshark recording maybe?

@ebaauw
Copy link
Owner

ebaauw commented Sep 18, 2020

What do you mean by “everything”? Do you actually have a light for which Home exposes the adaptive lighting? Please post some screenshots of what that looks like.

The traffic between Home / the HomeKit runtime should be HAP and is encrypted. You would probably need to setup a man-in-the-middle to see anything useful in Wireshark. I’ve seen reports that they managed to do that for the Hue API, but I haven’t for HAP. Typically, you need a HomeKit app to see how the Hue bridge exposes the adaptive lighting characteristics to HomeKit and to reverse engineer how they work. They use a modified version of HMCatalog (distributed as XCode sample app) to reverse engineer the Eve history, see https://github.com/simont77/fakegato-history#how-to-contribute. Not sure if that still compiles with the latest versions of Swift, XCode, and iOS.

Next, we need to figure out how the Hue bridge implements the adaptive lighting. I’m guessing/hoping it would be thru regular Hue bridge rules and/or schedules, and not in the light firmware. In that case, a full state dump (ph get /) before and after would suffice. If not, we might need to sniff the Zigbee traffic between the Hue bridge and the Hue lights.

@jensflorian
Copy link

Here are some screenshots: https://www.homekitauthority.com/philips-hue-homekit-adaptive-lighting-feature-close-to-launch/?amp=1

However this seems to be associated with the lights firmware.

@ebaauw
Copy link
Owner

ebaauw commented Oct 18, 2020

Here are some screenshots

Do you actually have this running? Seen this before, not really useful for reverse engineering.

However this seems to be associated with the lights firmware.

What makes you think that? The linked text and previous information suggests it's linked to the bridge firmware.

@delusho
Copy link

delusho commented Oct 18, 2020

If it’s linked to the firmware I am hopefully that the conbee is getting it - what do you think?

@jensflorian
Copy link

Do you actually have this running? Seen this before, not really useful for reverse engineering.

No, I do not own a hue bridge, just Deconz.

What makes you think that? The linked text and previous information suggests it's linked to the bridge firmware.

Behause according to a hueblog.de post, only Philips Hue White and Color Ambiance Lights are supported.

@itavero
Copy link

itavero commented Oct 18, 2020

There are indeed some extra characteristic, as is also mentioned in homebridge/homebridge#2687.

By the way, @jensflorian, the reason that those are the only lights supported, is probably because those lights are the only ones that support changing the color temperatures (Hue has some light that have a fixed temperature and are only dimmable, and some others that only have RGB support).

@HomeKidd
Copy link

By the way, @jensflorian, the reason that those are the only lights supported, is probably because those lights are the only ones that support changing the color temperatures (Hue has some light that have a fixed temperature and are only dimmable, and some others that only have RGB support).

Exactly! According to the latest non-commercial HAP docs, Color temperature characteristic only can be added to non-RGB lights and I think Adaptive Lighting characteristics only can be added to Light service with Color Temperature (and Brightness) characteristic only.

RGB lights with both cold and warm white LEDs (so not RGBW lights) are tricky: When CCT LEDs used it disables the RGB ones completely and CCT disabled when RGB used 😁
Color Temp characteristic using Mired scale for setting Color temp (Mired value = 1000000/ Kelvin) and since RGB Light characteristics are using HSV colors its nearly impossible to convert it to Mired😅 I’ve spend a few days for understanding what’s happening based on Tasmota😂

BTW I’m also curious about the Adaptive Lighting code 🙌🤓

@ebaauw
Copy link
Owner

ebaauw commented Oct 28, 2020

Just got a mail from Eve that their lightstrip now supports adaptive lighting with the latest firmware. It does mention, that Adaptive Lighting requires a home hub, suggesting the actual adaptations are triggered from HomeKit automations, rather than by the light itself. See https://www.evehome.com/en/eve-light-strip and https://www.evehome.com/en/blog/adaptive-lighting.

@llamafilm
Copy link

I hope it will eventually be possible to imitate this feature in the plugin or in deCONZ using any CCT adjustable bulbs.

@ebaauw
Copy link
Owner

ebaauw commented Nov 11, 2020

My Hue bridge just received a firmware update and now supports Adaptive Lighting. I’ll have a detailed look this weekend.

@renssies
Copy link

It has been implemented in the beta HAP-NodeJS. But it's accidentally called "Ambient Lightning": https://github.com/homebridge/HAP-NodeJS/blob/beta/src/accessories/Light-AmbientLightning_accessory.ts

@Zer0x00
Copy link

Zer0x00 commented Nov 12, 2020

It has been implemented in the beta HAP-NodeJS. But it's accidentally called "Ambient Lightning": https://github.com/homebridge/HAP-NodeJS/blob/beta/src/accessories/Light-AmbientLightning_accessory.ts

I've created a PR for that :)

homebridge/HAP-NodeJS#855

@kaeferfreund
Copy link

Should the early beta implementation be working with 5c006f0 installed?

@ebaauw
Copy link
Owner

ebaauw commented Nov 17, 2020

That’s still work in progress. I think I have the interaction with HomeKit working (without the need for Homebridge beta or HAP-NodeJS beta), but I am still working on updating the lights.

@kaeferfreund
Copy link

okay - I read #814. Any way I can test this? I updated my setup to 5c006f0 but I don't see the adaptive icon in my HomeKit. I also couldn't find any other branch to try.

I'm 100% aware that this is pre alpha at this point, but I'm willing to try out some stuff at my place

@ebaauw
Copy link
Owner

ebaauw commented Nov 17, 2020

Please try beta v0.12.1-2 v0.12.1.3.

@NewsGuyTor
Copy link

I tried the latest 0.12.1.5 now, and immediately as I clicked the button to active Adaptive Lightning in the Home app on iOS 14, homebridge crashed:

[18.11.2020, 08:30:26] [Hue] LED-stripe: homekit transition control set to {"control":{"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T07:30:26.542Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":1,"curve":{"entries":[{"adjustmentFactor":-1.4222222566604614,"mired":374.22222900390625,"offset":0},{"adjustmentFactor":-1.5333333015441895,"mired":367.3333435058594,"offset":1774000},{"adjustmentFactor":-1.600000023841858,"mired":360,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":352.77777099609375,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":350.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":349.77777099609375,"offset":1800000,"duration":3600000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":350.5555419921875,"offset":1800000,"duration":3600000},{"adjustmentFactor":-1.6111111640930176,"mired":352.1111145019531,"offset":1800000},{"adjustmentFactor":-1.5555555820465088,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.4666666984558105,"mired":358.6666564941406,"offset":1800000},{"adjustmentFactor":-1.3777778148651123,"mired":364.77777099609375,"offset":1800000},{"adjustmentFactor":-1.288888931274414,"mired":371.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2333333492279053,"mired":382.3333435058594,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":397.4444580078125,"offset":1800000},{"adjustmentFactor":-1.3111110925674438,"mired":416.1111145019531,"offset":1800000},{"adjustmentFactor":-1.4555555582046509,"mired":439.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6333333253860474,"mired":463.3333435058594,"offset":1800000},{"adjustmentFactor":-1.8333333730697632,"mired":487.3333435058594,"offset":1800000},{"adjustmentFactor":-2,"mired":508,"offset":1800000},{"adjustmentFactor":-2.0888888835906982,"mired":520.888916015625,"offset":1800000},{"adjustmentFactor":-2.0333333015441895,"mired":520.3333129882812,"offset":1800000},{"adjustmentFactor":-1.9777777194976807,"mired":519.7777709960938,"offset":1800000},{"adjustmentFactor":-1.8777778148651123,"mired":515.7777709960938,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":1800000},{"adjustmentFactor":-1.8111110925674438,"mired":512.111083984375,"offset":1800000,"duration":10800000},{"adjustmentFactor":-1.755555510520935,"mired":503.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6666666269302368,"mired":490.6666564941406,"offset":1800000},{"adjustmentFactor":-1.5777777433395386,"mired":476.77777099609375,"offset":1800000},{"adjustmentFactor":-1.4777777194976807,"mired":462.77777099609375,"offset":1800000},{"adjustmentFactor":-1.355555534362793,"mired":447.5555419921875,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":433.4444580078125,"offset":1800000},{"adjustmentFactor":-1.1555556058883667,"mired":419.5555419921875,"offset":1800000},{"adjustmentFactor":-1.1333333253860474,"mired":407.3333435058594,"offset":1800000},{"adjustmentFactor":-1.1888889074325562,"mired":395.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2999999523162842,"mired":385,"offset":1800000},{"adjustmentFactor":-1.4222222566604614,"mired":375.22222900390625,"offset":1800000},{"adjustmentFactor":-1.4222222566604614,"mired":374.22222900390625,"offset":26000}],"adjustmentIid":11,"adjustmentRange":{"min":10,"max":100}},"updateInterval":60000,"notifyIntervalThreshold":600000}}}
[18.11.2020, 08:30:26] [Hue] LED-stripe: set homekit transition control to {"control":{"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T07:30:26.542Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":361}}}
[18.11.2020, 08:30:26] [Hue] LED-stripe: set homekit active transition count to 1
[18.11.2020, 08:30:26] [Hue] LED-stripe: homekit adaptive lighting color temperature changed from 459 mired to 339 mired
[18.11.2020, 08:30:26] [Hue] LED-stripe: set homekit hue from 222˚ to 39˚
[18.11.2020, 08:30:26] [Hue] LED-stripe: set homekit saturation from 0% to 48%
[18.11.2020, 08:30:26] [Hue] LED-stripe: set homekit transition control to {"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T07:30:26.542Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":436}}
[18.11.2020, 08:30:26] [Hue] LED-stripe: set homekit transition control to {"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T07:30:26.542Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":443}}
[18.11.2020, 08:30:27] [Hue] LED-stripe: set homekit transition control to {"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T07:30:26.542Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":471}}
[18.11.2020, 08:30:27] TypeError: Cannot read property 'colorTemperature' of undefined
    at AdaptiveLighting.parseControlWrite (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:221:35)
    at HueLight.setTransitionControl (/usr/local/lib/node_modules/homebridge-hue/lib/HueLight.js:1761:13)
    at _Characteristics.<computed>.emit (events.js:315:20)
    at _Characteristics.<computed>.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at _Characteristics.<computed>.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:652:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1439:24
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._this._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1281:10)
    at HAPServer.emit (events.js:315:20)
    at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
[18.11.2020, 08:30:27] [Hue] heartbeat 40, drift 283
[18.11.2020, 08:30:27] Got SIGTERM, shutting down Homebridge...
[18.11.2020, 08:30:32] [Hue] goodbye

After restarting homebridge, it seemed to work fine for a bit (hard to say since it's just a white color when observed for just a minute), but after changing colors a few times in the Home app to test more it crashed again:

[18.11.2020, 08:43:16] [Hue] LED-stripe: set homekit transition control to {"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T07:41:51.523Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":85213}}
[18.11.2020, 08:43:17] TypeError: Cannot read property 'colorTemperature' of undefined
    at AdaptiveLighting.parseControlWrite (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:221:35)
    at HueLight.setTransitionControl (/usr/local/lib/node_modules/homebridge-hue/lib/HueLight.js:1761:13)
    at _Characteristics.<computed>.emit (events.js:315:20)
    at _Characteristics.<computed>.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at _Characteristics.<computed>.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:652:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1439:24
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._this._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1281:10)
    at HAPServer.emit (events.js:315:20)
    at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
[18.11.2020, 08:43:17] Got SIGTERM, shutting down Homebridge...

The light in question is a Gledopto RGB+CCT controller with a LED strip attached.

@ebaauw
Copy link
Owner

ebaauw commented Nov 18, 2020

Can you please provide the full debug logfile? I think HomeKit is sending a slightly different transition control value that Homebridge Hue chokes on.

Note to self: need to guard this stuff with try / catch, so Homebridge won’t crash.

@NewsGuyTor
Copy link

NewsGuyTor commented Nov 18, 2020

This is what I got with homebridge -D

[18.11.2020, 11:22:47] [Hue] LED-stripe: homekit transition control set to {"control":{"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T10:22:47.191Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":1,"curve":{"entries":[{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":0},{"adjustmentFactor":-1.6777777671813965,"mired":349.77777099609375,"offset":1800000,"duration":4033000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":350.5555419921875,"offset":1800000,"duration":3600000},{"adjustmentFactor":-1.6111111640930176,"mired":352.1111145019531,"offset":1800000},{"adjustmentFactor":-1.5555555820465088,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.4666666984558105,"mired":358.6666564941406,"offset":1800000},{"adjustmentFactor":-1.3777778148651123,"mired":364.77777099609375,"offset":1800000},{"adjustmentFactor":-1.288888931274414,"mired":371.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2333333492279053,"mired":382.3333435058594,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":397.4444580078125,"offset":1800000},{"adjustmentFactor":-1.3111110925674438,"mired":416.1111145019531,"offset":1800000},{"adjustmentFactor":-1.4555555582046509,"mired":439.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6333333253860474,"mired":463.3333435058594,"offset":1800000},{"adjustmentFactor":-1.8333333730697632,"mired":487.3333435058594,"offset":1800000},{"adjustmentFactor":-2,"mired":508,"offset":1800000},{"adjustmentFactor":-2.0888888835906982,"mired":520.888916015625,"offset":1800000},{"adjustmentFactor":-2.0333333015441895,"mired":520.3333129882812,"offset":1800000},{"adjustmentFactor":-1.9777777194976807,"mired":519.7777709960938,"offset":1800000},{"adjustmentFactor":-1.8777778148651123,"mired":515.7777709960938,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":1800000},{"adjustmentFactor":-1.8111110925674438,"mired":512.111083984375,"offset":1800000,"duration":10800000},{"adjustmentFactor":-1.755555510520935,"mired":503.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6666666269302368,"mired":490.6666564941406,"offset":1800000},{"adjustmentFactor":-1.5777777433395386,"mired":476.77777099609375,"offset":1800000},{"adjustmentFactor":-1.4777777194976807,"mired":462.77777099609375,"offset":1800000},{"adjustmentFactor":-1.355555534362793,"mired":447.5555419921875,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":433.4444580078125,"offset":1800000},{"adjustmentFactor":-1.1555556058883667,"mired":419.5555419921875,"offset":1800000},{"adjustmentFactor":-1.1333333253860474,"mired":407.3333435058594,"offset":1800000},{"adjustmentFactor":-1.1888889074325562,"mired":395.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2999999523162842,"mired":385,"offset":1800000},{"adjustmentFactor":-1.4222222566604614,"mired":375.22222900390625,"offset":1800000},{"adjustmentFactor":-1.5333333015441895,"mired":367.3333435058594,"offset":1800000},{"adjustmentFactor":-1.600000023841858,"mired":360,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":352.77777099609375,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":350.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1367000}],"adjustmentIid":11,"adjustmentRange":{"min":10,"max":100}},"updateInterval":60000,"notifyIntervalThreshold":600000}}}
[18.11.2020, 11:22:47] [Hue] LED-stripe: set homekit transition control to {"control":{"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T10:22:47.191Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":43}}}
[18.11.2020, 11:22:47] [Hue] LED-stripe: set homekit active transition count to 1
[18.11.2020, 11:22:47] [Hue] LED-stripe: homekit adaptive lighting color temperature changed from 371 mired to 227 mired
[18.11.2020, 11:22:47] [Hue] Philips hue: bridge request 20: put /lights/6/state {"ct":227}
[18.11.2020, 11:22:47] [Hue] LED-stripe: set homekit transition control to {"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T10:22:47.191Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":63}}
[18.11.2020, 11:22:47] [Hue] Philips hue: bridge request 20: ok
[18.11.2020, 11:22:47] [Hue] LED-stripe: light xy predicted to change by ct from [0.6936,0.2961] to [0.3641,0.3659]
[18.11.2020, 11:22:47] [Hue] LED-stripe: set homekit hue from 354˚ to 44˚
[18.11.2020, 11:22:47] [Hue] LED-stripe: set homekit saturation from 100% to 20%
[18.11.2020, 11:22:47] [Hue] LED-stripe: set homekit transition control to {"colorTemperature":{"iid":22,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-18T10:22:47.191Z","2.1.2.3":"32ACD24364EFCBC6"},"runtime":132}}
[18.11.2020, 11:22:47] TypeError: Cannot read property 'colorTemperature' of undefined
    at AdaptiveLighting.parseControlWrite (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:221:35)
    at HueLight.setTransitionControl (/usr/local/lib/node_modules/homebridge-hue/lib/HueLight.js:1761:13)
    at _Characteristics.<computed>.emit (events.js:315:20)
    at _Characteristics.<computed>.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at _Characteristics.<computed>.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:652:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1439:24
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._this._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1281:10)
    at HAPServer.emit (events.js:315:20)
    at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
[18.11.2020, 11:22:47] Got SIGTERM, shutting down Homebridge...
[18.11.2020, 11:22:47] [Hue] last heartbeat 56, drift 0

@ebaauw
Copy link
Owner

ebaauw commented Nov 18, 2020

Thanks. The LED-stripe is actually looking good. I think the type Error comes from the request to set adaptive lighting for the next light. Unfortunately, the log gives no clue which light that is. Can you list all the set homekit supported transition configuration messages?

I'll cook a new beta version logging the raw value and guarding the parsing.

@NewsGuyTor
Copy link

[18.11.2020, 12:01:42] [Hue] LED-stripe: set homekit supported transition configuration to {"configuration":[{"iid":11,"characteristic":1},{"iid":22,"characteristic":2}]}

@llamafilm
Copy link

llamafilm commented Nov 22, 2020

Ah ok. Can this be set in config.json so it sticks? I don’t really need to change it more than once.
I can’t think of a great name that is short enough for HomeKit. Mired factor? It would probably be more clear to add it to config.json instead, this way you can have a proper description of how it works in the GUI, and clarify that it only applies adaptive lighting.
Also, this would make it easy to type a value over 100%. Not sure if this is necessary, but maybe someone wants to match the cool color of a cloudy day.

@ebaauw
Copy link
Owner

ebaauw commented Nov 22, 2020

I had it in config.json originally, but then wanted to test a number of values, so made it dynamic. Could do both: set startup value in config.json and still allow dynamic change.

I don’t think you appreciate how the correction factor works: it is applied to the light’s brightness, not to the colour temperature.

ebaauw added a commit that referenced this issue Nov 22, 2020
Add `birghtnessAdjustment` parameter, see #766.
ebaauw added a commit that referenced this issue Nov 22, 2020
Add `birghtnessAdjustment` config.json parameter, see #766.
ebaauw added a commit that referenced this issue Nov 22, 2020
Use `brightnessAdjustment` config.json parameter, insteaf of bridge/gateway characteristic, see #766.
@ebaauw
Copy link
Owner

ebaauw commented Nov 22, 2020

Added brightnessAdjustment config.json parameter and removed the Brightness characteristic from the Hue bridge.

Published v0.12.2.

@ebaauw ebaauw closed this as completed Nov 22, 2020
@ebaauw ebaauw pinned this issue Nov 22, 2020
@llamafilm
Copy link

llamafilm commented Nov 23, 2020

This test was done at 10:30pm. I think the ranges change throughout the day. With factor 10 the color doesn't change at all dimming from 0-full.

brightnessAdjustment Min Mireds Max Mireds dimmer range where color adapts
10 495 (2020K) 495 (2020K) none
20 495 (2020K) 475 (2100K) 20-100%
50 495 (2020K) 415 (2410K) 20-100%
100 495 (2020K) 318 (3140K) 10-100%

@simplenotezy
Copy link

Got the following error on install:

image

[11/23/2020, 8:25:33 PM] [Hue] Bathroom Left: homekit transition control set to {"colorTemperature":{"iid":20,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-23T19:25:33.681Z"},"runtime":1,"curve":{"entries":[{"adjustmentFactor":-1.7999999523162842,"mired":483,"offset":0},{"adjustmentFactor":-1.8333333730697632,"mired":487.3333435058594,"offset":267000},{"adjustmentFactor":-2,"mired":508,"offset":1800000},{"adjustmentFactor":-2.0888888835906982,"mired":520.888916015625,"offset":1800000},{"adjustmentFactor":-2.0333333015441895,"mired":520.3333129882812,"offset":1800000},{"adjustmentFactor":-1.9777777194976807,"mired":519.7777709960938,"offset":1800000},{"adjustmentFactor":-1.8777778148651123,"mired":515.7777709960938,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":0},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":9000000},{"adjustmentFactor":-1.8111110925674438,"mired":512.111083984375,"offset":1800000},{"adjustmentFactor":-1.755555510520935,"mired":503.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6666666269302368,"mired":490.6666564941406,"offset":1800000},{"adjustmentFactor":-1.5777777433395386,"mired":476.77777099609375,"offset":1800000},{"adjustmentFactor":-1.4777777194976807,"mired":462.77777099609375,"offset":1800000},{"adjustmentFactor":-1.355555534362793,"mired":447.5555419921875,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":433.4444580078125,"offset":1800000},{"adjustmentFactor":-1.1555556058883667,"mired":419.5555419921875,"offset":1800000},{"adjustmentFactor":-1.1333333253860474,"mired":407.3333435058594,"offset":1800000},{"adjustmentFactor":-1.1888889074325562,"mired":395.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2999999523162842,"mired":385,"offset":1800000},{"adjustmentFactor":-1.4222222566604614,"mired":375.22222900390625,"offset":1800000},{"adjustmentFactor":-1.5333333015441895,"mired":367.3333435058594,"offset":1800000},{"adjustmentFactor":-1.600000023841858,"mired":360,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":352.77777099609375,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":350.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":349.77777099609375,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":350.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6111111640930176,"mired":352.1111145019531,"offset":1800000},{"adjustmentFactor":-1.5555555820465088,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.4666666984558105,"mired":358.6666564941406,"offset":1800000},{"adjustmentFactor":-1.3777778148651123,"mired":364.77777099609375,"offset":1800000},{"adjustmentFactor":-1.288888931274414,"mired":371.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2333333492279053,"mired":382.3333435058594,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":397.4444580078125,"offset":1800000},{"adjustmentFactor":-1.3111110925674438,"mired":416.1111145019531,"offset":1800000},{"adjustmentFactor":-1.4555555582046509,"mired":439.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6333333253860474,"mired":463.3333435058594,"offset":1800000},{"adjustmentFactor":-1.7999999523162842,"mired":483,"offset":1533000}],"adjustmentIid":11,"adjustmentRange":{"min":10,"max":100}},"updateInterval":60000,"notifyIntervalThreshold":600000}}
[11/23/2020, 8:25:34 PM] [Hue] Bathroom Left: cannot handle transition control: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (buffer.js:333:9)
    at tlvFromHexString (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:159:37)
    at AdaptiveLighting._generateControl (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:195:9)
    at AdaptiveLighting.generateControlResponse (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:205:34)
    at HueLight.setTransitionControl (/usr/local/lib/node_modules/homebridge-hue/lib/HueLight.js:1801:37)
    at _Characteristics.<computed>.emit (events.js:315:20)
    at _Characteristics.<computed>.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at _Characteristics.<computed>.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:652:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1439:24
    at Array.forEach (<anonymous>)
[11/23/2020, 8:25:34 PM] [Hue] Walk-in Closet: set homekit motion from 0 to 1
[11/23/2020, 8:25:35 PM] [Hue] Diego 4: set homekit transition control to ""
[11/23/2020, 8:25:35 PM] [Hue] Hallway Entrance Sensor: set homekit motion from 0 to 1
[11/23/2020, 8:25:38 PM] [Hue] Kitchen: set homekit motion from 0 to 1
[11/23/2020, 8:25:38 PM] [Hue] Kitchen Left: homekit on changed from 0 to 1
[11/23/2020, 8:25:38 PM] [Hue] Kitchen Right: homekit on changed from 0 to 1
[11/23/2020, 8:25:57 PM] [Hue] Bathroom Left: homekit transition control set to {"colorTemperature":{"iid":20,"transitionParameters":{"2.1.2.1":"C4F33DA963C94C0F8B896C36A33EEF9E","startTime":"2020-11-23T19:25:56.548Z"},"runtime":1,"curve":{"entries":[{"adjustmentFactor":-1.8111110925674438,"mired":484.1111145019531,"offset":0},{"adjustmentFactor":-1.8333333730697632,"mired":487.3333435058594,"offset":244000},{"adjustmentFactor":-2,"mired":508,"offset":1800000},{"adjustmentFactor":-2.0888888835906982,"mired":520.888916015625,"offset":1800000},{"adjustmentFactor":-2.0333333015441895,"mired":520.3333129882812,"offset":1800000},{"adjustmentFactor":-1.9777777194976807,"mired":519.7777709960938,"offset":1800000},{"adjustmentFactor":-1.8777778148651123,"mired":515.7777709960938,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":1800000},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":0},{"adjustmentFactor":-1.855555534362793,"mired":518.5555419921875,"offset":9000000},{"adjustmentFactor":-1.8111110925674438,"mired":512.111083984375,"offset":1800000},{"adjustmentFactor":-1.755555510520935,"mired":503.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6666666269302368,"mired":490.6666564941406,"offset":1800000},{"adjustmentFactor":-1.5777777433395386,"mired":476.77777099609375,"offset":1800000},{"adjustmentFactor":-1.4777777194976807,"mired":462.77777099609375,"offset":1800000},{"adjustmentFactor":-1.355555534362793,"mired":447.5555419921875,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":433.4444580078125,"offset":1800000},{"adjustmentFactor":-1.1555556058883667,"mired":419.5555419921875,"offset":1800000},{"adjustmentFactor":-1.1333333253860474,"mired":407.3333435058594,"offset":1800000},{"adjustmentFactor":-1.1888889074325562,"mired":395.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2999999523162842,"mired":385,"offset":1800000},{"adjustmentFactor":-1.4222222566604614,"mired":375.22222900390625,"offset":1800000},{"adjustmentFactor":-1.5333333015441895,"mired":367.3333435058594,"offset":1800000},{"adjustmentFactor":-1.600000023841858,"mired":360,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":352.77777099609375,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":350.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6777777671813965,"mired":349.77777099609375,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6888889074325562,"mired":349.8888854980469,"offset":1800000},{"adjustmentFactor":-1.6555556058883667,"mired":350.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6111111640930176,"mired":352.1111145019531,"offset":1800000},{"adjustmentFactor":-1.5555555820465088,"mired":355.5555419921875,"offset":1800000},{"adjustmentFactor":-1.4666666984558105,"mired":358.6666564941406,"offset":1800000},{"adjustmentFactor":-1.3777778148651123,"mired":364.77777099609375,"offset":1800000},{"adjustmentFactor":-1.288888931274414,"mired":371.8888854980469,"offset":1800000},{"adjustmentFactor":-1.2333333492279053,"mired":382.3333435058594,"offset":1800000},{"adjustmentFactor":-1.244444489479065,"mired":397.4444580078125,"offset":1800000},{"adjustmentFactor":-1.3111110925674438,"mired":416.1111145019531,"offset":1800000},{"adjustmentFactor":-1.4555555582046509,"mired":439.5555419921875,"offset":1800000},{"adjustmentFactor":-1.6333333253860474,"mired":463.3333435058594,"offset":1800000},{"adjustmentFactor":-1.8111110925674438,"mired":484.1111145019531,"offset":1556000}],"adjustmentIid":11,"adjustmentRange":{"min":10,"max":100}},"updateInterval":60000,"notifyIntervalThreshold":600000}}
[11/23/2020, 8:25:57 PM] [Hue] Bathroom Left: cannot handle transition control: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (buffer.js:333:9)
    at tlvFromHexString (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:159:37)
    at AdaptiveLighting._generateControl (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:195:9)
    at AdaptiveLighting.generateControlResponse (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:205:34)
    at HueLight.setTransitionControl (/usr/local/lib/node_modules/homebridge-hue/lib/HueLight.js:1801:37)
    at _Characteristics.<computed>.emit (events.js:315:20)
    at _Characteristics.<computed>.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at _Characteristics.<computed>.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:652:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1439:24
    at Array.forEach (<anonymous>)
[11/23/2020, 8:26:15 PM] [Hue] Hallway Bathroom: set homekit motion from 1 to 0
[11/23/2020, 8:26:15 PM] [Hue] Bathroom: set homekit motion from 1 to 0
[11/23/2020, 8:26:24 PM] [Hue] Bathroom Left: homekit transition control set to {"colorTemperature":{"iid":20}}
[11/23/2020, 8:26:24 PM] [Hue] Bathroom Left: cannot handle transition control: TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined
    at Function.from (buffer.js:333:9)
    at tlvFromHexString (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:159:37)
    at AdaptiveLighting._generateControl (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:195:9)
    at AdaptiveLighting.generateControlResponse (/usr/local/lib/node_modules/homebridge-hue/lib/AdaptiveLighting.js:205:34)
    at HueLight.setTransitionControl (/usr/local/lib/node_modules/homebridge-hue/lib/HueLight.js:1801:37)
    at _Characteristics.<computed>.emit (events.js:315:20)
    at _Characteristics.<computed>.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at _Characteristics.<computed>.Characteristic._this.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:652:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1439:24
    at Array.forEach (<anonymous>)
[11/23/2020, 8:26:30 PM] [Hue] Bathroom Left: homekit adaptive lighting color temperature changed from undefined mired to 376 mired
[11/23/2020, 8:26:30 PM] [Hue] Bath

@ebaauw
Copy link
Owner

ebaauw commented Nov 23, 2020

Do you see the cannot handle transition control error for all your 16 lights or only for the three listed? Could you please attach the debug dump file and the full log file, preferably with Homebridge debug mode enabled?

@simplenotezy
Copy link

@ebaauw all of the lights. I tried removing the once that showed the error but same message

Sent with GitHawk

@ebaauw
Copy link
Owner

ebaauw commented Nov 23, 2020

What iOS version are you on? What brands and models of lights do you have? Home seems to be sending a slightly different transition control setting here; I wonder what's causing the difference.

ebaauw added a commit that referenced this issue Nov 23, 2020
Handle transition control setting without the `2.1.2.3` value, see #766.
@ebaauw
Copy link
Owner

ebaauw commented Nov 23, 2020

Could you try v0.12.3. I hope it fixes the error, but lacking a debug log file, I cannot test it myself.

@sieren
Copy link
Contributor

sieren commented Nov 24, 2020

I don’t think you appreciate how the correction factor works: it is applied to the light’s brightness, not to the colour temperature.

I actually wonder if it'd be possible to add an offset to that. I also find the lights a bit too cool throughout the day and night settings on max brightness. (In all fairness, I know this is more on Apple's side since Homebridge-Hue is fairly in line with first-party adaptive lighting colors like eve strip or hue)

@ebaauw
Copy link
Owner

ebaauw commented Nov 24, 2020

That's what brightnessAdjustment is for: the light displays the colour temperature corresponding to a lower brightness than the light is actually at.

@sieren
Copy link
Contributor

sieren commented Nov 24, 2020

Ahhh, I see. This is what I understood in the first place, but then got confused after your comment to @llamafilm . Thanks for clarifying 👍 :)

Suppose something a bit more verbose like brightnessToColorAdjustment could be helpful? Just a thought though

@ebaauw
Copy link
Owner

ebaauw commented Nov 24, 2020

I'm not very creative in making up names, I'm afraid, but there is a description in the Wiki: https://github.com/ebaauw/homebridge-hue/wiki/Configuration.

@Marfre888
Copy link

@ebaauw so brightnessAdjustment is used to offset color temp to bulb brightness, but my question is, is there any way to verify that the bulbs are applying the correct ct by design

I'm running AdaptiveLighting on a variety of bulbs, Hue color 1st gen, Hue white ambiance 3rd, innr white ambiance, innr color, and they all look a bit bland, and not much change happens over the course of a day. Since I haven't got the official update from Hue yet, I have nothing to compare these bulbs to.

I'm wondering if the gradual change is as Apple intended, and is homebridge-hue simply receiving the data from Apple and offering it up to the light, or is the plug-in or individual bulbs interpreting Apple's data in their own way

@ebaauw
Copy link
Owner

ebaauw commented Nov 26, 2020

is there any way to verify that the bulbs are applying the correct ct by design

Apple hasn’t published any design for this, so the only way is comparing it to lights that natively support adaptive lighting.

I'm wondering if the gradual change is as Apple intended, and is homebridge-hue simply receiving the data from Apple and offering it up to the light, or is the plug-in or individual bulbs interpreting Apple's data in their own way

RTFM, #766 (comment)

@aje89
Copy link

aje89 commented Dec 11, 2020

In my log i can see the following:

[11/12/2020, 18:06:50] [Hue] Schreibtisch: set homekit supported transition configuration to {"configuration":[{"iid":11,"characteristic":1},{"iid":13,"characteristic":2}]}

Its a Tradfri Bulb E14 WS opal 400lm on Firmware 2.3.50 on deconz 2.7.0

But in HomeApp adaptive Lighting does not show up the function does not show up.

All my devices are on IOS 14.2 .

Homebridge is on 1.2.4
homebridge-hue v0.12.11
Node.js Version | v14.15.1
NPM | v6.14.9

@ebaauw
Copy link
Owner

ebaauw commented Dec 11, 2020

Haven’t seen that before. Did you restart your iOS device? Otherwise, turn on debug mode in Homebridge and capture and attach the log file, from Homebridge startup to running for a couple of minutes.

@WeylandYutani82
Copy link

With 100% brightness, the recipe yields colour temperature values between 181 (~5500K) and 333 (~3000K). With 10% brightness, it yields values between 333 mired (~3000K) and 500 mired (2000K). Most of my on/off lights produce 2700K (370 mired), so for full brightness, adaptive lighting looks unpleasantly white. I've added a brightnessAdjustment config.json key, to set a correction factor for the light brightness, to soften the adaptive lighting temperature. It defaults to 100% (using the light brightness) on Homebridge startup. When you set it to 50%, it applies the recipe for a half the light brightness; when you set it to 10%, it applies the 10% brightness recipe for all brightness values.

I like the 181 mired during noon, but I don't like the minimum 333 mired during night time. With the brightness options <100% it is too yellowish during noon, with brightness >10% it's too white at night. I'd prefer the 500 mired during night and 181 during day, so to have the full spectrum between night and day.
Would there be a way to e.g. give parameters for minimum and maximum mireds?

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

No branches or pull requests