From 6aa9256052ada430ca1e880c3d9aba754f22842b Mon Sep 17 00:00:00 2001 From: "bernhard.trinnes" Date: Tue, 15 Sep 2020 14:41:54 +0200 Subject: [PATCH] added google calender --- debian/control | 15 ++++++ debian/nymea-plugin-google.install.in | 3 ++ google/google.pro | 4 ++ google/integrationplugingoogle.json | 50 +++++++++++++++++ google/integrationplugingoogle.py | 77 +++++++++++++++++++++++++++ google/requirements.txt | 15 ++++++ nymea-plugins.pro | 1 + 7 files changed, 165 insertions(+) create mode 100644 debian/nymea-plugin-google.install.in create mode 100644 google/google.pro create mode 100644 google/integrationplugingoogle.json create mode 100755 google/integrationplugingoogle.py create mode 100644 google/requirements.txt diff --git a/debian/control b/debian/control index ab8e6238..e7098a82 100644 --- a/debian/control +++ b/debian/control @@ -278,6 +278,21 @@ Description: nymea integration plugin for Garadget This package contains the nymea integration plugin for Garadget Garage Door Opener +Package: nymea-plugin-google +Architecture: any +Depends: ${misc:Depends}, + nymea-plugins-translations, + python3-pip, +Description: nymea.io plugin for Google services + The nymea daemon is a plugin based IoT (Internet of Things) server. The + server works like a translator for devices, things and services and + allows them to interact. + With the powerful rule engine you are able to connect any device available + in the system and create individual scenes and behaviors for your environment. + . + This package will install the nymea.io plugin for Google services + + Package: nymea-plugin-gpio Architecture: any Depends: ${shlibs:Depends}, diff --git a/debian/nymea-plugin-google.install.in b/debian/nymea-plugin-google.install.in new file mode 100644 index 00000000..ee7508d2 --- /dev/null +++ b/debian/nymea-plugin-google.install.in @@ -0,0 +1,3 @@ +google/integrationplugingoogle.json usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/google/ +google/integrationplugingoogle.py usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/google/ +google/requirements.txt usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/google/ diff --git a/google/google.pro b/google/google.pro new file mode 100644 index 00000000..9e1ea0b2 --- /dev/null +++ b/google/google.pro @@ -0,0 +1,4 @@ +TEMPLATE = aux + +OTHER_FILES = integrationplugingoogle.py \ + integrationplugingoogle.json diff --git a/google/integrationplugingoogle.json b/google/integrationplugingoogle.json new file mode 100644 index 00000000..2ca009fb --- /dev/null +++ b/google/integrationplugingoogle.json @@ -0,0 +1,50 @@ +{ + "id": "", + "name": "google", + "displayName": "Google services", + "vendors": [ + { + "id": "", + "name": "google", + "displayName": "Google", + "thingClasses": [ + { + "id": "", + "name": "account", + "displayName": "Account", + "createMethods": [""], + "setupMethod": "", + "interfaces": ["account"], + "stateTypes": [ + { + "id": "", + "name": "connected", + "displayName": "Connected", + "displayNameEvent": "Connected changed", + "type": "bool", + "cached": false, + "defaultValue": false + }, + { + "id": "", + "name": "username", + "displayName": "Username", + "displayNameEvent": "Username changed", + "type": "QString", + "defaultValue": "-" + }, + { + "id": "", + "name": "loggedIn", + "displayName": "Logged in", + "displayNameEvent": "Logged in changed", + "type": "bool", + "defaultValue": false, + "cached": false + } + ] + } + ] + } + ] +} diff --git a/google/integrationplugingoogle.py b/google/integrationplugingoogle.py new file mode 100755 index 00000000..d170de08 --- /dev/null +++ b/google/integrationplugingoogle.py @@ -0,0 +1,77 @@ +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # +# +# Copyright 2013 - 2020, nymea GmbH +# Contact: contact@nymea.io +# +# This file is part of nymea. +# This project including source code and documentation is protected by +# copyright law, and remains the property of nymea GmbH. All rights, including +# reproduction, publication, editing and translation, are reserved. The use of +# this project is subject to the terms of a license agreement to be concluded +# with nymea GmbH in accordance with the terms of use of nymea GmbH, available +# under https://nymea.io/license +# +# GNU Lesser General Public License Usage +# Alternatively, this project may be redistributed and/or modified under the +# terms of the GNU Lesser General Public License as published by the Free +# Software Foundation; version 3. This project is distributed in the hope that +# it will be useful, but WITHOUT ANY WARRANTY; without even the implied +# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with this project. If not, see . +# +# For any further details and any questions please contact us under +# contact@nymea.io or see our FAQ/Licensing Information on +# https://nymea.io/license/faq +# +# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # + +import nymea +import datetime +import pickle +import os.path +from googleapiclient.discovery import build +from google_auth_oauthlib.flow import InstalledAppFlow +from google.auth.transport.requests import Request + +timers = {} + +def init(): + logger.log("google init") + + +def deinit(): + for timer in timers: + timers[timer].cancel() + +def discoverThings(info): + info.finish(nymea.ThingErrorNoError) + +def setupThing(info): + logger.log("setupThing", info.thing.name) + info.thing.nameChangedHandler = nameChanged + timers[info.thing] = threading.Timer(10, runTestForever, [info.thing]) + timers[info.thing].start() + info.finish(nymea.ThingErrorNoError) + +def postSetupThing(thing): + logger.log("postSetupThing", thing) + + +def nameChanged(thing): + logger.log("Thing name changed:", thing.name) + + +def thingRemoved(thing): + logger.log("thingRemoved:", thing.name) + timers[thing].cancel() + del timers[thing] + + +def executeAction(info): + logger.log("executeAction") + if info.actionTypeId == speedtestRunTestActionTypeId: + info.finish(nymea.ThingErrorNoError) + runTest(info.thing, duration=info.paramValue(speedtestRunTestActionDurationParamTypeId)) diff --git a/google/requirements.txt b/google/requirements.txt new file mode 100644 index 00000000..8cea8274 --- /dev/null +++ b/google/requirements.txt @@ -0,0 +1,15 @@ + +fastdotcom==0.0.3 \ + --hash=sha256:84647d665119cfbef01bf785607b85d7a29353208605ca53a4155c331e407cd6 \ + --hash=sha256:c77689b5595e0ef89d60d5d3a2f669ef2f158d2868fda65e1201d91b53e013b3 +requests==2.24.0 \ + --hash=sha256:b3559a131db72c33ee969480840fff4bb6dd111de7dd27c8ee1f820f4f00231b \ + --hash=sha256:fe75cc94a9443b9246fc7049224f75604b113c36acb93f87b80ed42c44cbb898 +certifi==2017.4.17 \ + --hash=sha256:f4318671072f030a33c7ca6acaef720ddd50ff124d1388e50c1bda4cbd6d7010 +idna==2.10 \ + --hash=sha256:b97d804b1e9b523befed77c48dacec60e6dcb0b5391d57af6a65a312a90648c0 +chardet==3.0.4 \ + --hash=sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691 +urllib3==1.25.10 \ + --hash=sha256:e7983572181f5e1522d9c98453462384ee92a0be7fac5f1413a1e35c56cc0461 diff --git a/nymea-plugins.pro b/nymea-plugins.pro index b2b754f8..69c122b3 100644 --- a/nymea-plugins.pro +++ b/nymea-plugins.pro @@ -28,6 +28,7 @@ PLUGIN_DIRS = \ fronius \ garadget \ goecharger \ + google \ gpio \ i2cdevices \ httpcommander \