Set up an Alexa Local node to trigger a Group of Lights

I’m wondering what the best way is to setup an Alexa trigger for a group of lights. I can get it to work, mostly, by using an alexa-local node and sending the output to a call service node. I’m just not sure I am doing it the best way or calling the best service option.

I currently have a Living Room group, group.living_room, that has 4 lights in it. If I set the alexa-local node to send its output to a service node, I can toggle the group.living_room and get the 4 lights to change their state. The only issue I see is it’s just a toggle. If 2 of the lights were already on, it doesn’t set all 4 to on, it just toggles the 2 that were on off, and the 2 that were off on. Am I just calling the wrong service? I’m guessing maybe so, but I’m just starting to get the different services figured out in node-red.

Thanks.

I just started looking at node-RED, so I am just speculating here as I don’t know its capabilities with Alexa, but could you just trigger a scene in Home Assistant, this way your scene is setup with the proper lights, level and color.

I can try that, but I’m not sure it solves my problem. I think a scene only has the service turn_on, so there is not a way to turn off the scene using a service.

OK, just confirmed. Scene service has the option turn_on, but not turn_off. I can tie a scene to the Alexa node, and it turns on the lights, but there is no way to turn them off.

Make two scenes, one with the lights on and the lights off. Have your Node-Red flow check the state of the lights (is your living group group on or off) and turn on the appropriate scene.

Will checking the group status work? I think the group shows on if any light in the group is on. So you could have one light on and not another and the group still shows on. Is there a way to check if all lights are on or off in the group?

Yes, I do the same as rcallison, I have a scene where all my values are zeros (0,0,0) same from brightness etc. I just turn on that scene to turn my lights off. Real easy

So I got this flow working with the two scenes from my scenes.yaml. Works regardless of the status of either of the two lights when it is called.

 - name: Upstairs TV Room On
   entities:
     light.upstairs_lamp: on
     light.upstairs_tv_lamp: on

 - name: Upstairs TV Room Off
   entities:
     light.upstairs_lamp: off
     light.upstairs_tv_lamp: off

alexa-local-scene-control

I realize I can also do this in the Alexa app, but I wanted to do it in Node-Red to keep everything centralized.

Should the Service Node just turn on lights with any message payload it gets? I don’t really understand what message payload I need to send to a Service node to cause it to do something. I am trying to use a binary.sensor to trigger a light and it isn’t working. The binary sensor is definitely outputting its state into the Service node but the service node won’t activate. I am using light.turn_on as the service function. Any ideas/help much appreciated.

Here’s my setup in Node-Red to trigger individual lights or all in the room. My solution was to build a light router using a switch.

I set the payload:

var payload = {
    "device_name": msg.device_name,
    "payload": {
        "data": {
            "brightness_pct": msg.bri
        }
    }
}
return payload;

Then the light router filters based on msg.device_name

I do something similar, but all I need is the msg.bri value. If it’s zero the light is off, otherwise the light is on.

Would you mind sharing the flow code?