šŸ“ State Notifications & Actions

You just use the start or end actions and input your telegram notification in there.

Blacky :smiley:

@Blacky
Can this blueprint be used to notify me when a device becomes unavaible?
Do I need to include all my devices one by one or is there a group name like you have with battery operated devices?
I have smart plugs, sensors for door/window, smart bulbs, push buttons etcā€¦
And can it be used as a alarm system when smoke detector or door is opened when not at home?

@Fred54

Yes but unlike the battery blueprint you will not know what one has become unavailable so once notified you will have to search for it. You have to add every entity you would like to monitor. Please make sure you spell ā€˜unavailableā€™ correctly.

Have a look at ā€˜Alarmoā€™, I donā€™t use this integration but I know a lot of people use it and looks to be well supported with good reviews so you may want to take a look at it.

Hope this helps you.

Blacky :smiley:

Hi there,

Iā€™m trying to see if I can use this to notify my wife and my phone upon completion of a timer. If possible to clear the notification from each otherā€™s phone if either of us dismiss it.

I have a timer helper setup. Must I use the event bus and ā€œfinishedā€ as the trigger, or is there another good way to accomplish this.

@Cake1468

In this blueprint it allows you to send a ā€˜Confirmation Messageā€™ that confirms the action has been done. Then ether you or your wife will know that it has been done and you can clear the message.

Blacky

1 Like

Thanks for checking in and for this idea. I will keep it in mind for the future.

For this case I figured out the Alert function that is configured inside configuration.yaml. I was able to incorporate a couple of my goals including repeating notification, as well as making the notification disappear on all notified devices.

Nice one, thanks for letting us know.

Blacky :smiley:

Iā€™m a total HA newbie and I feel like I should be able to make use of this blueprint, but Iā€™m having trouble specifically with setting up an action when the automation fires to be able to turn things off that trigger my automation.

Context: I have a number of lights and switch entities that I have all configured to trigger my automation (Iā€™m thinking I may need to create helpers to make these all lights or switches to make this simpler?) and my desired end state is that the notification that fires gives me the ability in the notification to turn off the lights / switches of those that specifically turned on. I donā€™t want to just turn off everything, just those that are turned on.

My issue is Iā€™m trying to latch onto the triggering light / switch entity id. When I specify one of my entities it looks like the YAML below. However I donā€™t want this to be static I want this to be dynamic based on the triggering entity id. Iā€™ve tried supplying {{trigger.entity_id}} for the entity_id in start_action_1 but this produces an error.

Any ideas for how I can make this work? Thanks in advance!

alias: "LIGHTS TEST: Lights on While Away"
description: Notify when lights are turned on at the house when I'm away
use_blueprint:
  path: Blackshome/state-notifications-and-actions.yaml
  input:
    entity_a_trigger:
      - light.dimmer_switch_2
      - light.dimmer_switch
      - light.master_bedroom_dimmer_1
      - light.master_bedroom_dimmer_2
      - light.master_closet_light_switch
      - light.3rd_floor_office_light_dimmer
      - switch.s2_on_off_switch
    entity_a_state: "on"
    time_delay_a_state: 0.5
    global_conditions:
      - condition: not
        conditions:
          - condition: zone
            entity_id: person.me
            zone: zone.home
    include_start_notify: enable_start_notify_options
    start_notify_device:
      - <notify_device_id>
    start_title: Home Lights Turned On
    start_message: While you're away from the house, lights were turned on
    include_start_action_buttons: []
    start_action_button_1: Turn Off Lights
    start_action_button_stop: Ack
    start_time_delay:
      hours: 0
      minutes: 10
      seconds: 0
    start_action_1:
      - service: switch.turn_off
        metadata: {}
        data: {}
        target:
         ## vv THIS IS WHERE I NEED HELP vv
          entity_id: switch.s2_on_off_switch
        ## ^^ THIS IS WHERE I NEED HELP ^^
    include_start_auto_actions:
      - enable_start_action_1


@apizz

Hi AP, well this is a bit tricky but because you have switch and lights you are best to use a ā€˜Home Assistant Core Integration: Generic turn offā€™ and then you will need to edit in YAML and your YAML will be as shown below.

service: homeassistant.turn_off
data:
  entity_id: "{{ trigger.entity_id }}"

or here is your full YAML but you will need to select your device in ā€˜Start Notify - Devices To Notifyā€™ as it was also not selected. I also ā€˜Enable action button 1ā€™ in ā€˜Start Notify - Action Buttons Options (Optional)ā€™. Copy Paste this YAML and add your device and it should work.

