added openweathermap plugin
removed weatherground and meisteranker plugin from code...they need later some more time
This commit is contained in:
parent
9bb71fbdfc
commit
8a4f06f47f
@ -18,7 +18,7 @@ SOURCES += plugin/device.cpp \
|
|||||||
types/statetype.cpp \
|
types/statetype.cpp \
|
||||||
types/eventtype.cpp \
|
types/eventtype.cpp \
|
||||||
types/event.cpp \
|
types/event.cpp \
|
||||||
types/vendor.cpp
|
types/vendor.cpp
|
||||||
|
|
||||||
HEADERS += plugin/device.h \
|
HEADERS += plugin/device.h \
|
||||||
plugin/deviceclass.h \
|
plugin/deviceclass.h \
|
||||||
@ -33,5 +33,5 @@ HEADERS += plugin/device.h \
|
|||||||
types/eventtype.h \
|
types/eventtype.h \
|
||||||
types/event.h \
|
types/event.h \
|
||||||
types/vendor.h \
|
types/vendor.h \
|
||||||
types/typeutils.h
|
types/typeutils.h
|
||||||
|
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
TEMPLATE = subdirs
|
TEMPLATE = subdirs
|
||||||
SUBDIRS += elro \
|
SUBDIRS += elro \
|
||||||
intertechno \
|
intertechno \
|
||||||
meisteranker \
|
# meisteranker \
|
||||||
wifidetector \
|
wifidetector \
|
||||||
conrad \
|
conrad \
|
||||||
mock \
|
mock \
|
||||||
weatherground \
|
# weatherground \
|
||||||
|
openweathermap \
|
||||||
|
|
||||||
# boblight \
|
# boblight \
|
||||||
|
|||||||
@ -0,0 +1,186 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#include "devicepluginopenweathermap.h"
|
||||||
|
|
||||||
|
#include "plugin/device.h"
|
||||||
|
#include "devicemanager.h"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
#include <QStringList>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QDateTime>
|
||||||
|
|
||||||
|
|
||||||
|
VendorId openweathermapVendorId = VendorId("bf1e96f0-9650-4e7c-a56c-916d54d18e7a");
|
||||||
|
|
||||||
|
DevicePluginOpenweathermap::DevicePluginOpenweathermap()
|
||||||
|
{
|
||||||
|
m_openweaher = new OpenWeatherMap(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Vendor> DevicePluginOpenweathermap::supportedVendors() const
|
||||||
|
{
|
||||||
|
QList<Vendor> ret;
|
||||||
|
Vendor openweathermap(openweathermapVendorId, "openweathermap");
|
||||||
|
ret.append(openweathermap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<DeviceClass> DevicePluginOpenweathermap::supportedDevices() const
|
||||||
|
{
|
||||||
|
QList<DeviceClass> ret;
|
||||||
|
|
||||||
|
DeviceClass deviceClassOpenweathermap(pluginId(), openweathermapVendorId, DeviceClassId("985195aa-17ad-4530-88a4-cdd753d747d7"));
|
||||||
|
deviceClassOpenweathermap.setName("Weather from openweathermap");
|
||||||
|
|
||||||
|
QVariantList weatherParams;
|
||||||
|
QVariantMap autoDetectParam;
|
||||||
|
autoDetectParam.insert("name", "autodetect");
|
||||||
|
autoDetectParam.insert("type", "bool");
|
||||||
|
weatherParams.append(autoDetectParam);
|
||||||
|
|
||||||
|
// Actions
|
||||||
|
QList<ActionType> weatherActions;
|
||||||
|
ActionType updateWeather(ActionTypeId("cfbc6504-d86f-4856-8dfa-97b6fbb385e4"));
|
||||||
|
updateWeather.setName("refresh");
|
||||||
|
weatherActions.append(updateWeather);
|
||||||
|
|
||||||
|
// States
|
||||||
|
QList<StateType> weatherStates;
|
||||||
|
StateType cityNameState(StateTypeId("fd9e7b7f-cf1f-4093-8f6d-fff5b223471f"));
|
||||||
|
cityNameState.setName("city name");
|
||||||
|
cityNameState.setType(QVariant::String);
|
||||||
|
cityNameState.setDefaultValue("");
|
||||||
|
weatherStates.append(cityNameState);
|
||||||
|
|
||||||
|
StateType cityIdState(StateTypeId("c6ef1c07-e817-4251-b83d-115bbf6f0ae9"));
|
||||||
|
cityIdState.setName("city id");
|
||||||
|
cityIdState.setType(QVariant::String);
|
||||||
|
cityIdState.setDefaultValue("");
|
||||||
|
weatherStates.append(cityIdState);
|
||||||
|
|
||||||
|
StateType countryNameState(StateTypeId("0e607a5f-1938-4e77-a146-15e9ad15bfad"));
|
||||||
|
countryNameState.setName("country name");
|
||||||
|
countryNameState.setType(QVariant::String);
|
||||||
|
countryNameState.setDefaultValue("");
|
||||||
|
weatherStates.append(countryNameState);
|
||||||
|
|
||||||
|
StateType updateTimeState(StateTypeId("98e48095-87da-47a4-b812-28c6c17a3e76"));
|
||||||
|
updateTimeState.setName("last update [unixtime]");
|
||||||
|
updateTimeState.setType(QVariant::UInt);
|
||||||
|
updateTimeState.setDefaultValue(0);
|
||||||
|
weatherStates.append(updateTimeState);
|
||||||
|
|
||||||
|
StateType temperatureState(StateTypeId("2f949fa3-ff21-4721-87ec-0a5c9d0a5b8a"));
|
||||||
|
temperatureState.setName("temperature [°C]");
|
||||||
|
temperatureState.setType(QVariant::Double);
|
||||||
|
temperatureState.setDefaultValue(-999.9);
|
||||||
|
weatherStates.append(temperatureState);
|
||||||
|
|
||||||
|
StateType temperatureMinState(StateTypeId("701338b3-80de-4c95-8abf-26f44529d620"));
|
||||||
|
temperatureMinState.setName("temperature minimum [Celsius]");
|
||||||
|
temperatureMinState.setType(QVariant::Double);
|
||||||
|
temperatureMinState.setDefaultValue(-999.9);
|
||||||
|
weatherStates.append(temperatureMinState);
|
||||||
|
|
||||||
|
StateType temperatureMaxState(StateTypeId("f69bedd2-c997-4a7d-9242-76bf2aab3d3d"));
|
||||||
|
temperatureMaxState.setName("temperature maximum [Celsius]");
|
||||||
|
temperatureMaxState.setType(QVariant::Double);
|
||||||
|
temperatureMaxState.setDefaultValue(999.9);
|
||||||
|
weatherStates.append(temperatureMaxState);
|
||||||
|
|
||||||
|
StateType humidityState(StateTypeId("3f01c9f0-206b-4477-afa2-80d6e5e54fbb"));
|
||||||
|
humidityState.setName("humidity [%]");
|
||||||
|
humidityState.setType(QVariant::Int);
|
||||||
|
humidityState.setDefaultValue(-1);
|
||||||
|
weatherStates.append(humidityState);
|
||||||
|
|
||||||
|
StateType pressureState(StateTypeId("6a57b6e9-7010-4a89-982c-ce0bc2a71f11"));
|
||||||
|
pressureState.setName("pressure [hPa]");
|
||||||
|
pressureState.setType(QVariant::Double);
|
||||||
|
pressureState.setDefaultValue(-1);
|
||||||
|
weatherStates.append(pressureState);
|
||||||
|
|
||||||
|
StateType windSpeedState(StateTypeId("12dc85a9-825d-4375-bef4-abd66e9e301b"));
|
||||||
|
windSpeedState.setName("wind speed [m/s]");
|
||||||
|
windSpeedState.setType(QVariant::Double);
|
||||||
|
windSpeedState.setDefaultValue(-1);
|
||||||
|
weatherStates.append(windSpeedState);
|
||||||
|
|
||||||
|
StateType windDirectionState(StateTypeId("a8b0383c-d615-41fe-82b8-9b797f045cc9"));
|
||||||
|
windDirectionState.setName("wind direction [°]");
|
||||||
|
windDirectionState.setType(QVariant::Int);
|
||||||
|
windDirectionState.setDefaultValue(-1);
|
||||||
|
weatherStates.append(windDirectionState);
|
||||||
|
|
||||||
|
StateType cloudinessState(StateTypeId("0c1dc881-560e-40ac-a4a1-9ab69138cfe3"));
|
||||||
|
cloudinessState.setName("cloudiness [%]");
|
||||||
|
cloudinessState.setType(QVariant::Int);
|
||||||
|
cloudinessState.setDefaultValue(-1);
|
||||||
|
weatherStates.append(cloudinessState);
|
||||||
|
|
||||||
|
StateType weatherDescriptionState(StateTypeId("e71d98e3-ebd8-4abf-ad25-9ecc2d05276a"));
|
||||||
|
weatherDescriptionState.setName("weather description");
|
||||||
|
weatherDescriptionState.setType(QVariant::String);
|
||||||
|
weatherDescriptionState.setDefaultValue("");
|
||||||
|
weatherStates.append(weatherDescriptionState);
|
||||||
|
|
||||||
|
StateType sunsetState(StateTypeId("5dd6f5a3-25d6-4e60-82ca-e934ad76a4b6"));
|
||||||
|
sunsetState.setName("sunset [unixtime]");
|
||||||
|
sunsetState.setType(QVariant::UInt);
|
||||||
|
sunsetState.setDefaultValue(0);
|
||||||
|
weatherStates.append(sunsetState);
|
||||||
|
|
||||||
|
StateType sunriseState(StateTypeId("413b3fc6-bd1c-46fb-8c86-03096254f94f"));
|
||||||
|
sunriseState.setName("sunrise [unixtime]");
|
||||||
|
sunriseState.setType(QVariant::UInt);
|
||||||
|
sunriseState.setDefaultValue(0);
|
||||||
|
weatherStates.append(sunriseState);
|
||||||
|
|
||||||
|
//Events
|
||||||
|
|
||||||
|
|
||||||
|
deviceClassOpenweathermap.setActions(weatherActions);
|
||||||
|
deviceClassOpenweathermap.setStates(weatherStates);
|
||||||
|
|
||||||
|
ret.append(deviceClassOpenweathermap);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceManager::HardwareResources DevicePluginOpenweathermap::requiredHardware() const
|
||||||
|
{
|
||||||
|
return DeviceManager::HardwareResourceTimer;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString DevicePluginOpenweathermap::pluginName() const
|
||||||
|
{
|
||||||
|
return "Openweathermap";
|
||||||
|
}
|
||||||
|
|
||||||
|
QUuid DevicePluginOpenweathermap::pluginId() const
|
||||||
|
{
|
||||||
|
return QUuid("bc6af567-2338-41d5-aac1-462dec6e4783");
|
||||||
|
}
|
||||||
|
|
||||||
|
void DevicePluginOpenweathermap::guhTimer()
|
||||||
|
{
|
||||||
|
m_openweaher->update();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -0,0 +1,54 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
* *
|
||||||
|
* This file is part of guh. *
|
||||||
|
* *
|
||||||
|
* Guh is free software: you can redistribute it and/or modify *
|
||||||
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
* the Free Software Foundation, version 2 of the License. *
|
||||||
|
* *
|
||||||
|
* Guh 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 General Public License for more details. *
|
||||||
|
* *
|
||||||
|
* You should have received a copy of the GNU General Public License *
|
||||||
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
||||||
|
* *
|
||||||
|
***************************************************************************/
|
||||||
|
|
||||||
|
#ifndef DEVICEPLUGINOPENWEATHERMAP_H
|
||||||
|
#define DEVICEPLUGINOPENWEATHERMAP_H
|
||||||
|
|
||||||
|
#include "plugin/deviceplugin.h"
|
||||||
|
#include "openweathermap.h"
|
||||||
|
|
||||||
|
|
||||||
|
class DevicePluginOpenweathermap : public DevicePlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
Q_PLUGIN_METADATA(IID "org.guh.DevicePlugin" FILE "devicepluginopenweathermap.json")
|
||||||
|
Q_INTERFACES(DevicePlugin)
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit DevicePluginOpenweathermap();
|
||||||
|
|
||||||
|
OpenWeatherMap *m_openweaher;
|
||||||
|
|
||||||
|
QList<Vendor> supportedVendors() const override;
|
||||||
|
QList<DeviceClass> supportedDevices() const override;
|
||||||
|
DeviceManager::HardwareResources requiredHardware() const override;
|
||||||
|
|
||||||
|
QString pluginName() const override;
|
||||||
|
QUuid pluginId() const override;
|
||||||
|
|
||||||
|
void guhTimer() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // DEVICEPLUGINOPENWEATHERMAP_H
|
||||||
@ -0,0 +1 @@
|
|||||||
|
{}
|
||||||
223
plugins/deviceplugins/openweathermap/openweathermap.cpp
Normal file
223
plugins/deviceplugins/openweathermap/openweathermap.cpp
Normal file
@ -0,0 +1,223 @@
|
|||||||
|
#include "openweathermap.h"
|
||||||
|
|
||||||
|
OpenWeatherMap::OpenWeatherMap(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
|
{
|
||||||
|
m_manager = new QNetworkAccessManager(this);
|
||||||
|
|
||||||
|
connect(m_manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::updateLocationData()
|
||||||
|
{
|
||||||
|
QString urlString = "http://ip-api.com/json";
|
||||||
|
QNetworkRequest locationRequest;
|
||||||
|
locationRequest.setUrl(QUrl(urlString));
|
||||||
|
|
||||||
|
m_locationReplay = m_manager->get(locationRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::updateSearchData()
|
||||||
|
{
|
||||||
|
QString urlString = "http://api.openweathermap.org/data/2.5/find?q=" + m_cityName;
|
||||||
|
QNetworkRequest searchRequest;
|
||||||
|
searchRequest.setUrl(QUrl(urlString));
|
||||||
|
|
||||||
|
m_searchReplay = m_manager->get(searchRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::updateWeatherData()
|
||||||
|
{
|
||||||
|
QString urlString = "http://api.openweathermap.org/data/2.5/weather?id="+ m_cityId + "&mode=json&units=metric";
|
||||||
|
QNetworkRequest weatherRequest;
|
||||||
|
weatherRequest.setUrl(QUrl(urlString));
|
||||||
|
|
||||||
|
m_weatherReplay = m_manager->get(weatherRequest);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::processLocationResponse(QByteArray data)
|
||||||
|
{
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||||
|
|
||||||
|
if(error.error != QJsonParseError::NoError) {
|
||||||
|
qWarning() << "failed to parse data" << data << ":" << error.errorString();
|
||||||
|
}
|
||||||
|
//qDebug() << jsonDoc.toJson();
|
||||||
|
|
||||||
|
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
||||||
|
if(dataMap.contains("city")){
|
||||||
|
QString cityName = dataMap.value("city").toString();
|
||||||
|
if(m_cityName != cityName){
|
||||||
|
m_cityName = cityName;
|
||||||
|
updateSearchData();
|
||||||
|
return;
|
||||||
|
}else{
|
||||||
|
updateWeatherData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::processSearchResponse(QByteArray data)
|
||||||
|
{
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||||
|
|
||||||
|
if(error.error != QJsonParseError::NoError) {
|
||||||
|
qWarning() << "failed to parse data" << data << ":" << error.errorString();
|
||||||
|
}
|
||||||
|
//qDebug() << jsonDoc.toJson();
|
||||||
|
|
||||||
|
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
||||||
|
if(dataMap.contains("list")){
|
||||||
|
QVariantList list = dataMap.value("list").toList();
|
||||||
|
foreach (QVariant key, list) {
|
||||||
|
QVariantMap elemant = key.toMap();
|
||||||
|
if(elemant.contains("id")){
|
||||||
|
m_cityId = elemant.value("id").toString();
|
||||||
|
updateWeatherData();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::processWeatherResponse(QByteArray data)
|
||||||
|
{
|
||||||
|
QJsonParseError error;
|
||||||
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||||
|
|
||||||
|
if(error.error != QJsonParseError::NoError) {
|
||||||
|
qWarning() << "failed to parse data" << data << ":" << error.errorString();
|
||||||
|
}
|
||||||
|
//qDebug() << jsonDoc.toJson();
|
||||||
|
|
||||||
|
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
||||||
|
if(dataMap.contains("clouds")){
|
||||||
|
int cloudiness = dataMap.value("clouds").toMap().value("all").toInt();
|
||||||
|
if(m_cloudiness != cloudiness){
|
||||||
|
m_cloudiness = cloudiness;
|
||||||
|
//emit cloudiness changed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(dataMap.contains("dt")){
|
||||||
|
uint lastUpdate = dataMap.value("dt").toUInt();
|
||||||
|
if(m_lastUpdate != lastUpdate){
|
||||||
|
m_lastUpdate = lastUpdate;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataMap.contains("main")){
|
||||||
|
double temperatur = dataMap.value("main").toMap().value("temp").toDouble();
|
||||||
|
if(m_temperatur != temperatur){
|
||||||
|
m_temperatur = temperatur;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
|
||||||
|
double temperaturMax = dataMap.value("main").toMap().value("temp_max").toDouble();
|
||||||
|
if(m_temperaturMax != temperaturMax){
|
||||||
|
m_temperaturMax = temperaturMax;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
|
||||||
|
double temperaturMin = dataMap.value("main").toMap().value("temp_min").toDouble();
|
||||||
|
if(m_temperaturMin != temperaturMin){
|
||||||
|
m_temperaturMin = temperaturMin;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
|
||||||
|
double pressure = dataMap.value("main").toMap().value("pressure").toDouble();
|
||||||
|
if(m_pressure != pressure){
|
||||||
|
m_pressure = pressure;
|
||||||
|
//emit
|
||||||
|
}
|
||||||
|
|
||||||
|
int humidity = dataMap.value("main").toMap().value("humidity").toInt();
|
||||||
|
if(m_humidity != humidity){
|
||||||
|
m_humidity = humidity;
|
||||||
|
//emit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataMap.contains("sys")){
|
||||||
|
uint sunrise = dataMap.value("sys").toMap().value("sunrise").toUInt();
|
||||||
|
if(m_sunrise != sunrise){
|
||||||
|
m_sunrise = sunrise;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
|
||||||
|
uint sunset = dataMap.value("sys").toMap().value("sunset").toUInt();
|
||||||
|
if(m_sunset != sunset){
|
||||||
|
m_sunset = sunset;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataMap.contains("weather")){
|
||||||
|
QString description = dataMap.value("weather").toMap().value("description").toString();
|
||||||
|
if(m_weatherDescription != description){
|
||||||
|
m_weatherDescription = description;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(dataMap.contains("wind")){
|
||||||
|
int windDirection = dataMap.value("wind").toMap().value("deg").toInt();
|
||||||
|
if(m_windDirection != windDirection){
|
||||||
|
m_windDirection = windDirection;
|
||||||
|
//emit
|
||||||
|
}
|
||||||
|
|
||||||
|
double windSpeed = dataMap.value("wind").toMap().value("speed").toDouble();
|
||||||
|
if(m_windSpeed != windSpeed){
|
||||||
|
m_windSpeed = windSpeed;
|
||||||
|
// emit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// qDebug() << "#########################################################";
|
||||||
|
// qDebug() << m_cityName << m_cityId;
|
||||||
|
// qDebug() << "#########################################################";
|
||||||
|
// qDebug() << "temp" << m_temperatur;
|
||||||
|
// qDebug() << "temp min" << m_temperaturMin;
|
||||||
|
// qDebug() << "temp max" << m_temperaturMax;
|
||||||
|
// qDebug() << "cloudiness" << m_cloudiness;
|
||||||
|
// qDebug() << "humidity" << m_humidity;
|
||||||
|
// qDebug() << "pressure" << m_pressure;
|
||||||
|
// qDebug() << "sunrise" << QDateTime::fromTime_t(m_sunrise);
|
||||||
|
// qDebug() << "wind dir" << m_windDirection;
|
||||||
|
// qDebug() << "wind speed" << m_windSpeed;
|
||||||
|
// qDebug() << "sunrise" << QDateTime::fromTime_t(m_sunrise);
|
||||||
|
// qDebug() << "sunset" << QDateTime::fromTime_t(m_sunset);
|
||||||
|
// qDebug() << "last update" << QDateTime::fromTime_t(m_lastUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::update()
|
||||||
|
{
|
||||||
|
updateLocationData();
|
||||||
|
}
|
||||||
|
|
||||||
|
void OpenWeatherMap::replyFinished(QNetworkReply *reply)
|
||||||
|
{
|
||||||
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
|
QByteArray data;
|
||||||
|
|
||||||
|
if(reply == m_locationReplay && status == 200){
|
||||||
|
data = reply->readAll();
|
||||||
|
processLocationResponse(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reply == m_searchReplay && status == 200){
|
||||||
|
data = reply->readAll();
|
||||||
|
processSearchResponse(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(reply == m_weatherReplay && status == 200){
|
||||||
|
data = reply->readAll();
|
||||||
|
processWeatherResponse(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
60
plugins/deviceplugins/openweathermap/openweathermap.h
Normal file
60
plugins/deviceplugins/openweathermap/openweathermap.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
#ifndef OPENWEATHERMAP_H
|
||||||
|
#define OPENWEATHERMAP_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QNetworkAccessManager>
|
||||||
|
#include <QNetworkRequest>
|
||||||
|
#include <QNetworkReply>
|
||||||
|
#include <QJsonDocument>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
|
class OpenWeatherMap : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit OpenWeatherMap(QObject *parent = 0);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QNetworkAccessManager *m_manager;
|
||||||
|
|
||||||
|
QString m_cityName;
|
||||||
|
QString m_cityId;
|
||||||
|
|
||||||
|
QNetworkReply *m_locationReplay;
|
||||||
|
QNetworkReply *m_searchReplay;
|
||||||
|
QNetworkReply *m_weatherReplay;
|
||||||
|
|
||||||
|
QString m_country;
|
||||||
|
QString m_weatherDescription;
|
||||||
|
uint m_lastUpdate;
|
||||||
|
uint m_sunrise;
|
||||||
|
uint m_sunset;
|
||||||
|
double m_temperatur;
|
||||||
|
double m_temperaturMin;
|
||||||
|
double m_temperaturMax;
|
||||||
|
double m_pressure;
|
||||||
|
double m_windSpeed;
|
||||||
|
int m_windDirection;
|
||||||
|
int m_humidity;
|
||||||
|
int m_cloudiness;
|
||||||
|
|
||||||
|
void updateLocationData();
|
||||||
|
void updateSearchData();
|
||||||
|
void updateWeatherData();
|
||||||
|
|
||||||
|
void processLocationResponse(QByteArray data);
|
||||||
|
void processSearchResponse(QByteArray data);
|
||||||
|
void processWeatherResponse(QByteArray data);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void update();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void replyFinished(QNetworkReply *reply);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPENWEATHERMAP_H
|
||||||
15
plugins/deviceplugins/openweathermap/openweathermap.pro
Normal file
15
plugins/deviceplugins/openweathermap/openweathermap.pro
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
include(../../plugins.pri)
|
||||||
|
|
||||||
|
TARGET = $$qtLibraryTarget(guh_devicepluginopenweathermap)
|
||||||
|
|
||||||
|
QT+= network
|
||||||
|
|
||||||
|
SOURCES += \
|
||||||
|
devicepluginopenweathermap.cpp \
|
||||||
|
openweathermap.cpp
|
||||||
|
|
||||||
|
HEADERS += \
|
||||||
|
devicepluginopenweathermap.h \
|
||||||
|
openweathermap.h
|
||||||
|
|
||||||
|
|
||||||
@ -26,7 +26,6 @@
|
|||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
|
|
||||||
// Key: 779a480dea5163c6
|
|
||||||
|
|
||||||
VendorId weathergroundVendorId = VendorId("68f84197-b158-4d24-9d7b-709cfff843c1");
|
VendorId weathergroundVendorId = VendorId("68f84197-b158-4d24-9d7b-709cfff843c1");
|
||||||
|
|
||||||
@ -48,7 +47,7 @@ QList<DeviceClass> DevicePluginWeatherground::supportedDevices() const
|
|||||||
QList<DeviceClass> ret;
|
QList<DeviceClass> ret;
|
||||||
|
|
||||||
DeviceClass deviceClassWeatherground(pluginId(), weathergroundVendorId, DeviceClassId("af2e15f0-650e-4452-b379-fa76a2dc46c6"));
|
DeviceClass deviceClassWeatherground(pluginId(), weathergroundVendorId, DeviceClassId("af2e15f0-650e-4452-b379-fa76a2dc46c6"));
|
||||||
deviceClassWeatherground.setName("Weather");
|
deviceClassWeatherground.setName("Weather from Weatherground");
|
||||||
|
|
||||||
QVariantList weatherParams;
|
QVariantList weatherParams;
|
||||||
QVariantMap cityParam;
|
QVariantMap cityParam;
|
||||||
@ -153,16 +152,6 @@ QUuid DevicePluginWeatherground::pluginId() const
|
|||||||
|
|
||||||
void DevicePluginWeatherground::guhTimer()
|
void DevicePluginWeatherground::guhTimer()
|
||||||
{
|
{
|
||||||
qDebug() << "update Weatherground states...";
|
m_parser->updateData();
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginWeatherground::setState(const QUuid &stateTypeId, const QVariant &value)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void DevicePluginWeatherground::executeAction(Device *device, const Action &action)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -45,10 +45,8 @@ public:
|
|||||||
void guhTimer() override;
|
void guhTimer() override;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void setState(const QUuid &stateTypeId, const QVariant &value);
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void executeAction(Device *device, const Action &action) override;
|
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -6,11 +6,12 @@ WeathergroundParser::WeathergroundParser(QObject *parent) :
|
|||||||
m_manager = new QNetworkAccessManager(this);
|
m_manager = new QNetworkAccessManager(this);
|
||||||
|
|
||||||
m_cityCode = "/q/zmw:00000.2.11034";
|
m_cityCode = "/q/zmw:00000.2.11034";
|
||||||
m_language = "DL";
|
m_language = "EN";
|
||||||
|
m_apikey = "779a480dea5163c6";
|
||||||
|
|
||||||
connect(m_manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));
|
connect(m_manager,SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*)));
|
||||||
connect(this,SIGNAL(dataReady(QByteArray)),this,SLOT(processResponse(QByteArray)));
|
connect(this,SIGNAL(dataReady(QByteArray)),this,SLOT(processResponse(QByteArray)));
|
||||||
connect(this,SIGNAL(locationDetected()),this,SLOT(getDataFromLocation()));
|
connect(this,SIGNAL(locationDetected(QString,QString)),this,SLOT(updateData(QString,QString)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeathergroundParser::replyFinished(QNetworkReply *reply)
|
void WeathergroundParser::replyFinished(QNetworkReply *reply)
|
||||||
@ -23,14 +24,14 @@ void WeathergroundParser::processResponse(const QByteArray &data)
|
|||||||
QJsonParseError error;
|
QJsonParseError error;
|
||||||
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
QJsonDocument jsonDoc = QJsonDocument::fromJson(data, &error);
|
||||||
|
|
||||||
|
qDebug() << jsonDoc.toJson();
|
||||||
|
|
||||||
if(error.error != QJsonParseError::NoError) {
|
if(error.error != QJsonParseError::NoError) {
|
||||||
qDebug() << "failed to parse data" << data << ":" << error.errorString();
|
qWarning() << "failed to parse data" << data << ":" << error.errorString();
|
||||||
}
|
}
|
||||||
//qDebug() << "-------------------------\n" << jsonDoc.toJson();
|
|
||||||
|
|
||||||
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
QVariantMap dataMap = jsonDoc.toVariant().toMap();
|
||||||
|
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
// Pars answere
|
// Pars answere
|
||||||
|
|
||||||
@ -41,32 +42,25 @@ void WeathergroundParser::processResponse(const QByteArray &data)
|
|||||||
m_cityCode = locationMap.value("l").toString();
|
m_cityCode = locationMap.value("l").toString();
|
||||||
m_country = locationMap.value("country_iso3166").toString();
|
m_country = locationMap.value("country_iso3166").toString();
|
||||||
|
|
||||||
qDebug() << m_cityName << m_country << m_cityCode;
|
emit locationDetected(m_cityCode,m_language);
|
||||||
qDebug() << "-------------------";
|
|
||||||
emit locationDetected();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
if(dataMap.contains("RESULTS")){
|
if(dataMap.contains("RESULTS")){
|
||||||
QVariantList list = dataMap.value("RESULTS").toList();
|
QVariantList list = dataMap.value("RESULTS").toList();
|
||||||
|
// foreach (QVariant key, list) {
|
||||||
QStringList *cityList;
|
// qDebug() << "----------------------------------------";
|
||||||
|
// QVariantMap elemant = key.toMap();
|
||||||
foreach (QVariant key, list) {
|
// if(elemant.contains("name")){
|
||||||
qDebug() << "----------------------------------------";
|
// qDebug() << elemant.value("name").toString();
|
||||||
QVariantMap elemant = key.toMap();
|
// qDebug() << elemant.value("l").toString();
|
||||||
if(elemant.contains("name")){
|
// }
|
||||||
qDebug() << elemant.value("name").toString();
|
// }
|
||||||
qDebug() << elemant.value("l").toString();
|
emit querryListReady(list);
|
||||||
cityList->append(elemant.value("name").toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
emit querryListReady(cityList);
|
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
if(dataMap.contains("sun_phase")){
|
if(dataMap.contains("sun_phase")){
|
||||||
qDebug() << jsonDoc.toJson();
|
|
||||||
int sunRiseH = dataMap.value("sun_phase").toMap().value("sunrise").toMap().value("hour").toInt();
|
int sunRiseH = dataMap.value("sun_phase").toMap().value("sunrise").toMap().value("hour").toInt();
|
||||||
int sunRiseM = dataMap.value("sun_phase").toMap().value("sunrise").toMap().value("minute").toInt();
|
int sunRiseM = dataMap.value("sun_phase").toMap().value("sunrise").toMap().value("minute").toInt();
|
||||||
|
|
||||||
@ -76,52 +70,39 @@ void WeathergroundParser::processResponse(const QByteArray &data)
|
|||||||
m_sunrise = QTime(sunRiseH,sunRiseM);
|
m_sunrise = QTime(sunRiseH,sunRiseM);
|
||||||
m_sunset = QTime(sunSetH,sunSetM);
|
m_sunset = QTime(sunSetH,sunSetM);
|
||||||
|
|
||||||
qDebug() << "sunrise =" << m_sunrise.toString();
|
|
||||||
qDebug() << "sunset =" << m_sunset.toString();
|
|
||||||
|
|
||||||
emit sunDataReady(m_sunset, m_sunrise);
|
emit sunDataReady(m_sunset, m_sunrise);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------
|
//----------------------------------------------------
|
||||||
if(dataMap.contains("current_observation")){
|
if(dataMap.contains("current_observation")){
|
||||||
//qDebug() << jsonDoc.toJson();
|
|
||||||
m_weather = dataMap.value("current_observation").toMap().value("weather").toString();
|
m_weather = dataMap.value("current_observation").toMap().value("weather").toString();
|
||||||
qDebug() << "Currently = " << m_weather;
|
|
||||||
m_temperature = dataMap.value("current_observation").toMap().value("temp_c").toDouble();
|
m_temperature = dataMap.value("current_observation").toMap().value("temp_c").toDouble();
|
||||||
qDebug() << "Temperature =" << m_temperature;
|
|
||||||
m_temperatureFeeling = dataMap.value("current_observation").toMap().value("feelslike_c").toDouble();
|
m_temperatureFeeling = dataMap.value("current_observation").toMap().value("feelslike_c").toDouble();
|
||||||
qDebug() << "Temperature feels like =" << m_temperatureFeeling;
|
|
||||||
m_humidity = dataMap.value("current_observation").toMap().value("relative_humidity").toString();
|
m_humidity = dataMap.value("current_observation").toMap().value("relative_humidity").toString();
|
||||||
qDebug() << "Humidity =" << m_humidity ;
|
|
||||||
m_windSpeed = dataMap.value("current_observation").toMap().value("wind_kph").toDouble();
|
m_windSpeed = dataMap.value("current_observation").toMap().value("wind_kph").toDouble();
|
||||||
qDebug() << "Wind speed =" << m_windSpeed ;
|
|
||||||
m_windDirection = dataMap.value("current_observation").toMap().value("wind_dir").toString();
|
m_windDirection = dataMap.value("current_observation").toMap().value("wind_dir").toString();
|
||||||
qDebug() << "Wind direction =" << m_windDirection;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeathergroundParser::getDataFromLocation()
|
|
||||||
{
|
|
||||||
QUrl url = "http://api.wunderground.com/api/bc9fbd0a246f151c/conditions/lang:" + m_language + m_cityCode + ".json";
|
|
||||||
m_manager->get(QNetworkRequest(url));
|
|
||||||
|
|
||||||
url = "http://api.wunderground.com/api/bc9fbd0a246f151c/astronomy/lang:" + m_language + m_cityCode + ".json";
|
|
||||||
m_manager->get(QNetworkRequest(url));
|
|
||||||
}
|
|
||||||
|
|
||||||
void WeathergroundParser::updateData()
|
void WeathergroundParser::updateData()
|
||||||
{
|
{
|
||||||
qDebug() << "=============================================";
|
// qDebug() << "=============================================";
|
||||||
qDebug() << QTime::currentTime().toString();
|
// qDebug() << QTime::currentTime().toString();
|
||||||
|
|
||||||
QUrl url = QUrl("http://api.wunderground.com/api/bc9fbd0a246f151c/geolookup/lang:" + m_language + "/q/autoip.json");
|
QUrl url = QUrl("http://api.wunderground.com/api/" + m_apikey +"/geolookup/lang:" + m_language + "/q/autoip.json");
|
||||||
m_manager->get(QNetworkRequest(url));
|
m_manager->get(QNetworkRequest(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
void WeathergroundParser::updateData(QString cityCode, QString language)
|
void WeathergroundParser::updateData(const QString &cityCode, const QString &language)
|
||||||
{
|
{
|
||||||
QUrl url = "http://api.wunderground.com/api/bc9fbd0a246f151c/conditions/lang:" + m_language + m_cityCode + ".json";
|
QUrl url = "http://api.wunderground.com/api/" + m_apikey +"/conditions/lang:" + language + cityCode + ".json";
|
||||||
m_manager->get(QNetworkRequest(url));
|
m_manager->get(QNetworkRequest(url));
|
||||||
|
|
||||||
url = "http://api.wunderground.com/api/bc9fbd0a246f151c/astronomy/lang:" + m_language + m_cityCode + ".json";
|
url = "http://api.wunderground.com/api/" + m_apikey +"/astronomy/lang:" + language + cityCode + ".json";
|
||||||
|
m_manager->get(QNetworkRequest(url));
|
||||||
|
}
|
||||||
|
|
||||||
|
void WeathergroundParser::searchCity(const QString &searchString)
|
||||||
|
{
|
||||||
|
QUrl url = QUrl("http://autocomplete.wunderground.com/aq?query=" + searchString);
|
||||||
m_manager->get(QNetworkRequest(url));
|
m_manager->get(QNetworkRequest(url));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,6 +21,8 @@ private:
|
|||||||
QString m_cityName;
|
QString m_cityName;
|
||||||
QString m_country;
|
QString m_country;
|
||||||
QString m_language;
|
QString m_language;
|
||||||
|
QString m_apikey;
|
||||||
|
|
||||||
QTime m_currentTime;
|
QTime m_currentTime;
|
||||||
|
|
||||||
//current weather
|
//current weather
|
||||||
@ -38,20 +40,26 @@ private:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void dataReady(const QByteArray &data);
|
void dataReady(const QByteArray &data);
|
||||||
void locationDetected();
|
void locationDetected(const QString &cityCode, const QString &language);
|
||||||
void querryListReady(const QStringList *citys);
|
void querryListReady(const QVariantList &querryList);
|
||||||
|
|
||||||
void temperatureReady(const double &temperature);
|
void temperatureReady(const double &temperature);
|
||||||
void humidityReady(const double &humidity);
|
void humidityReady(const double &humidity);
|
||||||
|
void windSpeedReady(const double &windSpeed);
|
||||||
|
void windDirectionReady(const QString &windDirection);
|
||||||
|
void currentWeatherReady(const QString ¤tWeather);
|
||||||
|
void moonAgeReady(const int &age);
|
||||||
|
void moonIlluminationReady(const int &age);
|
||||||
void sunDataReady(const QTime &sunSet, const QTime &sunRise);
|
void sunDataReady(const QTime &sunSet, const QTime &sunRise);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void replyFinished(QNetworkReply *reply);
|
void replyFinished(QNetworkReply *reply);
|
||||||
void processResponse(const QByteArray &data);
|
void processResponse(const QByteArray &data);
|
||||||
void getDataFromLocation();
|
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void updateData();
|
void updateData();
|
||||||
void updateData(QString cityCode, QString language);
|
void updateData(const QString &cityCode, const QString &language);
|
||||||
|
void searchCity(const QString &searchString);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@ -23,11 +23,12 @@
|
|||||||
|
|
||||||
Q_IMPORT_PLUGIN(DevicePluginElro)
|
Q_IMPORT_PLUGIN(DevicePluginElro)
|
||||||
Q_IMPORT_PLUGIN(DevicePluginIntertechno)
|
Q_IMPORT_PLUGIN(DevicePluginIntertechno)
|
||||||
Q_IMPORT_PLUGIN(DevicePluginMeisterAnker)
|
//Q_IMPORT_PLUGIN(DevicePluginMeisterAnker)
|
||||||
Q_IMPORT_PLUGIN(DevicePluginWifiDetector)
|
Q_IMPORT_PLUGIN(DevicePluginWifiDetector)
|
||||||
Q_IMPORT_PLUGIN(DevicePluginConrad)
|
Q_IMPORT_PLUGIN(DevicePluginConrad)
|
||||||
Q_IMPORT_PLUGIN(DevicePluginMock)
|
Q_IMPORT_PLUGIN(DevicePluginMock)
|
||||||
Q_IMPORT_PLUGIN(DevicePluginWeatherground)
|
//Q_IMPORT_PLUGIN(DevicePluginWeatherground)
|
||||||
|
Q_IMPORT_PLUGIN(DevicePluginOpenweathermap)
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
@ -17,8 +17,9 @@ SOURCES += main.cpp
|
|||||||
# FIXME: Drop this and link them dynamically
|
# FIXME: Drop this and link them dynamically
|
||||||
LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro
|
LIBS += -L../plugins/deviceplugins/elro/ -lguh_devicepluginelro
|
||||||
LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno
|
LIBS += -L../plugins/deviceplugins/intertechno/ -lguh_devicepluginintertechno
|
||||||
LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker
|
#LIBS += -L../plugins/deviceplugins/meisteranker/ -lguh_devicepluginmeisteranker
|
||||||
LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector
|
LIBS += -L../plugins/deviceplugins/wifidetector/ -lguh_devicepluginwifidetector
|
||||||
LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad
|
LIBS += -L../plugins/deviceplugins/conrad -lguh_devicepluginconrad
|
||||||
LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock
|
LIBS += -L../plugins/deviceplugins/mock -lguh_devicepluginmock
|
||||||
LIBS += -L../plugins/deviceplugins/weatherground -lguh_devicepluginweatherground
|
#LIBS += -L../plugins/deviceplugins/weatherground -lguh_devicepluginweatherground
|
||||||
|
LIBS += -L../plugins/deviceplugins/openweathermap -lguh_devicepluginopenweathermap
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
if [ -z $1 ]; then
|
if [ -z $1 ]; then
|
||||||
echo "usage $0 host device"
|
echo "usage $0 host device"
|
||||||
elif [ $1 == "list" ]; then
|
elif [ $1 == "list" ]; then
|
||||||
echo "elroremote elroswitch intertechnoremote meisteranker wifidetector"
|
echo "elroremote elroswitch intertechnoremote wifidetector mock1 mock2 openweathermap"
|
||||||
elif [ -z $2 ]; then
|
elif [ -z $2 ]; then
|
||||||
echo "usage $0 host device"
|
echo "usage $0 host device"
|
||||||
else
|
else
|
||||||
@ -17,9 +17,9 @@ else
|
|||||||
elif [ $2 == "intertechnoremote" ]; then
|
elif [ $2 == "intertechnoremote" ]; then
|
||||||
# Adds an intertechno remote control
|
# Adds an intertechno remote control
|
||||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{ab73ad2f-6594-45a3-9063-8f72d365c5e5}","deviceParams":{"familyCode":"J"}}}'; sleep 1) | nc $1 1234
|
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{ab73ad2f-6594-45a3-9063-8f72d365c5e5}","deviceParams":{"familyCode":"J"}}}'; sleep 1) | nc $1 1234
|
||||||
elif [ $2 == "meisteranker" ]; then
|
# elif [ $2 == "meisteranker" ]; then
|
||||||
# Adds an intertechno remote control
|
# # Adds an intertechno remote control
|
||||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{e37e9f34-95b9-4a22-ae4f-e8b874eec871}","deviceParams":{"id":"1"}}}'; sleep 1) | nc $1 1234
|
# (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{e37e9f34-95b9-4a22-ae4f-e8b874eec871}","deviceParams":{"id":"1"}}}'; sleep 1) | nc $1 1234
|
||||||
elif [ $2 == "wifidetector" ]; then
|
elif [ $2 == "wifidetector" ]; then
|
||||||
# Adds a WiFi detector
|
# Adds a WiFi detector
|
||||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{bd216356-f1ec-4324-9785-6982d2174e17}","deviceParams":{"mac":"90:cf:15:1b:ce:bb"}}}'; sleep 1) | nc $1 1234
|
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{bd216356-f1ec-4324-9785-6982d2174e17}","deviceParams":{"mac":"90:cf:15:1b:ce:bb"}}}'; sleep 1) | nc $1 1234
|
||||||
@ -29,7 +29,13 @@ else
|
|||||||
elif [ $2 == "mock2" ]; then
|
elif [ $2 == "mock2" ]; then
|
||||||
# Adds a Mock device
|
# Adds a Mock device
|
||||||
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{753f0d32-0468-4d08-82ed-1964aab03298}","deviceParams":{"httpport":"8082"}}}'; sleep 1) | nc $1 1234
|
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{753f0d32-0468-4d08-82ed-1964aab03298}","deviceParams":{"httpport":"8082"}}}'; sleep 1) | nc $1 1234
|
||||||
|
# elif [ $2 == "weatherground" ]; then
|
||||||
|
# # Adds a weatherground device
|
||||||
|
# (echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{af2e15f0-650e-4452-b379-fa76a2dc46c6}","deviceParams":{"autodetect":"true"}}}'; sleep 1) | nc $1 1234
|
||||||
|
elif [ $2 == "openweathermap" ]; then
|
||||||
|
# Adds a openweathermap device
|
||||||
|
(echo '{"id":1, "method":"Devices.AddConfiguredDevice", "params":{"deviceClassId": "{985195aa-17ad-4530-88a4-cdd753d747d7}","deviceParams":{"autodetect":"true"}}}'; sleep 1) | nc $1 1234
|
||||||
else
|
else
|
||||||
echo "unknown type $2. Possible values are: elroremote, elroswitch, intertechnoremote, meisteranker, wifidetector, mock1, mock2"
|
echo "unknown type $2. Possible values are: elroremote, elroswitch, intertechnoremote, wifidetector, mock1, mock2, openweathermap"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user