Hello,
in my automations I use this
for_each: '{{ expand(''group.users'') | selectattr(''state'', ''eq'',''home'')
| map(attribute=''attributes.source'') | list | replace(''device_tracker.'',
"notify.mobile_app_") }}'
to list users who are at home and only notify them.
the issue now is that I added ping as an aditional devicetracker, because on android phones gps sometimes was to laggy.
now people have multiple device trackers. and I only want to send notifications to phones because I cannot send other notifications.
For now I just added a bunch of replaces like this.
{{ expand('group.users') | selectattr('state', 'eq','home') |
map(attribute='attributes.source') | list | replace('device_tracker.',
"notify.mobile_app_") | replace('192_168_180_42',
"sm_g780f")
| replace('192_168_180_43',
"bkmobile")}}
but I would prefer to list the services like this
{{ expand('group.users') | selectattr('state', 'eq','home') |
map(attribute='attributes.device_trackers') | list | replace('device_tracker.',
"notify.mobile_app_") }}
result:
[
[
"notify.mobile_app_sm_g780f",
"notify.mobile_app_192_168_180_42"
],
[
"notify.mobile_app_bkmobile",
"notify.mobile_app_192_168_180_43"
]
]
and then exlude the once having 192 in it and also get rid of the double array.
does someone know how to accomplish this? I tried but couldn’t find the correct way.