本帖最后由 luyuheng 于 2022-12-24 13:10 编辑
由于家里路由器设定的是每天凌晨重启,重启过程中z2m网关会短暂断联,采取addon方式的z2m重启时有概率无法连接上z2m,需要经常手动重启addon。一直在困惑如何稳定的连接网关。
于是想了个办法,通过自带的自动化每分钟检测z2m是否正常运行并及时触发重启。判断是否正常运行可以通过检查设备是否有正常状态来判断。
抛砖引玉一下,可以类比到其他z2m不稳定的场景。alias: z2m auto restart
description: ''
trigger:
- platform: time_pattern
seconds: '30'
condition:
- condition: not
conditions:
- condition: or
conditions:
- condition: device
type: is_off
device_id: 37a0d1a2a20863517e0cf8c97826804d
entity_id: switch.bedroom_left
domain: switch
- condition: device
type: is_on
device_id: 37a0d1a2a20863517e0cf8c97826804d
entity_id: switch.bedroom_left
domain: switch
action:
- service: hassio.addon_restart
data:
addon: 45df7312_zigbee2mqtt
- delay:
hours: 0
minutes: 1
seconds: 5
milliseconds: 0
mode: single
|