Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 96121

Stumped by Template Binary Sensor! Looking for guidance

$
0
0

@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

Read full topic


Viewing all articles
Browse latest Browse all 96121

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>