Notify everyone at home

Tags: #<Tag:0x00007f326dc49130> #<Tag:0x00007f326dc48dc0> #<Tag:0x00007f326dc48b18> #<Tag:0x00007f326dc488e8>

Hi all,

I have a notification script which I use to send notifications to various notify services. I feed this script with a data property called who. This who can contain for instance husband, wife, daughter, parents, at_home. Based on this value I do some if ... else logic within the script to call the correct service mentioned below.

notify.husband
notify.wife
notify.daughter
notify.parents (notify group with notify.husband and notify.wife)
notify.family (notify group with all family members)

This works fine for all scenarios expect the at_home one. For some automation’s I would like to notify only the people who are at home. For instance if someone is at the door. I know the status of people so that’s not the problem. The problem is that I cant make a dynamic notify group which only contains the people at home.

Does anyone have any idea if and how to make a dynamic notify group where notify services can be added conditionally? Or is there another way to make this dynamically?

Notify script

notify_engine:
  sequence:
    - service: >
          {% if who == 'husband' %}
            notify.husband
          {% elif who == 'wife' %}
            notify.wife
          {% elif who == 'daughter' %}
            notify.daughter
          {% elif who == 'parents' %}
            notify.parents
          {% elif who == 'family' %}
            notify.family
          {% elif who == 'at_home' %}
            // todo: notify.at_home group
          {% else %}
            notify.husband
          {% endif %}
      data_template:
        title: "{{ title }}"
        message: "{{ message }}"

Dynamically, in NodeRED, I can accomplish this quite easily. If you don’t use it, I would suggest adding it to your toolbox. It’s very powerful.

I would watch the event bus in NodeRED, creating a flow that captures when a person’s location changes to Home. When it does, they would be added to an array stored as a global variable in NodeRED.

When they go from Home to something else, they would be removed from that array.

When I want to send the notification, I would simply split the array into individual messages and fire them off based who shows up in the array.

If you stick with YAML, you could probably script something that, rather than saying, if WHO is something, you would say, if WHO contains something and then make WHO be a collection of those who are at home…then loop through WHO to send a notification to each person until you’ve looped through one time.