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

Template Binary Sensor Always - Day & Time Issue

$
0
0

@Phill_Healey wrote:

I’m trying to create a template binary sensor that checks if the current time is between between a specified on & off time. So if its after the start time the sensor is true but, once the off time is reached the sensor is off again.

I’ve got the following which works fine:

- platform: template
  sensors:
    test_sensor_5:
      friendly_name: "test_sensor_5"
      value_template: >-
        {{  states("input_select.aquarium_light_off") >= now().time().strftime("%R") <= states("input_select.aquarium_light_off")  }}

However I only want this to work during workdays eg: The sensor is only on between 12:00 and 22:00hrs Mon -Fri. So, I added in what I thought was a simple “and” condition but this just sets the sensor to off 24/7.

- platform: template
  sensors:
    test_sensor_5:
      friendly_name: "test_sensor_5"
      value_template: >-
        {{ ( states("input_select.aquarium_light_off") >= now().time().strftime("%R") <= states("input_select.aquarium_light_off") ) and binary_sensor.workday_sensor == 'On' }}

Any ideas why this doesn’t work?

Thanks.

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95481

Trending Articles



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