πŸ“ State Notifications & Actions

@psakaris

That is good news glad it all works now.

The zone blueprint triggers when it meet the trigger condition.

Blacky :grinning_face:

How do I configure in Custom Actions to notify my phone a particular person (or device) has arrived home?

For example: "Maria" is home

How to write the template in the message box the triggered person (or device) is home?

I would appreciate your help.

Thank you.

@psakaris

See this FAQ , click here

{{ states[trigger.entity_id].attributes.friendly_name }} is home

Blacky :grinning_face:

Thank you for all the help.

I am bit confused what results with your blueprint. I want to receive a notification when each family member is either home or away. The zone is my home with a certain radius. Do I need to make 2 automations; one for entering inside the zone so I can receive a message this person is home and another for outside the zone to get this person has left home. Or, do I create one automation enabling either inside or outside zone using the On and Off feature. I am assuming On would be in the zone and Off outside the zone.

Can you please clarify. Thank you once again.

@psakaris

No, well maybe no just test it. The reason being if 2 people enter at the exact same time you may get only one notification. If this happens make one automation per person and that may be you preferred way anyway.

You have a start and a end trigger (2 triggers). Start can be your home trigger and end can be you away trigger. So as they come and go you can be notified. If you use one automation for everyone (everyone entered in the State Entities) then you will need to know who triggered the automation. To do this I have a FAQ and you will probably want to use the friendly name code. Link to the faq click here

So you message will be something like this.

Start message

{{ states[trigger.entity_id].attributes.friendly_name }} has arrive home.

End message

{{ states[trigger.entity_id].attributes.friendly_name }} has left home.

If you decide to do one automation per device (person) then you will still use the start and end triggers but your message can be just for that person, example: Blacky has arrived home and Blacky has left home don't need to use the trigger code in the message.

Blacky :grinning_face:

I am getting mixed results. I get a notification one member is arriving home when in fact the person is leaving. In another instance the notification is correct. My setup is 1 automation tracking 4 people entities set for inside zone. I have configured the ON message to leave home and the OFF to arrive home for each person. I realize it is something stupid but I cannot figure it out. What am I doing wrong?

@psakaris

Could you please provide us your YAML of the automation? This YAML code are the settings you have selected in the automation so I can help. To do this go into your automation, top right 3 dots, Edit in YAML, copy all the code, come back to the forum and in your reply at the top tool bar click on β€œ</>” and paste code in there.

Blacky :grinning_face:

Here you go. Thank you so much for helping me out.

mode: restart
variables:
  zone_entity: zone.home
  zone_name: "{{ zone_entity.split('.')[-1] }}"
  zone_condition: inside_zone
  tracking_mode: people
  people:
    - person.peter
    - person.zoe
    - person.joanna
    - person.vicky
    - person.nikitas
  devices: []
  min_count: 1
  include_presence_helper: disable_presence_helper
  presence_helper: []
  presence_helper_on_delay: 0
  presence_helper_off_delay: 0
  include_bypass: disable_bypass
  bypass_entity: []
  include_custom_actions:
    - enable_on_custom_actions
    - enable_off_custom_actions
  on_custom_actions:
    - action: notify.mobile_app_peters_iphone
      metadata: {}
      data:
        message: >-
          {{ states[trigger.entity_id].attributes.friendly_name }} has arrived
          home
  off_custom_actions:
    - action: notify.mobile_app_peters_iphone
      metadata: {}
      data:
        message: "{{ states[trigger.entity_id].attributes.friendly_name }} has left home"
triggers:
  - trigger: state
    id: t0
    entity_id:
      - person.peter
      - person.zoe
      - person.joanna
      - person.vicky
      - person.nikitas
    to: null
  - trigger: state
    id: t1
    entity_id: []
    to: null
