Add energy validation (#54567)

This commit is contained in:
Paulus Schoutsen 2021-08-18 11:21:51 -07:00 committed by GitHub
parent 6d0ce814e7
commit 2f77b5025c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 765 additions and 1 deletions

View file

@ -18,6 +18,7 @@ from .data import (
EnergyPreferencesUpdate,
async_get_manager,
)
from .validate import async_validate
EnergyWebSocketCommandHandler = Callable[
[HomeAssistant, websocket_api.ActiveConnection, Dict[str, Any], "EnergyManager"],
@ -35,6 +36,7 @@ def async_setup(hass: HomeAssistant) -> None:
websocket_api.async_register_command(hass, ws_get_prefs)
websocket_api.async_register_command(hass, ws_save_prefs)
websocket_api.async_register_command(hass, ws_info)
websocket_api.async_register_command(hass, ws_validate)
def _ws_with_manager(
@ -113,3 +115,18 @@ def ws_info(
) -> None:
"""Handle get info command."""
connection.send_result(msg["id"], hass.data[DOMAIN])
@websocket_api.websocket_command(
{
vol.Required("type"): "energy/validate",
}
)
@websocket_api.async_response
async def ws_validate(
hass: HomeAssistant,
connection: websocket_api.ActiveConnection,
msg: dict,
) -> None:
"""Handle validate command."""
connection.send_result(msg["id"], (await async_validate(hass)).as_dict())