#Quick follow up on this I see that

1 messages ยท Page 1 of 1 (latest)

marsh saffron
#

Sorry, meant for this to tag @royal sinew.

marsh saffron
#

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

green jetty
#

you can only use group.set on an actual group entity. Not on a notify group

#

you can't set those dynamically

marsh saffron
#

Ah well, that's a pity. Thank you for your help. Plenty of work arounds, just really hoped for a shortcut on this one ๐Ÿ™‚

green jetty
#

Well, I would make sure the notify services and person entities are named similar

#

so eg person.thefes and notify.mobile_app_thefes

marsh saffron
#

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 ๐Ÿ™‚

green jetty
#

and then you can check which person entities are at home, and send the message to the right person in a repeat

marsh saffron
#

A repeat? I've not heard this term before. I'll have to look up some docs for that ๐Ÿ™‚

green jetty
#
- 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!
marsh saffron
#

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" :/

green jetty
#

if source is an attribute of the person, you need to use attributes.source

marsh saffron
#

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.

green jetty
#
- 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?

marsh saffron
#

Ooo, simple and to the point. I like it!

green jetty
#

added an underscore

marsh saffron
#

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

green jetty
#
- 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!
marsh saffron
#

I love you XD

green jetty
#

sorry, it needs the full source

#

amended

marsh saffron
green jetty
#

you don't need to define the variables you use in the service call

#

so no need to define an empty variable for message or title