Template sensor after and before times?

I’m wanting to create a template sensor (maybe a binary sensor?) that’s ‘true’ between the times of 8:00 pm and 11:30 pm.

I’ve seen a few examples on these forums, but not quite applicable for my use case (and I found them a little confusing, so couldn’t adapt them for my use case).

Does anyone have an idea on how to achieve this? :slightly_smiling_face:

  - binary_sensor:
      - name: "True between 20:00-23:30"
        state: "{{ today_at('20:00') <= now() <= today_at('23:30') }}"

You could also do it with a Trigger-based template binary sensor or Schedule.

1 Like

There’s also this integration which can be set up from the UI:

1 Like

Perfect, thanks!

I didn’t realise this could be done from the frontend, thanks :raised_hands: