I’m trying to configure a binary template sensor that recomputes on/off (or true/false) based on a time interval, although the derived state would rely on other sensor inputs. I do this because want to rate-limit it, so that it doesn’t update too rapidly based the inputs on which it relies.
I created a template binary sensor through the UI, and added this YAML:
Do you mean the Template Editor in Developer Tools or the Template Helper editor?
Advanced functions like trigger are not available through the UI Template helper. You must set up the sensor in your YAML configuration. Also, the State template field in the UI Template Helper editor is only for the state template, not YAML configuration.
If that’s what you did then there’s no place in the form that’s designed to receive YAML. The form has a field named State Template and that’s where you put the Jinja template. In addition, a Template Helper cannot be used to create a Trigger-based Template Binary Sensor.
The YAML you posted can only be used in a text file (like configuration.yaml) and cannot be used to create a Trigger-based Template Binary Sensor via the UI.
I also suggest you get in the habit of wrapping on and off in quotes so that the YAML processor handles them as strings. Otherwise, unquoted on and off are understood to be boolean true and false. In this particular case it doesn’t matter because a Template Binary Sensor accepts true/false, 1/0, 'on'/'off', etc. In other cases it will, like when comparing string values.
Since I don’t fully understand why, could you perhaps point me to a good explanation or tutorial on HA YAML?
Admittedly I just cobble things together from examples in the forums and documentation, but I find YAML to be difficult to read and write because it’s not at all intuitive!