Can the Times of the Day (tod) sensor be templated?

Hi,
I’m using a couple of tod binary sensors to switch between phases of my heating schedule (e.g. reduce temperatures at night time).
I’m wondering if it was possible to template the specific time settings for each sensor.
I would like to have different time ranges for weekends and weekdays.

I tried something like:

binary_sensor:
  platform: tod
  name: timeofday_night
  before: '07:00'
  after: {%if true %}21:00{%else%}22:00{%endif%}

but that’s not working…

Is there a way?

Sebastian

It cannot. Just use a template sensor. Also, that logic will always output 21:00… not sure if that is your intentions or not.

Right, a template sensor should indeed do the trick, thanks!
I’m aware that the template in the example makes no sense - this was just for illustration purposes.

Sebastian

1 Like