homeassistant: интеграция hass-configurator

master 92
parent 5d1ab7d912
commit 85efd3e2e3

@ -0,0 +1 @@
# Calculate env=install ac_install_merge==on mergepkg(www-servers/nginx)!= append=skip

@ -0,0 +1,2 @@
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
hass-configurator:x:997:

@ -0,0 +1,2 @@
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
hass-configurator:x:997:997:Filesystem-browser and text-editor:/var/calculate/www/hass-configurator:/bin/bash

@ -0,0 +1,2 @@
# Calculate path=/etc name=#-cut(1,.)-# append=after protected
hass-configurator:!:19459:0:99999:7:::

@ -0,0 +1 @@
# Calculate path=/var/calculate name=hass-configurator chmod=700 chown=hass-configurator:hass-configurator

@ -0,0 +1,22 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=# exists(/var/calculate/www/hass-configurator/hass-configurator-live)!=
#!/sbin/openrc-run
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
description="Filesystem-browser and text-editor"
user="hass-configurator"
group="hass-configurator"
command="/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live/.venv/bin/hass-configurator"
directory="/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live"
command_args="/var/calculate/hass-configurator/settings.conf"
command_user="${user}:${group}"
command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"
output_log="/var/log/${RC_SVCNAME}.log"
error_log="${output_log}"
start_pre() {
checkpath --file --owner $user --mode 0644 $output_log
}

@ -0,0 +1 @@
# Calculate path=/etc name=#-cut(1,.)-# link=/var/calculate/#-cut(1,.)-# symbolic protected

@ -0,0 +1 @@
# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic exists(/var/calculate/www/#-cut(1,.)-#/#-cut(1,.)-#-live)!=

@ -0,0 +1 @@
# Calculate chmod=700 chown=hass-configurator:hass-configurator

