ZIGBEE2MQTT configuration for gfw
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

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