The entity_id option is now depracated as of 0.61, however I’ve just started using it as part of a solution.
I have the following sensor:
- platform: template
sensors:
my_event_offset:
friendly_name: "My Event offset"
entity_id:
- calendar.myevents
- sensor.date__time
value_template: >
{% if as_timestamp(states.calendar.myevents.attributes.start_time) - as_timestamp(now()) < 21600 %}on{% else %}off{% endif %}
The attribute start_time will only update daily or weekly, so I think the sensor would only update them. However, for the maths to actually detect that the current time is within the offset period the sensor must update every minute.
This has been achieved by using the entity_id and listing the date__time sensor. How can I force the sensor to stay up to date without using the entity_id option?