Merge PR #313: New Plugin: Fastcom

master
Jenkins nymea 2020-11-02 18:47:56 +01:00
commit c5b4048095
12 changed files with 319 additions and 0 deletions

16
debian/control vendored
View File

@ -276,6 +276,22 @@ Description: nymea.io plugin for elgato
This package will install the nymea.io plugin for elgato
Package: nymea-plugin-fastcom
Architecture: any
Depends: ${misc:Depends},
nymea-plugins-translations,
python3-pip,
Description: nymea.io plugin for fast.com based internet speed test
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 performing ineternet speed
tests using fast.com
Package: nymea-plugin-flowercare
Architecture: any
Depends: ${shlibs:Depends},

View File

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

6
fastcom/README.md Normal file
View File

@ -0,0 +1,6 @@
# Fast.com
A nymea plugin to monitor your internet connection speed using fast.com servers.
The speed test can be triggered manually, or configured to automatically run after
a specified interval.

4
fastcom/fastcom.pro Normal file
View File

@ -0,0 +1,4 @@
TEMPLATE = aux
OTHER_FILES = integrationpluginfastcom.py \
integrationpluginfastcom.json

1
fastcom/fastcom.svg Normal file
View File

@ -0,0 +1 @@
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 141.15 129.19"><defs><style>.cls-1{fill:#e50914;}</style></defs><title>Fast_Logo_Stacked_Black_RGB</title><path class="cls-1" d="M250.15,226.91v9.5a19.78,19.78,0,0,1,20.38,20.44H280A29.24,29.24,0,0,0,250.15,226.91ZM286,221a49.53,49.53,0,0,0-35.23-14.65h-0.59v10.16a39.66,39.66,0,0,1,40.21,40.33h10.16c0-.2,0-0.39,0-0.59A49.53,49.53,0,0,0,286,221Z" transform="translate(-179.53 -186.34)"/><path class="cls-1" d="M179.53,256.82a70.57,70.57,0,0,1,141.15,0v7.38h-19v-7.3h9.39v-0.08a61,61,0,0,0-121.91,0v0.08h9.39v7.3h-19v-7.38Z" transform="translate(-179.53 -186.34)"/><path d="M255.22,250.7l-5-54.66-5,54.66A8,8,0,1,0,255.22,250.7Z" transform="translate(-179.53 -186.34)"/><path d="M188.52,282.26V291H208v8.17H188.52v15.82h-9V274.09h31.11v8.17H188.52Z" transform="translate(-179.53 -186.34)"/><path d="M241.08,314.95l-3.74-9.16H220.07l-3.74,9.16h-9.16l17.51-41.15H233l17.51,41.15h-9.4ZM228.71,284.6l-5.43,13.25h10.86Z" transform="translate(-179.53 -186.34)"/><path d="M269.27,315.53A26,26,0,0,1,251.93,309l5.31-6.36c3.68,3,7.53,5,12.2,5,3.68,0,5.9-1.46,5.9-3.85v-0.12c0-2.28-1.4-3.44-8.23-5.19-8.23-2.1-13.54-4.38-13.54-12.49v-0.12c0-7.41,6-12.32,14.3-12.32A23.65,23.65,0,0,1,283,278.7l-4.67,6.77c-3.62-2.51-7.18-4-10.62-4S262.5,283,262.5,285v0.12c0,2.68,1.75,3.56,8.81,5.37,8.29,2.16,13,5.14,13,12.26v0.12C284.27,311,278.08,315.53,269.27,315.53Z" transform="translate(-179.53 -186.34)"/><path d="M308.25,282.38v32.57h-9V282.38H286.82v-8.29h33.85v8.29H308.25Z" transform="translate(-179.53 -186.34)"/></svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -0,0 +1,83 @@
{
"id": "142bdfae-43b1-4915-8906-99949e0a6f85",
"name": "fastcom",
"displayName": "fast.com speed test",
"vendors": [
{
"id": "8ff41f1e-0aa4-4b86-a959-2c54dc9c716c",
"name": "fastcom",
"displayName": "fast.com",
"thingClasses": [
{
"id": "dcd2d320-18b2-4655-8188-dd46a1c27360",
"name": "speedtest",
"displayName": "Internet connection speed test",
"createMethods": ["user"],
"setupMethod": "justAdd",
"settingsTypes": [
{
"id": "12646890-9335-4c4e-ada2-ac9e603c4f2c",
"name": "interval",
"displayName": "Interval for speed tests",
"type": "uint",
"unit": "Minutes",
"defaultValue": 60
}
],
"eventTypes": [
{
"id": "c29dcc25-40b1-4db8-a8ad-6552b2813ee8",
"name": "testCompleted",
"displayName": "Test run completed",
"paramTypes": [
{
"id": "3d101deb-a3b7-451c-ad07-02ff38afd617",
"name": "result",
"displayName": "Test result",
"type": "double",
"defaultValue": 0
}
]
}
],
"stateTypes": [
{
"id": "07c2bddd-6e5c-4fa0-a114-9393adb6cb65",
"name": "lastResult",
"displayName": "Last result",
"displayNameEvent": "Last result changed",
"type": "double",
"defaultValue": 0
},
{
"id": "9ad90ce5-3d66-4469-8d04-4e6bfc132db4",
"name": "testRunning",
"displayName": "Test is running",
"displayNameEvent": "Test started or stopped",
"type": "bool",
"defaultValue": false,
"cached": false
}
],
"actionTypes": [
{
"id": "7f77a7cf-3ba1-4119-959d-9d652449d1fb",
"name": "runTest",
"displayName": "Run test",
"paramTypes": [
{
"id": "af5f3b43-2c60-4330-a82d-20b98fac9096",
"name": "duration",
"displayName": "Duration",
"type": "int",
"unit": "Seconds",
"defaultValue": 15
}
]
}
]
}
]
}
]
}

