mirror of
https://github.com/esphome/home-assistant-addon.git
synced 2024-12-17 15:57:46 +01:00
Hass.io ingress
This commit is contained in:
parent
f8314cb026
commit
a0d8fcd037
@ -1,11 +1,10 @@
|
|||||||
ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.4.3
|
ARG BUILD_FROM=esphome/esphome-hassio-base-amd64:1.5.1
|
||||||
FROM ${BUILD_FROM}
|
FROM ${BUILD_FROM}
|
||||||
|
|
||||||
# Copy root filesystem
|
# Copy root filesystem
|
||||||
COPY rootfs /
|
COPY rootfs /
|
||||||
|
|
||||||
RUN \
|
RUN pip2 install --no-cache-dir https://github.com/esphome/esphome/archive/dev.zip
|
||||||
pip2 install --no-cache-dir --no-binary :all: https://github.com/esphome/esphome/archive/dev.zip
|
|
||||||
|
|
||||||
# Build arguments
|
# Build arguments
|
||||||
ARG BUILD_VERSION=dev
|
ARG BUILD_VERSION=dev
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
"squash": false,
|
"squash": false,
|
||||||
"build_from": {
|
"build_from": {
|
||||||
"aarch64": "esphome/esphome-hassio-base-aarch64:1.4.1",
|
"amd64": "esphome/esphome-hassio-base-amd64:1.5.0",
|
||||||
"amd64": "esphome/esphome-hassio-base-amd64:1.4.1",
|
"i386": "esphome/esphome-hassio-base-i386:1.5.0",
|
||||||
"armhf": "esphome/esphome-hassio-base-armhf:1.4.1",
|
"armv7": "esphome/esphome-hassio-base-armv7:1.5.0",
|
||||||
"i386": "esphome/esphome-hassio-base-i386:1.4.1"
|
"aarch64": "esphome/esphome-hassio-base-aarch64:1.5.0"
|
||||||
},
|
},
|
||||||
"args": {}
|
"args": {}
|
||||||
}
|
}
|
@ -1,43 +1,48 @@
|
|||||||
{
|
{
|
||||||
"name": "ESPHome (dev)",
|
|
||||||
"version": "dev",
|
|
||||||
"slug": "esphome-dev",
|
|
||||||
"description": "Development Version! Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files",
|
|
||||||
"url": "https://esphome.io/",
|
"url": "https://esphome.io/",
|
||||||
"webui": "http://[HOST]:[PORT:6052]",
|
"webui": "http://[HOST]:[PORT:6052]",
|
||||||
"startup": "application",
|
"startup": "application",
|
||||||
|
"boot": "auto",
|
||||||
"arch": [
|
"arch": [
|
||||||
"amd64",
|
"amd64",
|
||||||
"armhf",
|
"i386",
|
||||||
"i386"
|
"armv7",
|
||||||
|
"aarch64"
|
||||||
],
|
],
|
||||||
"hassio_api": true,
|
"hassio_api": true,
|
||||||
"auth_api": true,
|
"auth_api": true,
|
||||||
"hassio_role": "default",
|
"hassio_role": "default",
|
||||||
"homeassistant_api": false,
|
"homeassistant_api": false,
|
||||||
"host_network": true,
|
"host_network": true,
|
||||||
"boot": "auto",
|
"ingress": true,
|
||||||
|
"ingress_port": 0,
|
||||||
|
"panel_icon": "mdi:chip",
|
||||||
"auto_uart": true,
|
"auto_uart": true,
|
||||||
|
"ports": {
|
||||||
|
"6052/tcp": null
|
||||||
|
},
|
||||||
|
"ports_description": {
|
||||||
|
"6052/tcp": "Web interface (Not required for Hass.io Ingress)"
|
||||||
|
},
|
||||||
"map": [
|
"map": [
|
||||||
"ssl",
|
"ssl",
|
||||||
"config:rw"
|
"config:rw"
|
||||||
],
|
],
|
||||||
"options": {
|
|
||||||
"ssl": false,
|
|
||||||
"certfile": "fullchain.pem",
|
|
||||||
"keyfile": "privkey.pem",
|
|
||||||
"port": 6052,
|
|
||||||
"esphome_version": "dev"
|
|
||||||
},
|
|
||||||
"schema": {
|
"schema": {
|
||||||
"ssl": "bool",
|
"ssl": "bool?",
|
||||||
"certfile": "str",
|
"certfile": "str?",
|
||||||
"keyfile": "str",
|
"keyfile": "str?",
|
||||||
"port": "int",
|
|
||||||
"leave_front_door_open": "bool?",
|
"leave_front_door_open": "bool?",
|
||||||
"esphome_version": "str?",
|
"esphome_version": "str?",
|
||||||
"streamer_mode": "bool?",
|
"streamer_mode": "bool?",
|
||||||
"relative_url": "str?",
|
"relative_url": "str?",
|
||||||
"status_use_ping": "bool?"
|
"status_use_ping": "bool?"
|
||||||
|
},
|
||||||
|
"name": "ESPHome (dev)",
|
||||||
|
"version": "dev",
|
||||||
|
"slug": "esphome-dev2",
|
||||||
|
"description": "Development Version! Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files",
|
||||||
|
"options": {
|
||||||
|
"esphome_version": "dev"
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -6,21 +6,29 @@
|
|||||||
|
|
||||||
declare certfile
|
declare certfile
|
||||||
declare keyfile
|
declare keyfile
|
||||||
declare port
|
declare direct_port
|
||||||
|
declare ingress_interface
|
||||||
|
declare ingress_port
|
||||||
|
|
||||||
mkdir -p /var/log/nginx
|
mkdir -p /var/log/nginx
|
||||||
|
|
||||||
# Enable SSL
|
direct_port=$(bashio::addon.port 6052)
|
||||||
if bashio::config.true 'ssl'; then
|
if bashio::var.has_value "${direct_port}"; then
|
||||||
rm /etc/nginx/nginx.conf
|
if bashio::config.true 'ssl'; then
|
||||||
mv /etc/nginx/nginx-ssl.conf /etc/nginx/nginx.conf
|
certfile=$(bashio::config 'certfile')
|
||||||
|
keyfile=$(bashio::config 'keyfile')
|
||||||
|
|
||||||
certfile=$(bashio::config 'certfile')
|
mv /etc/nginx/servers/direct-ssl.disabled /etc/nginx/servers/direct.conf
|
||||||
keyfile=$(bashio::config 'keyfile')
|
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/servers/direct.conf
|
||||||
|
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/servers/direct.conf
|
||||||
|
else
|
||||||
|
mv /etc/nginx/servers/direct.disabled /etc/nginx/servers/direct.conf
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx.conf
|
sed -i "s/%%port%%/${direct_port}/g" /etc/nginx/servers/direct.conf
|
||||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx.conf
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
port=$(bashio::config 'port')
|
ingress_port=$(bashio::addon.ingress_port)
|
||||||
sed -i "s/%%port%%/${port}/g" /etc/nginx/nginx.conf
|
ingress_interface=$(bashio::addon.ip_address)
|
||||||
|
sed -i "s/%%port%%/${ingress_port}/g" /etc/nginx/servers/ingress.conf
|
||||||
|
sed -i "s/%%interface%%/${ingress_interface}/g" /etc/nginx/servers/ingress.conf
|
||||||
|
@ -10,6 +10,6 @@ if bashio::config.has_value 'esphome_version'; then
|
|||||||
esphome_version=$(bashio::config 'esphome_version')
|
esphome_version=$(bashio::config 'esphome_version')
|
||||||
full_url="https://github.com/esphome/esphome/archive/${esphome_version}.zip"
|
full_url="https://github.com/esphome/esphome/archive/${esphome_version}.zip"
|
||||||
bashio::log.info "Installing esphome version '${esphome_version}' (${full_url})..."
|
bashio::log.info "Installing esphome version '${esphome_version}' (${full_url})..."
|
||||||
pip2 install --no-cache-dir --no-binary :all: "${full_url}" \
|
pip2 install -U --no-cache-dir "${full_url}" \
|
||||||
|| bashio::exit.nok "Failed installing esphome pinned version."
|
|| bashio::exit.nok "Failed installing esphome pinned version."
|
||||||
fi
|
fi
|
||||||
|
96
esphome-dev/rootfs/etc/nginx/includes/mime.types
Normal file
96
esphome-dev/rootfs/etc/nginx/includes/mime.types
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
types {
|
||||||
|
text/html html htm shtml;
|
||||||
|
text/css css;
|
||||||
|
text/xml xml;
|
||||||
|
image/gif gif;
|
||||||
|
image/jpeg jpeg jpg;
|
||||||
|
application/javascript js;
|
||||||
|
application/atom+xml atom;
|
||||||
|
application/rss+xml rss;
|
||||||
|
|
||||||
|
text/mathml mml;
|
||||||
|
text/plain txt;
|
||||||
|
text/vnd.sun.j2me.app-descriptor jad;
|
||||||
|
text/vnd.wap.wml wml;
|
||||||
|
text/x-component htc;
|
||||||
|
|
||||||
|
image/png png;
|
||||||
|
image/svg+xml svg svgz;
|
||||||
|
image/tiff tif tiff;
|
||||||
|
image/vnd.wap.wbmp wbmp;
|
||||||
|
image/webp webp;
|
||||||
|
image/x-icon ico;
|
||||||
|
image/x-jng jng;
|
||||||
|
image/x-ms-bmp bmp;
|
||||||
|
|
||||||
|
font/woff woff;
|
||||||
|
font/woff2 woff2;
|
||||||
|
|
||||||
|
application/java-archive jar war ear;
|
||||||
|
application/json json;
|
||||||
|
application/mac-binhex40 hqx;
|
||||||
|
application/msword doc;
|
||||||
|
application/pdf pdf;
|
||||||
|
application/postscript ps eps ai;
|
||||||
|
application/rtf rtf;
|
||||||
|
application/vnd.apple.mpegurl m3u8;
|
||||||
|
application/vnd.google-earth.kml+xml kml;
|
||||||
|
application/vnd.google-earth.kmz kmz;
|
||||||
|
application/vnd.ms-excel xls;
|
||||||
|
application/vnd.ms-fontobject eot;
|
||||||
|
application/vnd.ms-powerpoint ppt;
|
||||||
|
application/vnd.oasis.opendocument.graphics odg;
|
||||||
|
application/vnd.oasis.opendocument.presentation odp;
|
||||||
|
application/vnd.oasis.opendocument.spreadsheet ods;
|
||||||
|
application/vnd.oasis.opendocument.text odt;
|
||||||
|
application/vnd.openxmlformats-officedocument.presentationml.presentation
|
||||||
|
pptx;
|
||||||
|
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet
|
||||||
|
xlsx;
|
||||||
|
application/vnd.openxmlformats-officedocument.wordprocessingml.document
|
||||||
|
docx;
|
||||||
|
application/vnd.wap.wmlc wmlc;
|
||||||
|
application/x-7z-compressed 7z;
|
||||||
|
application/x-cocoa cco;
|
||||||
|
application/x-java-archive-diff jardiff;
|
||||||
|
application/x-java-jnlp-file jnlp;
|
||||||
|
application/x-makeself run;
|
||||||
|
application/x-perl pl pm;
|
||||||
|
application/x-pilot prc pdb;
|
||||||
|
application/x-rar-compressed rar;
|
||||||
|
application/x-redhat-package-manager rpm;
|
||||||
|
application/x-sea sea;
|
||||||
|
application/x-shockwave-flash swf;
|
||||||
|
application/x-stuffit sit;
|
||||||
|
application/x-tcl tcl tk;
|
||||||
|
application/x-x509-ca-cert der pem crt;
|
||||||
|
application/x-xpinstall xpi;
|
||||||
|
application/xhtml+xml xhtml;
|
||||||
|
application/xspf+xml xspf;
|
||||||
|
application/zip zip;
|
||||||
|
|
||||||
|
application/octet-stream bin exe dll;
|
||||||
|
application/octet-stream deb;
|
||||||
|
application/octet-stream dmg;
|
||||||
|
application/octet-stream iso img;
|
||||||
|
application/octet-stream msi msp msm;
|
||||||
|
|
||||||
|
audio/midi mid midi kar;
|
||||||
|
audio/mpeg mp3;
|
||||||
|
audio/ogg ogg;
|
||||||
|
audio/x-m4a m4a;
|
||||||
|
audio/x-realaudio ra;
|
||||||
|
|
||||||
|
video/3gpp 3gpp 3gp;
|
||||||
|
video/mp2t ts;
|
||||||
|
video/mp4 mp4;
|
||||||
|
video/mpeg mpeg mpg;
|
||||||
|
video/quicktime mov;
|
||||||
|
video/webm webm;
|
||||||
|
video/x-flv flv;
|
||||||
|
video/x-m4v m4v;
|
||||||
|
video/x-mng mng;
|
||||||
|
video/x-ms-asf asx asf;
|
||||||
|
video/x-ms-wmv wmv;
|
||||||
|
video/x-msvideo avi;
|
||||||
|
}
|
16
esphome-dev/rootfs/etc/nginx/includes/proxy_params.conf
Normal file
16
esphome-dev/rootfs/etc/nginx/includes/proxy_params.conf
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
proxy_http_version 1.1;
|
||||||
|
proxy_ignore_client_abort off;
|
||||||
|
proxy_read_timeout 86400s;
|
||||||
|
proxy_redirect off;
|
||||||
|
proxy_send_timeout 86400s;
|
||||||
|
proxy_max_temp_file_size 0;
|
||||||
|
|
||||||
|
proxy_set_header Accept-Encoding "";
|
||||||
|
proxy_set_header Connection $connection_upgrade;
|
||||||
|
proxy_set_header Host $http_host;
|
||||||
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
|
proxy_set_header X-Forwarded-Proto $scheme;
|
||||||
|
proxy_set_header X-NginX-Proxy true;
|
||||||
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
proxy_set_header Authorization "";
|
6
esphome-dev/rootfs/etc/nginx/includes/server_params.conf
Normal file
6
esphome-dev/rootfs/etc/nginx/includes/server_params.conf
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
root /dev/null;
|
||||||
|
server_name $hostname;
|
||||||
|
|
||||||
|
add_header X-Content-Type-Options nosniff;
|
||||||
|
add_header X-XSS-Protection "1; mode=block";
|
||||||
|
add_header X-Robots-Tag none;
|
9
esphome-dev/rootfs/etc/nginx/includes/ssl_params.conf
Normal file
9
esphome-dev/rootfs/etc/nginx/includes/ssl_params.conf
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
ssl_protocols TLSv1.2;
|
||||||
|
ssl_prefer_server_ciphers on;
|
||||||
|
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
|
||||||
|
ssl_ecdh_curve secp384r1;
|
||||||
|
ssl_session_timeout 10m;
|
||||||
|
ssl_session_cache shared:SSL:10m;
|
||||||
|
ssl_session_tickets off;
|
||||||
|
ssl_stapling on;
|
||||||
|
ssl_stapling_verify on;
|
@ -1,62 +0,0 @@
|
|||||||
worker_processes 1;
|
|
||||||
pid /var/run/nginx.pid;
|
|
||||||
error_log stderr;
|
|
||||||
|
|
||||||
events {
|
|
||||||
worker_connections 1024;
|
|
||||||
}
|
|
||||||
|
|
||||||
http {
|
|
||||||
access_log stdout;
|
|
||||||
include mime.types;
|
|
||||||
default_type application/octet-stream;
|
|
||||||
sendfile on;
|
|
||||||
keepalive_timeout 65;
|
|
||||||
|
|
||||||
upstream esphome {
|
|
||||||
ip_hash;
|
|
||||||
server unix:/var/run/esphome.sock;
|
|
||||||
}
|
|
||||||
map $http_upgrade $connection_upgrade {
|
|
||||||
default upgrade;
|
|
||||||
'' close;
|
|
||||||
}
|
|
||||||
|
|
||||||
server {
|
|
||||||
server_name hassio.local;
|
|
||||||
listen %%port%% default_server ssl;
|
|
||||||
root /dev/null;
|
|
||||||
|
|
||||||
ssl_certificate /ssl/%%certfile%%;
|
|
||||||
ssl_certificate_key /ssl/%%keyfile%%;
|
|
||||||
ssl_protocols TLSv1.2;
|
|
||||||
ssl_prefer_server_ciphers on;
|
|
||||||
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
|
|
||||||
ssl_ecdh_curve secp384r1;
|
|
||||||
ssl_session_timeout 10m;
|
|
||||||
ssl_session_cache shared:SSL:10m;
|
|
||||||
ssl_session_tickets off;
|
|
||||||
ssl_stapling on;
|
|
||||||
ssl_stapling_verify on;
|
|
||||||
|
|
||||||
# Redirect http requests to https on the same port.
|
|
||||||
# https://rageagainstshell.com/2016/11/redirect-http-to-https-on-the-same-port-in-nginx/
|
|
||||||
error_page 497 https://$http_host$request_uri;
|
|
||||||
|
|
||||||
location / {
|
|
||||||
proxy_redirect off;
|
|
||||||
proxy_pass http://esphome;
|
|
||||||
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection $connection_upgrade;
|
|
||||||
proxy_set_header Authorization "";
|
|
||||||
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-NginX-Proxy true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
51
esphome-dev/rootfs/etc/nginx/nginx.conf
Executable file → Normal file
51
esphome-dev/rootfs/etc/nginx/nginx.conf
Executable file → Normal file
@ -1,46 +1,33 @@
|
|||||||
worker_processes 1;
|
daemon off;
|
||||||
|
user root;
|
||||||
pid /var/run/nginx.pid;
|
pid /var/run/nginx.pid;
|
||||||
error_log stderr;
|
worker_processes 1;
|
||||||
|
# Hass.io addon log
|
||||||
|
error_log /proc/1/fd/1 error;
|
||||||
events {
|
events {
|
||||||
worker_connections 1024;
|
worker_connections 1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
http {
|
http {
|
||||||
access_log stdout;
|
include /etc/nginx/includes/mime.types;
|
||||||
include mime.types;
|
access_log stdout;
|
||||||
default_type application/octet-stream;
|
default_type application/octet-stream;
|
||||||
sendfile on;
|
gzip on;
|
||||||
keepalive_timeout 65;
|
keepalive_timeout 65;
|
||||||
|
sendfile on;
|
||||||
|
server_tokens off;
|
||||||
|
|
||||||
upstream esphome {
|
|
||||||
ip_hash;
|
|
||||||
server unix:/var/run/esphome.sock;
|
|
||||||
}
|
|
||||||
map $http_upgrade $connection_upgrade {
|
map $http_upgrade $connection_upgrade {
|
||||||
default upgrade;
|
default upgrade;
|
||||||
'' close;
|
'' close;
|
||||||
}
|
}
|
||||||
|
|
||||||
server {
|
# Use Hass.io supervisor as resolver
|
||||||
server_name hassio.local;
|
resolver 172.30.32.2;
|
||||||
listen %%port%% default_server;
|
|
||||||
root /dev/null;
|
|
||||||
|
|
||||||
location / {
|
upstream esphome {
|
||||||
proxy_redirect off;
|
server unix:/var/run/esphome.sock;
|
||||||
proxy_pass http://esphome;
|
|
||||||
|
|
||||||
proxy_http_version 1.1;
|
|
||||||
proxy_set_header Upgrade $http_upgrade;
|
|
||||||
proxy_set_header Connection $connection_upgrade;
|
|
||||||
proxy_set_header Authorization "";
|
|
||||||
|
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
|
||||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
||||||
proxy_set_header X-Forwarded-Proto $scheme;
|
|
||||||
proxy_set_header Host $http_host;
|
|
||||||
proxy_set_header X-NginX-Proxy true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include /etc/nginx/servers/*.conf;
|
||||||
}
|
}
|
||||||
|
17
esphome-dev/rootfs/etc/nginx/servers/direct-ssl.disabled
Normal file
17
esphome-dev/rootfs/etc/nginx/servers/direct-ssl.disabled
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
server {
|
||||||
|
listen %%port%% default_server ssl http2;
|
||||||
|
|
||||||
|
include /etc/nginx/includes/server_params.conf;
|
||||||
|
include /etc/nginx/includes/proxy_params.conf;
|
||||||
|
include /etc/nginx/includes/ssl_params.conf;
|
||||||
|
# Clear Hass.io Ingress header
|
||||||
|
proxy_set_header X-Hassio-Ingress "";
|
||||||
|
|
||||||
|
# Redirect http requests to https on the same port.
|
||||||
|
# https://rageagainstshell.com/2016/11/redirect-http-to-https-on-the-same-port-in-nginx/
|
||||||
|
error_page 497 https://$http_host$request_uri;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://esphome;
|
||||||
|
}
|
||||||
|
}
|
12
esphome-dev/rootfs/etc/nginx/servers/direct.disabled
Normal file
12
esphome-dev/rootfs/etc/nginx/servers/direct.disabled
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
server {
|
||||||
|
listen %%port%% default_server;
|
||||||
|
|
||||||
|
include /etc/nginx/includes/server_params.conf;
|
||||||
|
include /etc/nginx/includes/proxy_params.conf;
|
||||||
|
# Clear Hass.io Ingress header
|
||||||
|
proxy_set_header X-Hassio-Ingress "";
|
||||||
|
|
||||||
|
location / {
|
||||||
|
proxy_pass http://esphome;
|
||||||
|
}
|
||||||
|
}
|
16
esphome-dev/rootfs/etc/nginx/servers/ingress.conf
Normal file
16
esphome-dev/rootfs/etc/nginx/servers/ingress.conf
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
server {
|
||||||
|
listen %%interface%%:%%port%% default_server;
|
||||||
|
|
||||||
|
include /etc/nginx/includes/server_params.conf;
|
||||||
|
include /etc/nginx/includes/proxy_params.conf;
|
||||||
|
# Set Hass.io Ingress header
|
||||||
|
proxy_set_header X-Hassio-Ingress "YES";
|
||||||
|
|
||||||
|
location / {
|
||||||
|
# Only allow from Hass.io supervisor
|
||||||
|
allow 172.30.32.2;
|
||||||
|
deny all;
|
||||||
|
|
||||||
|
proxy_pass http://esphome;
|
||||||
|
}
|
||||||
|
}
|
@ -4,5 +4,11 @@
|
|||||||
# Runs the NGINX proxy
|
# Runs the NGINX proxy
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
|
bashio::log.info "Waiting for dashboard to come up..."
|
||||||
|
|
||||||
|
while [[ ! -S /var/run/esphome.sock ]]; do
|
||||||
|
sleep 0.5
|
||||||
|
done
|
||||||
|
|
||||||
bashio::log.info "Starting NGINX..."
|
bashio::log.info "Starting NGINX..."
|
||||||
exec nginx -g "daemon off;"
|
exec nginx
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
; This file allows the docker build file to install the required platformio
|
|
||||||
; platforms
|
|
||||||
|
|
||||||
[env:espressif8266]
|
|
||||||
platform = espressif8266@1.8.0
|
|
||||||
board = nodemcuv2
|
|
||||||
framework = arduino
|
|
||||||
|
|
||||||
[env:espressif32]
|
|
||||||
platform = espressif32@1.5.0
|
|
||||||
board = nodemcu-32s
|
|
||||||
framework = arduino
|
|
48
script/generate.py
Executable file
48
script/generate.py
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
import yaml
|
||||||
|
from pathlib import Path
|
||||||
|
from enum import Enum
|
||||||
|
import json
|
||||||
|
from shutil import copyfile
|
||||||
|
|
||||||
|
class Channel(Enum):
|
||||||
|
stable = 'stable'
|
||||||
|
beta = 'beta'
|
||||||
|
dev = 'dev'
|
||||||
|
|
||||||
|
parser = argparse.ArgumentParser(description='Generate ESPHome Hass.io config.json')
|
||||||
|
parser.add_argument('channels', nargs='+', type=Channel, choices=list(Channel))
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
root = Path(__file__).parent.parent
|
||||||
|
templ = root / 'template'
|
||||||
|
|
||||||
|
with open(templ / "config.yaml", 'r') as f:
|
||||||
|
config = yaml.safe_load(f)
|
||||||
|
|
||||||
|
copyf = config['copy_files']
|
||||||
|
|
||||||
|
for channel in args.channels:
|
||||||
|
conf = config[f'esphome-{channel.value}']
|
||||||
|
base_image = conf.pop('base_image')
|
||||||
|
dir_ = root / conf.pop('directory')
|
||||||
|
path = dir_ / 'config.json'
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
json.dump(conf, f, indent=2)
|
||||||
|
|
||||||
|
for file_, conf_ in copyf.items():
|
||||||
|
copyfile(templ / file_, dir_ / file_)
|
||||||
|
|
||||||
|
if channel == Channel.dev:
|
||||||
|
path = dir_ / 'build.json'
|
||||||
|
build_conf = {
|
||||||
|
'squash': False,
|
||||||
|
"build_from": {arch: base_image.format(arch=arch) for arch in conf['arch']},
|
||||||
|
"args": {}
|
||||||
|
}
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
json.dump(build_conf, f, indent=2)
|
||||||
|
|
||||||
|
print(f"Wrote {path}")
|
129
template/README.md
Normal file
129
template/README.md
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
# ESPHome Hass.io Add-On
|
||||||
|
|
||||||
|
[![ESPHome logo](https://raw.githubusercontent.com/esphome/hassio/master/esphome-dev/logo.png)](https://esphome.io/)
|
||||||
|
|
||||||
|
[![GitHub stars](https://img.shields.io/github/stars/esphome/esphome.svg?style=social&label=Star&maxAge=2592000)](https://github.com/esphome/esphome)
|
||||||
|
[![GitHub Release][releases-shield]][releases]
|
||||||
|
[![Discord][discord-shield]][discord]
|
||||||
|
|
||||||
|
## About
|
||||||
|
|
||||||
|
This add-on allows you to manage and program your ESP8266 and ESP32 based microcontrollers
|
||||||
|
directly through Hass.io **with no programming experience required**. All you need to do
|
||||||
|
is write YAML configuration files; the rest (over-the-air updates, compiling) is all
|
||||||
|
handled by ESPHome.
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img title="ESPHome dashboard screenshot" src="https://raw.githubusercontent.com/esphome/hassio/master/esphome-dev/images/screenshot.png" width="700px"></img>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
[_View the ESPHome documentation here_](https://esphome.io/)
|
||||||
|
|
||||||
|
## Example
|
||||||
|
|
||||||
|
With ESPHome, you can go from a few lines of YAML straight to a custom-made
|
||||||
|
firmware. For example, to include a [DHT22][dht22].
|
||||||
|
temperature and humidity sensor, you just need to include 8 lines of YAML
|
||||||
|
in your configuration file:
|
||||||
|
|
||||||
|
<img title="ESPHome DHT configuration example" src="https://raw.githubusercontent.com/esphome/hassio/master/esphome-dev/images/dht-example.png" width="500px"></img>
|
||||||
|
|
||||||
|
Then just click UPLOAD and the sensor will magically appear in Home Assistant:
|
||||||
|
|
||||||
|
<img title="ESPHome Home Assistant MQTT discovery" src="https://raw.githubusercontent.com/esphome/hassio/master/esphome-dev/images/temperature-humidity.png" width="600px"></img>
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
|
||||||
|
To install this Hass.io add-on you need to add the ESPHome add-on repository
|
||||||
|
first:
|
||||||
|
|
||||||
|
1. Add the epshomeyaml add-ons repository to your Hass.io instance. You can do this by navigating to the "Add-on Store" tab in the Hass.io panel and then entering https://github.com/esphome/hassio in the "Add new repository by URL" field.
|
||||||
|
2. Now scroll down and select the "ESPHome" add-on.
|
||||||
|
3. Press install to download the add-on and unpack it on your machine. This can take some time.
|
||||||
|
4. Optional: If you're using SSL certificates and want to encrypt your communication to this add-on, please enter `true` into the `ssl` field and set the `fullchain` and `certfile` options accordingly.
|
||||||
|
5. Start the add-on, check the logs of the add-on to see if everything went well.
|
||||||
|
6. Click "OPEN WEB UI" to open the ESPHome dashboard. You will be asked for your Home Assistant credentials - ESPHome uses Hass.io's authentication system to log you in.
|
||||||
|
|
||||||
|
**NOTE**: Installation on RPis running in 64-bit mode is currently not possible. Please use the 32-bit variant of HassOS instead.
|
||||||
|
|
||||||
|
You can view the ESPHome docs here: https://esphome.io/
|
||||||
|
|
||||||
|
## Configuration
|
||||||
|
|
||||||
|
**Note**: _Remember to restart the add-on when the configuration is changed._
|
||||||
|
|
||||||
|
Example add-on configuration:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"ssl": false,
|
||||||
|
"certfile": "fullchain.pem",
|
||||||
|
"keyfile": "privkey.pem",
|
||||||
|
"port": 6052
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option: `port`
|
||||||
|
|
||||||
|
The port to start the dashboard server on. Default is 6052.
|
||||||
|
|
||||||
|
### Option: `ssl`
|
||||||
|
|
||||||
|
Enables/Disables encrypted SSL (HTTPS) connections to the web server of this add-on.
|
||||||
|
Set it to `true` to encrypt communications, `false` otherwise.
|
||||||
|
Please note that if you set this to `true` you must also generate the key and certificate
|
||||||
|
files for encryption. For example using [Let's Encrypt](https://www.home-assistant.io/addons/lets_encrypt/)
|
||||||
|
or [Self-signed certificates](https://www.home-assistant.io/docs/ecosystem/certificates/tls_self_signed_certificate/).
|
||||||
|
|
||||||
|
### Option: `certfile`
|
||||||
|
|
||||||
|
The certificate file to use for SSL. If this file doesn't exist, the add-on start will fail.
|
||||||
|
|
||||||
|
**Note**: The file MUST be stored in `/ssl/`, which is the default for Hass.io
|
||||||
|
|
||||||
|
### Option: `keyfile`
|
||||||
|
|
||||||
|
The private key file to use for SSL. If this file doesn't exist, the add-on start will fail.
|
||||||
|
|
||||||
|
**Note**: The file MUST be stored in `/ssl/`, which is the default for Hass.io
|
||||||
|
|
||||||
|
### Option: `leave_front_door_open`
|
||||||
|
|
||||||
|
Adding this option to the add-on configuration allows you to disable
|
||||||
|
authentication by setting it to `true`.
|
||||||
|
|
||||||
|
### Option: `esphome_version`
|
||||||
|
|
||||||
|
Manually override which ESPHome version to use in the addon.
|
||||||
|
For example to install the latest development version, use `"esphome_version": "dev"`,
|
||||||
|
or for version 1.10.0: `"esphome_version": "v1.10.0""`.
|
||||||
|
|
||||||
|
Please note that this does not always work and is only meant for testing, usually the
|
||||||
|
ESPHome add-on and dashboard version must match to guarantee a working system.
|
||||||
|
|
||||||
|
### Option: `relative_url`
|
||||||
|
|
||||||
|
Host the ESPHome dashboard under a relative URL, so that it can be integrated
|
||||||
|
into existing web proxys like nginx under a relative URl. Defaults to `/`.
|
||||||
|
|
||||||
|
### Option: `status_use_ping`
|
||||||
|
|
||||||
|
By default the dashboard uses mDNS to check if nodes are online. This does
|
||||||
|
not work across subnets unless your router supports mDNS forwarding or avahi.
|
||||||
|
|
||||||
|
Setting this to `true` will make ESPHome use ICMP ping requests to get the node status. Use this if all nodes always have offline status even when they're connected.
|
||||||
|
|
||||||
|
### Option: `streamer_mode`
|
||||||
|
|
||||||
|
If set to `true`, this will enable stremer mode, which makes ESPHome hide all
|
||||||
|
potentially private information. So for example WiFi (B)SSIDs (which could be
|
||||||
|
used to find your location), usernames etc. Please note that you need to use
|
||||||
|
the `!secret` tag in your YAML file to also prevent these from showing up
|
||||||
|
while editing and validating.
|
||||||
|
|
||||||
|
[discord-shield]: https://img.shields.io/discord/429907082951524364.svg
|
||||||
|
[dht22]: https://esphome.io/components/sensor/dht.html
|
||||||
|
[discord]: https://discord.me/KhAMKrd
|
||||||
|
[releases-shield]: https://img.shields.io/github/release/esphome/esphome.svg
|
||||||
|
[releases]: https://esphome.io/changelog/index.html
|
||||||
|
[repository]: https://github.com/esphome/esphome
|
75
template/config.yaml
Normal file
75
template/config.yaml
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
---
|
||||||
|
base: &base
|
||||||
|
url: https://esphome.io/
|
||||||
|
webui: 'http://[HOST]:[PORT:6052]'
|
||||||
|
startup: application
|
||||||
|
boot: auto
|
||||||
|
arch:
|
||||||
|
- amd64
|
||||||
|
- i386
|
||||||
|
- armv7
|
||||||
|
- aarch64
|
||||||
|
# Uses Hass.io API (auth)
|
||||||
|
hassio_api: true
|
||||||
|
auth_api: true
|
||||||
|
hassio_role: default
|
||||||
|
# Doesn't use HA API
|
||||||
|
homeassistant_api: false
|
||||||
|
# Host network mode for mDNS
|
||||||
|
host_network: true
|
||||||
|
# Ingress settings
|
||||||
|
ingress: true
|
||||||
|
ingress_port: 0
|
||||||
|
panel_icon: 'mdi:chip'
|
||||||
|
# Automatically add UART devices to addon
|
||||||
|
auto_uart: true
|
||||||
|
ports:
|
||||||
|
'6052/tcp': null
|
||||||
|
ports_description:
|
||||||
|
'6052/tcp': "Web interface (Not required for Hass.io Ingress)"
|
||||||
|
map:
|
||||||
|
- ssl
|
||||||
|
- config:rw
|
||||||
|
schema:
|
||||||
|
ssl: bool?
|
||||||
|
certfile: str?
|
||||||
|
keyfile: str?
|
||||||
|
leave_front_door_open: bool?
|
||||||
|
esphome_version: str?
|
||||||
|
streamer_mode: bool?
|
||||||
|
relative_url: str?
|
||||||
|
status_use_ping: bool?
|
||||||
|
base_image: esphome/esphome-hassio-base-{arch}:1.5.1
|
||||||
|
|
||||||
|
esphome-dev:
|
||||||
|
<<: *base
|
||||||
|
directory: esphome-dev
|
||||||
|
name: ESPHome (dev)
|
||||||
|
version: dev
|
||||||
|
slug: esphome-dev2
|
||||||
|
description: "Development Version! Manage and program ESP8266/ESP32 microcontrollers through YAML configuration files"
|
||||||
|
options:
|
||||||
|
esphome_version: dev
|
||||||
|
|
||||||
|
esphome-beta:
|
||||||
|
<<: *base
|
||||||
|
directory: esphome-beta
|
||||||
|
name: ESPHome (beta)
|
||||||
|
version: 1.12.2
|
||||||
|
description: "Beta version of ESPHome Hass.io add-on."
|
||||||
|
image: esphome/esphome-hassio-{arch}
|
||||||
|
options: {}
|
||||||
|
|
||||||
|
esphome-stable:
|
||||||
|
<<: *base
|
||||||
|
directory: esphome
|
||||||
|
name: ESPHome
|
||||||
|
version: 1.12.2
|
||||||
|
description: "ESPHome Hass.io add-on for intelligently managing all your ESP8266/ESP32 devices."
|
||||||
|
image: esphome/esphome-hassio-{arch}
|
||||||
|
options: {}
|
||||||
|
|
||||||
|
copy_files:
|
||||||
|
icon.png:
|
||||||
|
logo.png:
|
||||||
|
README.md:
|
BIN
template/icon.png
Normal file
BIN
template/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.4 KiB |
BIN
template/logo.png
Normal file
BIN
template/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
Loading…
Reference in New Issue
Block a user