Je viens de teste sur ma pro est ca fonctionne
Verifie que tu as bien positionné
platform: rest en dessous de sensor:
pareil pour le binary_sensor
je te met les codes yaml
template:
- binary_sensor:
- name: vacances_scolaires_aujourdhui
unique_id: binary_sensor.vacances_scolaires_aujourdhui
state: |-
{% set aujourdhui = now().strftime('%Y-%m-%d')%}
{% if aujourdhui < states.sensor.vacances_scolaires.attributes["start_date"] or aujourdhui > states.sensor.vacances_scolaires.attributes["end_date"] %}
false
{% else %}
true
{% endif %}
- binary_sensor:
- name: vacances_scolaires_demain
unique_id: binary_sensor.vacances_scolaires_demain
state: |-
{% set demain = (as_timestamp(now()) + (24*3600)) | timestamp_custom('%Y-%m-%d', True) %}
{% if demain < states.sensor.vacances_scolaires.attributes["start_date"] or demain > states.sensor.vacances_scolaires.attributes["end_date"] %}
false
{% else %}
true
{% endif %}
et
sensor:
- platform: rest
scan_interval: '00:30:00'
name: vacances_scolaires
json_attributes_path: "$.records[0].fields"
json_attributes:
- start_date
- end_date
- description
resource_template: |-
{% set location = 'Aix-Marseille' %}
{% set rows = '1'%}
{% set aujourdhui = now().strftime('%Y-%m-%d')%}
{% set dayOfYear = now().strftime('%j') %}
{% 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=fr-en-calendrier-scolaire&facet=start_date&facet=end_date&rows={{rows}}&refine.location={{location}}&sort=-end_date&q=end_date%3E={{aujourdhui}}
value_template: |-
{% set aujourdhui = now().strftime('%Y-%m-%d')%}
{% for record in value_json.records -%}
{% if aujourdhui >= record.fields.start_date and aujourdhui <= record.fields.end_date %}
{%- if record.fields.description %}{{record.fields.description}} jusqu'au {{ as_timestamp(record.fields.end_date) | timestamp_custom('%d-%m-%Y') }} {% endif %}
{% else %}
{%- if record.fields.end_date > aujourdhui and record.fields.description %} prochaines : {{record.fields.description}} {{ as_timestamp(record.fields.start_date) | timestamp_custom('%d-%m-%Y') }}{% endif %}
{% endif %}
{%- endfor %}