Seite 1 von 1
Actionable Notification Problem
Verfasst: Do 19. Sep 2024, 23:41
von SveBzh
Hallo zusammen,
ich versuche aktuell eine actionable notifications zu "basteln" - bisher ohne großen Erfolg. 
Ziel ist es, dass ich nach Erhalt der Meldung über die nicht abgeschlossene Haustür die Möglichkeit habe, diese zu schließen oder nicht. Ich erhalte schon die Push-Nachricht, aber nach Auswahl der Aktion passiert nichts.
Wo könnte der Denkfehler stecken? 
alias: Hauseingangstür
description: >-
Hauseingangstür ist nicht gesperrt. Soll diese gesperrt werden, da scheinbar
keiner zu Hause?
trigger:
- platform: state
entity_id:
- sensor.bozhanov_s_home_pixel_8_pro_fahrtrichtung
- sensor.bozhanov_s_home_sm_s926b_fahrtrichtung
from: arrived
to: away_from
condition:
- condition: and
conditions:
- condition: device
device_id: e02c9494a96f06a2167e265e948cdc52
domain: lock
entity_id: 22a8866eb2fc52ea392617cd41f58b6f
type: is_unlocked
- condition: state
entity_id: sensor.bozhanov_s_home_sm_s926b_fahrtrichtung
state: away_from
- condition: state
entity_id: sensor.bozhanov_s_home_pixel_8_pro_fahrtrichtung
state: away_from
action:
- alias: Ask for the door to be locked
action: notify.notify
data:
message: >-
Hauseingangstür ist nicht gesperrt. Soll diese abgeschlossen werden, da
scheinbar niemand mehr zu Hause?
title: Hauseingangstür ist nicht abgeschlossen!
data:
actions:
- action: action_lock
title: Ja, Tür abschließen!
- action: action_no_lock
title: Nicht abschließen!
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: notify.notify
event_data:
action: "{{ action_lock }}"
- platform: event
event_type: notify.notify
event_data:
action: "{{ action_no_lock }}"
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_lock }}"
sequence:
- action: lock.lock
target:
device_id: e02c9494a96f06a2167e265e948cdc52
data: {}
- action: notify.send_message
metadata: {}
data:
message: Okay, die Tür wird abgeschlossen!
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_no_lock }}"
sequence:
- action: notify.send_message
metadata: {}
data:
message: Okay, die Tür wird nicht abgeschlossen!
mode: single
Re: Actionable Notification Problem
Verfasst: Fr 20. Sep 2024, 09:55
von SveBzh
Hier der Code im richtigen Format, entschuldigt bitte.
Code: Alles auswählen
alias: Hauseingangstür
description: >-
Hauseingangstür ist nicht gesperrt. Soll diese gesperrt werden, da scheinbar
keiner zu Hause?
trigger:
- platform: state
entity_id:
- sensor.bozhanov_s_home_pixel_8_pro_fahrtrichtung
- sensor.bozhanov_s_home_sm_s926b_fahrtrichtung
from: arrived
to: away_from
condition:
- condition: and
conditions:
- condition: device
device_id: e02c9494a96f06a2167e265e948cdc52
domain: lock
entity_id: 22a8866eb2fc52ea392617cd41f58b6f
type: is_unlocked
- condition: state
entity_id: sensor.bozhanov_s_home_sm_s926b_fahrtrichtung
state: away_from
- condition: state
entity_id: sensor.bozhanov_s_home_pixel_8_pro_fahrtrichtung
state: away_from
action:
- alias: Ask for the door to be locked
action: notify.notify
data:
message: >-
Hauseingangstür ist nicht gesperrt. Soll diese abgeschlossen werden, da
scheinbar niemand mehr zu Hause?
title: Hauseingangstür ist nicht abgeschlossen!
data:
actions:
- action: action_lock
title: Ja, Tür abschließen!
- action: action_no_lock
title: Nicht abschließen!
- alias: Wait for a response
wait_for_trigger:
- platform: event
event_type: notify.notify
event_data:
action: "{{ action_lock }}"
- platform: event
event_type: notify.notify
event_data:
action: "{{ action_no_lock }}"
- alias: Perform the action
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_lock }}"
sequence:
- action: lock.lock
target:
device_id: e02c9494a96f06a2167e265e948cdc52
data: {}
- action: notify.send_message
metadata: {}
data:
message: Okay, die Tür wird abgeschlossen!
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_no_lock }}"
sequence:
- action: notify.send_message
metadata: {}
data:
message: Okay, die Tür wird nicht abgeschlossen!
Re: Actionable Notification Problem
Verfasst: Fr 20. Sep 2024, 11:57
von Osorkon
Bin grad ein wenig kurz angebunden.
Aber hast Du Dir mal die Skript Vorlage zum Thema Confirmable Notification angeschaut?

