MedicusOne
(Medicus One)
July 14, 2024, 3:41pm
132
Hi panhams,
the periodic bug is still exists.
I updatet the bluprint to version 2.4.0 and created a new automatition.
(HA core is 2024.7.2)
alias: Test2 Fenster offen
description: ""
use_blueprint:
path: panhans/entity_state_persistent_notification.yaml
input:
sensor_entity:
- input_boolean.test_fenster
for_time_m:
hours: 0
minutes: 2
seconds: 0
notify_group: BachiAppsNotity
title: "{{ entity_name }} ist offen"
message: >-
Achtung: {{ entity_name }} ist schon {{ ((now() - [sensor] | expand |
map(attribute='last_changed') | first).total_seconds() / 60) | int }}
Minuten lang geƶffnet
stop_button_text: Benachrichtigung deaktivieren
period:
hours: 0
minutes: 2
seconds: 0
status_bar_icon: mdi:window-open-variant
notification_color:
- 255
- 255
- 0
channel: Fenster/TĆ¼ren
group: offene Fenster
Here is my tested situation:
17:14:30 turn sensor on
17:16:31 notification received
17:17:10 turn sensor off
17:17:15 turn sensor on
17:18:31 notification received << this should not happend (from first sensor on?)
17:19:11 notification received << this should not happend (from first sensor off?)
17:19:15 notification received
17:20:00 turn sensor off
If i turn off the sensor after the first mobile notify was received and turn on the sensor in a short time, then i get three periodic notifications on my phone.
17:18:31 and 17:19:11 are both pntc_event.
1 Like
panhans
(Panhans)
July 15, 2024, 8:30am
133
Sry, for that inconvenience. I did some changes to the latest version. My tests look promising. I wait for your feedback.
MedicusOne
(Medicus One)
July 15, 2024, 1:11pm
134
Hi panhans,
here is my feedback.
I updatet the blueprint to version 2.4.1.
I testet again my tests.
Sorry, the problem is still exists.
Remember, duration and periodic are 2 minutes in my tests.
14:46:00 turn sensor on
14:48:00 notification received >> correct from 1st on
14:49:10 turn sensor off
14:49:15 turn sensor on again
14:50:01 notification received << this should not happend
14:51:15 notification received >> correct from 2nd on
14:52:01 notification received << this should not happend
14:52:14 turn sensor off
After sensor is switch to 1st OFF and then to 2nd ON, periodic notifications from the 1st ON should not be happened.
Do you need the traces from this test?
MedicusOne
(Medicus One)
July 17, 2024, 3:24pm
135
Hi panhans,
i found a solution for the periodic problem.
I will send you a pull request on github.
1 Like
panhans
(Panhans)
July 20, 2024, 9:54am
136
Atm I am a little busy but I am looking forward to review your request theses days. Thank you for your effort!!!
After update the blueprint to lasts version I get a problem with my notifications:
Error: UndefinedError: 'dict object' has no attribute 'from_state'
alias: BuzĆ³n de correo. Notificar ha llegado correo
description: ""
use_blueprint:
path: panhans/entity_state_persistent_notification.yaml
input:
sensor_entity:
- binary_sensor.estado_de_buzon_de_correo
for_time_m: 0
notify_group: all_mobile_devices
message: Tienes nuevo correo en el buzĆ³n
title: Tienes correo
period: 10
notification_color:
- 1
- 102
- 142
channel: BuzonCorreo
group: BuzonCorreo
status_bar_icon: mdi:mailbox-up
panhans
(Panhans)
July 23, 2024, 9:56am
138
You manually triggered the automation, didnāt you? For testing purpose you have to set the entity to its state youāre aiming for or set the state in the developer options for your entity manually. Simply triggering the automation will result in this error.
Also check the State Duration and the Periodical Notification selectors. The type changes and so they need to get reconfigured.
1 Like
You are right. Sorry for the lack of knowledge! Thank you!
Iām having an issue where there is a significant delay, about 10 minutes in triggering my notifications after the initial trigger.
active_state: 'on'
sensor_entity:
- binary_sensor.refrigerator_sensor_contact
group_target: all_ios_phones
ha_notification: true
notify_device: null
period:
hours: 0
minutes: 0
seconds: 0
action_prefix: STOP_{{this.entity_id}}
notification_color:
- 100
- 200
- 240
notification_color_hex: >-
#{{ '%02x%02x%02x' | format(notification_color[0], notification_color[1],
notification_color[2]) }}
led_color:
- 100
- 200
- 240
led_color_hex: '#{{ ''%02x%02x%02x'' | format(led_color[0], led_color[1], led_color[2]) }}'
trigger:
- platform: state
entity_id:
- binary_sensor.refrigerator_sensor_contact
to: 'on'
for:
hours: 0
minutes: 5
seconds: 0
id: 'on'
- platform: state
entity_id:
- binary_sensor.refrigerator_sensor_contact
from: 'on'
id: 'off'
- platform: event
event_type: pntc_event
id: period
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: template
value_template: '{{ trigger.id == ''on'' }}'
- condition: and
conditions: []
- condition: template
value_template: '{{ trigger.id == ''off'' }}'
- condition: and
conditions:
- condition: template
value_template: >-
{{ trigger.id == 'period' and trigger.event.data.automation ==
this.entity_id }}
- condition: and
conditions: []
action:
- variables:
is_period_trigger: '{{ trigger.id == ''period'' }}'
sensor: |
{% if is_period_trigger %}
{{ trigger.event.data.s_entity }}
{% else %}
{{ trigger.from_state.entity_id }}
{% endif %}
entity_name: '{{ state_attr(sensor,''friendly_name'') }}'
tag: '{{ this.entity_id.split(''.'')[1] + sensor.split(''.'')[1] }}'
action_tag: '{{ action_prefix }}_{{ sensor }}'
st_last_changed: |
{% if is_period_trigger %}
{{ trigger.event.data.st_last_changed }}
{% else %}
{{ as_timestamp([sensor] | expand | map(attribute='last_changed') | first) }}
{% endif %}
- if:
- condition: template
value_template: '{{ is_period_trigger or trigger.to_state.state == active_state }}'
then:
- if:
- condition: template
value_template: '{{ notify_device != none }}'
then:
- if:
- condition: template
value_template: '{{ now() != now() + timedelta(**period) }}'
then:
- data:
title: '{{ entity_name }} is open'
message: >-
Close the refrigerator door. Itās been open for over 5
minutes
data:
ttl: 0
priority: high
notification_icon: mdi:home-assistant
tag: '{{ tag }}'
persistent: true
sticky: true
channel: General
group: refrigeratoropen
color: '{{ notification_color_hex }}'
vibrationPattern: 100, 100
ledColor: '{{led_color_hex}}'
actions:
- action: '{{ action_tag }}'
title: Stop notifying
action: >-
notify.mobile_app_{{ device_attr(notify_device, "name") |
slugify }}
else:
- data:
title: '{{ entity_name }} is open'
message: >-
Close the refrigerator door. Itās been open for over 5
minutes
data:
ttl: 0
priority: high
notification_icon: mdi:home-assistant
tag: '{{ tag }}'
persistent: true
sticky: true
channel: General
group: refrigeratoropen
color: '{{ notification_color_hex }}'
vibrationPattern: 100, 100
ledColor: '{{led_color_hex}}'
action: >-
notify.mobile_app_{{ device_attr(notify_device, "name") |
slugify }}
- if:
- condition: template
value_template: '{{ group_target is defined and group_target != '''' }}'
then:
- if:
- condition: template
value_template: '{{ now() != now() + timedelta(**period) }}'
then:
- data:
title: '{{ entity_name }} is open'
message: >-
Close the refrigerator door. Itās been open for over 5
minutes
data:
ttl: 0
priority: high
notification_icon: mdi:home-assistant
tag: '{{ tag }}'
persistent: true
sticky: true
channel: General
group: refrigeratoropen
color: '{{ notification_color_hex }}'
vibrationPattern: 100, 100
ledColor: '{{led_color_hex}}'
actions:
- action: '{{ action_tag }}'
title: Stop notifying
action: notify.{{ group_target }}
else:
- data:
title: '{{ entity_name }} is open'
message: >-
Close the refrigerator door. Itās been open for over 5
minutes
data:
ttl: 0
priority: high
notification_icon: mdi:home-assistant
tag: '{{ tag }}'
persistent: true
sticky: true
channel: General
group: refrigeratoropen
color: '{{ notification_color_hex }}'
vibrationPattern: 100, 100
ledColor: '{{led_color_hex}}'
action: notify.{{ group_target }}
- if:
- condition: template
value_template: '{{ ha_notification }}'
then:
- data:
title: '{{ entity_name }} is open'
message: Close the refrigerator door. Itās been open for over 5 minutes
notification_id: '{{ tag }}'
action: persistent_notification.create
else:
- data:
data:
tag: '{{ tag }}'
ttl: 0
priority: high
message: clear_notification
action: notify.notify
- data:
notification_id: '{{ tag }}'
action: persistent_notification.dismiss
- if:
- condition: template
value_template: '{{ timedelta(hours=0,minutes=0,seconds=0) != timedelta(**period) }}'
- condition: template
value_template: '{{ now() != now() + timedelta(**period) }}'
- condition: template
value_template: '{{ trigger.id != ''off'' }}'
then:
- wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: '{{ action_tag }}'
timeout:
hours: 0
minutes: 0
seconds: 0
- variables:
s_last_changed: >
{{ as_timestamp([sensor] | expand | map(attribute='last_changed') |
first) }}
- data:
level: debug
message: >
Last Changed {{ s_last_changed }} Last Change Trigger {{
st_last_changed }}
action: system_log.write
- if:
- condition: template
value_template: '{{ states(sensor) == active_state }}'
- condition: template
value_template: '{{ wait.trigger == none }}'
- condition: template
value_template: '{{ st_last_changed == s_last_changed }}'
then:
- event: pntc_event
event_data:
s_entity: '{{ sensor }}'
automation: '{{ this.entity_id }}'
st_last_changed: '{{ s_last_changed }}'
- if:
- condition: template
value_template: '{{ is_period_trigger or trigger.to_state.state == active_state }}'
then:
- variables:
custom_action_on:
- action: tts.cloud_say
metadata: {}
data:
cache: false
message: Close the refrigerator door. Itās been open for over 5 minutes
entity_id: media_player.sonos_first_floor
- if:
- condition: template
value_template: '{{ custom_action_on != none }}'
then:
- choose: []
default:
- action: tts.cloud_say
metadata: {}
data:
cache: false
message: >-
Close the refrigerator door. Itās been open for over 5
minutes
entity_id: media_player.sonos_first_floor
else:
- variables:
custom_action_off: []
- if:
- condition: template
value_template: '{{ custom_action_off != none }}'
then:
- choose: []
default: []
mode: parallel
id: '1722567758433'
alias: 'Appliance: Refrigerator Door Open'
description: ''
panhans
(Panhans)
September 9, 2024, 7:23am
141
Hey, could you trigger your automation and post a trace log of this run? If you need any help just let me know.
seblor
(Sebastian)
September 25, 2024, 10:44am
142
I just tried it today again and it looks like it is working now. Thanks!
seblor
(Sebastian)
September 25, 2024, 11:11am
143
I digged in a bit deeper today and have a few question / suggestions:
ist it possible to use a sensor group and expand it instead of adding multiple sensors?
is it possible to combine the messages for all sensors in one message listing all the sensors?
can I configure the message title as optional?
is it possible to add a function to pause the notifications for eg. 30 mins?
Thanks,
Sebastian
seblor
(Sebastian)
October 1, 2024, 6:43am
144
One more, could there be a configurable target dashboard tap when clicking on the message?
Manny1
(Manny)
October 2, 2024, 12:28am
145
Iāve been looking for a blueprint like this, thank you.
I have it setup so when any of the doors remain open for x period of time, i get notified + Alexa makes an announcement that door is still open but Iām encountering one issue.
If I choose the āStop Notifyingā option via the message on my iOS, Alexa immediately makes one last announcememt that door is still open.
It does this every time I use the āStop Notifyingā open.
Iām using the āCustom Action Onā option with no āCustom Action Offā
Any suggestions ?
Thanks Manny.
seblor
(Sebastian)
October 2, 2024, 7:54pm
146
Iām trying to cover a specific scenario: inform me if the door handle is open or tilted and the door contact is closed longer than 5 mins
I tried it with the door handle sensor as trigger, and the door sensor as condition.
This works fine if the condition stays the same.
If I open the door for longer than 5 mins, then close it I donāt receive a notification. Even the door handle is still open.
It seems, that the condition is just checked the first time and not during the periodic notifications.
Can this be added? Check condition for every run and not just at the first run.
Sir_Goodenough
((SG) WhatAreWeFixing.Today)
October 3, 2024, 3:42am
147
seblor
(Sebastian)
October 8, 2024, 7:45am
148
Thanks for the explanation. Maybe the timer which is running anyways can check they state on a regular basis? @panhans could pls. have a look at my suggestions and questions?
seblor
(Sebastian)
October 28, 2024, 8:22am
149
@panhans just this still maintained by you?
panhans
(Panhans)
October 30, 2024, 9:42am
150
Yes, sorry for my late response. I am busy atm and put my time on one of my other blueprint. Hopefully I find time in the next days.
Sh500
November 11, 2024, 10:40am
151
Hello,
I am wanting to use this blueprint to notify me if my windows are open, but only when I/everyone am leaving the house.
As my alarm system is always automatically set to arm any entry/exit doors sensors, I thought I could use the alarmās disarmed state as a custom condition. But this of course only works if the alarm is already in a disarmed state and then the windows open.
Is there anyway of using this blueprint for my use case?