-
-
Notifications
You must be signed in to change notification settings - Fork 38k
Migrate homekit_controller light to color_mode #69261
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
660f971
Migrate homekit_controller light to color_mode
emontnemery 5ee6331
Update according to discussion in PR
emontnemery 298d529
Adjust tests
emontnemery 325a994
Revert "Update according to discussion in PR"
emontnemery 4e3a56a
Update according to discussion in PR
emontnemery 4fef9f7
Adjust tests
emontnemery File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not change the behavior compared to without this PR because it would always report a non-
Nonehs color for lights supporting hue/saturation which is interpreted as color mode hs by the base entity.However, for lights which support both hs and white mode it would be better to report according to the light's state.
I did not immediately find anything useful in the library though. Any idea, @Jc2k , @bdraco?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HomeKit (at least as defined in the public spec (https://developer.apple.com/file/?file=homekitspecification&agree=true)) doesn't have the concept of an active color mode. You can use h/s and you can use color temp. It has the characteristics you can see here, and thats it. There's no way to indicate which color mode is currently in use.
Sometimes you can figure out a bit more from the open source example code. There are some notes here:
https://github.com/apple/HomeKitADK/blob/b171c17dba6e593e243b5fdd61fb986e9fd3b5cb/HAP/HAPServiceTypes.h#L76
Again, theres no characteristic to indicate a color mode there.
#42807 (via @bdraco) says:
Does that help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I see. I'll add a comment in the code stating that's the case.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The situation has changed a bit in iOS 13+
The spec says that you're not supposed to have color and color temperature at the same time, but in practice even certified devices implement that now. Apple seems to be certifying them anyway, and the hope is that the spec will get updated in the next version to remove that restriction. iOS seems to handle it now so it seems like the documentation is behind the actual implementation
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The way iOS seems to handle it is, whichever characteristic was the last to get a notify/event for is the color mode you're in
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully we'll get a new spec or an ADK update... (doubt it).
It might be less sucky after I've done all the refactoring I want to in aiohomekit (I want the abstraction to be higher level than it is right now).
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Based on your discussion I don't think the simplification I did in 5ee6331 was correct, it should instead be like this:
supported_color_modes = {COLOR_MODE_COLOR_TEMP, COLOR_MODE_HS}(no change compared to before this PR)COLOR_MODE_HS(no change compared to before this PR)Is that right?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be more pedantic on the second bullet: the HAP protocol itself (rather than aiohomekit) doesn't really have a concept of a current colour mode to track and aiohomekit's abstraction doesn't let us work around that. And even if it did, it would be an incomplete work around (we would lose the "current colour mode" on a simple HA restart for example). I assume the official iOS implementation is subject to the same limitations too.
(The thing I'm being pedantic about is that despite the changes in iOS 13 it's still not the case there is a variable /to/ track, we would have to track multiple variables for multiple event types (push, put and poll) and then infer our own value from the event timestamps of a subset of event types, only to have a partially working implementation at the end of it).
In the future we could implement the heuristics described to make it closer to the ideal, but short of Apple adding a new colour mode characteristic there is a potential for our implementation to seem "glitchy". So we might not want to implement such heuristics at all.
But the ultimate conclusion is the same, I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, updated again.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bdraco, @Jc2k Is this PR OK now, or are more changes needed?