Drzet
(Drzet)
May 16, 2021, 10:57am
1
Well, this drives me nuts for 2 days now:
alias: Morning alarm
description: ''
trigger:
- platform: template
value_template: >-
'{{ states("sensor.date_time") ==
(as_timestamp(states('sensor.motorola_razr_5g_next_alarm'))| int -60)|
timestamp_custom("%Y-%m-%d, %H:%M") }}'
condition: []
action:
- service: mqtt.publish
data:
topic: blinds/side/percentage
payload: '10'
mode: single
MQTT works, Template works(checked with developer tools>Templates) but TRIGGER never happens.
Help please.
Remove the outside quotes around template.
Drzet
(Drzet)
May 16, 2021, 4:46pm
3
Thanks! It worked. I’ve found so many different variations of this template and all were wrong. Perhaps version changes introduce new syntaxes?
#HateC++
No, it’s been like this since I started using HA three years ago.
You need to quote your template if you enter it inline:
value_template: '{{ ... }}'
But if you use multi-line YAML, you do not:
value_template: >
{{ ... }}
Also, be careful how you use quotes inside quotes. You had:
'{{ ... 'xxx' ... }}'
If your outside quotes are single quote characters, then you should use double quote characters inside (and vice versa.)
'{{ ... "xxx" ... }}'
or
"{{ ... 'xxx' ... }}"
Drzet
(Drzet)
May 17, 2021, 6:12pm
5
pnbruckner:
You need to quote your template if you enter it inline:
value_template: '{{ ... }}'
But if you use multi-line YAML, you do not:
value_template: >
{{ ... }}
I think that’s were the problem originated. Try entering template into as a single line in the “New Automation” screen in Visual Editor. Save that automation and then open “Edit in YAML”. You will see that your single line is converted into >-
multiline but the quotes are still there.