šŸ“² Contact Sensor (Door or Window) Left Open Notification

You are not doing anything incorrectly but your use-case is not what this blueprint is intended for. You could just write your own small automation and straight up use the window sensors value for that as it represents the current state. I hope a understood your requirement.

I understand what you are trying to achieve. This is not possible. The behavior you are describing is expected. The notification does only trigger once if you havenā€™t set the repeat option and specified a time. With the repeat option turned on and the friendly name left empty you will get an enumeration of all sensors within that binary_sensor group that are in the issue state. Hope that this helps.
If you still want exactly your behavior you will have to create an individual automation for every sensor.

Hi Malte,
thanks for the blueprint I use it with several sensors.
But I am to stupid to do one automation.
Garagedoor should give an Alarm when it is open above 15 min but just after sunset before sunrise because during the day it is OK.
When I open my door before or after Sunrise/Sunset the automation works well but when I forgot to close my door during the day in donā€™t get a message after sunset that the door is still open (because it is over 15 mins open). Any suggestions how I can set the time from 15 min to 15+ mins?
I hope that you got what I like to say.
Thanks for your help.

Mathias

Iā€™m wondering why the notifier always shows the time of the first message and not the time of the event that fires the notify the first time. The message says some ā€œdoor-open-timeā€, but if I use a wait time the value is incorrect.
I tried to fix it with

{{ as_timestamp(initially_triggered_at - timedelta(minutes=10)) | timestamp_custom('%T', True) }}

in the notification message inside the frontend. It saves without problems, but I dont get a notification on the companion app, even though the trigger said its fired. Any suggestions?

1 Like

Seems that somebody is interested in the idea. I realised it by tweaking the blueprint at line 254 by changing the variable ā€œinitially_triggered_atā€:

initially_triggered_at: "{{ now() - timedelta(minutes=10) }}"

Sadly this only works if all delays of your corresponding automations are e.g. 10 min.

But Iā€™ve got one other question:
I would love to use a dynamic delay for the notification. Reason: it makes sense to adjust the opening duration for the windows depending on the outside temperature. So I set up a helper ā€œsensor.dauer_luftenā€ which has the outputs: 5, 10 or 15 depending on the temperature. But Iā€™m just not able to include this information into the blueprint.
I tried changing the !input variable ā€œduration_issue_stateā€ in lines 223 and 241 to "{{ states('sensor.dauer_luften') }}". But I realised, that ā€œforā€ needs something like

minutes: 10
seconds: 5

So I put the variables back where they were and tried to change the selector in the gui to ā€œtemplateā€, but the notification wonā€™t fire. I tried

but realised that YAML this gives

Are the quotation marks the problem? Iā€™m running out of ideasā€¦

Hey there, I currently do not have the time to check how to do this myself but from my quick research of the official documentation what you are trying to achieve seems pretty doable:

  • About your definition of initially_triggered_at. You could just use the value of the variable duration_issue_state in the timedelta object to make that dynamic.
  • About your sensor value not being in the correct format (that seems to be the problem): maybe these two links can help you:

If you are not already using the template option of the developer tools Iā€™d highly suggest them for your testing.
Open your Home Assistant instance and show your template developer tools.

@Malte This script is awesome! Exactly what I was looking for to announce a door is left open.

How can I combine custom actions to play on multiple echos more elegantly? I tried a comma, but got an error.

alias: Door Left Open 240916 v1
description: ""
use_blueprint:
  path: Raukze/contact-sensor-left-open-notification.yaml
  input:
    trigger_entity: binary_sensor.doors
    duration_issue_state:
      hours: 0
      minutes: 0
      seconds: 10
      days: 0
    notify_services_string: notify.mobile_app_sw_s23
    custom_action_issue_state:
      - action: notify.alexa_media_wylie_s_echo_show
        metadata: {}
        data:
          message: >-
            door {{friendly_name}} is open at {{
            as_timestamp(initially_triggered_at) | timestamp_custom('%T', True)
            }}.
      - action: notify.alexa_media_everywhere
        metadata: {}
        data:
          message: >-
            door {{friendly_name}} is open at {{
            as_timestamp(initially_triggered_at) | timestamp_custom('%T', True)
            }}.
      - action: notify.alexa_media_echo_master_bed
        metadata: {}
        data: {}
          message: >-
            door {{friendly_name}} is open at {{
            as_timestamp(initially_triggered_at) | timestamp_custom('%T', True)
            }}.
      - action: notify.alexa_media_library_fire_tv
        metadata: {}
        data: {}
          message: >-
            door {{friendly_name}} is open at {{
            as_timestamp(initially_triggered_at) | timestamp_custom('%T', True)
            }}.
    notification_click_url: /lovelace-doors/0

