明天上学?

在《公约》的背景下Pronote 的集成, 为了允许明天早上自动设置警报或设置Pronote更新,以免在学校假期更新,我需要知道我们是否在学校假期以及明天是否有学校。

一个工作日?

要确定我们是否是一个工作日,只需安装扩展。 工作 日 工作 日

没有什么更简单,一切都在里面。 文件.

我加了两次。 为了拥有明天,我们加上一个滞后1。

残疾人=非工作日

在学校放假吗?

要了解我们是否在学校放假,您必须询问国家教育部的API。 使用的脚本在V1中,它有一个V2.0,如果我有时间,我稍后会切换到V2.0。

  • 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

用于这些传感器的资源(感谢其作者):

  • https://github.com/papo-o/home-assistant-config/blob/master/integrations/vacances_scolaires.yaml
  • https://pon.fr/home-assistant-vacances-scolaires/

添加传感器"学校假期 _s"

在我的档案里 传感器.yaml, 我添加了这个传感器:

平台: REST Scan_interval : 00:30:00 姓名: Holidays_schools json_attributes_path : 》$.records[0].fields" json _attributes: start_date - end_date - 描述 resources_template: , |-{% 设置位置 = 'Aix-Marseille' %} {% 设置行='1'%} {% 设置今天 = now().strftime(')%Y-%M-%d) )%} {% 设置 DAYOFYEAR = now().strftime(')%我 ) %} {% 设置年份 = now().strftime(')%) | int %} {% 设定去年=一年-1 %} {% 设定下一年=一年+1 %} {% 如果DAYOFYEAR > '244' %} {% set schoolyear =(year | string)+ "-" +(nextyear θ string) %} {%不然 - 否则 -%} {% 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}} 值 _template: , |-{% 设置今天 = now().strftime(')%Y-%M-%d) )%} {% 记录值 _json.records -%} {% 如果今天 >= record.fields.start _date 和 today <= record.fields.end _date %} {%如果 record.fields.description %}{record.fields.description}} 直到 {{{ as_timestamp(record.fields.end_date)| timestamp _custom(')%d-%M-%Y')} {% Endif 的 %} {% 其他 其它 %} {%- 如果 record.fields.end _date > 今天和 record.fields.description %下一条: {record.fields.description}} { as_timestamp(record.fields.start _date)| timestamp _custom(')%d-%M-%Y')}{% Endif 的 %} {% Endif 的 %} {%- Endfor 的 %}    

当然,学院需要改变: "Corsica"、"Polynesia"、"New Caledonia"、"Guyane"、"Aix-Marseille"、"Aix-Marseille"、"Amiens"、"Besançon"、"Bordeaux"、"Clermont-Ferrand"、"Clermont-Ferrand"、"Créteil"、"Dijon"、"Grenoble"、"Lille"、 'Limoges', 'Lyon', 'Montpellier', 'Nancy-Metz', 'Nantes', 'Nantes', '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" 

此传感器的结果

这些信息必须能够以二进制_sensor的形式提取两条信息,可用于自动化或脚本。

增加两个二进制传感器 今天学校假期和明天学校假期

更新于2023年10月3日, 多亏了 相关评论Giga77 的, 我更正下面的代码并替换

state.sensor.vacances_scolaires.attributes["start_date"]
通过
state_attr('sensor.vacances_scolaires', 'start_date')

在我的档案里 模板.yaml, 我添加了这些传感器:

binary_sensor : 姓名: _ 学校假期 _ 现在独一无二的 _id: binary_sensor.vacances_schools_today 状态: , |-{% 设置今天 = now().strftime(')%Y-%M-%d) )%} {% 如果今天 < state_attr('sensor.vacances_scolaires', 'start_date')或今天 > state_attr('sensor.vacances_scolaires', 'end_date') %{fal } {% 其他 其它 %{\displaystyle } {% Endif 的 %二进制 _sensor : 姓名: 学校假期_single tomorrow_id: binary_sensor.vacations_scolaires_demain 状态: , |-{% 设置明天 =(as_timestamp(now())+(24*3600))| timestamp_custom(')%Y-%M-%d真的) %} {% 如果明天 < state_attr('sensor.vacances_scolaires', 'start_date')或明天 > state_attr('sensor.vacances_scolaires', 'end_date') %{fal } {% 其他 其它 %{\displaystyle } {% Endif 的 %}     

 

这些传感器的结果(在假期测试)

允许 Pronote 更新的 binary_sensor

无需在假期或非工作日更新Pronote。

我创建了一个二进制_sensor,允许Pronote更新或不更新。

在我的档案里 模板.yaml, 我添加了这个传感器:

binary_sensor : 姓名: 授权 _miseajour _pronote unique _id: binary_sensor.authorise_mise_miseajour_pronote 状态: { is_state('binary_sensor.vacances_today', 'off')和 is_state('binary_sensor.open_today', 'on')}

添加一个条件来启动更新

具体规定在 Pronote 集成 教程, 我们添加了一个自动化来定期启动 Pronote 更新,并且使用新的实体 binary_sensor.allow _miseajour _pronote,我们将只允许在 binary_sensor.allow _miseajour _pronote=on 时进行更新。

以下是自动化的完整YAML代码

化名 : 更新的注释说明: 触发器: 平台: Time_pattern 小时 : /4条件: 条件: 国家实体_id: binary_sensor.authorise_mise_miseajour_pronote 状态: "on" 行动: 服务: shell_command.update_pronote 数据: {} 模式: 单 人 单

因此,在工作日,不包括学校假期,授权被激活,Pronote将每4小时更新一次。