actions:
  - choose:
      - conditions:
          - condition: template
            value_template: |
              {% if tracking_mode == 'people' %}
                {{ (state_attr(zone_entity, 'persons') | list | select('in', people) | list | length) >= min_count if zone_condition == 'inside_zone'
                  else (people | reject('in', state_attr(zone_entity, 'persons') | list) | list | length) >= min_count }}
              {% else %}
                {{ expand(devices) | selectattr('state', 'eq', zone_name) | list | length >= min_count if zone_condition == 'inside_zone'
                  else expand(devices) | rejectattr('state', 'eq', zone_name) | list | length >= min_count }}
              {% endif %}
        sequence:
          - alias: Parallel actions to turn on
            parallel:
              - sequence:
                  - choose:
                      - alias: Check if toggle helper is enabled and helper is OFF
                        conditions:
                          - condition: template
                            value_template: >-
                              {{ include_presence_helper ==
                              'enable_presence_helper' }}
                          - condition: template
                            value_template: "{{ is_state(presence_helper, 'off') }}"
                        sequence:
                          - delay:
                              minutes: "{{ presence_helper_on_delay }}"
                          - action: homeassistant.turn_on
                            target:
                              entity_id: "{{ presence_helper }}"
              - sequence:
                  - choose:
                      - alias: Perform the custom ON action
                        conditions:
                          - condition: template
                            value_template: >-
                              {{ 'enable_on_custom_actions' in
                              include_custom_actions }}
                        sequence:
                          - action: notify.mobile_app_peters_iphone
                            metadata: {}
                            data:
                              message: >-
                                {{
                                states[trigger.entity_id].attributes.friendly_name
                                }} has arrived home
    default:
      - alias: Parallel actions to turn off
        parallel:
          - sequence:
              - choose:
                  - alias: Check if toggle helper is enabled and helper is ON
                    conditions:
                      - condition: template
                        value_template: >-
                          {{ include_presence_helper == 'enable_presence_helper'
                          }}
                      - condition: template
                        value_template: "{{ is_state(presence_helper, 'on') }}"
                    sequence:
                      - delay:
                          minutes: "{{ presence_helper_off_delay }}"
                      - action: homeassistant.turn_off
                        target:
                          entity_id: "{{ presence_helper }}"
          - sequence:
              - choose:
                  - alias: Perform the custom OFF action
                    conditions:
                      - condition: template
                        value_template: >-
                          {{ 'enable_off_custom_actions' in
                          include_custom_actions }}
                    sequence:
                      - action: notify.mobile_app_peters_iphone
                        metadata: {}
                        data:
                          message: >-
                            {{
                            states[trigger.entity_id].attributes.friendly_name
                            }} has left home
conditions:
  - condition: or
    conditions:
      - condition: and
        conditions:
          - condition: template
            value_template: "{{ tracking_mode == 'people' }}"
          - condition: trigger
            id: t0
      - condition: and
        conditions:
          - condition: template
            value_template: "{{ tracking_mode == 'devices' }}"
          - condition: trigger
            id: t1
  - condition: or
    conditions:
      - condition: template
        value_template: "{{ include_bypass == 'disable_bypass' }}"
      - condition: template
        value_template: "{{ bypass_entity == [] }}"
      - condition: template
        value_template: >-
          {{ (include_bypass == 'enable_bypass') and
          (states[bypass_entity].state == 'off') }}
alias: Zone Presence Notification (Home/Away)
description: ""

@psakaris

This is not your setting of the blueprint. Have to taken control of the blueprint? Something is not right.

If you taken control then I can't help.

Blacky :grinning_face:

Sorry about that. I re-entered all the info in the blueprint once again.

alias: Family Presence Notification (Home/Away)
description: ""
use_blueprint:
  path: Blackshome/zone-presence-people-device.yaml
  input:
    zone: zone.home
    zone_condition: outside_zone
    people:
      - person.peter_sakaris
      - person.zoe_angelopoulos
      - person.joanna_sakaris
      - person.vicky_sakaris
      - person.nikitas
    include_custom_actions:
      - enable_on_custom_actions
      - enable_off_custom_actions
    on_custom_actions:
      - action: notify.mobile_app_peters_iphone
        metadata: {}
        data:
          message: >-
            {{ states[trigger.entity_id].attributes.friendly_name }} has left
            home
    off_custom_actions:
      - action: notify.mobile_app_peters_iphone
        metadata: {}
        data:
          message: >-
            {{ states[trigger.entity_id].attributes.friendly_name }} has arrived
            home

