Sensor for weekday, help templating

Trying to get the opposite of a binary_sensor workday so a holiday (on when is holiday, off when is workday. The below template is wrong. Need help fixing it

value_template: ‘{% if is_state(“binary_sensor.workday”, “on”) off {% else %} on {% endif %}’

1 Like

maybe have a look in the dev-state, I am using the default

binary_sensor.workday_sensor (https://www.home-assistant.io/components/binary_sensor.workday/#name) as opposed to your binary_sensor.workday?

also if you want to test if it is off, just do

{{is_state('binary_sensor.workday_sensor','off')}}
this is true for holidays And weekends though, not sure if thats what you need, but it is what you asked for :wink:

I needed the opposite behaviour of the binary_sensor.workday.

Found solution myself, I missed a character, below is working (the new binary_sensor is on during the holidays and off during the workdays.

Having a hard time with template lol

holiday_lights_override:
value_template: ‘{% if is_state(“binary_sensor.workday”, “on”) %} off {% else %} on {% endif %}’

that template is On on non-workdays, so on holidays And weekends

just as the template I suggested, which is much simpler:

{{is_state('binary_sensor.workday_sensor','off')}}

don’t need to specify the on and off state in the template like this.

Yep that what I need (holiday and weekends are same in my user case: I want to sleep longer and have off some automation (some lights going on early morning)

Edit for me weekend are non working days, sorry for the confusion caused