Hi!
How can I use groups in my scripts?
I have a set of lights in a group and I want to use this group in my script (called ‘Soninho 1’). The idea is to turn off some lamps (this group). I know that I can set multiple actions in my script…but I will have to repeat this proccess in some other scripts, that’s why I would like to turn off just the ‘group’ device.
Also, I have more lights in this zone, so I can’t turn off entire zone.
Groups is already created in YAML.
But tks, the tip that groups are not devices, but entities, did light me up!
This combined with Call Service solved my issue with script. Tks!
I agree with @jmceara. I just tried to create a test automation and my YAML-based groups do not appear in the entity picker anymore. NOTE: I would think you actually want to use “Call Service” and then the “Light off” service and select the entity but I could not see them their either.
Then I selected to edit in YAML as shown below and “boom” they are there. So it looks like YAML-based groups do not appear in the GUI-based entity picker.
I would note that I like using the old groups better although I would say I have not tried the new groups. This is because it would require a lot for me to redefine many switches as lights and I also do several groups in other groups. This is just a snippet of my YAML groups:
One additional point, maybe should be reported as a bug. If I try to use the Entity picker as shown below, you can see nothing “pops” when I start to type groups.
But these controls works with YAML defined group too. I’m already using this for a long time. I have a button in dashboard set to my group and after changing color/brightness for this group, all lights are changed. No group in UI at all!
The difference is that my YAML uses old style groups. I can combine lights, switches and other groups this way. As I understand it, all members of light group must be in light domain now. So I would need to redefine many switches as lights. Then find out if you can add a light group to another group.
The answer was simple for my “old style” Groups. Of course you cannot use the service light.turn_on because they are not necessarily lights (some are switches and in some cases other things). You use the generic homeassistant.turn_on