Liebe SmartHome for Dummies Gemeinde.

Die phpBB Forum Software gehört nicht wirklich zu den modernsten seiner Art.
Ich habe mich an einer Migration zu Discourse versucht und bin leider kläglich gescheitert.

Möchte aber trotzdem einen Neuanfang auf einer modernen Plattform starten.
Gerne möchte ich Euch animieren das neue Discourse Forum zu benutzen.
Bestehenden Usern bleibt es leider nicht erspart, sich auf der neuen Platform neu anzumelden.

Das Forum hier, bleibt selbstverständlich Online. Ich würde versuchen einiges händisch zu migrieren.
Da fallen mir die Rubriken "Template Sammlungen" oder "Best Practice Automatisierungen" ein.

SmartHome for Dummies Discourse Platform.

Actionable Notification Problem Thema ist als GELÖST markiert

Rat und Tat rings um Home Assistant Automationen.


Antworten
SveBzh
Beiträge: 14
Registriert: Mi 21. Jun 2023, 21:48
1
Has thanked: 3 times

Actionable Notification Problem

Beitrag 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
SveBzh
Beiträge: 14
Registriert: Mi 21. Jun 2023, 21:48
1
Has thanked: 3 times

Re: Actionable Notification Problem

Beitrag 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!
Benutzeravatar
Osorkon
Administrator
Beiträge: 2105
Registriert: Sa 17. Jul 2021, 16:53
3
Wohnort: Langenargen
Has thanked: 63 times
Been thanked: 580 times
Kontaktdaten:

Re: Actionable Notification Problem

Beitrag von Osorkon »

Bin grad ein wenig kurz angebunden.
Aber hast Du Dir mal die Skript Vorlage zum Thema Confirmable Notification angeschaut?

IMG_5170.jpeg
IMG_5170.jpeg (200.66 KiB) 3564 mal betrachtet

Dann einfach eine Automatisierung mit Deinem Trigger und als Aktion das Script.

Gruß
Osorkon

Einer muss ja für Ordnung sorgen. :D
SveBzh
Beiträge: 14
Registriert: Mi 21. Jun 2023, 21:48
1
Has thanked: 3 times

Re: Actionable Notification Problem

Beitrag 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

SH-Atrappe
Beiträge: 1
Registriert: Do 23. Mär 2023, 08:51
2

Re: Actionable Notification Problem

Beitrag 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.

SveBzh
Beiträge: 14
Registriert: Mi 21. Jun 2023, 21:48
1
Has thanked: 3 times

Re: Actionable Notification Problem

Beitrag 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
Antworten