-
Notifications
You must be signed in to change notification settings - Fork 35
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
Allow listening for Hue events #48
Conversation
aiohue/lights.py
Outdated
if (color := update.get("color")) : | ||
state["xy"] = [color["xy"]["x"], color["xy"]["y"]] | ||
|
||
if ct := update.get("color_temperature"): | ||
state["ct"] = ct["mirek"] | ||
|
||
if "on" in update: | ||
state["on"] = update["on"]["on"] | ||
|
||
if dimming := update.get("dimming"): | ||
state["bri"] = dimming["brightness"] |
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.
Update events have their own format.
These are the ones that I found so far for lights.
aiohue/bridge.py
Outdated
for update in event["data"]: | ||
item_type = update["id_v1"].split("/", 2)[1] | ||
|
||
if item_type == "lights": |
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.
For first version we're only going to support update events for lights.
aiohue/bridge.py
Outdated
if self.proto is not None: | ||
raise | ||
|
||
self.proto = "http" | ||
return await self.request(method, path, json, auth) | ||
|
||
async def request_2(self, method, path): |
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.
I am available for all your naming inquiries.
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.
Looks good!
I'm still testing the timeouts on my end. Currently running a test without a timeout. |
@balloob , @Thomas-Vos, is this hue events API documented anywhere? |
@spudwebb the new API is not documented anywhere, you just need to try it and see what happens. Philips Hue said on their developer website that they have some "significant API announcements coming up soon". |
Does this work with the Hue motion sensor yet? |
Hi there, After a few weeks it seems it made it from dev branch to stable and I observed it working on my Tap switches amongst things. But as of late with core-2021.8.8 I seem to be getting about a 5 second response rate on key presses in the worst case and it makes me think polling is back on vs push. This has been a long "debated" topic on the web, but I just cannot figure out for the life of me how or where these settings are. Like can one set the polling rate statically somewhere? or can one toggle between polling vs pushing? What is the intended / expected behavior for the official HA hue integration here? I looked at these places: And been try with my limit python knowledge to figure it out from here: Thanks! |
I am experiencing the same polling slowness as @s3frank (up to 5s) with Philips Hue dimmer switches (V1 / V2). It seems like Hue dimmer remotes/motion detectors connected through the Philips Hue Hub are still using local polling and I haven't been able to find anywhere that mentions local push having been implemented either for anything other than lights. According to michielpost/Q42.HueApi#255 it sounds like it will be implemented eventually? That's hopeful. The https://github.com/azogue/fasthue polling speed-up hack still seems to be the best way to have a reasonable response time for Hue remotes/motion detectors. Thanks |
Hue Remotes seem to work great with local push as of the 2021.12 updates |
This will give an instant state update instead of having to poll.
This is MVP with some basic info for a light.
Test it out with
python3 example.py
. To see debug logs, runDEBUG=1 python3 example.py
Thanks to a discovery by @Thomas-Vos