mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Add Home Assistant integration discovery (#4328)
This commit is contained in:
parent
aca56fcdcc
commit
3e017efa30
7 changed files with 36 additions and 0 deletions
|
@ -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;
|
||||||
|
|
32
docker/ha-addon-rootfs/etc/s6-overlay/s6-rc.d/discovery/run
Executable file
32
docker/ha-addon-rootfs/etc/s6-overlay/s6-rc.d/discovery/run
Executable 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
|
|
@ -0,0 +1 @@
|
||||||
|
oneshot
|
|
@ -0,0 +1 @@
|
||||||
|
/etc/s6-overlay/s6-rc.d/discovery/run
|
Loading…
Reference in a new issue