@ -1,6 +1,6 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=# exists(/etc/homeassistant/configuration.yaml)!=
#!/sbin/openrc-run
# Copyright 2022 Gentoo Authors
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
description="Open-source home automation platform"
@ -12,20 +12,20 @@ serverlog="/var/log/homeassistant/server.log"
warningslog="/var/log/homeassistant/warnings.log"
retry="20"
command=/var/calculate/www/homeassistant/homeassistant-live/bin/hass
directory=/var/calculate/www/homeassistant
command=/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live/bin/hass
directory=/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live
start_stop_daemon_args="--user $user --stdout $stdoutlog --stderr $serverlog --wait 10"
command_args="
--config /var/calculate/homeassistant
--config /var/calculate/${RC_SVCNAME}
--log-file $warningslog
--log-rotate-days 9
${HASS_OPTS}
"
command_background=yes
pidfile=/run/homeassistant.pid
pidfile=/run/${RC_SVCNAME}.pid
depend() {
need net nginx postgresql

@ -1 +1 @@
# Calculate chmod=750 chown=homeassistant:homeassistant
# Calculate chmod=700 chown=homeassistant:homeassistant

@ -1,3 +1,4 @@
# Calculate format=samba path=/var/calculate name=#-cut(1)-# grep(/var/calculate/ini.env,\[nginx\])== protected
[nginx]
zigbee2mqtt_subpath = #-rnd(pas,32)-#
hass-configurator_subpath = #-rnd(pas,32)-#

@ -41,7 +41,6 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /#-ini(nginx.zigbee2mqtt_subpath)-#/api {
proxy_pass http://localhost:8080/api;
proxy_set_header Host $host;
@ -51,4 +50,11 @@ server {
proxy_set_header Connection "upgrade";
}
# HASS Configurator
location /#-ini(nginx.hass-configurator_subpath)-#/ {
proxy_pass http://localhost:3218/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}

@ -8,7 +8,7 @@ description="Allows you to use your Zigbee devices without the vendor's bridge o
user="zigbee2mqtt"
group="zigbee2mqtt"
command="/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live/.venv/bin/npm"
command="/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live/.venv/bin/npm"
directory="/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live"
command_args="start"
command_user="${user}:${group}"
@ -16,7 +16,7 @@ command_background="yes"
pidfile="/run/${RC_SVCNAME}.pid"
output_log="/var/log/${RC_SVCNAME}.log"
error_log="${output_log}"
export PATH="/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live/.venv/bin:$PATH"
export PATH="/var/calculate/www/${RC_SVCNAME}/${RC_SVCNAME}-live/.venv/bin:$PATH"
depend() {
need mosquitto

@ -1 +1 @@
# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic exists(/var/calculate/www/zigbee2mqtt/zigbee2mqtt-live)!=
# Calculate path=/etc/runlevels/default name=#-cut(1,.)-# link=/etc/init.d/#-cut(1,.)-# protected symbolic exists(/var/calculate/www/#-cut(1,.)-#/#-cut(1,.)-#-live)!=

@ -1 +1 @@
# Calculate chmod=750 chown=zigbee2mqtt:zigbee2mqtt
# Calculate chmod=700 chown=zigbee2mqtt:zigbee2mqtt

@ -1,2 +1,2 @@
# Calculate format=openrc path=/etc/conf.d name=#-cut(1,.)-#
RC_MONITOR_RESTART="zigbee2mqtt homeassistant mosquitto"
RC_MONITOR_RESTART="zigbee2mqtt homeassistant mosquitto hass-configurator"

@ -1,6 +1,7 @@
# Calculate path=/etc/init.d name=#-cut(1,.)-# chmod=755 comment=#
#!/sbin/openrc-run
# Copyright 2023 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
pidfile="/run/check_crashed.pid"
command="/var/calculate/bin/check-crashed"
command_args="${RC_MONITOR_RESTART}"

@ -52,13 +52,13 @@ echo '. ~/zigbee2mqtt-live/.venv/bin/activate' >> .bashrc
echo '. ~/zigbee2mqtt-live/.venv/bin/activate' >> .bash_profile
ebegin 'Setup zigbee2mqtt'
mv zigbee2mqtt-live/data/configuration.yaml zigbee2mqtt-live/data/configuration.yaml.old
cat > zigbee2mqtt-live/data/configuration.yaml << EOF
mv /etc/zigbee2mqtt/configuration.yaml /etc/zigbee2mqtt/configuration.yaml.old
cat > /etc/zigbee2mqtt/configuration.yaml << EOF
# Home Assistant integration (MQTT discovery)
homeassistant: true
# allow new devices to join
permit_join: true
permit_join: false
# MQTT settings
mqtt:

@ -0,0 +1,71 @@
#!/bin/bash
# Guide: https://github.com/danielperna84/hass-configurator
set -ueo pipefail
export PATH="/lib/rc/bin:$PATH"
test -e ~/hass-configurator-live && exit
SCRIPT=$(readlink -f $0)
[[ $UID == 0 ]] && exec su - hass-configurator -c "$SCRIPT"
. /var/db/repos/container/scripts/functions.sh
. /var/db/repos/calculate/scripts/ini.sh
cd
ver=$(curl -s https://api.github.com/repos/danielperna84/hass-configurator/releases/latest | grep tag_name | cut -d '"' -f 4) && echo "Latest hass-configurator version is ${ver}"
[[ -z $ver ]] && eerror 'The latest version of hass-configurator is not defined!'
wget -q https://github.com/danielperna84/hass-configurator/archive/refs/tags/${ver}.zip -O hass-configurator-${ver}.zip
einfo 'Extract the archive'
unzip -q -d versions hass-configurator-${ver}.zip
rm hass-configurator-${ver}.zip
ln -sf versions/hass-configurator-${ver} hass-configurator-live
einfo 'Install python env'
python -m venv hass-configurator-live/.venv
einfo 'Activate environment'
. hass-configurator-live/.venv/bin/activate
einfo 'Upgrade pip and wheel'
pip install --upgrade pip wheel
einfo 'Install HASS Configurator'
pip install hass-configurator
echo '. ~/hass-configurator-live/.venv/bin/activate' >> .bashrc
echo '. ~/hass-configurator-live/.venv/bin/activate' >> .bash_profile
ebegin 'Setup HASS Configurator'
if [[ ! -e /etc/hass-configurator/settings.conf ]]; then
cat > /etc/hass-configurator/settings.conf << EOF
{
"LISTENIP": "0.0.0.0",
"PORT": 3218,
"GIT": false,
"BASEPATH": null,
"ENFORCE_BASEPATH": false,
"SSL_CERTIFICATE": null,
"SSL_KEY": null,
"IGNORE_SSL": false,
"HASS_API": "http://127.0.0.1:8123/api/",
"HASS_WS_API": null,
"HASS_API_PASSWORD": null,
"USERNAME": null,
"PASSWORD": null,
"ALLOWED_NETWORKS": [],
"ALLOWED_DOMAINS": [],
"BANNED_IPS": [],
"BANLIMIT": 0,
"IGNORE_PATTERN": [],
"DIRSFIRST": false,
"SESAME": null,
"SESAME_TOTP_SECRET": null,
"VERIFY_HOSTNAME": null,
"ENV_PREFIX": "HC_",
"NOTIFY_SERVICE": "persistent_notification.create"
}
EOF
fi
eend

@ -34,9 +34,13 @@ recorder:
panel_iframe:
zigbee:
title: "Zigbee2mqtt"
url: "${ini[homeassistant.protocol]}://${ini[homeassistant.domain]}/${ini[nginx.zigbee2mqtt_subpath]}"
title: Zigbee2mqtt
url: ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]}/${ini[nginx.zigbee2mqtt_subpath]}
icon: mdi:zigbee
configurator:
title: Configurator
icon: mdi:wrench
url: ${ini[homeassistant.protocol]}://${ini[homeassistant.domain]}/${ini[nginx.hass-configurator_subpath]}
EOF
echo
Loading…
Cancel
Save