View File

@ -0,0 +1,91 @@
# 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 <https://www.gnu.org/licenses/>.
#
# 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
from fastdotcom import fast_com
import threading
timers = {}
def init():
logger.log("fast.com init")
def deinit():
for timer in timers:
timers[timer].cancel()
def setupThing(info):
logger.log("setupThing", info.thing.name, "Scheduling speed test in 10 seconds.")
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:
if info.thing.stateValue(speedtestTestRunningStateTypeId) == True:
info.finish(nymea.ThingErrorThingInUse, "A speed test is already running")
return
info.finish(nymea.ThingErrorNoError)
runTest(info.thing, duration=info.paramValue(speedtestRunTestActionDurationParamTypeId))
def runTest(thing, duration=10):
logger.log("Running speed test for:", thing.name, "with maximum duration", duration)
thing.setStateValue(speedtestTestRunningStateTypeId, True)
result = fast_com(maxtime=duration, verbose=True)
thing.setStateValue(speedtestLastResultStateTypeId, result)
logger.log("Speed test result:", result)
thing.setStateValue(speedtestTestRunningStateTypeId, False)
param = nymea.Param(speedtestTestCompletedEventResultParamTypeId, result)
params = [param]
thing.emitEvent(speedtestTestCompletedEventTypeId, params)
logger.log("all done")
def runTestForever(thing):
del timers[thing]
runTest(thing)
logger.log("Running next test in %i minutes." % thing.settings[0].value)
timers[thing] = threading.Timer(thing.settings[0].value * 60, runTestForever, [thing])
timers[thing].start()

13
fastcom/meta.json Normal file
View File

@ -0,0 +1,13 @@
{
"title": "fast.com",
"tagline": "Monitor your internet connection speed",
"icon": "fastcom.svg",
"stability": "consumer",
"offline": false,
"technologies": [
"cloud"
],
"categories": [
"online-service"
]
}

15
fastcom/requirements.txt Normal file
View File

@ -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

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE TS>
<TS version="2.1">
<context>
<name>fastcom</name>
<message>
<location filename="../bla.h" line="34"/>
<source>Duration</source>
<extracomment>The name of the ParamType (ThingClass: speedtest, ActionType: runTest, ID: {af5f3b43-2c60-4330-a82d-20b98fac9096})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="37"/>
<source>Internet connection speed test</source>
<extracomment>The name of the ThingClass ({dcd2d320-18b2-4655-8188-dd46a1c27360})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="40"/>
<source>Interval for speed tests</source>
<extracomment>The name of the ParamType (ThingClass: speedtest, Type: settings, ID: {12646890-9335-4c4e-ada2-ac9e603c4f2c})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="43"/>
<location filename="../bla.h" line="46"/>
<source>Last result</source>
<extracomment>The name of the ParamType (ThingClass: speedtest, EventType: lastResult, ID: {07c2bddd-6e5c-4fa0-a114-9393adb6cb65})
----------
The name of the StateType ({07c2bddd-6e5c-4fa0-a114-9393adb6cb65}) of ThingClass speedtest</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="49"/>
<source>Last result changed</source>
<extracomment>The name of the EventType ({07c2bddd-6e5c-4fa0-a114-9393adb6cb65}) of ThingClass speedtest</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="52"/>
<source>Run test</source>
<extracomment>The name of the ActionType ({7f77a7cf-3ba1-4119-959d-9d652449d1fb}) of ThingClass speedtest</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="55"/>
<location filename="../bla.h" line="58"/>
<source>Test is running</source>
<extracomment>The name of the ParamType (ThingClass: speedtest, EventType: testRunning, ID: {9ad90ce5-3d66-4469-8d04-4e6bfc132db4})
----------
The name of the StateType ({9ad90ce5-3d66-4469-8d04-4e6bfc132db4}) of ThingClass speedtest</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="61"/>
<source>Test result</source>
<extracomment>The name of the ParamType (ThingClass: speedtest, EventType: testCompleted, ID: {3d101deb-a3b7-451c-ad07-02ff38afd617})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="64"/>
<source>Test run completed</source>
<extracomment>The name of the EventType ({c29dcc25-40b1-4db8-a8ad-6552b2813ee8}) of ThingClass speedtest</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="67"/>
<source>Test started or stopped</source>
<extracomment>The name of the EventType ({9ad90ce5-3d66-4469-8d04-4e6bfc132db4}) of ThingClass speedtest</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="70"/>
<source>fast.com</source>
<extracomment>The name of the vendor ({8ff41f1e-0aa4-4b86-a959-2c54dc9c716c})</extracomment>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../bla.h" line="73"/>
<source>fast.com speed test</source>
<extracomment>The name of the plugin fastcom ({142bdfae-43b1-4915-8906-99949e0a6f85})</extracomment>
<translation type="unfinished"></translation>
</message>
</context>
</TS>

View File

@ -18,6 +18,7 @@ PLUGIN_DIRS = \
dynatrace \
elgato \
eq-3 \
fastcom \
flowercare \
fronius \
genericelements \

View File

@ -48,6 +48,7 @@ def init():
logger.log("Updating thing", thing.name, "Angle:", angle)
thing.setStateValue(sunPositionAngleStateTypeId, angle)
def deinit():
global loopRunning
loopRunning = False