mirror of
https://github.com/esphome/esphome.git
synced 2024-11-21 22:48:10 +01:00
Change most references from hassio to ha-addon (#3178)
This commit is contained in:
parent
e7dd6c52ac
commit
5c22065135
24 changed files with 42 additions and 36 deletions
4
.github/workflows/release.yml
vendored
4
.github/workflows/release.yml
vendored
|
@ -137,7 +137,7 @@ jobs:
|
||||||
--build-type "${{ matrix.build_type }}" \
|
--build-type "${{ matrix.build_type }}" \
|
||||||
manifest
|
manifest
|
||||||
|
|
||||||
deploy-hassio-repo:
|
deploy-ha-addon-repo:
|
||||||
if: github.repository == 'esphome/esphome' && github.event_name == 'release'
|
if: github.repository == 'esphome/esphome' && github.event_name == 'release'
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
needs: [deploy-docker]
|
needs: [deploy-docker]
|
||||||
|
@ -150,5 +150,5 @@ jobs:
|
||||||
-u ":$TOKEN" \
|
-u ":$TOKEN" \
|
||||||
-X POST \
|
-X POST \
|
||||||
-H "Accept: application/vnd.github.v3+json" \
|
-H "Accept: application/vnd.github.v3+json" \
|
||||||
https://api.github.com/repos/esphome/hassio/actions/workflows/bump-version.yml/dispatches \
|
https://api.github.com/repos/esphome/home-assistant-addon/actions/workflows/bump-version.yml/dispatches \
|
||||||
-d "{\"ref\":\"main\",\"inputs\":{\"version\":\"$TAG\"}}"
|
-d "{\"ref\":\"main\",\"inputs\":{\"version\":\"$TAG\"}}"
|
||||||
|
|
|
@ -102,7 +102,7 @@ RUN \
|
||||||
ARG BUILD_VERSION=dev
|
ARG BUILD_VERSION=dev
|
||||||
|
|
||||||
# Copy root filesystem
|
# Copy root filesystem
|
||||||
COPY docker/hassio-rootfs/ /
|
COPY docker/ha-addon-rootfs/ /
|
||||||
|
|
||||||
# First install requirements to leverage caching when requirements don't change
|
# First install requirements to leverage caching when requirements don't change
|
||||||
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
COPY requirements.txt requirements_optional.txt docker/platformio_install_deps.py platformio.ini /
|
||||||
|
|
|
@ -10,7 +10,7 @@ server {
|
||||||
ssl_certificate_key /ssl/%%keyfile%%;
|
ssl_certificate_key /ssl/%%keyfile%%;
|
||||||
|
|
||||||
# Clear Hass.io Ingress header
|
# Clear Hass.io Ingress header
|
||||||
proxy_set_header X-Hassio-Ingress "";
|
proxy_set_header X-HA-Ingress "";
|
||||||
|
|
||||||
# Redirect http requests to https on the same port.
|
# Redirect http requests to https on the same port.
|
||||||
# https://rageagainstshell.com/2016/11/redirect-http-to-https-on-the-same-port-in-nginx/
|
# https://rageagainstshell.com/2016/11/redirect-http-to-https-on-the-same-port-in-nginx/
|
|
@ -4,7 +4,7 @@ server {
|
||||||
include /etc/nginx/includes/server_params.conf;
|
include /etc/nginx/includes/server_params.conf;
|
||||||
include /etc/nginx/includes/proxy_params.conf;
|
include /etc/nginx/includes/proxy_params.conf;
|
||||||
# Clear Hass.io Ingress header
|
# Clear Hass.io Ingress header
|
||||||
proxy_set_header X-Hassio-Ingress "";
|
proxy_set_header X-HA-Ingress "";
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
proxy_pass http://esphome;
|
proxy_pass http://esphome;
|
|
@ -3,8 +3,8 @@ server {
|
||||||
|
|
||||||
include /etc/nginx/includes/server_params.conf;
|
include /etc/nginx/includes/server_params.conf;
|
||||||
include /etc/nginx/includes/proxy_params.conf;
|
include /etc/nginx/includes/proxy_params.conf;
|
||||||
# Set Hass.io Ingress header
|
# Set Home Assistant Ingress header
|
||||||
proxy_set_header X-Hassio-Ingress "YES";
|
proxy_set_header X-HA-Ingress "YES";
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
# Only allow from Hass.io supervisor
|
# Only allow from Hass.io supervisor
|
|
@ -4,7 +4,7 @@
|
||||||
# Runs the ESPHome dashboard
|
# Runs the ESPHome dashboard
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
export ESPHOME_IS_HASSIO=true
|
export ESPHOME_IS_HA_ADDON=true
|
||||||
|
|
||||||
if bashio::config.true 'leave_front_door_open'; then
|
if bashio::config.true 'leave_front_door_open'; then
|
||||||
export DISABLE_HA_AUTHENTICATION=true
|
export DISABLE_HA_AUTHENTICATION=true
|
||||||
|
@ -32,4 +32,4 @@ export PLATFORMIO_CACHE_DIR="${pio_cache_base}/cache"
|
||||||
export PLATFORMIO_GLOBALLIB_DIR=/piolibs
|
export PLATFORMIO_GLOBALLIB_DIR=/piolibs
|
||||||
|
|
||||||
bashio::log.info "Starting ESPHome dashboard..."
|
bashio::log.info "Starting ESPHome dashboard..."
|
||||||
exec esphome dashboard /config/esphome --socket /var/run/esphome.sock --hassio
|
exec esphome dashboard /config/esphome --socket /var/run/esphome.sock --ha-addon
|
|
@ -661,7 +661,7 @@ def parse_args(argv):
|
||||||
"--open-ui", help="Open the dashboard UI in a browser.", action="store_true"
|
"--open-ui", help="Open the dashboard UI in a browser.", action="store_true"
|
||||||
)
|
)
|
||||||
parser_dashboard.add_argument(
|
parser_dashboard.add_argument(
|
||||||
"--hassio", help=argparse.SUPPRESS, action="store_true"
|
"--ha-addon", help=argparse.SUPPRESS, action="store_true"
|
||||||
)
|
)
|
||||||
parser_dashboard.add_argument(
|
parser_dashboard.add_argument(
|
||||||
"--socket", help="Make the dashboard serve under a unix socket", type=str
|
"--socket", help="Make the dashboard serve under a unix socket", type=str
|
||||||
|
|
|
@ -20,7 +20,7 @@ from esphome.coroutine import FakeEventLoop as _FakeEventLoop
|
||||||
|
|
||||||
# pylint: disable=unused-import
|
# pylint: disable=unused-import
|
||||||
from esphome.coroutine import coroutine, coroutine_with_priority # noqa
|
from esphome.coroutine import coroutine, coroutine_with_priority # noqa
|
||||||
from esphome.helpers import ensure_unique_string, is_hassio
|
from esphome.helpers import ensure_unique_string, is_ha_addon
|
||||||
from esphome.util import OrderedDict
|
from esphome.util import OrderedDict
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
|
@ -568,12 +568,12 @@ class EsphomeCore:
|
||||||
return self.relative_build_path("src", *path)
|
return self.relative_build_path("src", *path)
|
||||||
|
|
||||||
def relative_pioenvs_path(self, *path):
|
def relative_pioenvs_path(self, *path):
|
||||||
if is_hassio():
|
if is_ha_addon():
|
||||||
return os.path.join("/data", self.name, ".pioenvs", *path)
|
return os.path.join("/data", self.name, ".pioenvs", *path)
|
||||||
return self.relative_build_path(".pioenvs", *path)
|
return self.relative_build_path(".pioenvs", *path)
|
||||||
|
|
||||||
def relative_piolibdeps_path(self, *path):
|
def relative_piolibdeps_path(self, *path):
|
||||||
if is_hassio():
|
if is_ha_addon():
|
||||||
return os.path.join("/data", self.name, ".piolibdeps", *path)
|
return os.path.join("/data", self.name, ".piolibdeps", *path)
|
||||||
return self.relative_build_path(".piolibdeps", *path)
|
return self.relative_build_path(".piolibdeps", *path)
|
||||||
|
|
||||||
|
|
|
@ -55,13 +55,13 @@ class DashboardSettings:
|
||||||
self.password_hash = ""
|
self.password_hash = ""
|
||||||
self.username = ""
|
self.username = ""
|
||||||
self.using_password = False
|
self.using_password = False
|
||||||
self.on_hassio = False
|
self.on_ha_addon = False
|
||||||
self.cookie_secret = None
|
self.cookie_secret = None
|
||||||
|
|
||||||
def parse_args(self, args):
|
def parse_args(self, args):
|
||||||
self.on_hassio = args.hassio
|
self.on_ha_addon = args.ha_addon
|
||||||
password = args.password or os.getenv("PASSWORD", "")
|
password = args.password or os.getenv("PASSWORD", "")
|
||||||
if not self.on_hassio:
|
if not self.on_ha_addon:
|
||||||
self.username = args.username or os.getenv("USERNAME", "")
|
self.username = args.username or os.getenv("USERNAME", "")
|
||||||
self.using_password = bool(password)
|
self.using_password = bool(password)
|
||||||
if self.using_password:
|
if self.using_password:
|
||||||
|
@ -77,14 +77,14 @@ class DashboardSettings:
|
||||||
return get_bool_env("ESPHOME_DASHBOARD_USE_PING")
|
return get_bool_env("ESPHOME_DASHBOARD_USE_PING")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def using_hassio_auth(self):
|
def using_ha_addon_auth(self):
|
||||||
if not self.on_hassio:
|
if not self.on_ha_addon:
|
||||||
return False
|
return False
|
||||||
return not get_bool_env("DISABLE_HA_AUTHENTICATION")
|
return not get_bool_env("DISABLE_HA_AUTHENTICATION")
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def using_auth(self):
|
def using_auth(self):
|
||||||
return self.using_password or self.using_hassio_auth
|
return self.using_password or self.using_ha_addon_auth
|
||||||
|
|
||||||
def check_password(self, username, password):
|
def check_password(self, username, password):
|
||||||
if not self.using_auth:
|
if not self.using_auth:
|
||||||
|
@ -138,10 +138,10 @@ def authenticated(func):
|
||||||
|
|
||||||
|
|
||||||
def is_authenticated(request_handler):
|
def is_authenticated(request_handler):
|
||||||
if settings.on_hassio:
|
if settings.on_ha_addon:
|
||||||
# Handle ingress - disable auth on ingress port
|
# Handle ingress - disable auth on ingress port
|
||||||
# X-Hassio-Ingress is automatically stripped on the non-ingress server in nginx
|
# X-HA-Ingress is automatically stripped on the non-ingress server in nginx
|
||||||
header = request_handler.request.headers.get("X-Hassio-Ingress", "NO")
|
header = request_handler.request.headers.get("X-HA-Ingress", "NO")
|
||||||
if str(header) == "YES":
|
if str(header) == "YES":
|
||||||
return True
|
return True
|
||||||
if settings.using_auth:
|
if settings.using_auth:
|
||||||
|
@ -792,23 +792,23 @@ class LoginHandler(BaseHandler):
|
||||||
self.render(
|
self.render(
|
||||||
"login.template.html",
|
"login.template.html",
|
||||||
error=error,
|
error=error,
|
||||||
hassio=settings.using_hassio_auth,
|
ha_addon=settings.using_ha_addon_auth,
|
||||||
has_username=bool(settings.username),
|
has_username=bool(settings.username),
|
||||||
**template_args(),
|
**template_args(),
|
||||||
)
|
)
|
||||||
|
|
||||||
def post_hassio_login(self):
|
def post_ha_addon_login(self):
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
"X-HASSIO-KEY": os.getenv("HASSIO_TOKEN"),
|
"Authentication": f"Bearer {os.getenv('SUPERVISOR_TOKEN')}",
|
||||||
}
|
}
|
||||||
data = {
|
data = {
|
||||||
"username": self.get_argument("username", ""),
|
"username": self.get_argument("username", ""),
|
||||||
"password": self.get_argument("password", ""),
|
"password": self.get_argument("password", ""),
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
req = requests.post("http://hassio/auth", headers=headers, data=data)
|
req = requests.post("http://supervisor/auth", headers=headers, data=data)
|
||||||
if req.status_code == 200:
|
if req.status_code == 200:
|
||||||
self.set_secure_cookie("authenticated", cookie_authenticated_yes)
|
self.set_secure_cookie("authenticated", cookie_authenticated_yes)
|
||||||
self.redirect("/")
|
self.redirect("/")
|
||||||
|
@ -835,8 +835,8 @@ class LoginHandler(BaseHandler):
|
||||||
self.render_login_page(error=error_str)
|
self.render_login_page(error=error_str)
|
||||||
|
|
||||||
def post(self):
|
def post(self):
|
||||||
if settings.using_hassio_auth:
|
if settings.using_ha_addon_auth:
|
||||||
self.post_hassio_login()
|
self.post_ha_addon_login()
|
||||||
else:
|
else:
|
||||||
self.post_native_login()
|
self.post_native_login()
|
||||||
|
|
||||||
|
|
|
@ -144,8 +144,8 @@ def get_bool_env(var, default=False):
|
||||||
return bool(os.getenv(var, default))
|
return bool(os.getenv(var, default))
|
||||||
|
|
||||||
|
|
||||||
def is_hassio():
|
def is_ha_addon():
|
||||||
return get_bool_env("ESPHOME_IS_HASSIO")
|
return get_bool_env("ESPHOME_IS_HA_ADDON")
|
||||||
|
|
||||||
|
|
||||||
def walk_files(path):
|
def walk_files(path):
|
||||||
|
|
|
@ -9,7 +9,7 @@ pyserial==3.5
|
||||||
platformio==5.2.4 # When updating platformio, also update Dockerfile
|
platformio==5.2.4 # When updating platformio, also update Dockerfile
|
||||||
esptool==3.2
|
esptool==3.2
|
||||||
click==8.0.3
|
click==8.0.3
|
||||||
esphome-dashboard==20220116.0
|
esphome-dashboard==20220209.0
|
||||||
aioesphomeapi==10.8.1
|
aioesphomeapi==10.8.1
|
||||||
zeroconf==0.37.0
|
zeroconf==0.37.0
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,13 @@ def lint_ext_check(fname):
|
||||||
|
|
||||||
|
|
||||||
@lint_file_check(
|
@lint_file_check(
|
||||||
exclude=["**.sh", "docker/hassio-rootfs/**", "docker/*.py", "script/*", "setup.py"]
|
exclude=[
|
||||||
|
"**.sh",
|
||||||
|
"docker/ha-addon-rootfs/**",
|
||||||
|
"docker/*.py",
|
||||||
|
"script/*",
|
||||||
|
"setup.py",
|
||||||
|
]
|
||||||
)
|
)
|
||||||
def lint_executable_bit(fname):
|
def lint_executable_bit(fname):
|
||||||
ex = EXECUTABLE_BIT[fname]
|
ex = EXECUTABLE_BIT[fname]
|
||||||
|
|
|
@ -124,13 +124,13 @@ def test_get_bool_env(monkeypatch, var, value, default, expected):
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize("value, expected", ((None, False), ("Yes", True)))
|
@pytest.mark.parametrize("value, expected", ((None, False), ("Yes", True)))
|
||||||
def test_is_hassio(monkeypatch, value, expected):
|
def test_is_ha_addon(monkeypatch, value, expected):
|
||||||
if value is None:
|
if value is None:
|
||||||
monkeypatch.delenv("ESPHOME_IS_HASSIO", raising=False)
|
monkeypatch.delenv("ESPHOME_IS_HA_ADDON", raising=False)
|
||||||
else:
|
else:
|
||||||
monkeypatch.setenv("ESPHOME_IS_HASSIO", value)
|
monkeypatch.setenv("ESPHOME_IS_HA_ADDON", value)
|
||||||
|
|
||||||
actual = helpers.is_hassio()
|
actual = helpers.is_ha_addon()
|
||||||
|
|
||||||
assert actual == expected
|
assert actual == expected
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue