Hi, I’m trying to control my kitchen fan (which is also controlled by other automations) so that this automation will only turn off the switch if said switch (switch.kjokken_vifte) was triggered by this automation last time.
This is my automation this far based on trigger context, however is failing to turn of the switch
alias: "Kjøkken: Kjøre vifte for bedre klima"
description: ""
triggers:
- trigger: time_pattern
minutes: "*"
id: fan_off
alias: Sjekk om vifte er av
- trigger: state
entity_id:
- switch.kjokken_vifte
to: "on"
for:
hours: 0
minutes: 0
seconds: 10
id: fan_on
alias: Vifte er på
conditions: []
actions:
- choose:
- conditions:
- condition: trigger
id:
- fan_on
- alias: Utløst av denne automasjonen?
condition: template
value_template: >-
{{ trigger.to_state.context.id ==
states.automation.kjokken_kjore_vifte_for_bedre_klima.context.id
}}
enabled: true
sequence:
- action: switch.turn_off
metadata: {}
data: {}
target:
entity_id: switch.kjokken_vifte
alias: Skru av vifte
- conditions:
- condition: trigger
id:
- fan_off
- condition: time
after: "07:00:00"
before: "21:30:00"
- condition: state
entity_id: switch.kjokken_vifte
state: "off"
for:
hours: 0
minutes: 0
seconds: 1
- condition: numeric_state
entity_id: zone.home
above: 0
sequence:
- action: switch.turn_on
metadata: {}
data: {}
target:
entity_id: switch.kjokken_vifte
alias: Skru på vifte
mode: single
In all essence it this condition I’m failing to complete correctly
- alias: Utløst av denne automasjonen?
condition: template
value_template: >-
{{ trigger.to_state.context.id ==
states.automation.kjokken_kjore_vifte_for_bedre_klima.context.id
}}
And by the looks of it, HASS does know who triggered the switch last time so this should be possible I guess?
However the condition is not becoming true so I must be doing something wrong here?