setup home-assistant with zigbee2mqtt
This commit is contained in:
parent
0efd88332b
commit
9f29195343
|
@ -22,6 +22,7 @@ haproxy:
|
|||
- ci.badjware.dev
|
||||
- grafana.badjware.dev
|
||||
- jellyfin.badjware.dev
|
||||
- actual.badjware.dev
|
||||
backend:
|
||||
- server: 192.168.20.20:8443
|
||||
- server: 192.168.20.21:8443
|
||||
|
@ -39,7 +40,6 @@ haproxy:
|
|||
- server: 192.168.20.24
|
||||
extra_param: backup
|
||||
- frontend:
|
||||
- hass.badjware.dev
|
||||
- longhorn.badjware.dev
|
||||
- traefik.badjware.dev
|
||||
- prometheus.badjware.dev
|
||||
|
@ -64,6 +64,19 @@ haproxy:
|
|||
- 127.0.0.1
|
||||
- 192.168.20.20/24
|
||||
- 192.168.30.20/24
|
||||
- 10.100.0.0/24
|
||||
- frontend:
|
||||
- hass.badjware.dev
|
||||
backend:
|
||||
- server: 192.168.31.20:8123
|
||||
ssl: false
|
||||
- frontend:
|
||||
- zigbee2mqtt.badjware.dev
|
||||
backend:
|
||||
- server: 192.168.31.20:8080
|
||||
allowlist:
|
||||
- 192.168.30.20 # only allow pallet
|
||||
ssl: false
|
||||
- frontend:
|
||||
- s3.badjware.dev
|
||||
backend:
|
||||
|
@ -158,5 +171,12 @@ wireguard:
|
|||
- public_key: 3mkPtY29F3/0WhSIEUkSAHJexJWOJfFzc6LOzBX9Hjc=
|
||||
allowed_ips: 10.100.0.2/32
|
||||
# pallet
|
||||
# - public_key: ZbLgn0EnkKbv8L6nxysix/fRoASNGFIIvEuLn/aLbm4=
|
||||
# allowed_ips: 10.100.0.3/32
|
||||
- public_key: ZbLgn0EnkKbv8L6nxysix/fRoASNGFIIvEuLn/aLbm4=
|
||||
allowed_ips: 10.100.0.3/32
|
||||
|
||||
homeassistant:
|
||||
version: 2024.1.3
|
||||
|
||||
zigbee2mqtt:
|
||||
serial:
|
||||
port: /dev/serial/by-id/usb-Silicon_Labs_Sonoff_Zigbee_3.0_USB_Dongle_Plus_0001-if00-port0
|
5
hosts
5
hosts
|
@ -40,6 +40,10 @@ all:
|
|||
- uuid: 649a9370-5cad-4553-93c8-cf0af25208dd
|
||||
name: jirost
|
||||
level: 4
|
||||
home-assistant:
|
||||
hosts:
|
||||
home-assistant:
|
||||
ansible_host: 192.168.31.20
|
||||
cups:
|
||||
hosts:
|
||||
cups:
|
||||
|
@ -78,6 +82,7 @@ all:
|
|||
k3s:
|
||||
plex:
|
||||
minecraft-server:
|
||||
home-assistant:
|
||||
cups:
|
||||
vars:
|
||||
ansible_user: ansible
|
||||
|
|
|
@ -27,6 +27,11 @@
|
|||
roles:
|
||||
- minecraft-server
|
||||
|
||||
- hosts: home-assistant
|
||||
roles:
|
||||
- zigbee2mqtt
|
||||
- home-assistant
|
||||
|
||||
- hosts: cups
|
||||
roles:
|
||||
- cups
|
|
@ -0,0 +1,2 @@
|
|||
homeassistant:
|
||||
version: 2023.5.4
|
|
@ -0,0 +1,11 @@
|
|||
default_config:
|
||||
|
||||
frontend:
|
||||
themes: !include_dir_merge_named themes
|
||||
|
||||
automation: !include automations.yaml
|
||||
|
||||
http:
|
||||
use_x_forwarded_for: true
|
||||
trusted_proxies:
|
||||
- 192.168.20.0/24
|
|
@ -0,0 +1,44 @@
|
|||
- name: Download docker repository gpg key
|
||||
get_url:
|
||||
url: https://download.docker.com/linux/ubuntu/gpg
|
||||
dest: /usr/share/keyrings/docker.asg
|
||||
|
||||
- name: Add docker repository
|
||||
apt_repository:
|
||||
repo: deb [arch=amd64 signed-by=/usr/share/keyrings/docker.asg] https://download.docker.com/linux/ubuntu {{ ansible_distribution_release }} stable
|
||||
|
||||
- name: Install docker
|
||||
apt:
|
||||
update_cache: true
|
||||
name:
|
||||
- docker-ce
|
||||
- docker-ce-cli
|
||||
- python3-docker
|
||||
|
||||
- name: Enable docker service
|
||||
systemd:
|
||||
name: docker
|
||||
state: started
|
||||
enabled: yes
|
||||
|
||||
- name: Create home-assistant config directory
|
||||
file:
|
||||
path: /opt/homeassistant/config
|
||||
state: directory
|
||||
|
||||
- name: Copy home-assistant config
|
||||
copy:
|
||||
src: configuration.yaml
|
||||
dest: /opt/homeassistant/config/configuration.yaml
|
||||
|
||||
- name: Start home-assistant
|
||||
docker_container:
|
||||
name: home-assistant
|
||||
image: ghcr.io/home-assistant/home-assistant:{{ homeassistant.version }}
|
||||
state: started
|
||||
restart_policy: unless-stopped
|
||||
privileged: true
|
||||
network_mode: host
|
||||
volumes:
|
||||
- /opt/homeassistant/config:/config
|
||||
# - /run/dbus:/run/dbus:ro
|
|
@ -1,13 +0,0 @@
|
|||
[Unit]
|
||||
Description=Home Assistant
|
||||
Documentation=https://www.home-assistant.io
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=homeassistant
|
||||
Group=homeassistant
|
||||
ExecStart=/srv/homeassistant/bin/python3 /srv/homeassistant/bin/hass
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
|
@ -1,61 +0,0 @@
|
|||
- name: Install packages
|
||||
apt:
|
||||
update_cache: yes
|
||||
name:
|
||||
- acl # for become unprivileged user
|
||||
- python3
|
||||
- python3-dev
|
||||
- python3-venv
|
||||
- python3-pip
|
||||
- bluez
|
||||
- libffi-dev
|
||||
- libssl-dev
|
||||
- libjpeg-dev
|
||||
- zlib1g-dev
|
||||
- autoconf
|
||||
- build-essential
|
||||
- libopenjp2-7
|
||||
- libtiff5
|
||||
- libturbojpeg0-dev
|
||||
- tzdata
|
||||
- ffmpeg
|
||||
- liblapack3
|
||||
- liblapack-dev
|
||||
- libatlas-base-dev
|
||||
|
||||
- name: Add user "homeassistant"
|
||||
user:
|
||||
name: homeassistant
|
||||
create_home: true
|
||||
system: true
|
||||
|
||||
- name: Create homeassistant install directory
|
||||
file:
|
||||
path: /srv/homeassistant
|
||||
owner: homeassistant
|
||||
group: homeassistant
|
||||
state: directory
|
||||
|
||||
- name: Install homeassistant
|
||||
become_user: homeassistant
|
||||
pip:
|
||||
virtualenv: /srv/homeassistant/
|
||||
virtualenv_command: /usr/bin/python3 -m venv
|
||||
name:
|
||||
- wheel
|
||||
- homeassistant==2023.5.4
|
||||
|
||||
- name: Copy hass service file
|
||||
copy:
|
||||
src: hass.service
|
||||
dest: /etc/systemd/system/hass.service
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
|
||||
- name: Enable hass service
|
||||
systemd:
|
||||
name: hass
|
||||
daemon_reload: yes
|
||||
state: started
|
||||
enabled: yes
|
|
@ -0,0 +1,3 @@
|
|||
zigbee2mqtt:
|
||||
serial:
|
||||
port: /dev/ttyACM0
|
|
@ -0,0 +1,5 @@
|
|||
- name: Restart zigbee2mqtt
|
||||
systemd:
|
||||
name: zigbee2mqtt
|
||||
daemon_reload: yes
|
||||
state: restarted
|
|
@ -0,0 +1,2 @@
|
|||
- include_tasks: mosquitto.yml
|
||||
- include_tasks: zigbee2mqtt.yml
|
|
@ -0,0 +1,12 @@
|
|||
- name: Install required packages
|
||||
apt:
|
||||
update_cache: true
|
||||
name:
|
||||
- mosquitto
|
||||
- mosquitto-clients
|
||||
|
||||
- name: Enable mosquitto service
|
||||
systemd:
|
||||
name: mosquitto
|
||||
state: started
|
||||
enabled: yes
|
|
@ -0,0 +1,64 @@
|
|||
- name: Download NodeSource repository gpg key
|
||||
get_url:
|
||||
url: https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key
|
||||
dest: /usr/share/keyrings/nodesource.asc
|
||||
|
||||
- name: Add NodeSource nodejs repository
|
||||
apt_repository:
|
||||
repo: deb [arch=amd64 signed-by=/usr/share/keyrings/nodesource.asc] https://deb.nodesource.com/node_20.x nodistro main
|
||||
|
||||
- name: Install required packages
|
||||
apt:
|
||||
update_cache: true
|
||||
name:
|
||||
- git
|
||||
- nodejs
|
||||
|
||||
- name: Clone a zigbee2mqtt git repository
|
||||
git:
|
||||
repo: https://github.com/Koenkk/zigbee2mqtt.git
|
||||
dest: /opt/zigbee2mqtt
|
||||
depth: 1
|
||||
update: false
|
||||
register: git_clone
|
||||
|
||||
- name: Install zigbee2mqtt
|
||||
shell:
|
||||
chdir: /opt/zigbee2mqtt
|
||||
cmd: npm ci && npm run build
|
||||
when: git_clone.changed
|
||||
notify: Restart zigbee2mqtt
|
||||
|
||||
- name: Enable zigbee2mqtt home-assistant integration
|
||||
lineinfile:
|
||||
path: /opt/zigbee2mqtt/data/configuration.yaml
|
||||
line: "homeassistant: true"
|
||||
regexp: '^homeassistant:'
|
||||
notify: Restart zigbee2mqtt
|
||||
|
||||
- name: Enable zigbee2mqtt frontend
|
||||
lineinfile:
|
||||
path: /opt/zigbee2mqtt/data/configuration.yaml
|
||||
line: 'frontend: true'
|
||||
regexp: '^frontend:'
|
||||
notify: Restart zigbee2mqtt
|
||||
|
||||
- name: Disable zigbee2mqtt network join
|
||||
lineinfile:
|
||||
path: /opt/zigbee2mqtt/data/configuration.yaml
|
||||
line: 'permit_join: false'
|
||||
regexp: '^permit_join:'
|
||||
notify: Restart zigbee2mqtt
|
||||
|
||||
- name: Install zigbee2mqtt systemd unit
|
||||
template:
|
||||
src: zigbee2mqtt.service
|
||||
dest: /etc/systemd/system/zigbee2mqtt.service
|
||||
mode: 0644
|
||||
notify: Restart zigbee2mqtt
|
||||
|
||||
- name: Enable zigbee2mqtt service
|
||||
systemd:
|
||||
name: zigbee2mqtt
|
||||
daemon_reload: yes
|
||||
enabled: yes
|
|
@ -0,0 +1,19 @@
|
|||
[Unit]
|
||||
Description=Zigbee to MQTT bridge
|
||||
Documentation=https://www.zigbee2mqtt.io/
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Environment=NODE_ENV=production
|
||||
Type=exec
|
||||
ExecStart=/usr/bin/npm start
|
||||
WorkingDirectory=/opt/zigbee2mqtt
|
||||
StandardOutput=inherit
|
||||
# Or use StandardOutput=null if you don't want Zigbee2MQTT messages filling syslog, for more options see systemd.exec(5)
|
||||
StandardError=inherit
|
||||
Environment=ZIGBEE2MQTT_CONFIG_SERIAL_PORT={{ zigbee2mqtt.serial.port }}
|
||||
Restart=always
|
||||
RestartSec=10s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue