Binary Sensor Template having Time

Hi,
I have a small ESPHOME display and I would like to turn it off using a binary sensor I would like to create using a template as per below.

I would like to this binary sensor to be ON when the alarm panel is “armed_home” and time of the day is between 6am and 11pm … but I dont know how I have to implement the time part. Can someone put me in the right direction pls?

  - platform: template
    sensors:
      display_on:
        friendly_name: Display On
        value_template: >
          {{ is_state('alarm_panel', 'armed_home') and
             is_state('time?', '??') }}

Hard coded times or from Input_time date.?
Both are doable
{{ ‘06:00’ <= states(‘sensor.time’) <= ‘23:00’ }}

1 Like

thanks will try it out and revert

Just warning you that is a code snippet that resolves to true/false its not your final solution, just a helping hand.
If you need more, comeback to me.
We are just trying to help you learn, not tease you and spoon feeding has only short term gains

will try it out … thanks for helping :slight_smile:

worked fine, just had to add sensor.time with the following in the config file

#time
  - platform: time_date
    display_options:
      - 'time'
      - 'date'
  - platform: template
    sensors:
      display_on:
        friendly_name: Display On
        value_template: >
          {{ is_state('alarm_control_panel.alarm_panel', 'armed_home') and
              '06:00' <= states('sensor.time') <= '23:00' }}

:+1: :+1:

Good for you