Create combinatoric groups: Including and excluding entities from other groups

You are referring to a variable browser_mod in the last line of your script, which I think is not part of my code. However, that variable seems to be undefined.

Hello, I just found this nice script and try to use it to setup my groups.
Just can’t figure out how to create a group for all my motion sensors.

data_template:
  name: TestGroup2
  types: "motion"
  include: null
  exclude: null
  expand_groups: true

Seems the only device class working for me with “types=” is ‘light’.

Tried few other device class constants like ‘motion’, ‘door’, ‘occupancy’, ‘opening’ but always ended with an error: “Entity ID is an invalid entity ID for dictionary value @ data[‘entities’].”.
If the script can be used for this, what is the correct type for pir/motion/occupancy sensors?

Sorry for being such a noob , I’m just starting with HA :slight_smile:
Thanks in advance

That’s because types are actually domains. And light is a domain. On the other hand, motion would be a device_class.

So, no, currently, the script cannot be used for this, directly. You could, however, use the entities field and pass some template to it, which outputs all entites with motion as device_class. (selectattr will be your friend.) If you do this, you can also simplify your script by using the group.set service directly.