Exclude Entities: Turn on/off everything, except X

I’d like to bring this up again, because I’m also missing an exclude function. Yes. working with groups as a workaround is possible but this gets pretty complex quiet fast and ends in way to much logical groups which get hard to take care of after a while.

But sticking to the concept of groups it would be great to exclude entities from groups - one example:

- action: homeassitant.turn_off
  entity_id: group.bathroom  
  exclude: switch.washingmachine

This would make my configs and groups look way more well arranged… :slight_smile:

2 Likes

I still agree, but ultimately use the suggested “interior / exterior” groups … not as convenient, as home assistant has the wonderful feature of service: light.turn_on which is a superior catch-all without having to touch the group config.

I’d like such a feature too, using groups may not always be the good answer.

Example

Using device tracker (with nmap), I want to be notified if an unknown device join the network. It would be pretty neat to do something like that :

groups.yaml

trusted_devices: device_tracker.my_computer, device_tracker.my_phone

automations.yanl

trigger:
  - platform: state
    entity_id: group.all_devices
    excludes: group.trusted_devices
    to: 'home'
(...)
2 Likes

+1 for this feature request

1 Like

I also vote for this feature, please implement it.

+1. The more lights you have controlled by home assistant, the more this feature is needed. I want to turn off all of my lights except for one in the kitchen, so I have to make a group of all of them except that one, and then when I add more lights, the scene breaks unless I remember to update that group. Then I want to turn off all of the lights except for one in the bedroom, so I have to make a group of all of them except that one, and when I add more lights I have to update both groups. Etc. You end up with a ton of huge groups and it’s not manageable.

I’ve been trying to work around this in scenes by turning off the group of all lights and then turning on the one light, but groups don’t seem to care about order and the behavior is unreliable. I’ve also tried using a script, but it waits for each light as it goes so it’s very slow.

As far as implementation goes, the most generally useful pattern I can think of would be something that allows both adding and subtracting entities to form a group as you go, like:

entity_group:
+group.all_lights
-group.bedroom_lights
+light.bed

2 Likes

+1

I have a number of groups that are just a replication of another group excluding one or 2 devices, it would be great to simplify this.

2 Likes

Hey Guys

Are you still interested in being able to exclude something from a group?

I also need this feature so I started tinkering with the code to make it work. It works roughly on groups so if you turn on/off a group with items excluded, those don’t get actioned. They do however participate in determining the group’s state. You can also use this in scripts for light/switch domains for now. Just add ‘exclude’ where you see ‘entity_id’. You should also be able to exclude a group from a group.

The initial commit is here:
https://github.com/mateuszdrab/home-assistant/commit/d4b7f62dc686759fd69719ff5ac82d8bcb1a582f

Example:

{
  "entity_id": "group.test2",
  "exclude":"light.bed_lamp"
}

and an example in a script

test_lights:
  sequence:
  - service: light.turn_on
    entity_id: group.test2
    exclude: light.bed_lamp

This is probably bound to be buggy as hell since I’m not a Python programmer but a C# guy however it seems that Python is amazingly simple and it’s gone well so far.

Looking forward to some feedback, you should be able to pull the master branch from me as this was merged with latest master from homeassistant today.

Thanks

1 Like

Did this ever get implemented? I would like this also!

Still not working I guess… Would be a good thing to have.

This would be awesome!

piling on here as I would also really like to see something like this. My use case is simple and I believe a very good argument for the need for this feature.

My automations, groupings and sheer number of devices is growing very quickly. Managing automations and scenes that turn on/off groups of devices becomes difficult to manage in terms of updating and maintaining them. Its much easier to split into groups and write automations that trigger scenes or turn on/off groups.

In many cases I need to aggregate groups together in order to avoid turning off or on something that otherwise belongs in the same group as everything else.

chiming in here as well - this would be great to see this implemented. My use case is similar to those above: I want to easily turn off all lights except the master suite. When I add more lights to HA, I don’t want to have to re-do groups to add them back in.

I would like to see this also. I have a few things I use all switches on for - issue is, i’ve added an alarm siren to my home and now when I turn all switches on, my alarm sounds outside. It seems like this feature should be here all ready! It’s been asked for since 2016…

I have tried everything and still need this feature in HASSIO. If I say google, turn everything on, it will turn on thing like sirens, whole house fans (with the windows closed), set off my smoke detectors! It becomes a dangerous command. We need to be able to exclude devices! This seems so easy to do?

+1 This feature would significantly simplify things

This would be a fantastic feature. I have an automation to turn off all the light except on ( at night ), when nobody is home. But now, I need to add all lights to one group to turn off all the lights except that one.

I too would like to see this feature. Being able to turn off all lights except the outdoor lights would be very practical in several scenarios.

You can try turning all off then turning one on.

Yes, this was already mentioned here in post #13: In a scene it’s unpredictable, which command (on or off) is executed first. You could implement it as a script and include a delay, but it makes this workaround even worse in my opinion.

And, last but not least, there are devices that take it badly to be turned off at all, f.e. computers. Or my lawn mower, which immediately starts panicking, if it can’t detect it’s perimeter wire anymore…