Wie immer ein super Video!
Sehr verständlich erklärt.
Ich würde das ganze aber gerne “einen Schritt weiter” machen, komme nur nicht drauf wie.
Folgende Ausgangssituation:
Ich meiner “Wohnung verlassen”-Automation gibt es den Step, dass ich eine Benachrichtigung bekommen wenn ein Fenster geöffnet ist (Aqara Sensoren). Diese zeigt mir an welche/s offen ist:
metadata: {}
data:
title: Home Assistant
message: >-
🪟 Fenster {{ expand('binary_sensor.sensor_windows_all')|selectattr('state',
'eq', 'on')|map(attribute='name')|list|join(', - ') }} ist offen!
action: notify.mobile_app_iphone_david
Jetzt wäre es natürlich super, dass ich die Möglichkeit habe über die Notification den bzw. die Rollläden zu öffnen/schließen bei den geöffneten Fenster.
In einer anderen Automation, zum Öffnen der Rollläden wenn ein Fenster geöffnet wird nutze, ich Variablen um herauszufinden bei welchem Fenster welcher Rollladen sich öffnen soll:
alias: open Cover
description: open Cover when Window is open
triggers:
- entity_id:
- binary_sensor.window_hallway_contact
- binary_sensor.window_bedroom_1_contact
- binary_sensor.window_bedroom_2_contact
- binary_sensor.window_office_1_contact
- binary_sensor.window_office_2_contact
- binary_sensor.window_livingroom_1_contact
- binary_sensor.window_livingroom_2_contact
- binary_sensor.window_livingroom_3_contact
- binary_sensor.door_balcony_contact
from: "off"
to: "on"
trigger: state
conditions: []
actions:
- variables:
covers:
window_hallway_contact: hallway
window_bedroom_1_contact: bedroom_1
window_bedroom_2_contact: bedroom_2
window_office_1_contact: office_1
window_office_2_contact: office_2
window_livingroom_1_contact: livingroom_1
window_livingroom_2_contact: livingroom_2
window_livingroom_3_contact: livingroom_3
door_balcony_contact: balcony
- data:
position: 100
target:
entity_id: cover.{{ covers[trigger.to_state.object_id] }}
action: cover.set_cover_position
mode: single
ich würde jetzt natürlich gern beides kombinieren, damit ich in der Notification einfach nur auf “öffnen” oder “schließen” gehen muss und den Rollladen am geöffneten Fenster bzw. den geöffneten Fenstern auf/zu geht.
Da ich ja aber {{ expand('binary_sensor.sensor_windows_all')|selectattr('state', 'eq', 'on')|map(attribute='name')|list|join(', - ') }}
in der Notification nutze, ist das glaube ich nicht so einfach, bzw. komme ich nicht drauf.
Hat da jemand eine Idee?
sollte jemand hier drüber stolpern und das gleiche vor haben:
die notification:
metadata: {}
data:
title: Home Assistant
message: >-
🪟 Fenster {{ expand('binary_sensor.sensor_windows_all')|selectattr('state',
'eq', 'on')|map(attribute='name')|list|join(', - ') }} ist offen!
🔘 für Aktion halten
data:
actions:
- action: open
icon: sfsymbols:arrow.up.circle
title: diese Cover öffnen
- action: close
icon: sfsymbols:arrow.down.circle
title: diese Cover schließen
action: notify.mobile_app_iphone_david
die automation:
alias: Fenster Rolladensteuerung via Mobile Notification
description: ""
triggers:
- trigger: event
event_type: mobile_app_notification_action
event_data:
action: open
id: open
- trigger: event
event_type: mobile_app_notification_action
event_data:
action: close
id: close
actions:
- variables:
action: "{{ trigger.event.data.action }}"
covers:
binary_sensor.window_hallway_contact: cover.hallway
binary_sensor.window_bedroom_1_contact: cover.bedroom_1
binary_sensor.window_bedroom_2_contact: cover.bedroom_2
binary_sensor.window_office_1_contact: cover.office_1
binary_sensor.window_office_2_contact: cover.office_2
binary_sensor.window_livingroom_1_contact: cover.livingroom_1
binary_sensor.window_livingroom_2_contact: cover.livingroom_2
binary_sensor.window_livingroom_3_contact: cover.livingroom_3
binary_sensor.door_balcony_contact: cover.balcony
- choose:
- conditions:
- condition: trigger
id:
- open
sequence:
- repeat:
for_each: "{{ covers.keys() | select('is_state', 'on') | list }}"
sequence:
- target:
entity_id: "{{ covers[repeat.item] }}"
data:
position: 100
action: cover.set_cover_position
- conditions:
- condition: trigger
id:
- close
sequence:
- repeat:
for_each: "{{ covers.keys() | select('is_state', 'on') | list }}"
sequence:
- target:
entity_id: "{{ covers[repeat.item] }}"
data:
position: 20
action: cover.set_cover_position
mode: parallel
Hallo Simon, hallo Community,
wieder einmal danke für dieses tolle Video.
Ich habe für einen anderen Anwendungsfall die Actionable Notification hergenommen. Allerdings überspringt er zum Schluss IMMER eine der beiden Auswahlmöglichkeiten und beendet die Automation und ich sitze seit drei Stunden hier und komme einfach nicht weiter. Warum zum Henker nimmt er keine der beiden Optionen? Ich habe den Code 1:1 kopiert und entsprechend meiner Konfiguration angepasst.
alias: 2h Test Abwesenheit Klima weiter#
description: ""
triggers:
- trigger: numeric_state
entity_id:
- zone.home
for:
hours: 0
minutes: 10
seconds: 0
below: 1
enabled: false
- trigger: state
entity_id:
- input_boolean.testschalter_fur_automationen
from: "off"
to: "on"
conditions:
- condition: state
entity_id: input_select.heizmodus
state: Heizen (tagsüber)
actions:
- variables:
action_ja: "{{ 'ja_' ~ context.id }}"
action_nein: "{{ 'nein_' ~ context.id }}"
- action: notify.mobile_app_kevins_iphone_14_pro
metadata: {}
data:
title: Heizung.
message: Soll ich die Heizung herunterdrehen? (bitte gedrückt halten)
data:
actions:
- action: "{{ action_ja }}"
title: Ja, bitte.
- action: "{{ action_nein }}"
title: Nein, danke.
- wait_for_trigger:
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_ja }}"
trigger: event
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_nein }}"
trigger: event
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
continue_on_timeout: false
enabled: true
- choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == \"action_ja\" }}"
sequence:
- action: notify.mobile_app_ipad_von_kevin_neu
metadata: {}
data:
message: Ja
title: Ja
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == \"action_nein\" }}"
sequence:
- action: notify.mobile_app_ipad_von_kevin_neu
metadata: {}
data:
title: NEIN
message: NEIN
enabled: true
mode: parallel
max: 10
Vielleicht findet ja jemand den Fehler.
Danke für eure Hilfe.
Liebe Grüße
Kevin
EDIT:
Ich konnte das Problem in der Zwischenzeit lösen.
Ich habe die Variablen-Definition weggelassen, die Variablen in der ActionableNotification einfacher gehalten und entsprechend im “Wait-Trigger” ergänzt.
Für die, die es interessiert anbei der Code.
actions:
- action: notify.mobile_app_kevins_iphone_14_pro
metadata: {}
data:
title: Heizung.
message: Soll ich die Heizung herunterdrehen? (bitte gedrückt halten)
data:
actions:
- action: JA
title: Ja, bitte.
- action: NEIN
title: Nein, danke.
- wait_for_trigger:
- event_type: mobile_app_notification_action
event_data:
action: JA
trigger: event
- event_type: mobile_app_notification_action
event_data:
action: NEIN
trigger: event
timeout:
hours: 0
minutes: 10
seconds: 0
milliseconds: 0
continue_on_timeout: false
enabled: true
- choose:
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == \"JA\" }}"
sequence:
- action: input_select.select_option
metadata: {}
data:
option: Absenkung (nachts/außer Haus)
target:
entity_id: input_select.heizmodus
enabled: false
- delay:
hours: 0
minutes: 0
seconds: 3
milliseconds: 0
- action: notify.mobile_app_kevins_iphone_14_pro
metadata: {}
data:
title: Alles klar, Chef!
message: Heizung ist heruntergedreht. 🫡
- conditions:
- condition: template
value_template: "{{ wait.trigger.event.data.action == \"NEIN\" }}"
sequence:
- action: notify.mobile_app_kevins_iphone_14_pro
metadata: {}
data:
title: Dann halt näääächt.
message: "#GretaIstTraurig 😢"
enabled: true
enabled: true
@simon42
Ich hoffe mal das das Video “längst überfällig” und nicht “längst überflüssig” ist.
Ich löse das mit den Messages ohne Variablen, nämlich so:
und mit einem Trigger springe ich wieder in dieselbe Automation rein. (Weil man 10min Zeit hat zu reagieren)
So muss die Automation nicht warten.
Wenn man einen “Tag” in der “Frage”-Message hinterlegt, kann man auch so witzige Sachen machen wie die Nachricht wieder von den Geräten die nicht gedrückt haben zu löschen.
Das hoffe ich doch auch
Danke fürs Teilen deiner Automation
Wie immer klasse Video! Vielen Dank dafür!
Ich habe das mal in einer Automation ausprobiert.
Soweit so gut bekomme ich die Benachrichtigung auf meinem Handy. Doch ich hätte gerne, dass eine der Aktionen ausgeführt wird, wenn niemand drückt.
Hintergrund:
Meine Frau schläft bei laufendem Fernseher ein. Dieser soll zu einer bestimmten Uhrzeit aus geschaltet werden. In der Benachrichtigung soll entschieden werden können, ob der Fernseher an bleibt oder aus soll. Und wenn keiner drückt, soll der Fernseher aus.
Könnt ihr mir da weiter helfen?
Vielen Dank im Voraus!
Genauso hab ich das bei meiner Schlaferkennung (1 Post weiter oben)
Die triggert um 00:30 und stellt die Frage, wenn einer reagiert springt der andere Trigger an und setzt einen Helper auf “An”, um 00:40 läuft der 3. Trigger, und wenn keiner reagiert hat, ist der Helper noch “Aus” und die Automation knipst alles aus und die Kameras an.
Hier der ganze Luxus bei uns daheim
alias: GoodNight_Flow_V2
description: ""
triggers:
- alias: Mami und Papi am schlafen
value_template: >-
{{ states('sensor.iphone_mami') == "blp_sz" and
states('sensor.iphone_papi') == "blp_sz" and
(states('sensor.modiphm_battery_state') == "Charging" or
states('sensor.modiphm_battery_state') == "Full") and
(states('sensor.modipha_battery_state') == "Charging" or
states('sensor.modipha_battery_state') == "Full") }}
for:
hours: 0
minutes: 30
seconds: 0
id: sleepboth
trigger: template
- alias: Mami allein am Schlafen
value_template: >-
{{ states('sensor.iphone_mami') == "blp_sz" and
states('device_tracker.modiphm') == "not_home" and
(states('sensor.modipha_battery_state') == "Charging" or
states('sensor.modipha_battery_state') == "Full") }}
for:
hours: 0
minutes: 30
seconds: 0
id: sleepmamialone
trigger: template
- alias: Papi allein am Schlafen
value_template: >-
{{ states('sensor.iphone_papi') == "blp_sz" and
states('device_tracker.modipha') == "not_home" and
(states('sensor.modiphm_battery_state') == "Charging" or
states('sensor.modiphm_battery_state') == "Full") }}
for:
hours: 0
minutes: 30
seconds: 0
id: sleeppapialone
trigger: template
- at: "00:30:00"
id: "0030"
trigger: time
- at: "00:40:00"
id: "0040"
trigger: time
- event_type: mobile_app_notification_action
event_data:
action: WeAreWake
id: WeAreWakeEvent
trigger: event
- entity_id:
- input_boolean.wearewake
to: "on"
id: WeAreWakeButton
from: "off"
trigger: state
conditions:
- condition: time
after: input_datetime.time_start_goodnightscene
before: input_datetime.time_end_goodnightscene
actions:
- choose:
- conditions:
- condition: trigger
id:
- WeAreWakeEvent
- WeAreWakeButton
sequence:
- data: {}
target:
entity_id: input_boolean.wearewake
action: input_boolean.turn_on
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 250
- data:
message: clear_notification
data:
tag: sleepdetectionmessage
action: notify.all_devices
- delay:
hours: 0
minutes: 0
seconds: 0
milliseconds: 250
- data:
message: clear_notification
data:
tag: sleepdetectionmessage
action: notify.all_devices
- conditions:
- condition: trigger
id:
- sleepboth
- sleepmamialone
- sleeppapialone
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.lightdetection_all
state: "on"
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.weihnachtszeit
state: "on"
- condition: state
entity_id: switch.christmas_lights
state: "on"
- condition: state
entity_id: input_boolean.wearewake
state: "off"
sequence:
- action: remote.turn_off
metadata: {}
data: {}
target:
entity_id: remote.harmony_wz
- if:
- condition: state
entity_id: binary_sensor.weihnachtszeit
state: "on"
then:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.christmas_lights
alias: Weihnachtsbeleuchtung
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.alle_lichter_nothome
- light.alle_displays
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id:
- switch.pir_cams
- if:
- condition: numeric_state
entity_id: sensor.voltmeter_server_onpower_voltmeter
above: 4
then:
- action: hassio.addon_stdin
data:
addon: core_rpc_shutdown
input: SRVHYPV2
- data:
title: Schlaferkennung
message: >-
Offensichtlich schlafen alle, deswegen wurden alle Lichter um
{{states('sensor.time') }} ausgeschaltet.
enabled: true
action: notify.all_mobiledevices
- conditions:
- condition: trigger
id:
- "0030"
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.lightdetection_all
state: "on"
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.weihnachtszeit
state: "on"
- condition: state
entity_id: switch.christmas_lights
state: "on"
sequence:
- metadata: {}
data: {}
target:
entity_id: input_boolean.wearewake
action: input_boolean.turn_off
- data:
title: Schlaferkennung
message: Frage zur Sicherheit, ist noch jemand wach?
data:
tag: sleepdetectionmessage
push:
interruption-level: time-sensitive
actions:
- action: WeAreWake
title: Ja
icon: sfsymbols:moon.zzz.fill
action: notify.all_devices
- conditions:
- condition: trigger
id:
- "0040"
sequence:
- data:
message: clear_notification
data:
tag: sleepdetectionmessage
action: notify.all_devices
- choose:
- conditions:
- condition: state
entity_id: input_boolean.wearewake
state: "off"
- condition: or
conditions:
- condition: state
entity_id: binary_sensor.lightdetection_all
state: "on"
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.weihnachtszeit
state: "on"
- condition: state
entity_id: switch.christmas_lights
state: "on"
sequence:
- action: remote.turn_off
metadata: {}
data: {}
target:
entity_id: remote.harmony_wz
- if:
- condition: state
entity_id: binary_sensor.weihnachtszeit
state: "on"
then:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.christmas_lights
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id:
- light.alle_lichter_nothome
- light.alle_displays
- if:
- condition: numeric_state
entity_id: sensor.voltmeter_server_onpower_voltmeter
above: 4
then:
- action: hassio.addon_stdin
data:
addon: core_rpc_shutdown
input: SRVHYPV2
alias: Weihnachtsbeleuchtung
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id:
- switch.pir_cams
- data:
title: Schlaferkennung
message: >-
Offensichtlich schlafen alle, deswegen wurden alle
Lichter ausgeschaltet.
enabled: true
action: notify.all_devices
- conditions:
- condition: state
entity_id: input_boolean.wearewake
state: "on"
sequence:
- data: {}
target:
entity_id: input_boolean.wearewake
action: input_boolean.turn_off
mode: single
Ah, okay. Das hätte ich nicht erkannt.
Das ist mir locker ein paar Stufen zu hoch (Stand heute) Mal sehen, ob ich davon was abkupfern kann, wenn ich etwas mehr Zeit habe. Meine bessere Hälfte fragt zwar schon, wann das endlich funktioniert, aber nun ja. Gut Ding will Weile haben und ich hätte ihr ja noch nicht davon erzählen müssen.
LG MiGoRy
Ich raffs grad nicht…
Wie kann ich als Action einfach einen boolischen Helfer einschalten?
action: notify.mobile_app_sm_g950f
metadata: {}
data:
message: Klima Boost?
title: Gedrückt halten
data:
actions:
- action: input_boolean.turn_on
title: ja
target:
entity_id: input_boolean.klima_wohnzimmer_boost
So klappt das nicht, ich steh grad auf nem ganz großen Schlauch…
Ich glaube du hast hier zu viele Action-Sequenzen zusammen gepackt
Probier mal Simons Code zu kopieren und dann abzuändern. Die eigentliche Action kommt bei ihm erst im choose-Teil. Ich schaue dabei auf das Beispiel “Türen öffnen”, finde ich einfacher. Das konnte ich für meinen Fall adaptieren.
Das hätte ich auch gern. Gibt es da keine Variante, wenn man
continue_on_timeout: true
setzt, dass man dann hier
value_template: "{{ wait.trigger.event.data.action == ?? }}"
abfragen kann auf Ablauf des Timeouts?
Ich habe nun den Wert des Templates so gesetzt:
{{ wait.trigger is none or wait.trigger.event.data.action == '??' }}
Damit wird die Aktion bei der Betätigung des Buttons oder wenn keine Reaktion erfolgt ist ausgeführt.
Irgendwas mach ich falsch, bei mit kommt die Frage in der App aber dann passiert nichts. Laut Trace bleibt die Automation im Timeout stehen und ignoriert wohl den Trigger. Sieht jemand den Fehler?
alias: Haustür öffnen
description: ""
triggers:
- trigger: state
entity_id:
- sensor.eureka_mike_direction_of_travel
from: towards
to: arrived
id: Mike
- trigger: state
entity_id:
- sensor.eureka_steffi_direction_of_travel
from: towards
to: arrived
id: Steffi
conditions: []
actions:
- variables:
action_open: "{{ 'OPEN_' ~ context.id }}"
action_no: "{{ 'NO_' ~ context.id }}"
- choose:
- conditions:
- condition: trigger
id:
- Mike
sequence:
- data:
message: Möchtest du, dass ich die Türen öffne? (Geht 5 Min.)
data:
actions:
- action: "{{ action_open }}"
title: Öffnen
- action: "{{ action_no }}"
title: Nein
title: Bitte gedrückt halten!
action: notify.mobile_app_mikes_iphone
- conditions:
- condition: trigger
id:
- Steffi
sequence:
- data:
message: Möchtest du, dass ich die Türen öffne? (Geht 5 Min.)
data:
actions:
- action: "{{ action_open }}"
title: Öffnen
- action: "{{ action_no }}"
title: Nein
title: Bitte gedrückt halten!
action: notify.mobile_app_mikes_iphone
- wait_for_trigger:
event_type: mobile_app_notifiction_action
event_data:
action: "{{ action_open }}"
trigger: event
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
continue_on_timeout: false
- device_id: xxx
domain: lock
entity_id: xxx
type: open
mode: parallel
max: 2
Bei mir das gleiche Problem wie bei @firebowl
Ganz so als würde keine Rückmeldung vom Handy kommen.
alias: Türen öffnen
description: Öffnet die Haustür und Wohnungstür bei Ankunft
triggers:
- entity_id:
- person.pascal_strak
from: not_home
to: home
enabled: true
id: Pascal
trigger: state
- entity_id:
- person.tomma
from: not_home
to: home
enabled: true
id: tomma
trigger: state
conditions:
- condition: or
conditions:
- condition: device
device_id: a42699d6c91d712fec5c76d394d70ded
domain: lock
entity_id: bc088466df454f51cd13dc755bc3ec1e
type: is_locked
- condition: template
value_template: >-
{{ state_attr("automation.turen_offnen", "last_triggered") == None or (
as_timestamp(now()) -
as_timestamp(state_attr("automation.automation.turen_offnen",
"last_triggered")) |int(0) ) > 300 }}
alias: Automation wurde nicht in den letzten 5 Minuten ausgeführt
enabled: false
actions:
- variables:
action_open: "{{ 'OPEN_' ~ context.id }}"
action_no: "{{ 'NO_' ~ context.id }}"
- choose:
- conditions:
- condition: trigger
id:
- Pascal
sequence:
- data:
message: Möchtest du, dass ich die Türen öffne? (Geht 5 Min.)
data:
actions:
- action: "{{ action_open }}"
title: Öffnen
- action: "{{ action_no }}"
title: Nein
title: Bitte gedrückt halten!
action: notify.mobile_app_iphone
- wait_for_trigger:
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_open }}"
trigger: event
continue_on_timeout: false
timeout:
hours: 0
minutes: 5
seconds: 0
milliseconds: 0
- parallel:
- device_id: a42699d6c91d712fec5c76d394d70ded
domain: lock
entity_id: bc088466df454f51cd13dc755bc3ec1e
type: unlock
- target:
entity_id: scene.wohnzimmer_entspannen
metadata: {}
action: scene.turn_on
data: {}
- if:
- condition: sun
after: sunset
then:
- action: light.turn_on
metadata: {}
data:
brightness_pct: 5
target:
entity_id:
- light.strahler_aussen
- light.spots_kuche
- delay:
hours: 0
minutes: 9
seconds: 0
milliseconds: 0
- action: light.turn_off
metadata: {}
data: {}
target:
entity_id: light.strahler_aussen
enabled: false
mode: parallel
max: 2
Keiner ne Idee? Schon ein wenig traurig.
@simon42 Kannst Du vielleicht helfen?
Moin zusammen,
Ich scheitere auch an meiner Automation.
Ziel ist es:
Sobald mein Wassermelder im Keller Wasser erkennt (In der Testautomation über eine Testtaste simuliert), meldet mein HomePod per TTS, dass Wasser entdeckt wurde und soll dies wiederholen, bis auf meine Benachrichtigung „Alarm ausschalten“ gedrückt wurde.
Hier meine Automation:
alias: Test2
description: ""
triggers:
- trigger: state
entity_id:
- input_button.testtaste
id: Testtaste
conditions: []
actions:
- variables:
action_silence: "{{ 'SILENCE_' ~ context.id }}"
enabled: true
- action: notify.mobile_app_iphone
metadata: {}
data:
message: Test
title: Test
data:
actions:
- action: "{{ action_silence }}"
title: Alarm deaktivieren
icon: sfsymbols:bell.slash
enabled: true
- repeat:
sequence:
- action: tts.cloud_say
metadata: {}
data:
entity_id: media_player.sonos_one
message: Test {{ trigger.to_state.name }}
until:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_silence }}"
- wait_for_trigger:
- trigger: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_silence}}"
timeout:
hours: 0
minutes: 10
seconds: 0
milliseconds: 0
continue_on_timeout: false
enabled: true
mode: single
Leider wird der Text nur einmal abgespielt und es erscheint die Pushbenachrichtigung.
Ich gehe davon aus, dass es an dem until Template liegt
until:
- condition: template
value_template: "{{ wait.trigger.event.data.action == action_silence }}"
Hat jemand eine Idee dazu?
Viele Grüße
Marco