add configuration template
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Robert Kaussow 2019-08-08 13:50:15 +02:00
parent 5d87099d08
commit e4a509776e
4 changed files with 121 additions and 2 deletions

View File

@ -8,3 +8,35 @@ zigbee2mqtt_secondary_groups:
- dialout
zigbee2mqtt_base_dir: /opt/zigbee2mqtt
zigbee2mqtt_log_dir: "{{ zigbee2mqtt_base_dir }}/log"
zigbee2mqtt_log_level: info
zigbee2mqtt_devices_file: "{{ zigbee2mqtt_base_dir }}/data/devices.yaml"
zigbee2mqtt_groups_file: "{{ zigbee2mqtt_base_dir }}/data/devices.yaml"
zigbee2mqtt_homeassistant_enabled: False
zigbee2mqtt_permit_join: True
zigbee2mqtt_mqtt_base_topic: zigbee2mqtt
zigbee2mqtt_mqtt_server: "mqtt://localhost:1883"
# zigbee2mqtt_mqtt_user: my_user # defaults to not set
# zigbee2mqtt_mqtt_password: my_password # defaults to not set
zigbee2mqtt_mqtt_client_id: zigbee2mqtt
zigbee2mqtt_mqtt_reject_unauthorized: False
zigbee2mqtt_mqtt_include_device_information: False
# zigbee2mqtt_serial_port: /dev/ttyACM0 # defaults not set
zigbee2mqtt_serial_disable_led: False
zigbee2mqtt_pan_id: "0x1a62"
zigbee2mqtt_ext_pan_id: "[0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD, 0xDD]"
zigbee2mqtt_channel: 11
zigbee2mqtt_cache_state: True
# zigbee2mqtt_network_key: [1, 3, 5, 7, 9, 11, 13, 15, 0, 2, 4, 6, 8, 10, 12, 13] # defaults to not set
zigbee2mqtt_last_seen: "disable"
zigbee2mqtt_homeassistant_discovery_topic: homeassistant
zigbee2mqtt_homeassistant_status_topic: "hass/status"
zigbee2mqtt_devices_ban: []
zigbee2mqtt_devices_whitelist: []

View File

@ -5,9 +5,10 @@
state: directory
owner: "{{ zigbee2mqtt_user }}"
group: "{{ zigbee2mqtt_group }}"
recurse: True
mode: 0750
with_items:
- "{{ zigbee2mqtt_base_dir }}"
- "{{ zigbee2mqtt_log_dir }}"
become: True
become_user: root
@ -58,6 +59,30 @@
become: True
become_user: "{{ zigbee2mqtt_user }}"
- block:
- name: Cleanup base directory
file:
path: "{{ zigbee2mqtt_base_dir }}/{{ item }}"
state: absent
loop:
- docker
- docs
- images
- LICENSE
- README.md
- scripts
- test
- update.sh
- name: Deploy configuration file
template:
src: "zigbee2mqtt/data/configuration.yaml.j2"
dest: "{{ zigbee2mqtt_base_dir }}/data/configuration.yaml"
mode: 0600
notify: __zigbee2mqtt_restart
become: True
become_user: "{{ zigbee2mqtt_user }}"
- block:
- name: Create systemd unit files
template:

View File

@ -1,4 +1,5 @@
# {{ ansible_managed }}
#jinja2:lstrip_blocks: True
{{ ansible_managed | comment }}
[Unit]
Description=zigbee2mqtt

View File

@ -0,0 +1,61 @@
#jinja2:lstrip_blocks: True
---
{{ ansible_managed | comment }}
homeassistant: "{{ zigbee2mqtt_homeassistant_enabled }}"
permit_join: "{{ zigbee2mqtt_permit_join }}"
mqtt:
base_topic: '"{{ zigbee2mqtt_mqtt_base_topic }}"'
server: '"{{ zigbee2mqtt_mqtt_server }}"'
{% if zigbee2mqtt_mqtt_user is defined and zigbee2mqtt_mqtt_user and zigbee2mqtt_mqtt_password is defined and zigbee2mqtt_mqtt_password %}
user: '"{{ zigbee2mqtt_mqtt_user }}"'
password: '"{{ zigbee2mqtt_mqtt_password }}"'
{% endif %}
client_id: '"{{ zigbee2mqtt_mqtt_client_id }}"'
reject_unauthorized: "{{ zigbee2mqtt_mqtt_reject_unauthorized }}"
include_device_information: "{{ zigbee2mqtt_mqtt_include_device_information }}"
{% if zigbee2mqtt_serial_port is defined and zigbee2mqtt_serial_port %}
serial:
port: '"{{ zigbee2mqtt_serial_port }}"'
disable_led: "{{ zigbee2mqtt_serial_disable_led }}"
{% endif %}
{% if zigbee2mqtt_devices_ban %}
# Ban devices from the network (by ieeeAddr)
ban:
{% for item in zigbee2mqtt_devices_ban %}
- '{{ item }}'
{% endfor %}
{% endif %}
{% if zigbee2mqtt_devices_whitelist %}
# Whitelist devices from the network (by ieeeAddr)
whitelist:
{% for item in zigbee2mqtt_devices_whitelist %}
- '{{ item }}'
{% endfor %}
{% endif %}
advanced:
pan_id: "{{ zigbee2mqtt_pan_id }}"
ext_pan_id: "{{ zigbee2mqtt_ext_pan_id }}"
channel: "{{ zigbee2mqtt_channel }}"
cache_state: "{{ zigbee2mqtt_cache_state }}"
log_level: "{{ zigbee2mqtt_log_level }}"
log_directory: "{{ zigbee2mqtt_log_dir }}"
{% if zigbee2mqtt_network_key is defined and zigbee2mqtt_network_key %}
network_key: "{{ zigbee2mqtt_network_key }}"
{% endif %}
last_seen: '{{ zigbee2mqtt_last_seen }}'
elapsed: false
report: "{{ zigbee2mqtt_report_enabled }}"
homeassistant_discovery_topic: '"{{ zigbee2mqtt_homeassistant_discovery_topic }}"'
homeassistant_status_topic: '"{{ zigbee2mqtt_homeassistant_status_topic }}'
queue:
delay: 250
simultaneously: 5
devices: "{{ zigbee2mqtt_devices_file }}"
groups: "{{ zigbee2mqtt_groups_file }}"