From 168eaca4d62008f23e56bbef3b0255d35f8cf0a6 Mon Sep 17 00:00:00 2001 From: Pascal Vizeli Date: Thu, 10 May 2018 18:07:10 +0200 Subject: [PATCH] Update Google Assistant SDK 0.5.0 (#298) * Update Dockerfile * Update config.json * Update CHANGELOG.md * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update Dockerfile * Update run.sh * Update hassio_gassistant.py * Update config.json * Update hassio_gassistant.py * Update hassio_gassistant.py * Update build.json * Update CHANGELOG.md --- google_assistant/CHANGELOG.md | 5 +++++ google_assistant/Dockerfile | 9 +++++++-- google_assistant/build.json | 4 ++-- google_assistant/config.json | 4 ++-- google_assistant/hassio_gassistant.py | 11 ++++++++--- google_assistant/run.sh | 1 + 6 files changed, 25 insertions(+), 9 deletions(-) diff --git a/google_assistant/CHANGELOG.md b/google_assistant/CHANGELOG.md index bcc9d39..3ec0c88 100644 --- a/google_assistant/CHANGELOG.md +++ b/google_assistant/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 2.0 +- Update Google Assistant SDK 0.5.0 +- Update Google Assistant Library 1.0.0 +- Revert base images + ## 1.5 - Change event handling diff --git a/google_assistant/Dockerfile b/google_assistant/Dockerfile index 2143fa5..6edca67 100644 --- a/google_assistant/Dockerfile +++ b/google_assistant/Dockerfile @@ -3,9 +3,14 @@ FROM $BUILD_FROM # Install packages RUN apt-get update \ - && apt-get install -y \ + && apt-get install -y --no-install-recommends \ jq tzdata python3 python3-dev python3-pip libportaudio2 alsa-utils \ - && pip3 install google-assistant-library google-auth requests_oauthlib cherrypy \ + && pip3 install --no-cache-dir --upgrade setuptools \ + && pip3 install --no-cache-dir \ + google-assistant-library==1.0.0 \ + google-assistant-sdk==0.5.0 \ + google-assistant-grpc==0.2.0 \ + google-auth requests_oauthlib cherrypy \ && apt-get remove -y --purge python3-pip python3-dev \ && apt-get clean -y \ && rm -rf /var/lib/apt/lists/* diff --git a/google_assistant/build.json b/google_assistant/build.json index af48e00..67c2c9d 100644 --- a/google_assistant/build.json +++ b/google_assistant/build.json @@ -1,6 +1,6 @@ { "build_from": { - "armhf": "multiarch/ubuntu-core:armhf-xenial", - "amd64": "multiarch/ubuntu-core:amd64-xenial" + "armhf": "multiarch/debian-debootstrap:armhf-stretch", + "amd64": "multiarch/debian-debootstrap:amd64-stretch" } } diff --git a/google_assistant/config.json b/google_assistant/config.json index ae60100..9fc7529 100644 --- a/google_assistant/config.json +++ b/google_assistant/config.json @@ -1,6 +1,6 @@ { - "name": "Google Assistant", - "version": "1.5", + "name": "Google Assistant SDK", + "version": "2.0", "slug": "google_assistant", "description": "A virtual personal assistant developed by Google", "url": "https://home-assistant.io/addons/google_assistant/", diff --git a/google_assistant/hassio_gassistant.py b/google_assistant/hassio_gassistant.py index fde2904..8dabbce 100644 --- a/google_assistant/hassio_gassistant.py +++ b/google_assistant/hassio_gassistant.py @@ -27,21 +27,24 @@ if __name__ == '__main__': device_json = Path(DEVICE_CONFIG) # open credentials + print("OAth with Google") with cred_json.open('r') as data: credentials = google.oauth2.credentials.Credentials(token=None, **json.load(data)) # Read device info + print("Initialize device infos") if device_json.exists(): with device_json.open('r') as data: device_info = json.load(data) - device_model_id = device_config['model_id'] - last_device_id = device_config.get('last_device_id', None) + device_model_id = device_info['model_id'] + last_device_id = device_info.get('last_device_id', None) else: device_model_id = sys.argv[3] last_device_id = None # run assistant + print("Run Google Assistant SDK") with Assistant(credentials, device_model_id) as assistant: events = assistant.start() device_id = assistant.device_id @@ -58,5 +61,7 @@ if __name__ == '__main__': 'model_id': device_model_id, }, dev_file) - for event in event: + for event in events: process_event(event) + + print("Close Google Assistant SDK") diff --git a/google_assistant/run.sh b/google_assistant/run.sh index 82f4e81..272a024 100644 --- a/google_assistant/run.sh +++ b/google_assistant/run.sh @@ -23,4 +23,5 @@ elif [ ! -f "$CRED_JSON" ]; then exit 1 fi +echo "[Info] Run Hass.io GAssisant SDK" exec python3 /hassio_gassistant.py "$CRED_JSON" "$PROJECT_ID" "$MODEL_ID" < /dev/null