- IMG_5170.jpeg (200.66 KiB) 3566 mal betrachtet
Dann einfach eine Automatisierung mit Deinem Trigger und als Aktion das Script.
Gruß
Osorkon
Re: Actionable Notification Problem
Verfasst: Sa 21. Sep 2024, 00:09
von SveBzh
Ich habe mich bislang mit den Confirmable Notifications noch nicht befasst, aber so wie ich die Logik vermute verstanden zu haben, sollte eine Automatisierung plus ein Script erstellt werden.
Ich glaube, dass es mit der Variante der Actionable Notifications etwas "schlanker" ist und es braucht keine zusätzlichen Scripts. Oder sehe ich es falsch?
Gruß
Sven
Re: Actionable Notification Problem
Verfasst: Sa 21. Sep 2024, 08:20
von SH-Atrappe
Gleiches Problem bei mir: Ausgabe der Push-Nachricht erfolgt, Antwort wird nicht zurückgegeben. Das Verhalten konnte ich in den Entwicklerwerkzeugen nachvollziehen. Die betreffende Actionable Notification hat bis vor ein paar Wochen noch funktioniert.
Re: Actionable Notification Problem
Verfasst: So 22. Sep 2024, 22:56
von SveBzh
Ich habe es hinbekommen! Nach einigem Probieren und Optimieren funktioniert es nun.
Der Fehler war der falsche "event_type". Nachfolgend der richtige Code:
Code: Alles auswählen
alias: Hauseingangstür
description: >-
Hauseingangstür ist nicht gesperrt. Soll diese gesperrt werden, da scheinbar
keiner zu Hause?
trigger:
- platform: state
entity_id:
- sensor.bozhanov_s_home_pixel_8_pro_fahrtrichtung
- sensor.bozhanov_s_home_sm_s926b_fahrtrichtung
from: arrived
to: away_from
condition:
- condition: and
conditions:
- condition: device
device_id: e02c9494a96f06a2167e265e948cdc52
domain: lock
entity_id: 22a8866eb2fc52ea392617cd41f58b6f
type: is_unlocked
- condition: state
entity_id: sensor.bozhanov_s_home_sm_s926b_fahrtrichtung
state: away_from
- condition: state
entity_id: sensor.bozhanov_s_home_pixel_8_pro_fahrtrichtung
state: away_from
action:
- alias: Einrichten von Variablen für die Aktionen
variables:
action_lock: "{{ 'LOCK_' ~ context.id }}"
action_nolock: "{{ 'NOLOCK_' ~ context.id }}"
- alias: Ask for the door to be locked
action: notify.notify
data:
message: >-
Hauseingangstür ist nicht gesperrt. Soll diese abgeschlossen werden, da
scheinbar niemand mehr zu Hause?
title: Hauseingangstür ist nicht abgeschlossen!
data:
actions:
- action: "{{ action_lock }}"
title: Ja, Tür abschließen!
- action: "{{ action_nolock }}"
title: Nicht abschließen!
- alias: Auf Antwort warten
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_lock }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_nolock }}"
- alias: Ausführen der Aktion
choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_lock }}"
sequence:
- action: lock.lock
target:
device_id: e02c9494a96f06a2167e265e948cdc52
data: {}
- action: notify.notify
metadata: {}
data:
message: Okay, die Hauseingangstür wird abgeschlossen!
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_nolock }}"
sequence:
- action: notify.notify
metadata: {}
data:
message: Okay, die Hauseingangstür wird nicht abgeschlossen!
mode: restart