In the context of theintegration of Pronote, in order to allow for the automatic creation of an alarm tomorrow morning or to set the Pronote update in order not to update it on school holidays, I need to know if we are on school holidays and if there is school tomorrow.

A working day?
To find out if we are a working day or not, just install the extension Workday
Nothing simpler, everything is in documentation.
I add it twice. To have tomorrow, we add with a lag of 1.



Disabled = non-working day
On school holidays?
To find out whether we are on school holidays or not, you have to ask the API of the Ministry of National Education. The script used is in V1, it has a V2.0, if I have some time, I will switch to the V2.0 later.
- V1: https://data.education.gouv.fr/api/v1/console/datasets/1.0/search/
- V2.0: https://data.education.gouv.fr/api/explore/v2.0/console
Resource used for these sensors (thanks to its author):
- https://github.com/papo-o/home-assistant-config/blob/master/integrations/vacances_scolaires.yaml
- https://pon.fr/home-assistant-vacances-scolaires/
Addition of a sensor ‘school holidays _s’
In my file sensors.yaml, I add this sensor:
- platform: rest scan_interval: '00:30:00' name: holidays_schools json_attributes_path: "$.records[0].fields" json _attributes: - start_date - end_date - description resource_template: |- {% set location = 'Aix-Marseille' %} {% set rows = '1'%} {% set today = now().strftime('%Y-%m-%d')%} {% set dayOfYear = now().strftime('%I') %} {% set year = now().strftime('%Y') | int %} {% set lastYear = year - 1 %} {% set nextYear = year + 1 %} {% if dayOfYear > '244' %} {% set schoolYear = (year | string) + "-" + (nextYear | string) %} {%- else -%} {% set schoolYear = (lastYear | string) + "-" + (year | string) %} {%- endif %} https://data.education.gouv.fr/api/records/1.0/search/?dataset=en-calendrier-scolaire&facet=start_date&facet=end_date&rows={{rows}}&refine.location={{location}}&sort=-end_date&q=end _date={{today}} value _template: |- {% set today = now().strftime('%Y-%m-%d')%} {% for record in value _json.records -%} {% if today >= record.fields.start _date and today <= record.fields.end _date %} {%- if record.fields.description %}{{record.fields.description}} until {{ as_timestamp(record.fields.end_date) | timestamp _custom('%d-%m-%Y') }} {% endif %} {% else %} {%- if record.fields.end _date > today and record.fields.description %} next: {{record.fields.description}} {{ as_timestamp(record.fields.start _date) | timestamp _custom('%d-%m-%Y') }}{% endif %} {% endif %} {%- endfor %}
Of course, the academy needs to be changed: ‘Corsica’, ‘Polynesia’, ‘New Caledonia’, ‘Guyane’, ‘Aix-Marseille’, ‘Amiens’, ‘Besançon’, ‘Bordeaux’, ‘Clermont-Ferrand’, ‘Créteil’, ‘Dijon’, ‘Grenoble’, ‘Lille’, ‘Limoges’, ‘Lyon’, ‘Montpellier’, ‘Nancy-Metz’, ‘Nantes’, ‘Nice’, ‘Orléans-Tours’, ‘Paris’, ‘Poitiers’, ‘Reims’, ‘Rennes’, ‘Strasbourg’, ‘Toulouse’, ‘Versailles’, ‘Mayotte’, ‘Réunion’, ‘Martinique’, ‘Saint Pierre et Miquelon’, ‘Wallis et Futuna’, ‘Caen’, ‘Rouen’, ‘Guadeloupe’, ‘Normandie’
Result of this sensor

This information must be able to extract two pieces of information in the form of binary _sensor that can be used in automations or scripts.
Addition of two binary sensors School holidays today and School holidays tomorrow
Updated on 03/10/2023, thanks to the relevant remark from Giga77, I correct the code below and replace
states.sensor.vacances_scolaires.attributes["start_date"]
bystate_attr('sensor.vacances_scolaires', 'start_date')
In my file templates.yaml, I add these sensors:
- binary_sensor: - name: _school holidays _now unique _id: binary_sensor.vacances_schools_today state: |- {% set today = now().strftime('%Y-%m-%d')%} {% if today < state_attr('sensor.vacances_scolaires', 'start_date') or today > state_attr('sensor.vacances_scolaires', 'end_date') %} false {% else %} true {% endif %} - binary _sensor: - name: _school holidays_single tomorrow_id: binary_sensor.vacations_scolaires_demain state: |- {% set tomorrow = (as_timestamp(now()) + (24*3600)) | timestamp_custom('%Y-%m-%d', True) %} {% if tomorrow < state_attr('sensor.vacances_scolaires', 'start_date') or tomorrow > state_attr('sensor.vacances_scolaires', 'end_date') %} false {% else %} true {% endif %}
Result of these sensors (tested on a holiday)


A binary_sensor to allow the Pronote update
There is no need to update Pronote during holidays or non-working days.
I have created a binary _sensor that will allow Pronote to be updated or not.
In my file templates.yaml, I add this sensor:
- binary_sensor: - name: authorise _miseajour _pronote unique _id: binary_sensor.authorise_miseajour_pronote state: "{{ is_state('binary_sensor.vacances_scolaires_today', 'off') and is_state('binary_sensor.open_today', 'on')}}"
![]()

Add a condition to launch the update
As specified in the Pronote integration tutorial, we add an automation to launch the Pronote update regularly, and with the new entity binary_sensor.allow _miseajour _pronote, we will allow the update only if binary_sensor.allow _miseajour _pronote=on

Here is the full YAML code of the automation
alias: Updated Pronote Description: "" trigger: - platform: time_pattern hours: /4 condition: - condition: state entity _id: binary_sensor.authorise_miseajour_pronote state: "on" action: - service: shell_command.update_pronote data: {} mode: single
Thus, on working days, excluding school holidays, authorisation is activated and Pronote will be updated every 4 hours.
