『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 3479|回复: 12

[技术探讨] ha可以设置定时重启吗?

[复制链接]

55

主题

137

帖子

736

积分

高级会员

Rank: 4

积分
736
金钱
599
HASS币
0
发表于 2023-1-4 03:37:19 来自手机 | 显示全部楼层 |阅读模式
有些灯带用的通断器。有时关闭了。重新开启后家庭就灯带没法重新连接。只能重启ha,所以想弄定时重启一次,让它可以恢复状态
回复

使用道具 举报

32

主题

1065

帖子

4946

积分

论坛元老

Rank: 8Rank: 8

积分
4946
金钱
3866
HASS币
90
发表于 2023-1-4 06:13:36 | 显示全部楼层
当然可以。

  - alias: Restart HA at midnight
    id: "1602722452776"
    description: ""
    trigger:
      - at: 04:00:00
        platform: time
    action:
      - service: homeassistant.restart
我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

12

主题

114

帖子

1412

积分

金牌会员

Rank: 6Rank: 6

积分
1412
金钱
1298
HASS币
0
发表于 2023-1-4 08:41:14 | 显示全部楼层
我觉得正确的思路应该是解决你的灯带的问题
回复

使用道具 举报

45

主题

452

帖子

1639

积分

金牌会员

Rank: 6Rank: 6

积分
1639
金钱
1187
HASS币
0
发表于 2023-1-4 08:51:03 | 显示全部楼层
relliky 发表于 2023-1-4 06:13
当然可以。

  - alias: Restart HA at midnight

这是要写在config.yaml里吗?
回复

使用道具 举报

0

主题

32

帖子

287

积分

中级会员

Rank: 3Rank: 3

积分
287
金钱
255
HASS币
0
发表于 2023-1-4 11:40:09 | 显示全部楼层
shayulei 发表于 2023-1-4 08:51
这是要写在config.yaml里吗?

这是HA的自动化
回复

使用道具 举报

45

主题

452

帖子

1639

积分

金牌会员

Rank: 6Rank: 6

积分
1639
金钱
1187
HASS币
0
发表于 2023-1-4 13:18:00 | 显示全部楼层
贰苍 发表于 2023-1-4 11:40
这是HA的自动化

谢谢!
回复

使用道具 举报

7

主题

114

帖子

1056

积分

论坛DIY达人

积分
1056
金钱
932
HASS币
60
发表于 2023-1-4 13:25:47 | 显示全部楼层
xiguaboy 发表于 2023-1-4 08:41
我觉得正确的思路应该是解决你的灯带的问题

同感,一但ha重启出问题,那影响的就不是一个灯带的事了。
回复

使用道具 举报

2

主题

366

帖子

2506

积分

金牌会员

Rank: 6Rank: 6

积分
2506
金钱
2135
HASS币
30
发表于 2023-1-4 15:33:25 | 显示全部楼层
治標不治本
如果有設備每小時都有問題,難度你要每小時重啟一次HA?
回复

使用道具 举报

20

主题

134

帖子

1000

积分

金牌会员

Rank: 6Rank: 6

积分
1000
金钱
866
HASS币
0
发表于 2023-1-4 15:44:48 来自手机 | 显示全部楼层
自动化可以设置重载某个集成,就不用重启整个HA了
回复

使用道具 举报

32

主题

1065

帖子

4946

积分

论坛元老

Rank: 8Rank: 8

积分
4946
金钱
3866
HASS币
90
发表于 2023-1-4 23:42:44 | 显示全部楼层
本帖最后由 relliky 于 2023-1-4 23:45 编辑
fung1006 发表于 2023-1-4 15:33
治標不治本
如果有設備每小時都有問題,難度你要每小時重啟一次HA?

很多时候问题出在各种地方,而且也不一定HA重启有用,换灯带固然好,但是还是要增加成本的。

比如localtuya的wifi灯泡比tuya集成容易掉线,需要重启HA,重载集成整个集成会崩溃。
hue的灯泡话掉线了需要重新断电开关,重启HA也不管用,这个时候就需要写个开关墙壁开关的自动化。

