mirror of
https://github.com/aljazceru/addons.git
synced 2025-12-17 13:14:21 +01:00
* Update config.json * Update CHANGELOG.md * Update config.json * Update run.sh * Update hassio_gassistant.py
33 lines
845 B
Python
33 lines
845 B
Python
"""Hass.IO Google Assistant."""
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import google.oauth2.credentials
|
|
|
|
from google.assistant.library import Assistant
|
|
from google.assistant.library.event import EventType
|
|
|
|
|
|
def process_event(event):
|
|
if event.type == EventType.ON_CONVERSATION_TURN_STARTED:
|
|
print()
|
|
|
|
print(event)
|
|
|
|
if (event.type == EventType.ON_CONVERSATION_TURN_FINISHED and event.args and not event.args['with_follow_on_turn']):
|
|
print()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
cred_json = Path(sys.argv[1])
|
|
|
|
# open credentials
|
|
with cred_json.open('r') as data:
|
|
credentials = google.oauth2.credentials.Credentials(token=None, **json.load(data))
|
|
|
|
# run assistant
|
|
with Assistant(credentials, sys.argv[2]) as assistant:
|
|
for event in assistant.start():
|
|
process_event(event)
|