Add support for locks in google assistant component (#18233)
* Add support for locks in google assistant component This is supported by the smarthome API, but there is no documentation for it. This work is based on an article I found with screenshots of documentation that was erroneously uploaded: https://www.androidpolice.com/2018/01/17/google-assistant-home-can-now-natively-control-smart-locks-august-vivint-first-supported/ Google Assistant now supports unlocking certain locks - Nest and August come to mind - via this API, and this commit allows Home Assistant to do so as well. Notably, I've added a config option `allow_unlock` that controls whether we actually honor requests to unlock a lock via the google assistant. It defaults to false. Additionally, we add the functionNotSupported error, which makes a little more sense when we're unable to execute the desired state transition. https://developers.google.com/actions/reference/smarthome/errors-exceptions#exception_list * Fix linter warnings * Ensure that certain groups are never exposed to cloud entities For example, the group.all_locks entity - we should probably never expose this to third party cloud integrations. It's risky. This is not configurable, but can be extended by adding to the cloud.const.NEVER_EXPOSED_ENTITIES array. It's implemented in a modestly hacky fashion, because we determine whether or not a entity should be excluded/included in several ways. Notably, we define this array in the top level const.py, to avoid circular import problems between the cloud/alexa components.
This commit is contained in:
parent
ddee5f8b86
commit
2bf2214d51
14 changed files with 283 additions and 43 deletions
|
@ -8,7 +8,8 @@ import pytest
|
|||
|
||||
from homeassistant import core, const, setup
|
||||
from homeassistant.components import (
|
||||
fan, cover, light, switch, climate, async_setup, media_player)
|
||||
fan, cover, light, switch, climate, lock, async_setup, media_player)
|
||||
from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES
|
||||
from homeassistant.components import google_assistant as ga
|
||||
|
||||
from . import DEMO_DEVICES
|
||||
|
@ -96,6 +97,13 @@ def hass_fixture(loop, hass):
|
|||
}]
|
||||
}))
|
||||
|
||||
loop.run_until_complete(
|
||||
setup.async_setup_component(hass, lock.DOMAIN, {
|
||||
'lock': [{
|
||||
'platform': 'demo'
|
||||
}]
|
||||
}))
|
||||
|
||||
return hass
|
||||
|
||||
|
||||
|
@ -116,6 +124,9 @@ def test_sync_request(hass_fixture, assistant_client, auth_header):
|
|||
sorted([dev['id'] for dev in devices])
|
||||
== sorted([dev['id'] for dev in DEMO_DEVICES]))
|
||||
|
||||
for dev in devices:
|
||||
assert dev['id'] not in CLOUD_NEVER_EXPOSED_ENTITIES
|
||||
|
||||
for dev, demo in zip(
|
||||
sorted(devices, key=lambda d: d['id']),
|
||||
sorted(DEMO_DEVICES, key=lambda d: d['id'])):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue