šŸ“ State Notifications & Actions

Window has to be open first to get closed so if you just use the start for open and the end for closed then it will work.

Blacky :smiley:

Sorry, but it does not. If I configure the start notification with 15 minutes delay and close the window immediately after opening it, then the end notification will be shown. But Iā€™d like to avoid it.

@meiser

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. :slight_smile:

alias: Benachrichtigung Fenster Bad
description: ""
use_blueprint:
  path: Blackshome/state-notifications-and-actions.yaml
  input:
    entity_a_trigger:
      - binary_sensor.parasoll_bad_contact
    entity_a_state: "on"
    entity_b_state: "off"
    include_start_notify: enable_start_notify_options
    start_notify_device:
      - 123456775657686868
    start_title: Fenster Bad offen
    start_message: Fenster Bad offen
    include_end_notify: enable_end_notify_options
    end_notify_device:
      - 123456775657686868
    end_title: Fenster Bad geschlossen
    end_message: Fenster Bad geschlossen
    entity_b_trigger:
      - binary_sensor.parasoll_bad_contact
    global_conditions: []
    time_delay_a_state: 15

Sorry I get what you are trying to do. Currently it just sends a notification when it happens. You could try and make a template sensor for the end to handle what you are trying to do and use that.

Blacky :smiley:

May I ask you to consider this as a feature request? I found this blueprint, but yours supports the global condition which I also use.

Could you try a global condition that the window must be open for X amount of time.

Blacky :smiley:

Hi, congratulations, nice project, Iā€™m starting to use it now, I wanted to ask you, would it be possible to insert notifications on Telegram, if so, how can I do it? Thank you

notify_group:
      name: Notification Group
      description: The name of the notification group to call.
      default: ""
variables:
  group_target: !input notify_group
action:
            - conditions: "{{ group_target is defined }}"
              sequence:
                - service: "notify.{{ group_target }}"
                  data:
                    message: !input notify_message

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