Workday sensor: State of next day?

How can I get the state of the workday sensor for the next day?
Actually I turn off a light earlier when the next day is a working day (Sunday to Thursday) and later when it is Friday or Saturday. It works fine during a normal week - but it doesn’t takes into account public holidays. Is there may be a solution with the workday sensor?

## Schrank aus werktags  
- alias: Schrankbel aus Werktag
  trigger:
    platform: time
    at: '22:45:00'
  condition:
    condition: time
    weekday:
    - mon
    - tue
    - wed
    - thu
    - sun
  action:
    service: light.turn_off
    entity_id: light.schrank

# Schrank aus Wochenende
- alias: Schrankbel aus Wochenende
  trigger:
    platform: time
    at: '23:20:00'
  condition:
    condition: time
    weekday:
    - fri
    - sat
  action:
    service: light.turn_off
    entity_id: light.schrank

Thanks!

Yes. That’s what the days_offset option is for. Define a workday sensor with that set to 1, which will indicate if tomorrow is a workday. Then you can use that sensor in the condition of your automations.

4 Likes

Apologies for the necromancy.

Is it known if configuring the second sensor will reference the add_holidays and remove_holidays from a previous entry?

Alternate phrasing: Do multiple instances of the same binary_sensor like this, use an aggregate data set, or individual?

I will be testing this, but if someone knows a definitive answer, that would be excellent.

Edit
Looks like its a fully individual instance (not surprising).

binary_sensor:
  # https://www.home-assistant.io/integrations/workday/
  - name: workday_today_sensor
    platform: workday
    country: US
    workdays: [mon, tue, wed, thu, fri]
    excludes: [sat, sun]
    add_holidays: []
    remove_holidays: []
  - name: school_night_sensor
    days_offset: 1
    platform: workday
    country: US

Results in school_night_sensor having the default for excludes of [sat, sun, holiday] even though its defined and omitted from workday_today_sensor.

image

2 Likes

It would be extremely helpful if an attr_days_offset would be an option that could be shown as an attribute…and allow multiple instances. 1 day offset for tomorrow. 3 day offset for Monday when it’s Friday, etc.

2 Likes

From the 2023.5 release it is very easy to define a “Workday tomorrow”-sensor in the UI. Go to settings and add a new workday sensor and set the offset to 1. Done :slight_smile:

As a Home Assistant beginner, while not directed at you personally, this is a point of frustration. I’ve gone down multiple paths and rabbit holes without success.

It’s easy in the UI, I think, based on experience. HOW do you add in the UI? There are many areas in Settings, of course. I haven’t had any luck trying this in Helpers, etc.

Thanks!

Workday is an integration. So you have to go to settings → devices & services → add integration (at the bottom right).
Then enter workday and it should show you the integration. When entered your country you can edit the preffered settings.

1 Like

That’s easy indeed. Unfortunately it results in a double (custom) holiday administration if one wants to know if today is a workday and if tomorrow is a workday.

For example, I have morning automations that use the workday sensor and I’d like to use it in the evening for the same reason as the topic starter mentioned.

I currently solved this by using a helper. At 1s before midnight it sets the helper to the state of tomorrow if it’s different. It however would be lovely to have an .AddDays(n) option.

Anyway, does anyone happen to have a better solution than my helper solution?

1 Like

In the same boat over here… Not happy with maintaining two workday calendars (School Day Today, School Day Tomorrow) especially since sometimes schedules change and then one has to make modifications in two places.

If it was possible to check Tomorrow as an attribute of Today that would be great.

Another solution would be to break out the custom holidays and have them as objects referenced by the custom Workday sensors…

That way you could have highly customizable Workday sensors AND the benefit of maintaining calendars in one place.