Possible to trigger Hue Labs from Home Assistant?

Has anyone had success in triggering Hue Labs experiments from inside of Home Assistant? I’d like to be able to trigger the candle flicker experiment as part of a ‘relax’ scene.

If that’s not possible yet… has anyone written a ‘candle flicker’ script? I suspect it’s possible using random delay and random brightness.

1 Like

Great Question! I’m trying to get Hue Labs Living Scenes to work with Home Assistant and found nothing so far … :confused:
It’s possible to make a script with brightness and colour changes, tough.
But beware! I once got my bridge to infinite loop the lights. I couldn’t cancel the loop and the lights went all crazy :stuck_out_tongue: No App and no hardware switch (Hue Tap) was able to shut them down.
Had to reset the hue bridge and reconfigure all the lights and groups …

1 Like

Have you had any luck with this or found a way to cycle the lights?

The individual light has the option for colorloop and random, which sounds promising, but I haven’t tried it yet. I’m not even sure where that comes from since I don’t see that through the hue ui.

No I haven’t, I gave up on the idea! I suspect it’s possible to mimic the candle flicker itself with some clever use of random numbers for brightness/warmth however I’ve not had the time or willingness to attempt it!

Ok. Today, I finally got living scenes to work with home assistant!
It’s a bit tricky, but with an amazon echo unit and a script from lötzimmer (https://blog.loetzimmer.de/2017/10/amazon-alexa-hort-auf-die-shell-echo.html) you will be able to trigger it.
You need to configure the living scene in the hue app with a virtual button, so that you can find the scene in the alexa app (with the installed hue skill).
Then you install the alexa_remote_control.sh script from loetzimmer in your home assistant config/ folder and configure these entries:
SECRETS_YAML=
LANGUAGE=
AMAZON=
ALEXA=
Here is some info to configure it with hassio: Running alexa_remote_control.sh inside Hass.io
After you have successfully installed the script you cannot just have alexa speak out anything you like and put out every data you like from home assistant, you can also start tunein radio stations, weather reports, traffic info, and much more on your echo unit. And finally you can start Alexa routines!
So you configure a routine which starts the living scene and then you configure home assistant to tell Alexa to starts your living scene routine. (Who said it has to be difficult? :P)
Here’s an example:

[configuration.yaml]
shell_command:
alexa_speak: /config/alexa_remote_control.sh -d “my Echo” -e speak:"{{text}}"
alexa_routine: /config/alexa_remote_control.sh -d “my Echo” -e automation:"{{text}}"

[scripts.yaml]
alexa_script:
sequence:

  • service: shell_command.alexa_speak
    data_template:
    text: ‘Starting your living scene.’
  • service: shell_command.alexa_routine
    data_template:
    text: ‘’

I hope someone has some use for it. It took me quite a while to connect all these dots together.
Have fun! :slight_smile:

Its possible to do if you call resource links on the hue api http:///api//resourcelinks you get a list of the labs scenes, look for the links key in the scene you want which will have several entries. Look for the only sensor value in the key. then make a state call http:///api///state use a PUT with status of 1 or 0 for off/on.

Then put it in a restful switch, although I did mine using resful/booleans/automations as I didn’t know resful switches existed.

If you have an iOS device and shortcuts, this might help you do it.

Actually heres a good explanation https://aarongodfrey.dev/home%20automation/automating-hue-labs-formulas/

1 Like

I tried this. It doesn’t seem like that virtual switch for hue labs is actually RESTful.

[raun@localhost ~]$ http -v PUT http://192.168.2.4/api/UID/sensors/3/state status:=1
------SNIP------
{
    "status": 1
}

But it doesn’t allow a GET request back to the same URL, which is a problem for the RESTful switch

[raun@localhost ~]$ http -v GET http://192.168.2.4/api/UID/sensors/3/state
-----SNIP------
[
    {
        "error": {
            "address": "/sensors/3/state",
            "description": "resource, /sensors/3/state, not available",
            "type": 3
        }
    }
]

It works.

The Shortcut from RoutineHub linked above is a good tool to indetify which Labs you want. But it can be guessed by polling the hue hub and checking for { modelid":"HUELABSVTOGGLE … }

Command-line switch should be configured as following in configuration.yaml;

switch curlhue:
- platform: command_line
  switches:
    hue_lab_candle_bedroom:
      command_on: curl -X PUT -d '{"status":1}' "http://IP/api/APIKEY/sensors/52/state"
      command_off: curl -X PUT -d '{"status":0}' "http://IP/api/APIKEY/sensors/52/state"
      command_state: 'curl http://IP/api/APIKEY/sensors/52'
      value_template: '{{ value_json.state.status == 1 }}'
      friendly_name: HUE Labs Candlestick Bedroom
    hue_lab_sunset_multiroom:
      command_on: curl -X PUT -d '{"status":1}' "http://IP/api/APIKEY/sensors/44/state"
      command_off: curl -X PUT -d '{"status":0}' "http://IP/api/APIKEY/sensors/44/state"
      command_state: 'curl http://IP/api/APIKEY/sensors/44'
      value_template: '{{ value_json.state.status == 1 }}'
      friendly_name: HUE Labs Sunset Multiroom
1 Like

This is really helpful. Thanks

or as a RESTful switch

  - platform: rest
    resource: http://IP/api/APIKEY/sensors/40/state
    state_resource: http://IP/api/APIKEY/sensors/40
    name: 'Hue Labs Under the Sea'
    method: put
    body_on: '{"status":1}'
    body_off: '{"status":0}'
    is_on_template: '{{ value_json.state.status == 1 }}'
    headers:
      Content-Type: application/json
2 Likes