Cloud: Add Alexa report state (#24536)

* Cloud: Add Alexa report state

* Lint

* Lint

* Only track state changes when we are logged in
This commit is contained in:
Paulus Schoutsen authored and GitHub committed 2019-06-17 13:50:01 -07:00
1 parent 5ab1996d3f
commit a02b69db38
17 files changed
+207 -33

No files matched your search

@@ -25,6 +25,7 @@ class AlexaConfig(AbstractConfig):
def __init__(self, hass, config):
"""Initialize Alexa config."""
super().__init__(hass)
self._config = config
if config.get(CONF_CLIENT_ID) and config.get(CONF_CLIENT_SECRET):
@@ -38,6 +39,11 @@ class AlexaConfig(AbstractConfig):
"""Return if config supports auth."""
return self._auth is not None
@property
def should_report_state(self):
"""Return if we should proactively report states."""
return self._auth is not None
@property
def endpoint(self):
"""Endpoint for report state."""
@@ -73,7 +79,7 @@ async def async_setup(hass, config):
smart_home_config = AlexaConfig(hass, config)
hass.http.register_view(SmartHomeView(smart_home_config))
if smart_home_config.supports_auth:
if smart_home_config.should_report_state:
await async_enable_proactive_mode(hass, smart_home_config)