#Quick follow up on this I see that
1 messages ยท Page 1 of 1 (latest)
It's looking unlikely to me. I've tried the following:
service: group.set
data:
object_id: notify.adults_at_home
add_entities: mobile_app_andy_s_iphone
But got the following error back: Failed to call service group.set. Entity ID mobile_app_andy_s_iphone is an invalid entity ID for dictionary value @ data['add_entities']. Got None invalid slug notify.adults_at_home (try notify_adults_at_home) for dictionary value @ data['object_id']. Got None
you can only use group.set on an actual group entity. Not on a notify group
you can't set those dynamically
Ah well, that's a pity. Thank you for your help. Plenty of work arounds, just really hoped for a shortcut on this one ๐
Well, I would make sure the notify services and person entities are named similar
so eg person.thefes and notify.mobile_app_thefes
Some good came out of reading those docs though, I discovered I can set up a group with all the data pre-applied for when I want to send critical notifications ๐
and then you can check which person entities are at home, and send the message to the right person in a repeat
A repeat? I've not heard this term before. I'll have to look up some docs for that ๐
- repeat:
for_each: "{{ states.person | selectattr('state', 'eq', 'home') | map(attribute='object_id') | list }}"
sequence:
- service: notify_mobile_app{{ repeat.item }}
data:
message: Something is happening!
Oooo, interesting. I wonder if I can repeat through person using said person's "device_to_track" value to get their phone name.
Curious, I can't use "source" but I also can't use "id", it has to be as you say, "object_id" :/
if source is an attribute of the person, you need to use attributes.source
Aha! Yes, that works nicely. Now I just need to strip that down to remove the domain off it. Right now it reads "device_tracker.ruairidhs_phone" for example. I expect there's a substring function I can use there.
- repeat:
for_each: "{{ states.person | selectattr('state', 'eq', 'home') | map(attribute='attributes.source') | list }}"
sequence:
- service: notify_mobile_app_{{ repeat.item.split('.')[1] }}
data:
message: Something is happening!
something like that?
Ooo, simple and to the point. I like it!
added an underscore
Finally I need to see if I can easily add some kind of intersection functionality, so I can compare the generated list with a fixed list of adults so I can create things like "notify_adults_in_house"
Otherwise my daughter is going to get very annoying very quickly XD
- variables:
adults:
- device_tracker.ruairidhs_phone
- device_tracker.another_phone
- repeat:
for_each: "{{ states.person | selectattr('state', 'eq', 'home') | map(attribute='attributes.source') | select('in', adults) | list }}"
sequence:
- service: notify_mobile_app_{{ repeat.item.split('.')[1] }}
data:
message: Something is happening!
I love you XD
Behold my monster script, which I shall test later as no one is at home right now ๐ https://justpaste.it/aowgj