From 423b8c8af99e9294cfa452e74ed7aa7c9b079ca7 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Wed, 18 Dec 2024 19:55:57 +0100 Subject: [PATCH] Init configuration for zigbee2mqtt --- bin/c2r.py | 30 ++++++++++++++++++++++++++++++ config/.gitkeep | 0 config_example/configuration.j2 | 25 +++++++++++++++++++++++++ 3 files changed, 55 insertions(+) create mode 100755 bin/c2r.py create mode 100644 config/.gitkeep create mode 100644 config_example/configuration.j2 diff --git a/bin/c2r.py b/bin/c2r.py new file mode 100755 index 0000000..de0976d --- /dev/null +++ b/bin/c2r.py @@ -0,0 +1,30 @@ +#!/bin/python3 +# +import re +import sys + +try: + src_file = sys.argv[1] + dst_file = sys.argv[2] +except IndexError: + print(sys.argv[0], " ") + sys.exit(17) + +try: + with open(src_file, 'r') as fh: + s = fh.read() +except (PermissionError, FileNotFoundError) as e: + print("Unable to open", '"' + src_file + '"') + sys.exit(18) + +n = re.sub('^.*server: .*', ' server: mqtt://{{ smart_sat_zigbee2mqtt_hostname }}', s, flags=re.MULTILINE) +n = re.sub('^.*user: .*', ' user: {{ smart_sat_zigbee2mqtt_username }}', n, flags=re.MULTILINE) +n = re.sub('^.*password: .*', ' password: {{ smart_sat_zigbee2mqtt_password }}', n, flags=re.MULTILINE) +n = re.sub('^.*auth_token: .*', ' auth_token: {{ smart_sat_zigbee2mqtt_auth_token }}', n, flags=re.MULTILINE) + +try: + with open(dst_file, 'w') as fh: + fh.write(n) +except PermissionError: + print("Unable to write", '"' + dst_file + '"') + sys.exit(19) diff --git a/config/.gitkeep b/config/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/config_example/configuration.j2 b/config_example/configuration.j2 new file mode 100644 index 0000000..8e53336 --- /dev/null +++ b/config_example/configuration.j2 @@ -0,0 +1,25 @@ +homeassistant: false +permit_join: false +mqtt: + base_topic: zigbee_gfe + server: mqtt://{{ smart_sat_zigbee2mqtt_hostname }} + user: {{ smart_sat_zigbee2mqtt_username }} + password: {{ smart_sat_zigbee2mqtt_password }} +serial: + port: /dev/ttyttyUSB0 + channel: 5 +advanced: + # Let Zigbee2MQTT generate a network key on first start + network_key: GENERATE + # Let Zigbee2MQTT generate a pan_id on first start + pan_id: GENERATE + # Let Zigbee2MQTT generate a ext_pan_id on first start + ext_pan_id: GENERATE +frontend: + port: 8038 + host: 0.0.0.0 + auth_token: {{ smart_sat_zigbee2mqtt_auth_token }} + url: http://localhost +device_options: + legacy: false +