I am fairly new to HA and struggling with the YAML syntax to create a binary_sensor
using tod
and helpers for the after
and before
properties. This is the content of my config/binary_sensor.yaml
file:
- platform: tod
name: Energy Savings
after: '{{ states("input_datetime.energy_savings_start_time") }}'
before: '{{ states("input_datetime.energy_savings_end_time" ) }}'
Both input_datetime.energy_savings_start_time
and input_datetime.energy_savings_end_time
are Date and/or time
(time only) helpers with start_time
set to 4:00 PM
and end_time
set to 9:00 PM
.
I have tried various combinations of single and doulbe quotes but have not come up with the correct combination. Everything seems to be OK in File editor
but errors when I Check Configuration
. the current error is:
Invalid config for [binary_sensor.tod]: Invalid time specified: {{ states("input_datetime.energy_savings_end_time" ) }} for dictionary value @ data['before']. Got '{{ states("input_datetime.energy_savings_end_time" ) }}'
Invalid time specified: {{ states("input_datetime.energy_savings_start_time") }} for dictionary value @ data['after']. Got '{{ states("input_datetime.energy_savings_start_time") }}'. (See ?, line ?).
What am I doing wrong? Is there a good reference or tutorial for writing advanced YAML for HA?
Thanks in advance.