Probably this is what you are looking for.

Is there a recommended path or modification to allow for a quick dismiss to temporarily disable the alert from the notification on iOS? e.g. Itā€™s alerting me the garage is open, but I know I need it open for the next x amount of time, so I suspend the repeat for a period of time?

No, sadly this is not something that can be easily added with the current blueprint implementation.

Hello Malte, thank you for your very useful blueprint. I use it to prevent open windows at low outside temperatures in some rooms. This works almost perfect for me. I only have two open points that I canĀ“t figure out as I am a HA beginner:

  • I want to be informed about the minutes since the window was opened instead of the time. The message should be like ā€œWindow is open since 15 Minutesā€. I found the info that the following should work:
    {{ (as_timestamp(now()) - as_timestamp(as_datetime(initially_triggered_at, default))) | timestamp_custom(ā€%Mā€, false) }}
    But there is an error message that I canĀ“t deal with.

  • The second question is related to the click-url. I donĀ“t want to use this feature so I put noAction into this field. But nevertheless when pressing on the message IĀ“m pushed to the overview of all rooms. How can I disable this feature?
    Regards
    Thomas

Hi, I often get this warning message in the logs, but everything seems to be working properly. Get a message when a window is opened.

Logger: homeassistant.helpers.template
Quelle: helpers/template.py:2742
Erstmals aufgetreten: 15:08:44 (2 Vorkommnisse)
Zuletzt protokolliert: 15:59:34

Template variable warning: ā€˜friendly_nameā€™ is undefined when rendering ā€˜Das{{ friendly_name }} ist noch offenā€™

Hello Malte, thanks for this useful blueprint. I tried to use it creating the first automation in my HA.
Unfortunately it throws the error message ā€œTemplate rendered invalid service: notify.mobile_app_SM-A725Fā€. It tried it with my second mobile too but got the same error.
Any ideas what the reason can be?
Regards
Hartmut

Hi Hartmut, I feel like the service name is incorrect. Iā€™ve never seen a service name containing a dash. Could you verify this?

Hi Malte, thank you for your hint. Replacing dash by underscore solved the issue.
I wasnā€™t thinking about the service name due to the system tooks the device name automatically. Really good to know that!
Thank you
Hartmut

Iā€™d like to second this! Having channels for the notification is vital to make sure I am aware of them. Being able to eben set them to critical would even improve this!

P.S.: Great blueprint, thanks!

Hi!

Thank you very much for this blueprint, itā€™s very useful for my purposes :slight_smile: Iā€™m just starting out with HA and maybe Iā€™m making another rookie mistake here:

I want to add a possibility to disable the notification globally. For this I have created a switch as an entity. I also want no notifications to be sent at temperatures above 16 degrees. It looks like this:

I now have the following behaviour:

  • Temperature is below the threshold value
  • Notifications are not switched off

The notifications are coming as desired.

If I now flip the switch in the entity for the switch to switch off the notifications, the notifications are still displayed. Am I making a mistake here?

I have combined the conditions with an AND, because they are actually mutually dependent.

Edit: What else I have noticed: If I have already flipped the switch for the notifications, the notifications remain muted. Could it be that the conditions are only checked once when the blueprint is called up and then no longer?

Just turn the automation on/off if you want to disable it

Thatā€™s not what I want. Normally, we should be told to close a window. But sometimes the temperature feels warmer than it is measured. In this case, I would simply like to have the option of temporarily switching off the notification via a switch until the windows have all been closed.
This means that if all the windows are closed and then opened again, the mechanism for the announcements takes effect as normal.
Switching off the automation would only affect the automation for one sensor in this case.

Hi Malte, I am having the same issue here - with repeat option activated.
I have several window contacts in a binary sensor group, but the notification message will list only the first one opened regardless of further windows being opened.

I would llike to get a notification like
ā€œOpen Windows
Kitchen since 11.45
Bathroom since 11.50ā€

Obviously the preconfigured message template wonā€™t achieve that as it is prepared for a single sensor only.

If not feasible I might go with dedicated automations per window.
Still saving efforts :slight_smile: