I have created a 2-level nested group. When I try to turn on the sub-group with an automation, the whole upper-group turns on. Is this a bug in HA or am I doing something dumb?
A group is on if any member of it is on. At the same time, a group being on does not necessarily mean all of its members are on - there just needs to be at least one member on. Thatâs on the state side of things.
On the service side of things, when you turn on a group, it recursively finds all the components in the group and any sub-groups, and turns them all on.
So, when you turn on outside_front_lights, that turns on all of its members (i.e., both switches.) Now that those switches are on that makes group.outside_front_lights on. And now that it is on that makes group.outside_lights on. That doesnât mean, however, that group.outside_outlet (and its members) have been turned on.
I know I could probably test this (and probably will) but thought Iâd ask. I feel like my goodnight routine is getting a bit combersome, as in once in a while I find a light or switch that does not get turned off. Itâs been happening a bit more lately, so I wanted to break up the lights in to a few different groups depending on type, etc. Anyway I have this automation
- alias: Light alert
trigger:
- platform: state
entity_id: input_select.security_system
to: 'Armed (Home)'
for:
minutes: 3
- platform: state
entity_id: input_select.security_system
to: 'Armed (Away)'
for:
minutes: 3
condition:
- condition: state
entity_id: group.good_night_devices_full
state: 'on'
action:
- service: homeassistant.turn_off
entity_id:
- group.good_night_devices_full
- delay:
seconds: 15
- condition: state
entity_id: group.good_night_devices_full
state: 'on'
- service: notify.pushbullet_notifications
data_template:
target:
- !secret pauls_secret_email
title: Lights failed to turn off
message: >
{% set lights_on = states | selectattr('entity_id', 'in', state_attr('group.good_night_devices_full','entity_id')) | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}
The following Lights failed to turn off: {{ lights_on }}. This was the second attempt. Please turn off using the app.
Basically the master group is a group of groups. Will this work? Will it return the name of a group or the entity in the sub group?
Well I think it would work based on my template testing, but it will not tell me which lights are on,just which groups are on. Need to parse the groups in the groups, haha. Iâll see what I can come up with
total hack here, but this could work with 2 layers.
{% set entities = states.group | selectattr('entity_id', 'in', state_attr('group.good_night_devices_full','entity_id')) | selectattr('state','eq','on') | map(attribute='attributes.entity_id') | list | join(', ') | replace('(','') | replace(')','') | replace("'",'') | replace('"','') %}
{% set entities = entities.split(', ') %}
{% set lights_on = states | selectattr('entity_id', 'in', entities) | selectattr('state','eq','on') | map(attribute='name') | list %}
The following Lights failed to turn off: {{ lights_on }}. This was the second attempt. Please turn off using the app.
{% set all = namespace(lights = []) %}
{% for group in state_attr('group.good_night_devices_full', 'entity_id') %}
{% set all.lights = all.lights + state_attr(group, 'entity_id')|list %}
{% endfor %}
The following Lights failed to turn off: {{
states|selectattr('entity_id', 'in', all.lights)
|selectattr('state', 'eq', 'on')
|map(attribute='name')|join(', ')
}}. This was the second attempt. Please turn off using the app.
Some lighting technologies support scenes. Instead of sending ten individual commands to turn off ten lights, you program all ten lights to be part of a scene (example: all ten lights turn off when they receive scene command #1). Now you can send one scene command to control ten lights. The advantage is less communications traffic (one command traveling on the network instead of ten) and speed (all lights react simultaneously).
If your lights normally respond well when operated individually but sometimes not when operated as a group, network congestion may be the culprit and using a scene may improve reliability.
Funny you mention Scenes. I posted this yesterday trying to get a good understanding of scenes.
So, scenes are aware of the state of all lights in the scene? I do use scenes quite a bit to turn on lights, but not so much for turning off groups of lights.
My goodnight routine turns off lights, switches, zwave, hue, zigbee, and a couple media players as well.
I know how to scene these items, but it really comes down to awareness. I just needed to know for sure thats how sceneâs worked.
I was referring to the (hardware-based) scenes provided by some lighting technologies not the (software-based) Scenes provided by Home Assistant.
The Scenes in Home Assistant donât reduce network traffic because they still send ten commands for ten lights.
Z-Wave and Zigbee support scenes but youâd have to confirm the devices you have support the feature.
You could create two âAll Lights Offâ (hardware) scenes, one for Z-Wave and another for Zigbee. Use either an automation, script, Scene, etc in Home Assistant to call the two âAll Lights Offâ scenes plus whatever additional commands to turn off other things (that donât support hardware-based scenes). The advantage of this approach is that you send only one Z-Wave and one Zigbee command to control multiple lights thereby minimizing traffic on their respective RF networks.
Ahh, got it thanks. Yeah I donât have any scene controllers at the moment. Well, I guess I have hue scenes. My lights are about 50% hue, 40% zwave (wall switches controlling ceiling lights, etc) and 10% zigbee plugs.
I might have a look at a scene controller. So if I understand correctly, if I get a scene controller for zwave lets say, that it will be aware of the state of the other lights, and send the commands to just the lights that need to be changed. Neat
You know this and the template from @petro have got me thinking about my whole goodnight and goodbye routines. I could use this to determine what lights/devices are on, and only send âoffâ commands to those. Which would greatly reduce my zwave network traffic. 50% of the devices in the group I use are usually off, but I have them in the group to turn off, just in case.
I never said you needed a âscene controllerâ. I have no idea where you go the idea of a âscene controllerâ.
Whatever Z-Wave/Zigbee controllers you are currently using are likely to support the sending of scene commands.
FWIW, Philips Hue uses the Zigbee protocol.
Using (hardware) scenes reduces the need for templates (to determine which lights are still off). Why? Because a scene is just one command to turn off all lights. Itâs very efficient.
Think of a (hardware) scene as a broadcast message. Instead of communicating separately with each device, you blast one message heard by all devices. The ones that understand the broadcasted message comply as per their programming (when I receive scene command #1, I have been programmed to turn myself off).
Sorry, misunderstood. When you say hardware scenes I assumed (incorrectly) you were talking about a scene controller.
I guess I dont understand then. Can you give me an example of a device that are talking about. Most of my zwave devices are in wall GE dimmers and switches. Iâve never noticed and âSceneâ stuff, but never looked for it either. I use HA scenes at the moment, which I understand from what youâve said is not the same. How do I set scenes using hardware?
I do know that hue is zigbee, but all if my devices are still using the hue hub, I prefer it that way. Easier for me anyway, to integrate with other apps outside of HA.
I have several scenes, but most of them happen to use my hue lights but here is one that includes a zwave light as well
- name: TV Lights
entities:
light.kitchen_cabinet_bottoms:
state: on
brightness: 152
rgb_color: [255, 240, 198]
light.kitchen_cabinet_tops:
state: on
brightness: 191
rgb_color: [164, 234, 255]
light.living_room_lamp_two:
state: off
light.living_room_lamp_one:
state: on
brightness: 190
rgb_color: [255, 207, 120]
light.left_shelf_lights:
state: on
brightness: 71
rgb_color: [246, 255, 254]
light.tv_backlights:
state: on
brightness: 71
rgb_color: [246, 255, 254]
light.right_shelf_lights:
state: on
brightness: 71
rgb_color: [246, 255, 254]
light.alcove_light:
state: on
brightness: 150
color_temp: 444
light.sconce_light:
state: on
The seem to come on or turn off at the same time. I use
service: scene.turn_on
to turn on the scene. That was my question in the begining, but I think Iâve not fully understood scenese. @123, has confused me a bit. This is a âsoftwareâ scene, right? What would be a hardware scene?
If I have a mixture of device types in my scene, zwave and Hue in my case, does my example above smart? I have another scene that has the state of many of these lights to âoffâ when turn on that scene, does it send commands to all lights âoffâ even if they are already off?
Typically with management software designed for the lighting technology. I donât use Z-Wave or Zigbee so I canât offer any examples. I know Homeseer can configure z-wave scenes ⌠but thatâs of no help for Home Assistant users. Iâll leave it to experienced Z-Wave/Zigbee users to chime in and explain the details.
In the Home Assistant Scene you defined (a software-based scene), you listed all the lights and how they should be controlled. When this Scene is executed, Home Assistant will run through that list and send commands to each light. So thatâs one command transmitted per light.
Now imagine that you could program each physical light with the same information. So something like âturn myself on and set my brightness to 75% and my color to warm yellowâ would be programmed into the lighting device itself and identified as âscene #1â. Another lightâs âscene #1â could be âturn myself on and set my brightness to 50% and my color to bright redâ. Now if you transmit a command to activate âscene #1â (just one command thatâs broadcasted to all devices) the devices that have âscene #1â programming will set themselves accordingly. The devices that donât have "scene #1â programming just ignore the command.
Thatâs how a hardware-based scene works. However, I caution you that the term âsceneâ is not universal and lighting technologies may use other terms like groups, associations, receive components, etc. Plus there may be subtle variations in how they implement the functionality.
Iâm not entirely convinced that the software scenes are the same as scripts anymore. A while back scenes was overhauled. If the lights come on in unison, chances are itâs utilizing the zwave scene control. Otherwise youâd see them come on/off in a sequence. I guess the only way to tell would be to monitor the zwave traffic.