"""Добавляет rest_command для отправки уведомлений в Matrix из HA.""" CFG = "/opt/smart-lxc/homeassistant/config/configuration.yaml" s = open(CFG, encoding="utf-8").read() if "hub_notify" in s: print(" уже есть") raise SystemExit(0) block = ''' rest_command: hub_notify: url: "http://192.168.1.10:9120/notify" method: POST content_type: "application/json" payload: '{"title": "{{ title }}", "message": "{{ message }}"}' ''' s = s.rstrip() + "\n" + block open(CFG, "w", encoding="utf-8").write(s) print(" rest_command.hub_notify добавлен")