Since my country is not on its workday list or to be exact the holiday. Is there a workaround?
I use an extra calendar for my vacations or extra holidays.
can you share your yaml? at least to get some understanding?
I use a google calendar for that and in my “google_calendars.yaml” I have something like that:
- cal_id:[email protected]
entities:
- device_id: holidays
ignore_availability: true
name: Holidays
track: true
search: vacation
That searches for the vacations in that calendar.
And than I have several sensors in order to check if today or tomorrow is a holiday or something else. That way I can get a notification when I go to bed and my alarm clock is still set for early in the morning.
binary_sensor:
- platform: template
sensors:
vacation_tomorrow:
friendly_name: 'Vacation tomorrow'
device_class: opening
value_template: >-
{% set nextVacation = state_attr('calendar.vacation', 'start_time') %}
{% if nextVacation == None %}
False
{% else %}
{% set nextVacationTime = strptime(state_attr('calendar.vacation', 'start_time'),'%Y-%m-%d %H:%M:%S') %}
{{ nextVacationTime.strftime('%j')|int - now().strftime('%j')|int == 1 }}
{% endif %}
This is exactly the approach I use. Most of my work holidays don’t fall on stat holidays because they are usually moved to the closed Monday or Friday. It costs megabucks to fire up our shop for production, so we really try to avoid 1 day shutdowns.
{{ nextVacationTime.strftime('%j')|int - now().strftime('%j')|int == 1 }}
This line is cool though. I took a different approach but I think I like yours better!
{% set start = as_timestamp(state_attr('calendar.work_holiday','start_time')) %}
{% set end = as_timestamp(state_attr('calendar.work_holiday','end_time')) %}
{% set now = as_timestamp(now()) %}
{{ (start - now < 0 and end - now > 86400) or (start - now > 0 and start - now < 86400) }}