Add Home Assistant integration discovery (#4328)

This commit is contained in:
Franck Nijhof 2023-01-26 17:48:04 +01:00 committed by GitHub
parent aca56fcdcc
commit 3e017efa30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 0 deletions

View File

@ -1,4 +1,5 @@
server { server {
listen 127.0.0.1:{{ .port }} default_server;
listen {{ .interface }}:{{ .port }} default_server; listen {{ .interface }}:{{ .port }} default_server;
include /etc/nginx/includes/server_params.conf; include /etc/nginx/includes/server_params.conf;
@ -9,6 +10,7 @@ server {
location / { location / {
allow 172.30.32.2; allow 172.30.32.2;
allow 127.0.0.1;
deny all; deny all;
proxy_pass http://esphome; proxy_pass http://esphome;

View File

@ -0,0 +1,32 @@
#!/command/with-contenv bashio
# shellcheck shell=bash
# ==============================================================================
# Home Assistant Add-on: ESPHome
# Sends discovery information to Home Assistant.
# ==============================================================================
declare config
declare port
# We only disable it when disabled explicitly
if bashio::config.false 'home_assistant_dashboard_integration';
then
bashio::log.info "Home Assistant discovery is disabled for this add-on."
bashio::exit.ok
fi
port=$(bashio::addon.ingress_port)
# Wait for NGINX to become available
bashio::net.wait_for "${port}" "127.0.0.1" 300
config=$(\
bashio::var.json \
host "127.0.0.1" \
port "^${port}" \
)
if bashio::discovery "esphome" "${config}" > /dev/null; then
bashio::log.info "Successfully send discovery information to Home Assistant."
else
bashio::log.error "Discovery message to Home Assistant failed!"
fi

View File

@ -0,0 +1 @@
oneshot

View File

@ -0,0 +1 @@
/etc/s6-overlay/s6-rc.d/discovery/run