core icon indicating copy to clipboard operation
core copied to clipboard

Add scene support for scenes defined in Home Assistant

Open finopsfuntimes opened this issue 4 years ago • 5 comments

Is your feature request related to a problem? Please describe.

I bought this light switch, which displays and allows you to activate Hue scenes for the chosen room. Violet smart switch lite It would be great to have this work natively with hass-emulated-hue !

Describe the feature that you would like to be added

Support for scenes:

  • Scenes defined in HomeAssistant should be exposed by the /scenes API route.
  • Scenes defined in HomeAssistant can can be recalled/activated by calls to the /groups/id/action route, specifying a scene ID in the request body as per the standard API.

Describe alternatives you've considered

I have used Postman to call the create scene API endpoint to define scenes manually, with some success.

Describe your use case for this feature

Exposing the scenes defined in home assistant will avoid having to create them manually and would be of benefit to all users, not just those who want to use the light switch I've mentioned!

Additional context

finopsfuntimes avatar Jul 24 '21 14:07 finopsfuntimes

One concern is that it wouldn't be modifiable through the hue API. The other major feature I would like to work on is the v2 api

alexyao2015 avatar Jul 24 '21 16:07 alexyao2015

The v2 api will be great to get implemented once we see the documentation for it :)

Could we just return an appropriate http error code if a user tried to edit a hass managed scene?

It would also be nice to have a config option to turn on the scene integration only if required.

finopsfuntimes avatar Jul 26 '21 15:07 finopsfuntimes

The issue with error messages is that all apps won't necessarily respond correctly to it as its not something that is normally encountered with the normal hue bridge. While I'm not sure of the exact outcome, I would not be surprised if many if not all apps crash when trying to do that.

Regardless, will consider this for the future as development here has been slow.

alexyao2015 avatar Jul 26 '21 16:07 alexyao2015

That's a good point about the crashes. I guess the other option is to discard the new values in the request and then return an OK response?

finopsfuntimes avatar Jul 26 '21 17:07 finopsfuntimes

Made some changes in my own fork that have got this working for my use case - compare

All the existing scene functionality is retained, but now the hass scenes are exposed as well. Hass scenes are identified by the presence of an entity_id attribute in the scene config and as such, when the action to recall a scene is handled, the command is directed to hass to turn_on the scene instead of running the original code.

If a user deletes a hass scene through the api, the scene does not get deleted from hass and will therefore get recreated automatically the next time the /scenes endpoint is called.

If a user edits a hass scene through the api, the changes are not propagated to hass, so the changes have no effect

finopsfuntimes avatar Jul 29 '21 10:07 finopsfuntimes