alias: "LIGHTS TEST: Lights on While Away"
description: Notify when lights are turned on at the house when I'm away
use_blueprint:
  path: Blackshome/state-notifications-and-actions.yaml
  input:
    entity_a_trigger:
      - light.dimmer_switch_2
      - light.dimmer_switch
      - light.master_bedroom_dimmer_1
      - light.master_bedroom_dimmer_2
      - light.master_closet_light_switch
      - light.3rd_floor_office_light_dimmer
      - switch.s2_on_off_switch
    entity_a_state: "on"
    time_delay_a_state: 0.5
    global_conditions:
      - condition: not
        conditions:
          - condition: zone
            entity_id: person.me
            zone: zone.home
    include_start_notify: enable_start_notify_options
    start_notify_device: []
    start_title: Home Lights Turned On
    start_message: While you're away from the house, lights were turned on
    include_start_action_buttons:
      - enable_start_action_button_1
    start_action_button_1: Turn Off Lights
    start_action_button_stop: Ack
    start_time_delay:
      hours: 0
      minutes: 10
      seconds: 0
    start_action_1:
      - service: homeassistant.turn_off
        data:
          entity_id: "{{ trigger.entity_id }}"
    include_start_auto_actions:
      - enable_start_action_1

Also note you have ā€˜Enable start auto action 1ā€™ and your time delay is 10 min so if you donā€™t action the notification in 10 min then it will do it for you.

Let us know how you go.

Blacky :smiley:

Blacky

Hi @Blacky! :slight_smile:

My goal is to use your script for the following:

  • Send a message when windows has been opened
  • Send a message when windows has been closed

I have created a helper with all my windows: binary_sensor.fenster

entity_id:
  - binary_sensor.burofenster
  - binary_sensor.schlafzimmerfenster
  - binary_sensor.badezimmerfenster
  - binary_sensor.terrassentur
  - binary_sensor.esszimmerfenster_links
  - binary_sensor.esszimmerfenster_rechts
  - binary_sensor.gastezimmerfenster
  - binary_sensor.hauswirtschaftsraumfenster
  - binary_sensor.gastebadfenster
  - binary_sensor.barfenster
icon: mdi:window-closed-variant
friendly_name: Fenster

Now I would like to get opened and closed messages with the individual name of the window that has been opened or closed. May you give me a hint how to realize that? :slight_smile:

Cheers

@viruz

Onto the next blueprint I see :+1:

For this you will need to use the start and end actions. Follow this.

  1. Start Entities = All your windows you would like to track. Enter in one by one.
  2. Start Trigger - Fixed State or Numeric State Options = Select ā€˜1 - Enable fixed state optionā€™
  3. Start Trigger - Fixed State Option = enter ā€˜onā€™ just the word on, no ā€™ ā€™
  4. End Entities = All your windows you would like to track. Enter in one by one
  5. End Trigger - Fixed State or Numeric State Options = Select ā€˜1 - Enable fixed state optionā€™
  6. End Trigger - Fixed State Option = enter ā€˜offā€™ just the word on, no ā€™ ā€™

Now you have 2 option.

OPTION 1: Use the notify inputs - Easy to do and recommended option

  1. For notify options see below. Image tells a thousand words.
  • For getting your entity ID in the message use this
{{ trigger.entity_id }}
  • For getting the friendly name of your entity in the message use this
{{ states[trigger.entity_id].attributes.friendly_name }}

OPTION 2: Or you can use the auto actions, see below.

  1. Use The Start Auto Action Options (Optional) = Select ā€˜Enable start auto action 1ā€™
  2. Start Action - Action 1 = add action, type ā€˜notiā€™ and select your notify device. Then edit in YAML and your code will be this
  • For getting your entity ID in the message use this
service: notify.mobile_app_your_device_here
data:
  title: Window Open
  message: "{{ trigger.entity_id }}"
  • For getting the friendly name of your entity in the message use this
service: notify.mobile_app_your_device_here
data:
  title: Window Open
  message: "{{ states[trigger.entity_id].attributes.friendly_name }}"
  1. Use The End Auto Action Options (Optional) = Select ā€˜Enable end auto action 1ā€™

  2. End Action - Action 1 = add action, type ā€˜notiā€™ and select your notify device. Then edit in YAML and your code will be this

