@Zoriontsu wrote:
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:
`{{ (((as_timestamp(states.calendar.home.attributes.start_time) - as_timestamp(now())) / 60) | int) <= 30 and (((as_timestamp(states.calendar.home.attributes.start_time) - as_timestamp(now())) / 60) | int) > 0 }}`
But… If used in my binary sensor, the sensor never changes:
- platform: template joint_calendar_event_within_30_minutes: friendly_name: 'Joint Calendar Event Within 30 Minutes' value_template: "{{ (((as_timestamp(states.calendar.home.attributes.start_time) - as_timestamp(now())) / 60) | int) <= 30 and (((as_timestamp(states.calendar.home.attributes.start_time) - as_timestamp(now())) / 60) | int) > 0 }}"
I have tried several variations such as:
joint_calendar_event_within_30_minutes: friendly_name: 'Joint Calendar Event Within 30 Minutes' value_template: >- {{ (((as_timestamp(states.calendar.home.attributes.start_time) - as_timestamp(now())) / 60) | int) <= 30 and (((as_timestamp(states.calendar.home.attributes.start_time) - as_timestamp(now())) / 60) | int) > 0 }}
Thanks in advance.
Posts: 6
Participants: 4