Coupling multiple switches with emulated hue and alexa

I’m trying to get the following behavior:

“Alexa, turn on the TV” -> Turns on the television, and the receiver (for audio)
“Alexa, turn off the TV” -> Turns off the television, and the receiver

I have switches in HA (broadlink platform) set up for this for each component, and emulated_hue working to control either of them separately. My first thought to couple the two switches to one voice command was to use a script, one to turn on both devices, and one to turn them both off. However, this doesn’t work as I’d like it to. Alexa wants a command of the form “turn on <device>”, and “turn off <device>”. But if <device> is a script, I don’t think any parameters get sent to the script, so I can’t distinguish between the script being called in an on or off context, without something awkward like “turn on tv on” and “turn on tv off”.

There must be a better way to organize it to get the desired behavior. Is there a way to make a dummy switch which actually controls a group of switches? Any ideas?

Input Boolean … and have an automation that triggers when the input Boolean turns on that the action contains both devices and an automation to do the same for off.
I have an input Boolean and with the emulated hue component and Alexa turns it on and off for me

Just group them, either in HA and expose that with emulated_hue or make a group of the two HA devices in the Alexa app and call it whatever you like.

I am still learning HA so be patient with me but I am trying to figure out how to do something similar but want to set the state of multiple other lights using Alexa and the emulated hue component. I already have all my lights exposed to Alexa through the emulated Hue and that works through smart things through mqtt for the time being. I am using virtual switches in smart things right now and exposing those to Alexa so once I can get that working in HA I can make the hard cutover and get completely off smart things.

Essentially what I want to do is say “Alexa, turn on dinner time” and dinner time would 1. Set light.kitchen to 60% dim, light.family_table to 100%, light.sofa to 0% or off, light.bloom_kitchen to 80% and set the color to yellow. I’d also like to be able to say “Alexa, turn off dinner time” and have that turn every associated light to off or maybe set all the lights back to the original state but that is more advanced and less important for now. I’d be happy just to get back to the same functionality I had working in smart things.

I am not sure how to get started with this or if anyone has examples of this they could point me to. I am not sure if I should be looking at the template switch or the input boolean along with something else to control.

Really simple, first create one scene for the on state and another for the off state. Then create an automation triggered by the state change of an input_boolean, on triggers the first scene and vice versa. Finally expose the input boolean to emulated hue.

1 Like

Thanks a lot for the tip. That actually did exactly what I needed once I figured out the yaml for scenes and got the switch working. I ran into an issue with Hue because of naming. It took me an hour to figure out why I had an extra light.kitchen. Turns out that in my Hue bridge (i.e. hue app) I had a kitchen group with my hues and home assistant was picking that up.

For anyone struggling with this here is what I added to my yaml. I need to figure out how to use percentage for the light brightness.

scene:

  • name: cooking_one
    entities:
    light.kitchen_light:
    state: on
    brightness: 255
    light.kitchen_hallway:
    state: on
    brightness: 255
    light.family_table:
    state: on
    brightness: 255
    light.sink:
    state: on
    brightness: 255

  • name: cooking_two
    entities:
    light.kitchen_light:
    state: off
    light.kitchen_hallway:
    state: off
    light.family_table:
    state: off
    light.sink:
    state: off

  • platform: template
    switches:
    cooking_switch:
    value_template: “{{ is_state(‘cooking_switch’, ‘on’) }}”
    turn_on:
    service: scene.turn_on
    entity_id: scene.cooking_one
    turn_off:
    service: scene.turn_on
    entity_id: scene.cooking_two

I then had alexa discover devices and saying “alexa turn on cooking switch” set all the lights in the scene. I am not sure if this is the best way to do this or not. Now I need to figure out how to preserve state and restore state as a next step.

Note: Make sure that in the off state you are turning on the second scene to activate it.

1 Like