I’m using a Google calendar to getting public holidays. So I want to change the workday state from a automation. I have a template gives me ‘workday’, ‘weekend’ or the name of the public holiday.
Now I try to update the binary sensor workday to off if the state of this template is not ‘workday’. Any idea how to make this?
if you are just interested in a binary sensor for workday, you can use the builtin platform workday. See https://www.home-assistant.io/integrations/workday/
The first part of the code snippet below enables this sensor for Niedersachsen. You have to set ‘HE’ for Hessen.
For my use case I extended this by adding a Google calendar for my vacations. Each vacation day gets a full-day appointment. The second snippet aggregates these two values into a binary sensor called template_workday.
Hope this helps,
Lutz
# Germany/Niedersachsen
- platform: workday
country: DE
province: NI
# this template sensor combines workday-sensor above and the holiday-calendar
- platform: template
sensors:
template_workday:
friendly_name: "Arbeitstag"
value_template: >-
{{ (states.binary_sensor.workday_sensor.state == 'on') and (states.calendar.vacation.state == 'off') }}