Skip to content

adaptive lighting support for CCT lights - #1028

Merged
timoschilling merged 5 commits into
mongoose-os-apps:masterfrom
markirb:features/adaptive_lighting
Jan 25, 2023
Merged

adaptive lighting support for CCT lights#1028
timoschilling merged 5 commits into
mongoose-os-apps:masterfrom
markirb:features/adaptive_lighting

Conversation

@markirb

@markirb markirb commented Jul 6, 2022

Copy link
Copy Markdown
Collaborator

I have been working on this for a while, as I really find this an interesting feature.
I think now it is in a state for review and testing.

currently it relies on one additional fix mongoose-os-libs/homekit-adk#10

This adds the Homekit feature adaptive lighting for Lights supporting ColorTemperature (CCT at the moment).
When adaptive lighting is enabled, the light gets a schedule every 24 hours how to adapt the color temperature according to the current night / daytime. Afterwards the schedule is ran on the device itself see e.g. https://www.howtogeek.com/712520/how-to-use-adaptive-lighting-with-apple-homekit-lights/ for how this works.

As this is not (yet) documented in the published Apple Homekit spec, this relies heavily on the reverse engineering of the TLV done by Homebridge specifically https://github.com/homebridge/HAP-NodeJS/blob/master/src/lib/controller/AdaptiveLightingController.ts.

The only thing missing is making the schedule permanent. But I do not know if this makes sense as it uses ~1kB of configuration storage and only would make sense if we have a notion of time on the device otherwise we do not know where to continue after a downtime.

@markirb markirb changed the title adaptive lightning support for CCT lights adaptive lighting support for CCT lights Jul 6, 2022
@markirb
markirb force-pushed the features/adaptive_lighting branch from 47ddb01 to 5954e5c Compare December 13, 2022 09:09
Comment thread mos.yml
@timoschilling

Copy link
Copy Markdown
Collaborator

Nice, didn't noticed this PR in July.

@bobziroll

Copy link
Copy Markdown

Any updates on this? I'm super excited I found this firmware for the Shelly RGBW2 and was able to get my RTF-Lighting FCOB CCT lights to work with tunable controls in HomeKit. Nothing else I tried worked as well as this.

The icing on the cake would be having adaptive lighting support as well 🤩

@markirb

markirb commented Jan 18, 2023

Copy link
Copy Markdown
Collaborator Author

Mh I use this every day since several months so I can say that for me works pretty well :)

If @rojer fixes the build pipeline by updating https://hub.docker.com/r/mgos/esp32-build/tags via cesanta/mongoose-os#603 then the GitHub action would provide some beta you could try on your device. Or you build it yourself? :)

Any feedback welcome...

@markirb
markirb force-pushed the features/adaptive_lighting branch from 68c88f7 to 763cd67 Compare January 18, 2023 20:11
@bobziroll

Copy link
Copy Markdown

Sorry, I'm pretty new to all this. How would I go about building it myself? As in, I would just flash it with your version of the firmware that's still waiting to be merged? If so, how do I go about doing that? I'd love to test it out if I can.

@markirb

markirb commented Jan 18, 2023

Copy link
Copy Markdown
Collaborator Author

Okay, this is the current build of commit 763cd67 for uploading via web interface
ShellyRGBW2.zip

@bobziroll

Copy link
Copy Markdown

Seems to be working! I had to remove the accessory and add it back into HomeKit but it's got the adaptive lighting option there now and seems to be working great!

@markirb

markirb commented Jan 18, 2023

Copy link
Copy Markdown
Collaborator Author

Readd? Strange... Are you on the "new architecture" of HomeKit of latest iOS update (that recently got pulled again?) might be the caching of this new architecture...

@bobziroll

bobziroll commented Jan 18, 2023

Copy link
Copy Markdown

I'm not sure, I don't know anything about it. How would I check?

It's also possible I didn't actually need to remove and add it back. That's just the first thing I tried when it wasn't showing adaptive lighting as an option after the firmware update.

