@BrianHanifin wrote:
I have noticed there is some concern about how to get along without the formerly automatically generated groups like
group.all_lights
. I promise you there is a way to make your code work without them. Ask here and we can help you.First off, the following is the correct way to turn off every light now.
service: light.turn_off entity_id: all # replace group.all_lights with `all`
Here are some example templates to get lists of entity_ids to get you thinking.
List of all lights
{{ states.light | map(attribute='entity_id') | join(',') }}
List of lights that are turned on
{{ states.light | selectattr('state','eq','on') | map(attribute='entity_id') | join(',') }}
With some slights changes you can make these work for covers.
List of all covers
{{ states.cover | map(attribute='entity_id') | join(',') }}
List of covers that are open
{{ states.light | selectattr('state','eq','open') | map(attribute='entity_id') | join(',') }}
If you really feel like you need the all groups back you have some options. For example you can create a script that rebuilds a group. The script below literally recreates
group.all_lights
. Call this script just before you need the group to update it.script: # Recreate group.all_lights update_all_light_group: sequence: - service: group.set data_template: object_id: "all_lights" entities: > {{ states.light | map(attribute='entity_id') | join(',') }} # Recreate group.all_switches update_all_switches_group: sequence: - service: group.set data_template: object_id: "all_switches" entities: > {{ states.switch | map(attribute='entity_id') | join(',') }}
While these group won’t updated every time the status of a state changes… well, your server doesn’t have to update the group every time a change happens. Every little bit helps on a Raspberry Pi… ammiright? Image may be NSFW.
Clik here to view.There also two AppDaemon apps available on HACS that intend to recreate those groups for you.
If you would like help converting a script post an example of your code in this topic.
Posts: 2
Participants: 1