Added switch for TestMode in plugin settings

Used hashin <package> for requirements.txt
Added dpkg files for smartcar package
This commit is contained in:
Paul Bot 2021-07-09 18:09:41 +03:00 committed by Michael Zanetti
parent 30d5315d1f
commit 5bbc3644c0
5 changed files with 48 additions and 6 deletions

16
debian/control vendored
View File

@ -749,6 +749,22 @@ Description: nymea.io plugin for Solar-Log
This package will install the nymea.io plugin for Solar-Log.
Package: nymea-plugin-smartcar
Architecture: any
Depends: ${shlibs:Depends},
${misc:Depends},
nymea-plugins-translations,
python3-pip,
Description: nymea.io plugin for smartcar
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 Smartcar (see https://smartcar.com/).
Package: nymea-plugin-tasmota
Architecture: any
Depends: ${shlibs:Depends},

View File

@ -0,0 +1,3 @@
smartcar/integrationpluginsmartcar.json usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/smartcar/
smartcar/integrationpluginsmartcar.py usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/smartcar/
smartcar/requirements.txt usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/smartcar/

View File

@ -3,6 +3,13 @@
"displayName": "Smartcar",
"id": "f33bb38d-640e-4b15-a39e-f0e7b2cc6993",
"paramTypes": [
{
"id": "70e2c7a1-55b4-47fd-83b5-549de30b1391",
"name": "testMode",
"displayName": "Test Mode",
"type": "bool",
"defaultValue": false
},
{
"id": "bb5ee037-5034-4921-b1d8-3936bc515fa6",
"name": "customClientId",

View File

@ -117,12 +117,15 @@ def createSmartcarClient():
clientSecret = apiKey.data("clientSecret")
redirectUri = "https://127.0.0.1:8888"
testMode = configValue(smartcarPluginTestModeParamTypeId)
logger.log("Test mode enabled: ", testMode)
smartcarClient = smartcar.AuthClient(
client_id=clientId,
client_secret=clientSecret,
redirect_uri=redirectUri,
scope=['required:read_vehicle_info', 'required:read_battery', 'required:read_charge'],
test_mode=True
test_mode=testMode
)
return smartcarClient
@ -200,5 +203,11 @@ def getAccessToken(client, thingId):
if smartcar.is_expired(expiration_date_time_obj):
token = client.exchange_refresh_token(token['refresh_token'])
saveToken(thingId, token)
return token['access_token']
return token['access_token']
def configValueChanged(paramTypeId, value):
if paramTypeId == smartcarPluginTestModeParamTypeId:
logger.log("Test mode enabled changed to: ", value)
#should retrigger a setup somehow here

View File

@ -1,4 +1,11 @@
Flask==1.0.2
flask-cors==3.0.9
requests==2.20.1
smartcar==5.2.1
Flask==1.0.2 \
--hash=sha256:2271c0070dbcb5275fad4a82e29f23ab92682dc45f9dfbc22c02ba9b9322ce48 \
--hash=sha256:a080b744b7e345ccfcbc77954861cb05b3c63786e93f2b3875e0913d44b43f05
Flask-Cors==3.0.9 \
--hash=sha256:6bcfc100288c5d1bcb1dbb854babd59beee622ffd321e444b05f24d6d58466b8 \
--hash=sha256:cee4480aaee421ed029eaa788f4049e3e26d15b5affb6a880dade6bafad38324
requests==2.20.1 \
--hash=sha256:65b3a120e4329e33c9889db89c80976c5272f56ea92d3e74da8a463992e3ff54 \
--hash=sha256:ea881206e59f41dbd0bd445437d792e43906703fff75ca8ff43ccdb11f33f263
smartcar==5.2.1 \
--hash=sha256:ee296d917b5fcf3f756737fb87a158558b0beaa5f0c5626de6a7c10f493ff957