From f11a8f42c96b90054bde2ffec77d32dec60c6636 Mon Sep 17 00:00:00 2001 From: Dirk Alders Date: Sun, 17 Nov 2024 11:30:46 +0100 Subject: [PATCH] Initial data for ansible added --- .gitignore | 16 ++++++++++------ bin/c2r.py | 30 ++++++++++++++++++++++++++++++ config_example/configuration.j2 | 21 +++++++++++++++++++++ 3 files changed, 61 insertions(+), 6 deletions(-) create mode 100755 bin/c2r.py create mode 100644 config_example/configuration.j2 diff --git a/.gitignore b/.gitignore index 61f03c6..2707980 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,6 @@ -# ---> Backup -*.bak -*.gho -*.ori -*.orig -*.tmp +# Zigbee2MQTT repo rule +config/configuration.yaml +config/log # ---> Linux *~ @@ -20,3 +17,10 @@ # .nfs files are created when an open file is removed but is still being accessed .nfs* +# ---> Backup +*.bak +*.gho +*.ori +*.orig +*.tmp + 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_example/configuration.j2 b/config_example/configuration.j2 new file mode 100644 index 0000000..e0f6b78 --- /dev/null +++ b/config_example/configuration.j2 @@ -0,0 +1,21 @@ +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/ttyACM0 +advanced: + network_key: GENERATE + ikea_ota_use_test_url: true + legacy_api: false + channel: 25 + homeassistant_legacy_entity_attributes: false + legacy_availability_payload: false +frontend: + port: 8038 + host: 0.0.0.0 + auth_token: {{ smart_sat_zigbee2mqtt_auth_token }} + url: http://localhost