Hi, I have an automation triggered by time matchine a time sensor, which works:
trigger:
- platform: time
minutes: ‘/1’
seconds: 0
condition:
- condition: template
value_template: ‘{{ now().strftime("%H:%M") == states.sensor.curtain_timewe.state }}’
However I can’t figure out how to make this trigger activate for example 5 minutes beforehand.
I’ve tried this, which isn’t working:
value_template: '{{ (as_timestamp(now().strftime("%H:%M") + 60)) == states.sensor.curtain_timewe.state }}'
Could anyone please point me the right direction? Thanks!
Try:
value_template: >
{{ (as_timestamp(now())+300)|timestamp_custom('%H:%M') ==
states('sensor.curtain_timewe') }}
Thanks for the help
however this:
value_template: ‘{{ (as_timestamp(now())+60)|timestamp_custom(’%H:%M’) == states.sensor.curtain_timewe.state }}’
Is giving me:
ERROR:homeassistant.util.yaml:while scanning for the next token
found character ‘%’ that cannot start any token
in “/home/homeassistant/.homeassistant/configuration.yaml”, line 1090, column 70
error
EDIT: AH! I needed to use double not single quotes in the custom timestamp. Thanks for getting me there ![:slight_smile: :slight_smile:](https://community.home-assistant.io/images/emoji/twitter/slight_smile.png?v=12)
1 Like