No hue.hue_get_scene : Extract and display active Hue scene per light

HI,

Im am trying to extract the active scene from a Hue-light. Created several json sensors through the Hue-api for …/scenes, … /lights, …/sensors etc etc Had hoped to have some Template-sensors for showing my Lights with their activated scenes, if any.

This is what i have now, and the scenes would be the ultimate addition:

50

Using the above able to find and list all scenes, sensors and lights (schedules and others are also available).
Unfortunately the Scenes seem not to have line with the lights that actually have this scene activated. (it does show the lights for which this scene is available, but thats not what Im looking for)

In the Lights-list, [numbered], all attributes are listed per light, but unfortunately the scene isn’t listed…

Anyone able to extract the Light/Scene combo? Hoping the hue.hue_get_scene service would be available…

It would be especially useful since i have created this small package for selecting and activating these scenes and need to have the feedback the scenes are actually set.

30
Thanks, Marius

1 Like

I think the scene setting is a one-way thing, meaning calling a scene will set the corresponding light parameters, but the lights themselves don’t know anything about scenes.
It’s just a convenient way of setting “light 1: brightness N, colour XYZ; light 2 … ; light 3 …”.

You could build up a kind of internal scene database from the bridge configuration and then match the current light settings against that.
You might end up with some false matches though, e.g. when scenes have common settings for some lights and all other lights are turned off - there would be no way to tell which scene caused the remaining lights to be set the way they are.

Sebastian

Yes i do believe for now that would be the only way…
hue.hue_get_scene would be way more convenient ;-()(

Ive posted on the Hue api developers forum, maybe they can point to a solution

taking a deep dive into the api call results now:

searching for the bri":94,“hue”:1382,“sat”:234,“ct”:153 arguments and matching these to a scene setting seems possible…

'7MyIlJMBKGvNBTO': {'name': 'Relax', 'lights': ['1', '2', '3', '4', '5', '6', '7', '8', '9'], 'owner': 'W5BalDNEw-VSc07ddGOnT7Wt0v7z9h12P83-MgtB', 'recycle': True, 'locked': False, 'appdata': {'version': 1, 'data': '00001_r00_d01'}, 'picture': '', 'lastupdated': '2018-01-19T14:05:21', 'version': 2}, 

'kPFcNzSXZ5I3f2P': {'name': 'Read', 'lights': ['1', '2', '3', '4', '5', '6', '7', '8', '9'], 'owner': 'W5BalDNEw-VSc07ddGOnT7Wt0v7z9h12P83-MgtB', 'recycle': True, 'locked': False, 'appdata': {'version': 1, 'data': '00002_r00_d02'}, 'picture': '', 'lastupdated': '2018-01-19T14:05:23', 'version': 2}, 

'SCphcjZwFWQwGHx': {'name': 'Concentrate', 'lights': ['1', '2', '3', '4', '5', '6', '7', '8', '9'], 'owner': 'W5BalDNEw-VSc07ddGOnT7Wt0v7z9h12P83-MgtB', 'recycle': True, 'locked': False, 'appdata': {'version': 1, 'data': '00003_r00_d03'}, 'picture': '', 'lastupdated': '2018-01-19T14:05:24', 'version': 2}, 

'CK-FySAVrJGxmWQ': {'name': 'Energize', 'lights': ['1', '2', '3', '4', '5', '6', '7', '8', '9'], 'owner': 'W5BalDNEw-VSc07ddGOnT7Wt0v7z9h12P83-MgtB', 'recycle': True, 'locked': False, 'appdata': {'version': 1, 'data': '00004_r00_d04'}, 'picture': '', 'lastupdated': '2018-01-19T14:05:25', 'version': 2}, 

and

per light:

{"1":{"state":{"on":false,"bri":94,"hue":1382,"sat":234,"effect":"none","xy":[0.6411,0.3332],"ct":153,"alert":"none","colormode":"xy","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2017-12-18T07:24:35"},"type":"Extended color light","name":"Dining corner","modelid":"LCT015","manufacturername":"Philips","capabilities":{"certified":true,"streaming":{"renderer":true,"proxy":true}},"uniqueid":"00:17:88:01:03:03:93:d5-0b","swversion":"1.29.0_r21169","swconfigid":"3416C2DD","productid":"Philips-LCT015-1-A19ECLv5"},

"2":{"state":{"on":false,"bri":64,"hue":1386,"sat":234,"effect":"none","xy":[0.6410,0.3332],"ct":153,"alert":"none","colormode":"xy","mode":"homeautomation","reachable":true},"swupdate":{"state":"noupdates","lastinstall":"2017-12-16T17:46:10"},"type":"Extended color light","name":"Kist","modelid":"LCT015","manufacturername":"Philips","capabilities":{"certified":true,"streaming":{"renderer":true,"proxy":true}},"uniqueid":"00:17:88:01:03:7f:3a:86-0b","swversion":"1.29.0_r21169","swconfigid":"3416C2DD","productid":"Philips-LCT015-1-A19ECLv5"},

etc etc

the scenes apply to groups of course, but in the groups configuration in Hue Api, there’s no mentioning of scenes either…?

Hello, is there a solution for this problem now? I also would like to see the active scene in home assistant.
Thanks

I wasted so many hours trying to get this to work with no luck and in the end it was much simpler and only took about 20 minutes to create light groups on homeassistant and scripts to activate them. I have a lot more control over the scenes too and can turn off other lights/scenes when they’re activated.
E.g turn on Island Lights can turn off all other kitchen lights except under cabinet Leds and turn on just island lights at say 10% brightness.
Works perfect with Alexa and input select from rotary dinners on the wall etc.

I was facing the same challenge, using the hue scenes and switching between then using the lovelace interface.

I really want to use the hue control, because of redundancy. I have the Home Assistant instance running at a remote location, and it might crash (actually it did a few times). Having hue in place gives you the option to bypass HA and have a second way to control the lights. (e.g. when electricity is interrupted, hue switches any non-hue bulb to on after the hue-bridge is back online)
Also the hue control is far better responsive then going through HA

My approach to this will be:

  • I use the hue switch only for turning on/off , so i when going from off to on I know the initial scene, using consistent namings in your scene may help, i.e. from Off to On might always be scene “Normal”

  • In the scene editor of HA, make sure every scene is attached to an area (I have not seen any other way to accomplish this) and add an icon to show in the UI.

  • I use Home Assistant GUI for switching scenes in stead of the multiple presses

  • I use an input_select to contain all scenes per area. This select keeps track of the current scene
    You can fill this input_select on home assistant start with all scenes in that area, i.e.:

{{ area_entities('Living room') | select('match', '^scene\.') | list }}

and also build some UI for selecting the scene:

               type: custom:auto-entities
                card:
                  type: grid
                card_param: cards
                filter:
                  include:
                    - area: Woonkamer
                      domain: scene
                      options:
                        type: custom:button-card
  • create an automation per area when it turns from on to off, (I have a group of lights per room which can be checked in the trigger). In this automation set the current selected value of the input_select to the correct initial scene

  • create other automations for selecting the other scenes and update the input_select, so you can highlight the current scene in the Lovelace interface

Optionally I can create automations on the switch for multiple presses to change scenes and update the input_select

Not sure if you’re using the new Hue Api V2 in current HA yet, but have a look here how you can easily set or select scenes fully automated

1 Like