yesâŠ
noticed that myself⊠first thought the one was listing as list, and the expand as comma separated, but they are not. they are identical. How odd.
The expand function is useful if you want to combine domains (or groups or entities). For example, this counts how many light and switch entities are off.
Nice! Out of curiously. The big batteries group topic uses an automation to periodically (or at startup) populate a group. Wouldnât that be an options for those who REALLY want those groups back?
The removal of group.all_devices is a bit of a disaster for me.
I use this very regularly as a trigger and condition for very many automations as it very reliably lets me tell if there is anyone home or not, or if someone has literally just gotten home (using nmap tracking of devices on Wifi)
There literally couldnât be anything simpler than a condition state check of home or not_home, and a trigger resulting in a state change from home to not_home, but it looks like I canât do this anymore.
Iâm going to see if I can build a sensor that creates a dynamic group to replicate the old behaviour. Manually creating a group with a list of devices wonât work in case people change devices (and end up with a new entity name). If I add additional devices in future I would have to remember to add them to the group. The group needs to update the second a new device appears home.
Is there any point in campaigning to keep just group.all_devices for this use case??
Thank you for your reply, the 2nd link looks ideal as it is a native script to create the dynamic group, so it can be called at startup and at any time should another device be added to home assistant. Iâll do some testing with this.
This makes me wonder if my entire approach to home / not home is incorrect, perhaps I should be using zones?
Is there an easy way to make a script that just creates the group.all_* automatically again?
I donât want to screw around with a lot of automations of mine that use device trackers, which use to use the group.all_devices status. I manually created a group called group.all_devices and added the entities manually.
Does anyone know a script or automation that may automatically write a group file?
I need group.all_devices as I use appdaemon and have a listen state on group.all_devices to trigger an action when âeveryoneâs leftâ home or âSomeoneâs arrivedâ.
Why would you need that for appdaemon? Theres about 900 ways to get all devices in appdaemon. Simply self.get_state('device_tracker') would get them all.
Hell, if you want to listen for all device_trackersâŠ
That will work for determining if âSomeone arrivedâ home. ie. whenever any device tracker changes state from not_home to home
What about for determining if âEveryone leftâ home. ie all device trackers that are currently home changes to not_home. Your suggestion will trigger as soon as the first device tracker changes state.
Iâm sure there are a million ways to do what I want in python, but group.all_* was the simplest.
Just make it the first if statement in your callback.
if all([ self.get_state(entity_id) == 'not_home' for entity_id, value in self.get_state('device_tracker') ]):
EDIT: Making it more readable.
Also an FYI to simulate the group being onâŠ
if any([ self.get_state(entity_id) == 'home' for entity_id, value in self.get_state('device_tracker') ]):
any() and all() are built in methods to python that are very powerful.
any() checks a list for 1 item that could be resolved to what python thinks is True. all() checks a list for all items that could be resolved to what python thinks is True.