this adds the homekit feature adaptive lightning.
as this is a non-officially documented feature by apple homekit
specification, it relies on the reverse engineering done by homebridge
@markirb
markirb force-pushed the features/adaptive_lighting branch 3 times, most recently from 85aa92f to deb843b Compare January 19, 2023 08:31
@markirb
markirb force-pushed the features/adaptive_lighting branch from deb843b to b9dafce Compare January 19, 2023 08:33
Comment thread mos.yml Outdated
Comment on lines +52 to +59
// Use adaptive lightning when possible (CCT)
std::unique_ptr<hap::AdaptiveLighting> adaptive_light;
adaptive_light.reset(new hap::AdaptiveLighting(hap_light.get(), lb_cfg));
auto st = adaptive_light->Init();
if (st.ok()) {
hap_light->SetAdaptiveLight(std::move(adaptive_light));
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be integrated in the CCTController? Because it's the only light which supports it.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it could. But on the other hand: the controller should not need to know about adaptive lights existing. And the Adaptive Lightning Protocol of Apple is generic in the way that it could support autotuning other characteristics, not limited to only color temperature, so I actually think it would make more sense this way

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good argument. My main point is that I don't like ot have redundant code in the device specific files. You follow the current pattern, so it's ok. That problem should be solved, but not in this PR.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree

@markirb

markirb commented Jan 19, 2023

Copy link
Copy Markdown
Collaborator Author

I'm not sure, I don't know anything about it. How would I check?

I guess currently it's complicated if you don't already know... so never mind.

@bobziroll

Copy link
Copy Markdown

@markirb I wasn't on the new architecture at the time. I just updated yesterday, so now I am. No issues so far.

markirb and others added 2 commits January 21, 2023 07:03
Co-authored-by: Timo Schilling <timo@schilling.io>
@timoschilling
timoschilling merged commit cd1a7e0 into mongoose-os-apps:master Jan 25, 2023
@bobziroll

Copy link
Copy Markdown

I tried installing the firmware from http://A.B.C.D/ota?url=http://shelly.rojer.cloud/update last night on my 2nd RGBW2 device after I saw this feature had been merged, but adaptive lighting still didn't show up as an option on HomeKit. Did I miss something? I made sure the firmware was updated before doing it.

I just ended up just installing the zip file from @markirb on it like I did on my first RGBW2 device instead.

@markirb

markirb commented Jan 27, 2023

Copy link
Copy Markdown
Collaborator Author

pushing to master does not equal a release.

first it will go to a beta, then somewhen a release

@timoschilling

Copy link
Copy Markdown
Collaborator

Here are some prerelease builds with this PR, for the devices which are supporting CCT.
shelly-homekit-ShellyRGBW2.zip
shelly-homekit-ShellyDuo.zip
(ping me if I missed one)

@bobziroll

Copy link
Copy Markdown

pushing to master does not equal a release. first it will go to a beta, then somewhen a release.

@markirb Ah, okay makes sense.

Here are some prerelease builds with this PR, for the devices which are supporting CCT.

@timoschilling Thanks so much! They seem to be working great so far.

@markirb
markirb deleted the features/adaptive_lighting branch October 20, 2024 08:32
@InventoryAndi

Copy link
Copy Markdown

Hi @markirb: is it there also a possibility to support this feature for Shelly Duo - RGBW? I just know that there are nanoleaf lights available which supports RGB and CCT and you can activate adaptive lighting in homekit. Not sure if it is a different technology in comparison to Shelly but I think Shelly Duo - RGBW have also cold and warm white so I think this feature could be possible?

@markirb

markirb commented Oct 25, 2024

Copy link
Copy Markdown
Collaborator Author

I do not understand so actually want to control your rgbw as though it was a CCT?

Or does HomeKit support the menu for RGBW also?

Can you show me the menu in HomeKit?

@InventoryAndi

Copy link
Copy Markdown

Hi. The idea was to enable adaptive light for the Shelly lamp RGBW (as it is available for CCT). At the moment it only works for the CCT.
I thought this might be possible because I have a nano leaf bulb RGBCW and for this bulb the adaptive light is also available. But maybe I'm wrong and the nano leaf is a RGBCCT and that's why for this build the adaptive light is available (and for shelly bulb RGBW is not)

Attached I added the HomeKit settings.
IMG_0801 = shelly bulb CCT with adaptive light availability on / off
IMG_0799 = shelly bulb RGBW with no adaptive light availability - only color
IMG_0802 = a nanoleaf bulb (on the website they call it RGBCW) with adaptive light availability on / off - and color
IMG_0801
IMG_0799
IMG_0802

@InventoryAndi

Copy link
Copy Markdown

Hi. Any ideas / feedback on that?

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

Successfully merging this pull request may close these issues.

4 participants