Cookies帮助我们提供我们的服务。如果要使用我们的服务,您需同意我们使用cookie。
2024年11月23日星期六 上午3:57:04
Holidays
- 楼主
- 6317
- 楼主
- 6317
{
"domain": "holidays",
"name": "Holidays",
"codeowners": [
"@bruxy70"
],
"config_flow": true,
"dependencies": [],
"documentation": "https://github.com/bruxy70/Holidays/",
"integration_type": "helper",
"iot_class": "calculated",
"issue_tracker": "https://github.com/bruxy70/Holidays/issues",
"requirements": [
"python-dateutil>=2.8.2",
"holidays>=0.14.2"
],
"version": "1.0"
}
0
- 楼主
- 6317
离线版法定节假日查询
原理是每周在https://timor.tech/查询一次当年和次年的所有节假日,然后把所有数据存在内存和硬盘中。这样就算断网也可正常使用
https://bbs.hassbian.com/thread-14672-1-1.html
原理是每周在https://timor.tech/查询一次当年和次年的所有节假日,然后把所有数据存在内存和硬盘中。这样就算断网也可正常使用
https://bbs.hassbian.com/thread-14672-1-1.html
0
- 楼主
- 6317
- 楼主
- 6317
把这段代码复制到 configuration.yaml 里面,然后重启HA,会发现多了一个cn_workdays 的实体,实体状态分为工作日和节假日,可以用来作为自动化的环境条件。离线版的要借助于node-red的文件存储,只需要把下面resource_template地址换成本地地址即可,如http://192.168.0.23:8123/local/cn_workdays.json
https://bbs.hassbian.com/thread-16397-1-1.html
#https://github.com/NateScarlet/holiday-cn
rest:
- scan_interval: 3600
resource_template: https://cdn.jsdelivr.net/gh/NateScarlet/holiday-cn@master/{{ now().strftime('%Y') }}.json
sensor:
- name: cn_workdays
value_template: |-
{%- set today = now().strftime('%Y-%m-%d') %}
{%- set lst = (value_json | default({},true)).days | default([]) %}
{%- set ns = namespace(isOffDay=None) %}
{%- for d in lst %}
{%- if today == (d.date | default(None)) %}
{%- set ns.isOffDay = (d.isOffDay | default(None)) %}
{%- endif %}
{%- endfor %}
{%- set isOffDay = ns.isOffDay %}
{%- if not isOffDay in [True,False] %}
{%- if now().isoweekday() in [6,7] %}
{%- set isOffDay = True %}
{%- else %}
{%- set isOffDay = False %}
{%- endif %}
{%- endif %}
{%- if isOffDay == True %}
节假日
{%- elif isOffDay == False %}
工作日
{%- else %}
unknown
{%- endif %}
json_attributes:
- year
- papers
https://bbs.hassbian.com/thread-16397-1-1.html
0
- 楼主
- 6317
[插件集成] 2018年【修复bug】【节假日】【纪念日】【倒计时】【农历】
https://bbs.hassbian.com/thread-9008-1-1.html
https://bbs.hassbian.com/thread-9008-1-1.html
0
- 楼主
- 6317
0
- 楼主
- 6317
https://community.home-assistant.io/t/workday-sensor-extra-working-days/395760/3?u=msly
binary_sensor:
- platform: workday
country: US
workdays: [mon, tue, wed, thu, fri, extra_workdays]
excludes: [sat, sun, holidays]
add_holidays:
- "2020-02-24"
- "2020-04-25"
add_extra_workdays:
- "2022-02-26" # Saturday
0