Zigbee2MQTT configuration for multimedia
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

c2r.py 1.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #!/bin/python3
  2. #
  3. import re
  4. import sys
  5. s = """homeassistant: false
  6. permit_join: false
  7. mqtt:
  8. base_topic: zigbee/gfw
  9. server: mqtt://mqtt
  10. user: smarthome
  11. password: Tc1IsZENNnSldRu8CGA6
  12. serial:
  13. port: /dev/ttyACM0
  14. advanced:
  15. ikea_ota_use_test_url: true
  16. legacy_api: false
  17. log_level: debug
  18. channel: 15
  19. homeassistant_legacy_entity_attributes: false
  20. legacy_availability_payload: false
  21. """
  22. try:
  23. src_file = sys.argv[1]
  24. dst_file = sys.argv[2]
  25. except IndexError:
  26. print(sys.argv[0], "<src> <dst>")
  27. sys.exit(17)
  28. try:
  29. with open(src_file, 'r') as fh:
  30. s = fh.read()
  31. except (PermissionError, FileNotFoundError) as e:
  32. print("Unable to open", '"' + src_file + '"')
  33. sys.exit(18)
  34. n = re.sub('^.*server: .*', ' server: <mqtt_smarthome_hostname>', s, flags=re.MULTILINE)
  35. n = re.sub('^.*user: .*', ' user: <mqtt_smarthome_username>', n, flags=re.MULTILINE)
  36. n = re.sub('^.*password: .*', ' password: <mqtt_smarthome_password>', n, flags=re.MULTILINE)
  37. n = re.sub('^.*auth_token: .*', ' auth_token: <zigbee_auth_token>', n, flags=re.MULTILINE)
  38. try:
  39. with open(dst_file, 'w') as fh:
  40. fh.write(n)
  41. except PermissionError:
  42. print("Unable to write", '"' + dst_file + '"')
  43. sys.exit(19)