Skip to content

Conversation

@derallye
Copy link

@derallye derallye commented Jan 1, 2026

The Spanish Regulation (BOE-A-2020-1066 ) states: "Se consideran como horas del periodo 3 (valle) todas las horas de los sábados, domingos, el 6 de enero y los días festivos de ámbito nacional, definidos como tales en el calendario oficial del año correspondiente, con exclusión tanto de los festivos sustituibles como de los que no tienen fecha fija."

That means that it is not required to set the national holidays per year, as the "Viernes Santo" hasn't a fixed date, so it is not included in the list. Just comparing date/month will be enough:

1 January
6 January
1 May
15 August
12 October
1 November
6 December
8 December
25 December

I have fixed the error of missing 2026 national holidays dictionary by changing it to just check for day/month.

@diamant-x
Copy link

Why not build on top of other holiday tracker packages, like https://github.com/vacanza/holidays which is the one used in https://www.home-assistant.io/integrations/workday as well? That way maintenance of what constitutes a holiday could be kept out of this package?

@ENK0DED
Copy link

ENK0DED commented Jan 1, 2026

I did take the approach of using the https://github.com/vacanza/holidays package in the PR I just published: #83

@kikediazfernandez
Copy link

As @derallye remarks, not all holidays are included in the regulation: "Se consideran como horas del periodo 3 (valle) todas las horas de los sábados, domingos, el 6 de enero y los días festivos de ámbito nacional, definidos como tales en el calendario oficial del año correspondiente, con exclusión tanto de los festivos sustituibles como de los que no tienen fecha fija.", so holidays is not valid

@kikediazfernandez
Copy link

kikediazfernandez commented Jan 3, 2026

The period is provided by indicator 1002. It should be better to get it there. I'll try to make a PR with that.
Edit: it doesn't get values in the future, so "next_period" and "hours_to_next_period" cannot be calculated in all cases using indicator 1002. For now, I will use @derallye solution.

@ssaavedra
Copy link

Hey, what is required to merge this?

@r-jordan
Copy link

Hi,

The test in test_tariff_attributes.py is failing. It should be changed because the test was checking incorrect holidays dates.

From this:

@pytest.mark.parametrize(
"year, days_weekend_p3, extra_days_p3",
(
(2021, 104, 7),
(2022, 105, 7),
(2023, 105, 9),
(2024, 104, 7),
(2025, 104, 7),
),

To this:

@pytest.mark.parametrize(
"year, days_weekend_p3, extra_days_p3",
(
(2021, 104, 6),
(2022, 105, 6),
(2023, 105, 8),
(2024, 104, 6),
(2025, 104, 6),
),

@derallye , could you commit this change to see the tests may finish ok?

@derallye
Copy link
Author

@r-jordan , apologies for the delay. Test fix done. That's ready to be merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants