Ask users for a pin when interacting with locks/garage doors (#23223)
* Ask users for a pin when interacting with locks/garage doors * Deprecate allow_unlock option
This commit is contained in:
parent
416af5cf57
commit
0533f56fe3
15 changed files with 290 additions and 138 deletions
|
@ -1,4 +1,5 @@
|
|||
"""Errors for Google Assistant."""
|
||||
from .const import ERR_CHALLENGE_NEEDED
|
||||
|
||||
|
||||
class SmartHomeError(Exception):
|
||||
|
@ -11,3 +12,31 @@ class SmartHomeError(Exception):
|
|||
"""Log error code."""
|
||||
super().__init__(msg)
|
||||
self.code = code
|
||||
|
||||
def to_response(self):
|
||||
"""Convert to a response format."""
|
||||
return {
|
||||
'errorCode': self.code
|
||||
}
|
||||
|
||||
|
||||
class ChallengeNeeded(SmartHomeError):
|
||||
"""Google Assistant Smart Home errors.
|
||||
|
||||
https://developers.google.com/actions/smarthome/create-app#error_responses
|
||||
"""
|
||||
|
||||
def __init__(self, challenge_type):
|
||||
"""Initialize challenge needed error."""
|
||||
super().__init__(ERR_CHALLENGE_NEEDED,
|
||||
'Challenge needed: {}'.format(challenge_type))
|
||||
self.challenge_type = challenge_type
|
||||
|
||||
def to_response(self):
|
||||
"""Convert to a response format."""
|
||||
return {
|
||||
'errorCode': self.code,
|
||||
'challengeNeeded': {
|
||||
'type': self.challenge_type
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue