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

Allow listening for Hue events #48

Merged
merged 16 commits into from
May 13, 2021
Merged

Allow listening for Hue events #48

merged 16 commits into from
May 13, 2021

Conversation

balloob
Copy link
Collaborator

@balloob balloob commented May 13, 2021

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, run DEBUG=1 python3 example.py

Thanks to a discovery by @Thomas-Vos

aiohue/lights.py Outdated
Comment on lines 96 to 106
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"]
Copy link
Collaborator Author

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":
Copy link
Collaborator Author

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):
Copy link
Collaborator Author

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.

aiohue/bridge.py Outdated Show resolved Hide resolved
aiohue/clip.py Outdated Show resolved Hide resolved
aiohue/clip.py Outdated Show resolved Hide resolved
aiohue/clip.py Outdated Show resolved Hide resolved
Copy link
Contributor

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good!

@balloob
Copy link
Collaborator Author

balloob commented May 13, 2021

I'm still testing the timeouts on my end. Currently running a test without a timeout.

@spudwebb
Copy link

spudwebb commented Jun 9, 2021

@balloob , @Thomas-Vos, is this hue events API documented anywhere?
how did you find about it?

@Thomas-Vos
Copy link

@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".

@willjgit
Copy link

Does this work with the Hue motion sensor yet?

@s3frank
Copy link

s3frank commented Sep 5, 2021

Hi there,
I was running the fasthue custom integration to have more responsiveness on HA side to event from Hue.
When HA enhanced it's io layer for hue to support push eventing that component was deprecated by the developer as mentioned in this thread.
azogue/fasthue#22

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?
Where is this documented?

I looked at these places:
https://www.home-assistant.io/integrations/hue/

And been try with my limit python knowledge to figure it out from here:
https://github.com/home-assistant-libs/aiohue

Thanks!

@phillipsawyer
Copy link

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

@phillipsawyer
Copy link

phillipsawyer commented Dec 31, 2021

Hue Remotes seem to work great with local push as of the 2021.12 updates

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.

7 participants