For getting your entity ID in the message use this

service: notify.mobile_app_your_device_here
data:
  title: Window Closed
  message: "{{ trigger.entity_id }}"

For getting the friendly name of your entity in the message use this

service: notify.mobile_app_your_device_here
data:
  title: Window Closed
  message: "{{ states[trigger.entity_id].attributes.friendly_name }}"

Let us know how you go.

Blacky :smiley:

1 Like

Works like a charm! :partying_face: Many thanks again. :slight_smile:

Cheers

1 Like

Amazingā€¦ thanks very much for the response and glad to know I was so close to the solution :slight_smile: can confirm this is looking good and my notification options are working. Love when a plan comes together, thanks again

1 Like

@apizz

Your welcomeā€¦ you were very close those ā€œā€ is all that was missing.

Nice one glad your up and running and thanks for getting back to us.

Enjoy

Blacky :smiley:

Would it be possible to add an option to Notify devices, only when they are Home/Away state? Thanks

@iona

You can do that by adding in a condition in the ā€œGlobal Conditionsā€.

Blacky :smiley:

1 Like

Novice here, soā€¦thank you for the Blueprint.
Exactly what I was looking for.

Iā€™ve added a bunch of Aqara entry sensors to the blueprint, Aqara sensors seem instantaneous, arrival of push varies in arrival time.

The push to device is my phone. Samsung S23 Ultra, Android. Nothing else added yet.

What am I doing wrong if anything? Can I fix it somehow?

If using notify and the companion app I read about priorities and some other things, but that doesnā€™t appear to be an option to push to. Or something like that.

So I donā€™t understand what I need to do to make sure push notifications are as fast as possible.

@G2740

If you are notifying a device it should be fast. notifications take about < 1 second.

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 :smiley:

Here you go and thanks for the time.

Let me say my Zigbee is Zha, all Aqara entry sensors.

Iā€™ll keep troubleshooting as Iā€™m uncertain whatā€™s happening. Zigbee visualization looks as usual.

What I think I may be seeing, but am still investigating. I ran some test.

Iā€™d listen for her to open a door that gets opened often. And expect a ping on my phone. Sound and push.

It seemed delayed, amount not determined yet.

But them on second test, I stood right at the door and opened and closed several times. Pined every time fast. Only did that 4 or 5 times. Sheā€™ll think Iā€™m losing it. :joy: Novice doesnā€™t even know how to paste code. Lol

If I discover any rhyme or reason Iā€™ll post.

Im certainly not blaming the Blueprint, just puzzled. Yaml :point_down:.

type or paste code here
alias: "Aqara Sensor Has Opened "
description: Something is up, Sensor Opened - investigate why
use_blueprint:
  path: Blackshome/state-notifications-and-actions.yaml
  input:
    entity_a_trigger:
      - binary_sensor.aqara_back_door_opening
      - binary_sensor.aqara_basement_inner_door_opening
      - binary_sensor.aqara_basement_outer_door_opening
      - binary_sensor.aqara_basement_window_1_opening
      - binary_sensor.aqara_basement_window_2_opening
      - binary_sensor.aqara_basement_window_3_opening
      - binary_sensor.aqara_basement_window_4_opening
      - binary_sensor.aqara_computer_rm_window_opening
      - binary_sensor.aqara_dave_s_bathroom_window_opening
      - binary_sensor.aqara_front_door_opening
      - binary_sensor.aqara_inner_garage_door_opening
      - binary_sensor.aqara_laundry_room_window_opening
      - binary_sensor.aqara_outer_garage_door_opening
      - binary_sensor.aqara_north_garage_window_opening
      - binary_sensor.aqara_toy_rm_window_1_opening
      - binary_sensor.aqara_toy_rm_window_2_opening
    entity_a_state: "on"
    time_delay_a_state: 0
    include_start_notify: enable_start_notify_options
    start_notify_device:
      - 98157786e5ad0eca1d113ad34ccd49fc
    start_title: "Entry Sensor Has Opened "
    start_message: "An Entry Sensor Has Opened - Investigate "

So it looks like it is working :+1:

Here is a TIP

Because you have a lot of sensors you can have the notification tell you what sensor opened so you know what is going ON.

  • For getting your entity ID in the message use this
{{ trigger.entity_id }}

  • For getting the friendly name of your entity in the message use this
{{ states[trigger.entity_id].attributes.friendly_name }}

Hope this helps you.

Blacky :smiley:

1 Like