我有一个自动化专门用来重启HA针对localtuya的设备的,用来查错用的,实在因为wifi信号不好容易掉线的就从localtuya换到tuya集成了,除了换灯泡也没太好的办法。


  - alias: L- Restart HA When localtuya lights Are Offline
    id: automation.restart_ha_when_localtuya_lights_are_offline
    mode: single
    trigger:
      - platform: state
        entity_id:
        #- light.ground_toilet_bulb_1_localtuya
        - light.ground_toilet_bulb_2_localtuya
        #- light.kitchen_spotlight_bulb_1_localtuya
        - light.kitchen_spotlight_bulb_2_localtuya
        - light.kitchen_spotlight_bulb_3_localtuya
        - light.kitchen_spotlight_bulb_4_localtuya
        - light.kitchen_spotlight_bulb_5_localtuya
        - light.kitchen_spotlight_bulb_6_localtuya
        - light.kitchen_spotlight_bulb_7_localtuya
        - light.master_room_lamp_1_localtuya
        - light.master_room_lamp_2_localtuya
        - light.guest_toilet_bulb_1_localtuya
        - light.guest_toilet_bulb_2_localtuya
        - light.guest_toilet_bulb_3_localtuya
        - light.living_room_landing_light_1_localtuya
        - light.living_room_3_head_lamp_1_localtuya
        - light.living_room_3_head_lamp_2_localtuya
        - light.living_room_3_head_lamp_3_localtuya
      - platform: time_pattern
        minutes: "5"
    condition:
      #  A tuya device is online but one of its localtuya integration is offline and needs to be reloaded
      - condition: or
        conditions:
          # Ground toilet 1/kitchen 1 have a large packet loss rate due to poor wifi connection
          #- "{{(states.light.ground_toilet_bulb_1_localtuya.state == 'unavailable')        and (states.light.ground_toilet_bulb_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.ground_toilet_bulb_2_localtuya.state == 'unavailable')        and (states.light.ground_toilet_bulb_2_tuya.state != 'unavailable')}}"
          #- "{{(states.light.kitchen_spotlight_bulb_1_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_2_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_3_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_3_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_4_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_4_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_5_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_5_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_6_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_6_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_7_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_7_tuya.state != 'unavailable')}}"
          - "{{(states.light.master_room_lamp_1_localtuya.state == 'unavailable')          and (states.light.master_room_lamp_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.master_room_lamp_2_localtuya.state == 'unavailable')          and (states.light.master_room_lamp_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.guest_toilet_bulb_1_localtuya.state == 'unavailable')         and (states.light.guest_toilet_bulb_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.guest_toilet_bulb_2_localtuya.state == 'unavailable')         and (states.light.guest_toilet_bulb_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.guest_toilet_bulb_3_localtuya.state == 'unavailable')         and (states.light.guest_toilet_bulb_3_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_landing_light_1_localtuya.state == 'unavailable') and (states.light.living_room_landing_light_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_3_head_lamp_1_localtuya.state == 'unavailable')   and (states.light.living_room_3_head_lamp_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_3_head_lamp_2_localtuya.state == 'unavailable')   and (states.light.living_room_3_head_lamp_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_3_head_lamp_3_localtuya.state == 'unavailable')   and (states.light.living_room_3_head_lamp_3_tuya.state != 'unavailable')}}"
    action:
      # Wait for 1 min to confirm the the localtuya device is still offline
      - delay: "00:03:00"
      #  A tuya device is online but one of its localtuya integration is offline and needs to be reloaded
      - condition: or
        conditions:
          #- "{{(states.light.ground_toilet_bulb_1_localtuya.state == 'unavailable')        and (states.light.ground_toilet_bulb_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.ground_toilet_bulb_2_localtuya.state == 'unavailable')        and (states.light.ground_toilet_bulb_2_tuya.state != 'unavailable')}}"
          #- "{{(states.light.kitchen_spotlight_bulb_1_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_2_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_3_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_3_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_4_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_4_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_5_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_5_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_6_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_6_tuya.state != 'unavailable')}}"
          - "{{(states.light.kitchen_spotlight_bulb_7_localtuya.state == 'unavailable')    and (states.light.kitchen_spotlight_bulb_7_tuya.state != 'unavailable')}}"
          - "{{(states.light.master_room_lamp_1_localtuya.state == 'unavailable')          and (states.light.master_room_lamp_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.master_room_lamp_2_localtuya.state == 'unavailable')          and (states.light.master_room_lamp_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.guest_toilet_bulb_1_localtuya.state == 'unavailable')         and (states.light.guest_toilet_bulb_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.guest_toilet_bulb_2_localtuya.state == 'unavailable')         and (states.light.guest_toilet_bulb_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.guest_toilet_bulb_3_localtuya.state == 'unavailable')         and (states.light.guest_toilet_bulb_3_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_landing_light_1_localtuya.state == 'unavailable') and (states.light.living_room_landing_light_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_3_head_lamp_1_localtuya.state == 'unavailable')   and (states.light.living_room_3_head_lamp_1_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_3_head_lamp_2_localtuya.state == 'unavailable')   and (states.light.living_room_3_head_lamp_2_tuya.state != 'unavailable')}}"
          - "{{(states.light.living_room_3_head_lamp_3_localtuya.state == 'unavailable')   and (states.light.living_room_3_head_lamp_3_tuya.state != 'unavailable')}}"
      - service: notify.mobile_app_tais_iphone_13_pro_max
        data:
          title: "Restarting HA in 1 Min"
          message: "A localtuya device is offline. Restarting HA to reload localtuya integration."
      # Do not run it too often
      - delay: "00:01:00"
      # Making HA restarts during this automation would likely make HA unable to capture the trace of this automation instance.
      - service: script.hassio_restart


我家全屋智能的HA设置 https://github.com/relliky/Tais_Home_Assistant_Config
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-25 07:36 , Processed in 0.329713 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表