Google Actions for Assistant (#9632)
* http: Add headers key to json[_message] * Add google_assistant component This component provides API endpoints for the Actions on Google Smart Home API to interact with Google Assistant. * google_assistant: Re-add fan support * google_assistant: Fix Scene handling - The way I originally wrote the MAPPING_COMPONENT and the way it's actual used changed so the comment was updated to match that. - Use const's in more places - Handle the ActivateScene command correctly * google_assistant: Fix flakey compare test Was failing on 3.4.2 and 3.5, this is more correct anyway. * google_assistant: Use volume attr for media_player
This commit is contained in:
1 parent
1d68777981
commit
9d20a53d63
9 files changed
+996
-4
No files matched your search
@@ -358,19 +358,21 @@ class HomeAssistantView(object):
|
||||
requires_auth = True # Views inheriting from this class can override this
|
||||
|
||||
# pylint: disable=no-self-use
|
||||
def json(self, result, status_code=200):
|
||||
def json(self, result, status_code=200, headers=None):
|
||||
"""Return a JSON response."""
|
||||
msg = json.dumps(
|
||||
result, sort_keys=True, cls=rem.JSONEncoder).encode('UTF-8')
|
||||
return web.Response(
|
||||
body=msg, content_type=CONTENT_TYPE_JSON, status=status_code)
|
||||
body=msg, content_type=CONTENT_TYPE_JSON, status=status_code,
|
||||
headers=headers)
|
||||
|
||||
def json_message(self, message, status_code=200, message_code=None):
|
||||
def json_message(self, message, status_code=200, message_code=None,
|
||||
headers=None):
|
||||
"""Return a JSON message response."""
|
||||
data = {'message': message}
|
||||
if message_code is not None:
|
||||
data['code'] = message_code
|
||||
return self.json(data, status_code)
|
||||
return self.json(data, status_code, headers=headers)
|
||||
|
||||
@asyncio.coroutine
|
||||
# pylint: disable=no-self-use
|
||||
|
||||
Reference in new issue
Block a user