浏览代码

Init configuration for zigbee2mqtt

master
Dirk Alders 4 天前
父节点
当前提交
423b8c8af9
共有 3 个文件被更改,包括 55 次插入0 次删除
  1. 30
    0
      bin/c2r.py
  2. 0
    0
      config/.gitkeep
  3. 25
    0
      config_example/configuration.j2

+ 30
- 0
bin/c2r.py 查看文件

@@ -0,0 +1,30 @@
1
+#!/bin/python3
2
+#
3
+import re
4
+import sys
5
+
6
+try:
7
+    src_file = sys.argv[1]
8
+    dst_file = sys.argv[2]
9
+except IndexError:
10
+    print(sys.argv[0], "<src> <dst>")
11
+    sys.exit(17)
12
+
13
+try:
14
+    with open(src_file, 'r') as fh:
15
+        s = fh.read()
16
+except (PermissionError, FileNotFoundError) as e:
17
+    print("Unable to open", '"' + src_file + '"')
18
+    sys.exit(18)
19
+
20
+n = re.sub('^.*server: .*', '  server: mqtt://{{ smart_sat_zigbee2mqtt_hostname }}', s, flags=re.MULTILINE)
21
+n = re.sub('^.*user: .*', '  user: {{ smart_sat_zigbee2mqtt_username }}', n, flags=re.MULTILINE)
22
+n = re.sub('^.*password: .*', '  password: {{ smart_sat_zigbee2mqtt_password  }}', n, flags=re.MULTILINE)
23
+n = re.sub('^.*auth_token: .*', '  auth_token: {{ smart_sat_zigbee2mqtt_auth_token }}', n, flags=re.MULTILINE)
24
+
25
+try:
26
+    with open(dst_file, 'w') as fh:
27
+        fh.write(n)
28
+except PermissionError:
29
+    print("Unable to write", '"' + dst_file + '"')
30
+    sys.exit(19)

+ 0
- 0
config/.gitkeep 查看文件


+ 25
- 0
config_example/configuration.j2 查看文件

@@ -0,0 +1,25 @@
1
+homeassistant: false
2
+permit_join: false
3
+mqtt:
4
+  base_topic: zigbee_gfe
5
+  server: mqtt://{{ smart_sat_zigbee2mqtt_hostname }}
6
+  user: {{ smart_sat_zigbee2mqtt_username }}
7
+  password: {{ smart_sat_zigbee2mqtt_password  }}
8
+serial:
9
+  port: /dev/ttyttyUSB0
10
+  channel: 5
11
+advanced:
12
+    # Let Zigbee2MQTT generate a network key on first start
13
+    network_key: GENERATE
14
+    # Let Zigbee2MQTT generate a pan_id on first start
15
+    pan_id: GENERATE
16
+    # Let Zigbee2MQTT generate a ext_pan_id on first start
17
+    ext_pan_id: GENERATE
18
+frontend:
19
+  port: 8038
20
+  host: 0.0.0.0
21
+  auth_token: {{ smart_sat_zigbee2mqtt_auth_token }}
22
+  url: http://localhost
23
+device_options:
24
+  legacy: false
25
+

正在加载...
取消
保存