2017-10-18 05:00:59 +00:00
|
|
|
"""Constants for Google Assistant."""
|
2019-04-18 05:37:39 +00:00
|
|
|
from homeassistant.components import (
|
|
|
|
binary_sensor,
|
|
|
|
camera,
|
|
|
|
climate,
|
|
|
|
cover,
|
|
|
|
fan,
|
|
|
|
group,
|
|
|
|
input_boolean,
|
|
|
|
light,
|
|
|
|
lock,
|
|
|
|
media_player,
|
|
|
|
scene,
|
|
|
|
script,
|
|
|
|
switch,
|
|
|
|
vacuum,
|
|
|
|
)
|
2017-10-18 05:00:59 +00:00
|
|
|
DOMAIN = 'google_assistant'
|
|
|
|
|
|
|
|
GOOGLE_ASSISTANT_API_ENDPOINT = '/api/google_assistant'
|
|
|
|
|
2018-01-09 23:14:56 +00:00
|
|
|
CONF_EXPOSE = 'expose'
|
|
|
|
CONF_ENTITY_CONFIG = 'entity_config'
|
2017-10-18 05:00:59 +00:00
|
|
|
CONF_EXPOSE_BY_DEFAULT = 'expose_by_default'
|
|
|
|
CONF_EXPOSED_DOMAINS = 'exposed_domains'
|
|
|
|
CONF_PROJECT_ID = 'project_id'
|
|
|
|
CONF_ALIASES = 'aliases'
|
2017-11-13 16:32:23 +00:00
|
|
|
CONF_API_KEY = 'api_key'
|
2018-02-22 23:24:41 +00:00
|
|
|
CONF_ROOM_HINT = 'room'
|
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.
2018-11-06 09:39:10 +00:00
|
|
|
CONF_ALLOW_UNLOCK = 'allow_unlock'
|
2019-04-19 21:50:21 +00:00
|
|
|
CONF_SECURE_DEVICES_PIN = 'secure_devices_pin'
|
2017-10-18 05:00:59 +00:00
|
|
|
|
|
|
|
DEFAULT_EXPOSE_BY_DEFAULT = True
|
|
|
|
DEFAULT_EXPOSED_DOMAINS = [
|
2018-10-22 18:07:11 +00:00
|
|
|
'climate', 'cover', 'fan', 'group', 'input_boolean', 'light',
|
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.
2018-11-06 09:39:10 +00:00
|
|
|
'media_player', 'scene', 'script', 'switch', 'vacuum', 'lock',
|
2019-04-24 02:19:23 +00:00
|
|
|
'binary_sensor', 'sensor'
|
2017-10-18 05:00:59 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
PREFIX_TYPES = 'action.devices.types.'
|
2019-03-23 16:16:43 +00:00
|
|
|
TYPE_CAMERA = PREFIX_TYPES + 'CAMERA'
|
2017-10-18 05:00:59 +00:00
|
|
|
TYPE_LIGHT = PREFIX_TYPES + 'LIGHT'
|
|
|
|
TYPE_SWITCH = PREFIX_TYPES + 'SWITCH'
|
2018-10-26 21:02:07 +00:00
|
|
|
TYPE_VACUUM = PREFIX_TYPES + 'VACUUM'
|
2017-10-18 05:00:59 +00:00
|
|
|
TYPE_SCENE = PREFIX_TYPES + 'SCENE'
|
2018-10-28 13:53:47 +00:00
|
|
|
TYPE_FAN = PREFIX_TYPES + 'FAN'
|
2017-11-01 14:44:59 +00:00
|
|
|
TYPE_THERMOSTAT = PREFIX_TYPES + 'THERMOSTAT'
|
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.
2018-11-06 09:39:10 +00:00
|
|
|
TYPE_LOCK = PREFIX_TYPES + 'LOCK'
|
2019-03-30 03:51:47 +00:00
|
|
|
TYPE_BLINDS = PREFIX_TYPES + 'BLINDS'
|
2019-04-15 20:05:53 +00:00
|
|
|
TYPE_GARAGE = PREFIX_TYPES + 'GARAGE'
|
2019-04-17 00:07:14 +00:00
|
|
|
TYPE_OUTLET = PREFIX_TYPES + 'OUTLET'
|
2019-04-18 05:37:39 +00:00
|
|
|
TYPE_SENSOR = PREFIX_TYPES + 'SENSOR'
|
2019-04-24 02:25:20 +00:00
|
|
|
TYPE_DOOR = PREFIX_TYPES + 'DOOR'
|
2017-11-13 16:32:23 +00:00
|
|
|
|
|
|
|
SERVICE_REQUEST_SYNC = 'request_sync'
|
|
|
|
HOMEGRAPH_URL = 'https://homegraph.googleapis.com/'
|
|
|
|
REQUEST_SYNC_BASE_URL = HOMEGRAPH_URL + 'v1/devices:requestSync'
|
2018-03-08 22:39:10 +00:00
|
|
|
|
|
|
|
# Error codes used for SmartHomeError class
|
2019-04-19 21:50:21 +00:00
|
|
|
# https://developers.google.com/actions/reference/smarthome/errors-exceptions
|
2018-03-08 22:39:10 +00:00
|
|
|
ERR_DEVICE_OFFLINE = "deviceOffline"
|
|
|
|
ERR_DEVICE_NOT_FOUND = "deviceNotFound"
|
|
|
|
ERR_VALUE_OUT_OF_RANGE = "valueOutOfRange"
|
|
|
|
ERR_NOT_SUPPORTED = "notSupported"
|
|
|
|
ERR_PROTOCOL_ERROR = 'protocolError'
|
|
|
|
ERR_UNKNOWN_ERROR = 'unknownError'
|
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.
2018-11-06 09:39:10 +00:00
|
|
|
ERR_FUNCTION_NOT_SUPPORTED = 'functionNotSupported'
|
2019-02-27 19:33:34 +00:00
|
|
|
|
2019-04-19 21:50:21 +00:00
|
|
|
ERR_CHALLENGE_NEEDED = 'challengeNeeded'
|
|
|
|
ERR_CHALLENGE_NOT_SETUP = 'challengeFailedNotSetup'
|
|
|
|
ERR_TOO_MANY_FAILED_ATTEMPTS = 'tooManyFailedAttempts'
|
|
|
|
ERR_PIN_INCORRECT = 'pinIncorrect'
|
|
|
|
ERR_USER_CANCELLED = 'userCancelled'
|
|
|
|
|
2019-02-27 19:33:34 +00:00
|
|
|
# Event types
|
2019-03-04 21:18:16 +00:00
|
|
|
EVENT_COMMAND_RECEIVED = 'google_assistant_command'
|
|
|
|
EVENT_QUERY_RECEIVED = 'google_assistant_query'
|
|
|
|
EVENT_SYNC_RECEIVED = 'google_assistant_sync'
|
2019-04-18 05:37:39 +00:00
|
|
|
|
|
|
|
DOMAIN_TO_GOOGLE_TYPES = {
|
|
|
|
camera.DOMAIN: TYPE_CAMERA,
|
|
|
|
climate.DOMAIN: TYPE_THERMOSTAT,
|
|
|
|
cover.DOMAIN: TYPE_BLINDS,
|
|
|
|
fan.DOMAIN: TYPE_FAN,
|
|
|
|
group.DOMAIN: TYPE_SWITCH,
|
|
|
|
input_boolean.DOMAIN: TYPE_SWITCH,
|
|
|
|
light.DOMAIN: TYPE_LIGHT,
|
|
|
|
lock.DOMAIN: TYPE_LOCK,
|
|
|
|
media_player.DOMAIN: TYPE_SWITCH,
|
|
|
|
scene.DOMAIN: TYPE_SCENE,
|
|
|
|
script.DOMAIN: TYPE_SCENE,
|
|
|
|
switch.DOMAIN: TYPE_SWITCH,
|
|
|
|
vacuum.DOMAIN: TYPE_VACUUM,
|
|
|
|
}
|
|
|
|
|
|
|
|
DEVICE_CLASS_TO_GOOGLE_TYPES = {
|
|
|
|
(cover.DOMAIN, cover.DEVICE_CLASS_GARAGE): TYPE_GARAGE,
|
2019-04-24 02:25:20 +00:00
|
|
|
(cover.DOMAIN, cover.DEVICE_CLASS_DOOR): TYPE_DOOR,
|
2019-04-18 05:37:39 +00:00
|
|
|
(switch.DOMAIN, switch.DEVICE_CLASS_SWITCH): TYPE_SWITCH,
|
|
|
|
(switch.DOMAIN, switch.DEVICE_CLASS_OUTLET): TYPE_OUTLET,
|
2019-04-24 02:25:20 +00:00
|
|
|
(binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_DOOR): TYPE_DOOR,
|
2019-04-18 05:37:39 +00:00
|
|
|
(binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_GARAGE_DOOR):
|
2019-04-24 16:56:22 +00:00
|
|
|
TYPE_GARAGE,
|
2019-04-18 05:37:39 +00:00
|
|
|
(binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_LOCK): TYPE_SENSOR,
|
|
|
|
(binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_OPENING): TYPE_SENSOR,
|
|
|
|
(binary_sensor.DOMAIN, binary_sensor.DEVICE_CLASS_WINDOW): TYPE_SENSOR,
|
|
|
|
}
|
2019-04-19 21:50:21 +00:00
|
|
|
|
|
|
|
CHALLENGE_ACK_NEEDED = 'ackNeeded'
|
|
|
|
CHALLENGE_PIN_NEEDED = 'pinNeeded'
|
|
|
|
CHALLENGE_FAILED_PIN_NEEDED = 'challengeFailedPinNeeded'
|