mirror of
https://github.com/home-assistant/core.git
synced 2025-07-25 22:27:07 +00:00
Rename experimental UI to lovelace (#15065)
* Rename experimental UI to lovelace * Bump frontend to 20180620.0
This commit is contained in:
parent
a729742757
commit
895306f822
@ -21,11 +21,12 @@ from homeassistant.components import websocket_api
|
|||||||
from homeassistant.config import find_config_file, load_yaml_config_file
|
from homeassistant.config import find_config_file, load_yaml_config_file
|
||||||
from homeassistant.const import CONF_NAME, EVENT_THEMES_UPDATED
|
from homeassistant.const import CONF_NAME, EVENT_THEMES_UPDATED
|
||||||
from homeassistant.core import callback
|
from homeassistant.core import callback
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.helpers.translation import async_get_translations
|
from homeassistant.helpers.translation import async_get_translations
|
||||||
from homeassistant.loader import bind_hass
|
from homeassistant.loader import bind_hass
|
||||||
from homeassistant.util.yaml import load_yaml
|
from homeassistant.util.yaml import load_yaml
|
||||||
|
|
||||||
REQUIREMENTS = ['home-assistant-frontend==20180619.0']
|
REQUIREMENTS = ['home-assistant-frontend==20180620.0']
|
||||||
|
|
||||||
DOMAIN = 'frontend'
|
DOMAIN = 'frontend'
|
||||||
DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log']
|
DEPENDENCIES = ['api', 'websocket_api', 'http', 'system_log']
|
||||||
@ -106,9 +107,9 @@ SCHEMA_GET_TRANSLATIONS = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
|
|||||||
vol.Required('type'): WS_TYPE_GET_TRANSLATIONS,
|
vol.Required('type'): WS_TYPE_GET_TRANSLATIONS,
|
||||||
vol.Required('language'): str,
|
vol.Required('language'): str,
|
||||||
})
|
})
|
||||||
WS_TYPE_GET_EXPERIMENTAL_UI = 'frontend/experimental_ui'
|
WS_TYPE_GET_LOVELACE_UI = 'frontend/lovelace_config'
|
||||||
SCHEMA_GET_EXPERIMENTAL_UI = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
|
SCHEMA_GET_LOVELACE_UI = websocket_api.BASE_COMMAND_MESSAGE_SCHEMA.extend({
|
||||||
vol.Required('type'): WS_TYPE_GET_EXPERIMENTAL_UI,
|
vol.Required('type'): WS_TYPE_GET_LOVELACE_UI,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
@ -216,8 +217,8 @@ async def async_setup(hass, config):
|
|||||||
WS_TYPE_GET_TRANSLATIONS, websocket_get_translations,
|
WS_TYPE_GET_TRANSLATIONS, websocket_get_translations,
|
||||||
SCHEMA_GET_TRANSLATIONS)
|
SCHEMA_GET_TRANSLATIONS)
|
||||||
hass.components.websocket_api.async_register_command(
|
hass.components.websocket_api.async_register_command(
|
||||||
WS_TYPE_GET_EXPERIMENTAL_UI, websocket_experimental_config,
|
WS_TYPE_GET_LOVELACE_UI, websocket_lovelace_config,
|
||||||
SCHEMA_GET_EXPERIMENTAL_UI)
|
SCHEMA_GET_LOVELACE_UI)
|
||||||
hass.http.register_view(ManifestJSONView)
|
hass.http.register_view(ManifestJSONView)
|
||||||
|
|
||||||
conf = config.get(DOMAIN, {})
|
conf = config.get(DOMAIN, {})
|
||||||
@ -265,7 +266,7 @@ async def async_setup(hass, config):
|
|||||||
await asyncio.wait(
|
await asyncio.wait(
|
||||||
[async_register_built_in_panel(hass, panel) for panel in (
|
[async_register_built_in_panel(hass, panel) for panel in (
|
||||||
'dev-event', 'dev-info', 'dev-service', 'dev-state',
|
'dev-event', 'dev-info', 'dev-service', 'dev-state',
|
||||||
'dev-template', 'dev-mqtt', 'kiosk', 'experimental-ui')],
|
'dev-template', 'dev-mqtt', 'kiosk', 'lovelace')],
|
||||||
loop=hass.loop)
|
loop=hass.loop)
|
||||||
|
|
||||||
hass.data[DATA_FINALIZE_PANEL] = async_finalize_panel
|
hass.data[DATA_FINALIZE_PANEL] = async_finalize_panel
|
||||||
@ -499,15 +500,26 @@ def websocket_get_translations(hass, connection, msg):
|
|||||||
hass.async_add_job(send_translations())
|
hass.async_add_job(send_translations())
|
||||||
|
|
||||||
|
|
||||||
def websocket_experimental_config(hass, connection, msg):
|
def websocket_lovelace_config(hass, connection, msg):
|
||||||
"""Send experimental UI config over websocket config."""
|
"""Send lovelace UI config over websocket config."""
|
||||||
async def send_exp_config():
|
async def send_exp_config():
|
||||||
"""Send experimental frontend config."""
|
"""Send lovelace frontend config."""
|
||||||
|
error = None
|
||||||
|
try:
|
||||||
config = await hass.async_add_job(
|
config = await hass.async_add_job(
|
||||||
load_yaml, hass.config.path('experimental-ui.yaml'))
|
load_yaml, hass.config.path('ui-lovelace.yaml'))
|
||||||
|
message = websocket_api.result_message(
|
||||||
connection.send_message_outside(websocket_api.result_message(
|
|
||||||
msg['id'], config
|
msg['id'], config
|
||||||
))
|
)
|
||||||
|
except FileNotFoundError:
|
||||||
|
error = ('file_not_found',
|
||||||
|
'Could not find ui-lovelace.yaml in your config dir.')
|
||||||
|
except HomeAssistantError as err:
|
||||||
|
error = 'load_error', str(err)
|
||||||
|
|
||||||
|
if error is not None:
|
||||||
|
message = websocket_api.error_message(msg['id'], *error)
|
||||||
|
|
||||||
|
connection.send_message_outside(message)
|
||||||
|
|
||||||
hass.async_add_job(send_exp_config())
|
hass.async_add_job(send_exp_config())
|
||||||
|
@ -415,7 +415,7 @@ hole==0.3.0
|
|||||||
holidays==0.9.5
|
holidays==0.9.5
|
||||||
|
|
||||||
# homeassistant.components.frontend
|
# homeassistant.components.frontend
|
||||||
home-assistant-frontend==20180619.0
|
home-assistant-frontend==20180620.0
|
||||||
|
|
||||||
# homeassistant.components.homekit_controller
|
# homeassistant.components.homekit_controller
|
||||||
# homekit==0.6
|
# homekit==0.6
|
||||||
|
@ -81,7 +81,7 @@ hbmqtt==0.9.2
|
|||||||
holidays==0.9.5
|
holidays==0.9.5
|
||||||
|
|
||||||
# homeassistant.components.frontend
|
# homeassistant.components.frontend
|
||||||
home-assistant-frontend==20180619.0
|
home-assistant-frontend==20180620.0
|
||||||
|
|
||||||
# homeassistant.components.influxdb
|
# homeassistant.components.influxdb
|
||||||
# homeassistant.components.sensor.influxdb
|
# homeassistant.components.sensor.influxdb
|
||||||
|
1
tests/components/frontend/__init__.py
Normal file
1
tests/components/frontend/__init__.py
Normal file
@ -0,0 +1 @@
|
|||||||
|
"""Tests for the frontend component."""
|
@ -5,6 +5,7 @@ from unittest.mock import patch
|
|||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
from homeassistant.exceptions import HomeAssistantError
|
||||||
from homeassistant.setup import async_setup_component
|
from homeassistant.setup import async_setup_component
|
||||||
from homeassistant.components.frontend import (
|
from homeassistant.components.frontend import (
|
||||||
DOMAIN, CONF_JS_VERSION, CONF_THEMES, CONF_EXTRA_HTML_URL,
|
DOMAIN, CONF_JS_VERSION, CONF_THEMES, CONF_EXTRA_HTML_URL,
|
||||||
@ -280,8 +281,8 @@ async def test_get_translations(hass, hass_ws_client):
|
|||||||
assert msg['result'] == {'resources': {'lang': 'nl'}}
|
assert msg['result'] == {'resources': {'lang': 'nl'}}
|
||||||
|
|
||||||
|
|
||||||
async def test_experimental_ui(hass, hass_ws_client):
|
async def test_lovelace_ui(hass, hass_ws_client):
|
||||||
"""Test experimental_ui command."""
|
"""Test lovelace_ui command."""
|
||||||
await async_setup_component(hass, 'frontend')
|
await async_setup_component(hass, 'frontend')
|
||||||
client = await hass_ws_client(hass)
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
@ -289,7 +290,7 @@ async def test_experimental_ui(hass, hass_ws_client):
|
|||||||
return_value={'hello': 'world'}):
|
return_value={'hello': 'world'}):
|
||||||
await client.send_json({
|
await client.send_json({
|
||||||
'id': 5,
|
'id': 5,
|
||||||
'type': 'frontend/experimental_ui',
|
'type': 'frontend/lovelace_config',
|
||||||
})
|
})
|
||||||
msg = await client.receive_json()
|
msg = await client.receive_json()
|
||||||
|
|
||||||
@ -297,3 +298,41 @@ async def test_experimental_ui(hass, hass_ws_client):
|
|||||||
assert msg['type'] == wapi.TYPE_RESULT
|
assert msg['type'] == wapi.TYPE_RESULT
|
||||||
assert msg['success']
|
assert msg['success']
|
||||||
assert msg['result'] == {'hello': 'world'}
|
assert msg['result'] == {'hello': 'world'}
|
||||||
|
|
||||||
|
|
||||||
|
async def test_lovelace_ui_not_found(hass, hass_ws_client):
|
||||||
|
"""Test lovelace_ui command cannot find file."""
|
||||||
|
await async_setup_component(hass, 'frontend')
|
||||||
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
with patch('homeassistant.components.frontend.load_yaml',
|
||||||
|
side_effect=FileNotFoundError):
|
||||||
|
await client.send_json({
|
||||||
|
'id': 5,
|
||||||
|
'type': 'frontend/lovelace_config',
|
||||||
|
})
|
||||||
|
msg = await client.receive_json()
|
||||||
|
|
||||||
|
assert msg['id'] == 5
|
||||||
|
assert msg['type'] == wapi.TYPE_RESULT
|
||||||
|
assert msg['success'] is False
|
||||||
|
assert msg['error']['code'] == 'file_not_found'
|
||||||
|
|
||||||
|
|
||||||
|
async def test_lovelace_ui_load_err(hass, hass_ws_client):
|
||||||
|
"""Test lovelace_ui command cannot find file."""
|
||||||
|
await async_setup_component(hass, 'frontend')
|
||||||
|
client = await hass_ws_client(hass)
|
||||||
|
|
||||||
|
with patch('homeassistant.components.frontend.load_yaml',
|
||||||
|
side_effect=HomeAssistantError):
|
||||||
|
await client.send_json({
|
||||||
|
'id': 5,
|
||||||
|
'type': 'frontend/lovelace_config',
|
||||||
|
})
|
||||||
|
msg = await client.receive_json()
|
||||||
|
|
||||||
|
assert msg['id'] == 5
|
||||||
|
assert msg['type'] == wapi.TYPE_RESULT
|
||||||
|
assert msg['success'] is False
|
||||||
|
assert msg['error']['code'] == 'load_error'
|
Loading…
x
Reference in New Issue
Block a user