mirror of
https://github.com/nymea/nymea-plugins.git
synced 2026-10-21 14:23:24 +02:00
added accuweather
This commit is contained in:
parent
cdff51655f
commit
40396872f8
8
accuweather/README.md
Normal file
8
accuweather/README.md
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# AccuWeather
|
||||||
|
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
|
||||||
|
## More
|
||||||
|
To generate API key go to https://developer.accuweather.com/user/register and after registration create an app.
|
||||||
4
accuweather/accuweather.pro
Normal file
4
accuweather/accuweather.pro
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
TEMPLATE = aux
|
||||||
|
|
||||||
|
OTHER_FILES = integrationpluginaccuweather.py \
|
||||||
|
integrationpluginaccuweather.json
|
||||||
189
accuweather/integrationpluginaccuweather.json
Normal file
189
accuweather/integrationpluginaccuweather.json
Normal file
@ -0,0 +1,189 @@
|
|||||||
|
{
|
||||||
|
"name": "accuWeather",
|
||||||
|
"displayName": "AccuWeather",
|
||||||
|
"id": "763cbaa9-d3e2-4b1d-8840-5562d0f943cd",
|
||||||
|
"apiKeys": ["accuweather"],
|
||||||
|
"paramTypes": [
|
||||||
|
{
|
||||||
|
"id": "aa842ac9-1fd3-4d2f-baee-080c25c75a49",
|
||||||
|
"name": "customApiKey",
|
||||||
|
"displayName": "Custom API key",
|
||||||
|
"type": "QString",
|
||||||
|
"defaultValue": ""
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"vendors": [
|
||||||
|
{
|
||||||
|
"name": "accuWeather",
|
||||||
|
"displayName": "AccuWeather",
|
||||||
|
"id": "5a37901c-642b-4b19-aa89-79fddf5dc663",
|
||||||
|
"thingClasses": [
|
||||||
|
{
|
||||||
|
"id": "18d0dc96-1bf3-41de-aae1-5c0d4636d662",
|
||||||
|
"name": "weather",
|
||||||
|
"displayName": "Weather",
|
||||||
|
"interfaces": ["weather", "daylightsensor"],
|
||||||
|
"createMethods": ["discovery"],
|
||||||
|
"paramTypes": [
|
||||||
|
{
|
||||||
|
"id": "41e98e23-ec49-40b2-87a4-72d3cb21f795",
|
||||||
|
"name": "latitude",
|
||||||
|
"displayName": "Latitude",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": "0.00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "ed2e8542-89c4-4bbd-ac13-7319c75ac8cc",
|
||||||
|
"name": "longitude",
|
||||||
|
"displayName": "Longitude",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": "0.00"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"actionTypes": [
|
||||||
|
{
|
||||||
|
"id": "24d86c32-6a2e-4390-a4f8-9fd75663e4ba",
|
||||||
|
"name": "refreshWeather",
|
||||||
|
"displayName": "Refresh"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"stateTypes": [
|
||||||
|
{
|
||||||
|
"id": "f16891f3-1174-44f6-a940-cffc8b64bdc1",
|
||||||
|
"name": "weatherCondition",
|
||||||
|
"displayName": "weather condition",
|
||||||
|
"displayNameEvent": "weather condition changed",
|
||||||
|
"type": "QString",
|
||||||
|
"possibleValues": ["clear-day", "clear-night", "few-clouds-day", "few-clouds-night", "clouds", "overcast", "light-rain", "shower-rain", "thunderstorm", "snow", "fog"],
|
||||||
|
"defaultValue": "clear-day"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "36b2f09b-7d77-4fbc-a68f-23d735dda0b1",
|
||||||
|
"name": "updateTime",
|
||||||
|
"displayName": "last update",
|
||||||
|
"displayNameEvent": "last update changed",
|
||||||
|
"unit": "UnixTime",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6013402f-b5b1-46b3-8490-f0c20d62fe61",
|
||||||
|
"name": "temperature",
|
||||||
|
"displayName": "temperature",
|
||||||
|
"displayNameEvent": "temperature changed",
|
||||||
|
"unit": "DegreeCelsius",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "14ec2781-cb04-4bbf-b097-7d01ef982630",
|
||||||
|
"name": "temperatureMin",
|
||||||
|
"displayName": "temperature minimum",
|
||||||
|
"displayNameEvent": "temperature minimum changed",
|
||||||
|
"unit": "DegreeCelsius",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "fefe5563-452f-4833-b5cf-49c3cc67c772",
|
||||||
|
"name": "temperatureMax",
|
||||||
|
"displayName": "temperature maximum",
|
||||||
|
"displayNameEvent": "temperature maximum changed",
|
||||||
|
"unit": "DegreeCelsius",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "6f32ec73-3240-4630-ada9-1c10b8e98123",
|
||||||
|
"name": "humidity",
|
||||||
|
"displayName": "humidity",
|
||||||
|
"displayNameEvent": "humidity changed",
|
||||||
|
"unit": "Percentage",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "4a42eea9-00eb-440b-915e-dbe42180f83b",
|
||||||
|
"name": "pressure",
|
||||||
|
"displayName": "pressure",
|
||||||
|
"displayNameEvent": "pressure changed",
|
||||||
|
"unit": "HectoPascal",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "2bf63430-e9e2-4fbf-88e6-6f1b4770f287",
|
||||||
|
"name": "windSpeed",
|
||||||
|
"displayName": "wind speed",
|
||||||
|
"displayNameEvent": "wind speed changed",
|
||||||
|
"unit": "MeterPerSecond",
|
||||||
|
"type": "double",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "589e2ea5-65b2-4afd-9b72-e3708a589a12",
|
||||||
|
"name": "windDirection",
|
||||||
|
"displayName": "wind direction",
|
||||||
|
"displayNameEvent": "wind direction changed",
|
||||||
|
"unit": "Degree",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "798553bc-45c7-42eb-9105-430bddb5d9b7",
|
||||||
|
"name": "cloudiness",
|
||||||
|
"displayName": "cloudiness",
|
||||||
|
"displayNameEvent": "cloudiness changed",
|
||||||
|
"unit": "Percentage",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "1e10d129-cb88-48b0-9244-e3e7e7b175d9",
|
||||||
|
"name": "visibility",
|
||||||
|
"displayName": "visibility",
|
||||||
|
"displayNameEvent": "visibility changed",
|
||||||
|
"unit": "Meter",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "f9539108-0e0e-4736-a306-6408f8e20a26",
|
||||||
|
"name": "weatherDescription",
|
||||||
|
"displayName": "weather description",
|
||||||
|
"displayNameEvent": "weather description changed",
|
||||||
|
"type": "QString",
|
||||||
|
"defaultValue": "-"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "af155e94-9492-44e1-8608-7d0ee8b5d50d",
|
||||||
|
"name": "sunsetTime",
|
||||||
|
"displayName": "sunset",
|
||||||
|
"displayNameEvent": "sunset changed",
|
||||||
|
"unit": "UnixTime",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "a1dddc3d-549f-4f20-b78b-be850548f286",
|
||||||
|
"name": "sunriseTime",
|
||||||
|
"displayName": "sunrise",
|
||||||
|
"displayNameEvent": "sunrise changed",
|
||||||
|
"unit": "UnixTime",
|
||||||
|
"type": "int",
|
||||||
|
"defaultValue": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "e0a14b66-c8e1-49fb-8eff-b48e5dce80de",
|
||||||
|
"name": "daylight",
|
||||||
|
"displayName": "daylight",
|
||||||
|
"displayNameEvent": "daylightChanged",
|
||||||
|
"type": "bool",
|
||||||
|
"defaultValue": false
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
102
accuweather/integrationpluginaccuweather.py
Normal file
102
accuweather/integrationpluginaccuweather.py
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
# 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
|
||||||
|
import threading
|
||||||
|
import asyncio
|
||||||
|
import threading
|
||||||
|
|
||||||
|
from accuweather import (
|
||||||
|
AccuWeather,
|
||||||
|
ApiError,
|
||||||
|
InvalidApiKeyError,
|
||||||
|
InvalidCoordinatesError,
|
||||||
|
RequestsExceededError,
|
||||||
|
)
|
||||||
|
from aiohttp import ClientError, ClientSession
|
||||||
|
|
||||||
|
LATITUDE = 52.0677904
|
||||||
|
LONGITUDE = 19.4795644
|
||||||
|
|
||||||
|
apikey = ""
|
||||||
|
timers = {}
|
||||||
|
|
||||||
|
def init():
|
||||||
|
logger.log("AccuWeather init")
|
||||||
|
|
||||||
|
|
||||||
|
def deinit():
|
||||||
|
for timer in timers:
|
||||||
|
timers[timer].cancel()
|
||||||
|
|
||||||
|
def discoverThings(info):
|
||||||
|
logger.log("discoverThings")
|
||||||
|
descriptor = nymea.ThingDescriptor(weatherThingClassId, "Weather")
|
||||||
|
info.addDescriptor(descriptor)
|
||||||
|
info.finish(nymea.ThingErrorNoError)
|
||||||
|
|
||||||
|
|
||||||
|
def setupThing(info):
|
||||||
|
logger.log("setupThing", info.thing.name, "Creating connection.")
|
||||||
|
timers[info.thing] = threading.Timer(30, getData, [info.thing])
|
||||||
|
timers[info.thing].start()
|
||||||
|
info.finish(nymea.ThingErrorNoError)
|
||||||
|
|
||||||
|
|
||||||
|
def postSetupThing(thing):
|
||||||
|
logger.log("postSetupThing", thing.name)
|
||||||
|
|
||||||
|
|
||||||
|
def nameChanged(thing):
|
||||||
|
logger.log("Thing name changed:", thing.name)
|
||||||
|
|
||||||
|
|
||||||
|
def thingRemoved(thing):
|
||||||
|
logger.log("Thing removed:", thing.name)
|
||||||
|
timers[thing].cancel()
|
||||||
|
del timers[thing]
|
||||||
|
|
||||||
|
|
||||||
|
def executeAction(info):
|
||||||
|
logger.log("executeAction")
|
||||||
|
info.finish(nymea.ThingErrorNoError)
|
||||||
|
|
||||||
|
|
||||||
|
def configValueChanged(paramTypeId, value):
|
||||||
|
if paramTypeId == accuWeatherPluginCustomApiKeyParamTypeId:
|
||||||
|
apikey = value
|
||||||
|
logger.log("API Key changed to", apikey)
|
||||||
|
|
||||||
|
|
||||||
|
def getData(thing):
|
||||||
|
lat = thing.paramValue(weatherThingLatitudeParamTypeId)
|
||||||
|
lon = thing.paramValue(weatherThingLatitudeParamTypeId)
|
||||||
|
websession = ClientSession()
|
||||||
|
accuweather = AccuWeather(
|
||||||
|
apikey, websession, lat, lon
|
||||||
|
)
|
||||||
|
current_conditions = accuweather.async_get_current_conditions()
|
||||||
|
logger.log("Current: {current_conditions}")
|
||||||
14
accuweather/meta.json
Normal file
14
accuweather/meta.json
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"title": "AccuWeather",
|
||||||
|
"tagline": "Get current weather data for your location",
|
||||||
|
"icon": "accuweather.png",
|
||||||
|
"stability": "consumer",
|
||||||
|
"offline": false,
|
||||||
|
"technologies": [
|
||||||
|
"cloud"
|
||||||
|
],
|
||||||
|
"categories": [
|
||||||
|
"weather",
|
||||||
|
"online-service"
|
||||||
|
]
|
||||||
|
}
|
||||||
3
accuweather/requirements.txt
Normal file
3
accuweather/requirements.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
accuweather==0.0.11 \
|
||||||
|
--hash=sha256:9338af6b76484f9b80592d725d6a55b68020e89bf33e5c61f7d0e7dca50df460 \
|
||||||
|
--hash=sha256:fb8bbe7c2740ecde3f6f612e004958ab36ea0fee22f92aa222be420ce4ea242f
|
||||||
16
debian/control
vendored
16
debian/control
vendored
@ -22,6 +22,22 @@ Build-depends: libboblight-dev,
|
|||||||
Standards-Version: 3.9.3
|
Standards-Version: 3.9.3
|
||||||
|
|
||||||
|
|
||||||
|
Package: nymea-plugin-accuweather
|
||||||
|
Architecture: any
|
||||||
|
Section: libs
|
||||||
|
Depends: ${shlibs:Depends},
|
||||||
|
${misc:Depends},
|
||||||
|
nymea-plugins-translations,
|
||||||
|
Description: nymea.io plugin for the AccuWeather weather service
|
||||||
|
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 AccuWeather
|
||||||
|
|
||||||
|
|
||||||
Package: nymea-plugin-anel
|
Package: nymea-plugin-anel
|
||||||
Architecture: any
|
Architecture: any
|
||||||
Section: libs
|
Section: libs
|
||||||
|
|||||||
1
debian/nymea-plugin-accuweather.install.in
vendored
Normal file
1
debian/nymea-plugin-accuweather.install.in
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
usr/lib/@DEB_HOST_MULTIARCH@/nymea/plugins/libnymea_integrationpluginaccuweather.so
|
||||||
@ -1,6 +1,7 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
|
|
||||||
PLUGIN_DIRS = \
|
PLUGIN_DIRS = \
|
||||||
|
accuweather \
|
||||||
anel \
|
anel \
|
||||||
aqi \
|
aqi \
|
||||||
avahimonitor \
|
avahimonitor \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user