2026/02/16

Matter over Wifi 장치 HA와 재연결


Matter over Wifi 장치는 ESPHome과 같은 wifi나 api 연결 실패시 재시작하는 기능이 없어 자동화와 쉘스크립트로 만듬.
매터 와이파이 장치가 10분동안 이용할 수 없는 상태가 됐을때 쉘스크립트로 openwrt 공유기의 matter장치 연결을 강제로 끊은 후 재연결되는 자동화.

configuration.yaml
automation: !include automation.yaml
shell_command: !include shell_command.yaml


automation.yaml
- id: system-switch/reconnect
  alias: system-switch/reconnect
  triggers:
    - trigger: state
      entity_id: switch.bathroom_button1
      to: 'unavailable'
      for: '00:10:00'
  actions:
    - action: shell_command.kick_matterswitch

shell_command.yaml
kick_matterswitch: ssh -i /config/id_rsa -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no root@192.168.1.1 "ubus call hostapd.phy0-ap1 del_client '{\"addr\":\"XX:XX:XX:XX:XX:XX\",\"reason\":5}'"




** 매터 장치가 이용할 수 없는 상태로 빠지면 homeassistant.reload_config_entry 서비스로 먼저 매터장치 리로드를 시도한 후 마찬가지면 공유기에서 wifi 연결을 끊은 후 재연결 시도.

automation.yaml
- id: system-device/reload
  alias: system-device/reload
  mode: restart
  triggers:
    - trigger: state
      entity_id: switch.bathroom_button1
      to: 'unavailable'
      for: '00:03:00'
  conditions:
    - "{{ states('sensor.core_uptime') | float > 120 }}"
  actions:
    - action: homeassistant.reload_config_entry
      target:
        device_id: 27cc926220fc01dfb9485e7cbabbc0e5