@psakaris

Ok now your using a diffrent blueprint of mine and asking questions about it in this thread, I see where the problem is now.

  1. Use this blueprint (State Notification & Actions) not the (Zone Presence of People & devices.
  2. Open up the blueprint (State Notification & Actions) and edit in YAML.
  3. Copy the code below and paste it in.
  4. Then go back and edit in visual editor.
  5. In both the Start Notify and End Notify enter in your Devices To Notify.
  6. Save it.

Now you have notifications when people leave and come home. In the Start Trigger and End Trigger I have set a Time Delay of 1 min. You may need to adjust this if your getting false triggers. What this does... the people your tracking must be in the state (home or away) for 1 min + before you will be notified. This will stop notifications when a person goes from home to away and back home again all in under 1 min (like a state flicker) You may want to adjust this to 5 or 10min depending on how quick you would like to know when they are home or not. A larger time will make sure that they are ether home or away and it not just a false state change.

alias: Family Presence Notification (Home/Away)
description: ""
use_blueprint:
  path: Blackshome/state-notifications-and-actions.yaml
  input:
    start_trigger_state: home
    end_trigger_state: not_home
    include_start_notify: enable_start_notify_options
    start_trigger_state_entity:
      - person.peter_sakaris
      - person.zoe_angelopoulos
      - person.joanna_sakaris
      - person.vicky_sakaris
      - person.nikitas
    start_time_delay_state:
      hours: 0
      minutes: 1
      seconds: 0
    start_title: Arrived Home
    start_message: "{{ states[trigger.entity_id].attributes.friendly_name }} has arrive home."
    include_end_notify: enable_end_notify_options
    end_trigger_state_entity:
      - person.peter_sakaris
      - person.zoe_angelopoulos
      - person.joanna_sakaris
      - person.vicky_sakaris
      - person.nikitas
    end_time_delay_state:
      hours: 0
      minutes: 1
      seconds: 0
    end_title: Left Home
    end_message: "{{ states[trigger.entity_id].attributes.friendly_name }} has left home."

Let us know if this now works for you.

Blacky :grinning_face:

Thank you for your help. This blueprint works perfectly.

1 Like

After using the blueprint for a few days I find if multiple people leave or arrive home at the same time I only get a notification for ONE person only. Is there anything I can do to have multiple notifications when multiple people leave or arrive home at the same time. Perhaps a delay of some sort.

Thank you.

@psakaris

I will update the blueprint to resolve this. Once I update it just press the Import Blueprint button at the top of this post again to update your blueprint then in your automation make sure you don't use the Notification Tag input. Make sure this is input is left blank.

Once you do this could your test it for me and let me know how you go. Thanks.

Blacky :grinning_face:

New Update 1.8

State Your Trigger: Turn State Changes Into Notifications and Actions! :rocket:

Maintenance :toolbox:

Run Mode - The run mode has been updated to allow multiple trigger events to run independently. This is useful when multiple people, devices, or sensors change state at the same time (for example arriving home or multiple windows opening within a short period). Each trigger event will now generate its own notification and automation run instead of cancelling or overwriting previous ones.

Be aware that if you are using the Notification Tag input, using the same tag for all notifications will cause them to replace or update each other. This may make it appear as though only one notification was sent. To avoid this, leave the tag input left blank to keep notifications separate.


If you like this blueprint? Consider hitting the :heart: button in the top post :+1:

If you like my blueprints, and would like to show your support or just say thank you? Click Here :smiling_face_with_three_hearts:

Enjoy

Blacky :grinning:

New version working great. I get multiple notifications now. Thank you.

1 Like

I was wondering what you think about adding a way to only sent the notification of this blueprint to people that are in a zone. Similar to what is available in πŸ“’ Notifications & Announcements. WDYT @Blacky ?

@FrankTub

I haven thought about this I can add it to the list of suggestions.

Blacky :grinning_face:

Before you β€œwaste” any time on it, I already created a forked version from your gist and I am in the process of testing it. So far it is working as I would expect. For anyone wondering, here is the fork.