Allow hassio frontend development (#14675)
* Allow hassio frontend development * Fix tests
This commit is contained in:
1 parent
d36c7c3de7
commit
8c7f0669c6
2 files changed
+36
-8
No files matched your search
@@ -28,6 +28,15 @@ _LOGGER = logging.getLogger(__name__)
|
||||
DOMAIN = 'hassio'
|
||||
DEPENDENCIES = ['http']
|
||||
|
||||
CONF_FRONTEND_REPO = 'development_repo'
|
||||
|
||||
CONFIG_SCHEMA = vol.Schema({
|
||||
vol.Optional(DOMAIN): vol.Schema({
|
||||
vol.Optional(CONF_FRONTEND_REPO): cv.isdir,
|
||||
}),
|
||||
}, extra=vol.ALLOW_EXTRA)
|
||||
|
||||
|
||||
DATA_HOMEASSISTANT_VERSION = 'hassio_hass_version'
|
||||
HASSIO_UPDATE_INTERVAL = timedelta(minutes=55)
|
||||
|
||||
@@ -142,7 +151,13 @@ def async_setup(hass, config):
|
||||
try:
|
||||
host = os.environ['HASSIO']
|
||||
except KeyError:
|
||||
_LOGGER.error("No Hass.io supervisor detect")
|
||||
_LOGGER.error("Missing HASSIO environment variable.")
|
||||
return False
|
||||
|
||||
try:
|
||||
os.environ['HASSIO_TOKEN']
|
||||
except KeyError:
|
||||
_LOGGER.error("Missing HASSIO_TOKEN environment variable.")
|
||||
return False
|
||||
|
||||
websession = hass.helpers.aiohttp_client.async_get_clientsession()
|
||||
@@ -152,6 +167,13 @@ def async_setup(hass, config):
|
||||
_LOGGER.error("Not connected with Hass.io")
|
||||
return False
|
||||
|
||||
# This overrides the normal API call that would be forwarded
|
||||
development_repo = config.get(DOMAIN, {}).get(CONF_FRONTEND_REPO)
|
||||
if development_repo is not None:
|
||||
hass.http.register_static_path(
|
||||
'/api/hassio/app-es5',
|
||||
os.path.join(development_repo, 'hassio/build-es5'), False)
|
||||
|
||||
hass.http.register_view(HassIOView(host, websession))
|
||||
|
||||
if 'frontend' in hass.config.components:
|
||||
|
||||
Reference in new issue
Block a user