I have many fairly complex binary sensors working without a hitch, but this on is really aggravating me, as I cannot make it work.
I am trying to create a binary sensor that will turn on if there is a Google Calendar event within 30 minutes.
The following template works perfectly in the Development Tools Template Editor:
All the events are showing up properly. So I know all is well, except the binary_sensor is not triggering.
Again, it works as designed in the Development Tools Template Editor.
I have tried so many iterations of parenthesis, quotes, etc.
NO JOY!
Yup, jwelter’s example resolves the issue using entity_id: sensor.time but there’s no reply from Zoriontsu confirming it.
@Zoriontsu
By adding entity_id: sensor.time to the Template Binary Sensor’s configuration, you’re instructing Home Assistant to evaluate the template whenever sensor.time changes state. That sensor changes state every minute.
In this example, I’ve added entity_id: sensor.time and revised the template to make it easier to understand its logic.
Naturally, you first have to define sensor.time in configuration.yaml before it can be used elsewhere.
You’ve arrived at an equivalent solution by replacing the now() function with sensor.time. Home Assistant detects the presence of sensor.time within the template and will evaluate the template every minute.