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

Binary Sensor Template with Time

$
0
0

@reclusivemonkey wrote:

I’m trying to create a binary sensor for ‘working from home’. When I try this in the template section of the developer tab it works as expected. However in use it does not perform as expected. The template I am using is;

{{ is_state('device_tracker.slim_charles', 'home')
  and is_state('calendar.google_work', 'off')
  and is_state('binary_sensor.workday', 'on')
  and (now().hour) >= 8
  and (now().hour) <= 16 }}

Right now (11:01 AM), in the template tester this is true. But my actual binary sensor reports it as off. I must be missing something really obvious but don’t understand what it is. Here is the full sensor for reference;

platform: template
sensors:
  working_from_home_luke:
    value_template: >-
      {{ is_state('device_tracker.slim_charles', 'home')
        and is_state('calendar.google_work', 'off')
        and is_state('binary_sensor.workday', 'on')
        and (now().hour) >= 8
        and (now().hour) <= 16 }}
    icon_template: >-
      {% if is_state('binary_sensor.working_from_home_luke', 'on') %}
        mdi:domain 
      {% else %}
        mdi:domain-off
      {% endif %}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 102659

Trending Articles



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