home-assistant-libs / aiohue

Python3 asyncio package to talk to Philips Hue
Apache License 2.0
60 stars 36 forks source link

Support for virtual Hue Labs switches #182

Open danielschenk opened 1 year ago

danielschenk commented 1 year ago

Hue Labs are a collection of experimental scenes, automations and rules which can be installed onto the bridge via the Hue Labs portal. This article shows an undocumented method to toggle these formulas (eg. dynamic scenes) via the API.

I now use a RESTful command in HA to toggle my labs formulas. This is cumbersome because it has no relation to the Hue integration at all, and I needed to get a separate API key from my bridge and put it into my secrets. Moreover, I need to fetch the resource links from my bridge with some other tool to find out the IDs I want to control.

Even though this resource links API method is undocumented, would it be a nice idea to add support for this in the library? I don't know if these resource links are subscribeable (like the usual objects) so I can imagine that keeping the Home Assistant DB in sync with these could be a pain. If aiohue can provide APIs to at least fetch them and set their state, then HA could maybe just periodically fetch them and provide them as controllable entities. Another option could be to put a button somewhere in the UI to trigger a fetch (and warn the user that this is an experimental feature, due to the API which could break at any time).

marcelveldt commented 1 year ago

The linked article mentions a method on the old/deprecated v1 api. Nowadays everything has moved to the v2 api. This is available in aiohue as script instances.

At some point it might be of interest to translate some/all of the available scripts as button entities or something like that.

danielschenk commented 1 year ago

Do I understand correctly, that it's possible to set labs formula states with aiohue, but it's not exposed in HA yet? Should I raise a ticket at HA itself for this?

marcelveldt commented 1 year ago

Well, you could raise a ticket but this is not a bug but a feature request ;-) So let's wait for someone to pick up the glove and implement it, all building blocks are already prepared.

If there is a lot of interest I might pick it up at some point just not now as I'm really busy with other things.

danielschenk commented 1 year ago

I'm experienced in Python but not familiar with the code base. Also I have done little with async up until now. It could be a nice opportunity to get more familiar with it, but have some other priorities as well.

If I feel like I could give it a try and have the time for it I'll let you know. Please let me know if you start with it instead.