Binary Sensor for Remote UI & Fix timezone (#22076)

* Binary Sensor for Remote UI

* Fix lint

* Revert make hass public

* Add tests
This commit is contained in:
Pascal Vizeli 2019-03-15 18:39:53 +01:00 committed by Paulus Schoutsen
parent 9520d38288
commit 17ba33004c
7 changed files with 124 additions and 6 deletions

View file

@ -6,15 +6,18 @@ from typing import Any, Dict
import aiohttp
from hass_nabucasa.client import CloudClient as Interface
from homeassistant.core import callback
from homeassistant.components.alexa import smart_home as alexa_sh
from homeassistant.components.google_assistant import (
helpers as ga_h, smart_home as ga)
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
from homeassistant.helpers.typing import HomeAssistantType
from homeassistant.helpers.dispatcher import async_dispatcher_send
from homeassistant.util.aiohttp import MockRequest
from . import utils
from .const import CONF_ENTITY_CONFIG, CONF_FILTER, DOMAIN
from .const import (
CONF_ENTITY_CONFIG, CONF_FILTER, DOMAIN, DISPATCHER_REMOTE_UPDATE)
from .prefs import CloudPreferences
@ -115,13 +118,19 @@ class CloudClient(Interface):
self._alexa_config = None
self._google_config = None
async def async_user_message(
self, identifier: str, title: str, message: str) -> None:
@callback
def user_message(self, identifier: str, title: str, message: str) -> None:
"""Create a message for user to UI."""
self._hass.components.persistent_notification.async_create(
message, title, identifier
)
@callback
def dispatcher_message(self, identifier: str, data: Any = None) -> None:
"""Match cloud notification to dispatcher."""
if identifier.startwith("remote_"):
async_dispatcher_send(self._hass, DISPATCHER_REMOTE_UPDATE, data)
async def async_alexa_message(
self, payload: Dict[Any, Any]) -> Dict[Any, Any]:
"""Process cloud alexa message to client."""