Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workday service workday.check_date does not consider weekends when no country is set #105187

Closed
jgoguen opened this issue Dec 7, 2023 · 3 comments · Fixed by #105241
Closed

Comments

@jgoguen
Copy link
Contributor

jgoguen commented Dec 7, 2023

The problem

When setting up a Workday sensor with no country, using all the default settings, the workday.check_date service incorrectly claims every day is a working day. The default settings exclude defined holidays, as well as Saturday and Sunday, so the date 2023-12-09 should return workday: false but it returns workday: true.

Only explicitly defined holidays, not other excluded days, are being considered by the workday.check_date service.

What version of Home Assistant Core has the issue?

core-2023.12.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

workday

Link to integration documentation on our website

https://www.home-assistant.io/integrations/workday/

Diagnostics information

No response

Example YAML snippet

N/A - set up a new Workday integration with no country and all default values.

Anything in the logs that might be useful for us?

N/A

Additional information

The service does correctly detect explicit holidays when defined, but since "Saturday" and "Sunday" are included in the exclusions list they also should indicate that the date is not a workday.

@home-assistant
Copy link

home-assistant bot commented Dec 7, 2023

Hey there @fabaff, @gjohansson-ST, mind taking a look at this issue as it has been labeled with an integration (workday) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of workday can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign workday Removes the current integration label and assignees on the issue, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


workday documentation
workday source
(message by IssueLinks)

@SVH-Powel
Copy link

It does not work even if country is set. Looking at the code, it seems to only consider official holidays and not excluded days like saturday and sunday.

async def check_date(self, check_date: date) -> ServiceResponse: """Check if date is workday or not.""" holiday_date = check_date in self._obj_holidays return {"workday": not holiday_date}

@gjohansson-ST
Copy link
Member

Right. It wasn't considered that some parts was outside the holiday object.
I'll get a fix ready shortly.

@github-actions github-actions bot locked and limited conversation to collaborators Jan 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants