Merge PR #774: Add Qt6 support
This commit is contained in:
commit
45895778cb
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -54,8 +54,9 @@ QUuid AirQualityIndex::searchByName(const QString &name)
|
|||||||
{
|
{
|
||||||
if (m_apiKey.isEmpty()) {
|
if (m_apiKey.isEmpty()) {
|
||||||
qCWarning(dcAirQualityIndex()) << "API key is not set, not sending request";
|
qCWarning(dcAirQualityIndex()) << "API key is not set, not sending request";
|
||||||
return "";
|
return QUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid requestId = QUuid::createUuid();;
|
QUuid requestId = QUuid::createUuid();;
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setUrl(m_baseUrl);
|
url.setUrl(m_baseUrl);
|
||||||
@ -75,13 +76,14 @@ QUuid AirQualityIndex::searchByName(const QString &name)
|
|||||||
|
|
||||||
// Check HTTP status code
|
// Check HTTP status code
|
||||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||||
if (status == 400) {
|
if (status == 400)
|
||||||
qCWarning(dcAirQualityIndex()) << "Request error due to exceeded request quota";
|
qCWarning(dcAirQualityIndex()) << "Request error due to exceeded request quota";
|
||||||
}
|
|
||||||
requestExecuted(requestId, false);
|
emit requestExecuted(requestId, false);
|
||||||
qCWarning(dcAirQualityIndex()) << "Request error:" << status << reply->errorString();
|
qCWarning(dcAirQualityIndex()) << "Request error:" << status << reply->errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray rawData = reply->readAll();
|
QByteArray rawData = reply->readAll();
|
||||||
qCDebug(dcAirQualityIndex()) << "Search response" << rawData;
|
qCDebug(dcAirQualityIndex()) << "Search response" << rawData;
|
||||||
|
|
||||||
@ -95,7 +97,7 @@ QUuid AirQualityIndex::searchByName(const QString &name)
|
|||||||
|
|
||||||
QList<Station> stations;
|
QList<Station> stations;
|
||||||
QVariantList stationList = doc.toVariant().toMap().value("data").toList();
|
QVariantList stationList = doc.toVariant().toMap().value("data").toList();
|
||||||
foreach (QVariant stationVariant, stationList) {
|
foreach (const QVariant &stationVariant, stationList) {
|
||||||
Station station;
|
Station station;
|
||||||
station.aqi = stationVariant.toMap().value("aqi").toInt();
|
station.aqi = stationVariant.toMap().value("aqi").toInt();
|
||||||
station.idx = stationVariant.toMap().value("idx").toInt();
|
station.idx = stationVariant.toMap().value("idx").toInt();
|
||||||
@ -107,10 +109,11 @@ QUuid AirQualityIndex::searchByName(const QString &name)
|
|||||||
station.location.longitude = stationVariant.toMap().value("city").toMap().value("geo").toList().last().toDouble();
|
station.location.longitude = stationVariant.toMap().value("city").toMap().value("geo").toList().last().toDouble();
|
||||||
stations.append(station);
|
stations.append(station);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!stations.isEmpty())
|
if (!stations.isEmpty())
|
||||||
emit stationsReceived(requestId, stations);
|
emit stationsReceived(requestId, stations);
|
||||||
|
|
||||||
requestExecuted(requestId, true);
|
emit requestExecuted(requestId, true);
|
||||||
});
|
});
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
@ -119,18 +122,23 @@ QUuid AirQualityIndex::getDataByIp()
|
|||||||
{
|
{
|
||||||
if (m_apiKey.isEmpty()) {
|
if (m_apiKey.isEmpty()) {
|
||||||
qCWarning(dcAirQualityIndex()) << "API key is not set, not sending request";
|
qCWarning(dcAirQualityIndex()) << "API key is not set, not sending request";
|
||||||
return "";
|
return QUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid requestId = QUuid::createUuid();
|
QUuid requestId = QUuid::createUuid();
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setUrl(m_baseUrl);
|
url.setUrl(m_baseUrl);
|
||||||
url.setPath("/feed/here/");
|
url.setPath("/feed/here/");
|
||||||
|
|
||||||
QUrlQuery query;
|
QUrlQuery query;
|
||||||
query.addQueryItem("token", m_apiKey);
|
query.addQueryItem("token", m_apiKey);
|
||||||
url.setQuery(query);
|
url.setQuery(query);
|
||||||
|
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setRawHeader("User-Agent", "nymea");
|
request.setRawHeader("User-Agent", "nymea");
|
||||||
|
|
||||||
qCDebug(dcAirQualityIndex()) << "Get data by IP request" << url.toString();
|
qCDebug(dcAirQualityIndex()) << "Get data by IP request" << url.toString();
|
||||||
QNetworkReply *reply = m_networkAccessManager->get(request);
|
QNetworkReply *reply = m_networkAccessManager->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
@ -139,17 +147,20 @@ QUuid AirQualityIndex::getDataByIp()
|
|||||||
|
|
||||||
// Check HTTP status code
|
// Check HTTP status code
|
||||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||||
if (status == 400) {
|
if (status == 400)
|
||||||
qCWarning(dcAirQualityIndex()) << "Request error due to exceeded request quota";
|
qCWarning(dcAirQualityIndex()) << "Request error due to exceeded request quota";
|
||||||
}
|
|
||||||
requestExecuted(requestId, false);
|
emit requestExecuted(requestId, false);
|
||||||
qCWarning(dcAirQualityIndex()) << "Request error:" << status << reply->errorString();
|
qCWarning(dcAirQualityIndex()) << "Request error:" << status << reply->errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!parseData(requestId, reply->readAll()))
|
if (!parseData(requestId, reply->readAll()))
|
||||||
requestExecuted(requestId, false);
|
emit requestExecuted(requestId, false);
|
||||||
requestExecuted(requestId, true);
|
|
||||||
|
emit requestExecuted(requestId, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -157,19 +168,23 @@ QUuid AirQualityIndex::getDataByGeolocation(double lat, double lng)
|
|||||||
{
|
{
|
||||||
if (m_apiKey.isEmpty()) {
|
if (m_apiKey.isEmpty()) {
|
||||||
qCWarning(dcAirQualityIndex()) << "API key is not set, not sending request";
|
qCWarning(dcAirQualityIndex()) << "API key is not set, not sending request";
|
||||||
return "";
|
return QUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid requestId = QUuid::createUuid();
|
QUuid requestId = QUuid::createUuid();
|
||||||
|
|
||||||
QUrl url;
|
QUrl url;
|
||||||
url.setUrl(m_baseUrl);
|
url.setUrl(m_baseUrl);
|
||||||
url.setPath(QString("/feed/geo:%1;%2/").arg(lat).arg(lng));
|
url.setPath(QString("/feed/geo:%1;%2/").arg(lat).arg(lng));
|
||||||
|
|
||||||
QUrlQuery query;
|
QUrlQuery query;
|
||||||
query.addQueryItem("token", m_apiKey);
|
query.addQueryItem("token", m_apiKey);
|
||||||
url.setQuery(query);
|
url.setQuery(query);
|
||||||
|
|
||||||
QNetworkRequest request;
|
QNetworkRequest request;
|
||||||
request.setUrl(url);
|
request.setUrl(url);
|
||||||
request.setRawHeader("User-Agent", "nymea");
|
request.setRawHeader("User-Agent", "nymea");
|
||||||
|
|
||||||
qCDebug(dcAirQualityIndex()) << "Get data by geo location request" << url.toString();
|
qCDebug(dcAirQualityIndex()) << "Get data by geo location request" << url.toString();
|
||||||
QNetworkReply *reply = m_networkAccessManager->get(request);
|
QNetworkReply *reply = m_networkAccessManager->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
connect(reply, &QNetworkReply::finished, this, [requestId, reply, this] {
|
||||||
@ -178,21 +193,22 @@ QUuid AirQualityIndex::getDataByGeolocation(double lat, double lng)
|
|||||||
|
|
||||||
// Check HTTP status code
|
// Check HTTP status code
|
||||||
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
if (status != 200 || reply->error() != QNetworkReply::NoError) {
|
||||||
if (status == 400) {
|
if (status == 400)
|
||||||
qCWarning(dcAirQualityIndex()) << "Request error due to exceeded request quota";
|
qCWarning(dcAirQualityIndex()) << "Request error due to exceeded request quota";
|
||||||
}
|
|
||||||
requestExecuted(requestId, false);
|
emit requestExecuted(requestId, false);
|
||||||
qCWarning(dcAirQualityIndex()) << "Request error:" << status << reply->errorString();
|
qCWarning(dcAirQualityIndex()) << "Request error:" << status << reply->errorString();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!parseData(requestId, reply->readAll()))
|
if (!parseData(requestId, reply->readAll()))
|
||||||
requestExecuted(requestId, false);
|
emit requestExecuted(requestId, false);
|
||||||
requestExecuted(requestId, true);
|
|
||||||
|
emit requestExecuted(requestId, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool AirQualityIndex::parseData(QUuid requestId, const QByteArray &data)
|
bool AirQualityIndex::parseData(QUuid requestId, const QByteArray &data)
|
||||||
{
|
{
|
||||||
qCDebug(dcAirQualityIndex()) << "Parsing data" << data;
|
qCDebug(dcAirQualityIndex()) << "Parsing data" << data;
|
||||||
@ -211,8 +227,8 @@ bool AirQualityIndex::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Station station;
|
Station station;
|
||||||
station.aqi = doc.toVariant().toMap().value("data").toMap().value("aqi").toInt();
|
station.aqi = doc.toVariant().toMap().value("data").toMap().value("aqi").toInt();
|
||||||
station.idx = doc.toVariant().toMap().value("data").toMap().value("idx").toInt();
|
station.idx = doc.toVariant().toMap().value("data").toMap().value("idx").toInt();
|
||||||
|
|
||||||
QVariantMap city = doc.toVariant().toMap().value("data").toMap().value("city").toMap();
|
QVariantMap city = doc.toVariant().toMap().value("data").toMap().value("city").toMap();
|
||||||
if (city["geo"].toList().length() == 2) {
|
if (city["geo"].toList().length() == 2) {
|
||||||
@ -241,6 +257,7 @@ bool AirQualityIndex::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
aqiData.co = iaqi["co"].toMap().value("v").toDouble();
|
aqiData.co = iaqi["co"].toMap().value("v").toDouble();
|
||||||
aqiData.temperature = iaqi["t"].toMap().value("v").toDouble();
|
aqiData.temperature = iaqi["t"].toMap().value("v").toDouble();
|
||||||
aqiData.windSpeed = iaqi["w"].toMap().value("v").toDouble();
|
aqiData.windSpeed = iaqi["w"].toMap().value("v").toDouble();
|
||||||
|
|
||||||
emit dataReceived(requestId, aqiData);
|
emit dataReceived(requestId, aqiData);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,12 +31,13 @@
|
|||||||
#ifndef AIRQUALITYINDEX_H
|
#ifndef AIRQUALITYINDEX_H
|
||||||
#define AIRQUALITYINDEX_H
|
#define AIRQUALITYINDEX_H
|
||||||
|
|
||||||
#include "network/networkaccessmanager.h"
|
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
|
|
||||||
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
class AirQualityIndex : public QObject
|
class AirQualityIndex : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -70,6 +71,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit AirQualityIndex(NetworkAccessManager *networkAccessManager, const QString &apiKey, QObject *parent = nullptr);
|
explicit AirQualityIndex(NetworkAccessManager *networkAccessManager, const QString &apiKey, QObject *parent = nullptr);
|
||||||
|
|
||||||
void setApiKey(const QString &apiKey);
|
void setApiKey(const QString &apiKey);
|
||||||
QUuid searchByName(const QString &name);
|
QUuid searchByName(const QString &name);
|
||||||
QUuid getDataByIp();
|
QUuid getDataByIp();
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT+= network
|
QT *= network
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
airqualityindex.cpp \
|
airqualityindex.cpp \
|
||||||
integrationpluginaqi.cpp \
|
integrationpluginaqi.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
airqualityindex.h \
|
airqualityindex.h \
|
||||||
integrationpluginaqi.h \
|
integrationpluginaqi.h
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -30,7 +30,8 @@
|
|||||||
|
|
||||||
#include "integrationpluginaqi.h"
|
#include "integrationpluginaqi.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "nymeasettings.h"
|
|
||||||
|
#include <nymeasettings.h>
|
||||||
|
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
|
|
||||||
@ -122,7 +123,8 @@ void IntegrationPluginAqi::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
if(!createAqiConnection()) {
|
if(!createAqiConnection()) {
|
||||||
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("API key is not available."));
|
return info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("API key is not available."));
|
||||||
}
|
}
|
||||||
connect(info, &ThingDiscoveryInfo::aborted, [this] {
|
|
||||||
|
connect(info, &ThingDiscoveryInfo::aborted, this, [this] {
|
||||||
if (myThings().filterByThingClassId(airQualityIndexThingClassId).isEmpty()) {
|
if (myThings().filterByThingClassId(airQualityIndexThingClassId).isEmpty()) {
|
||||||
m_aqiConnection->deleteLater();
|
m_aqiConnection->deleteLater();
|
||||||
m_aqiConnection = nullptr;
|
m_aqiConnection = nullptr;
|
||||||
@ -133,7 +135,9 @@ void IntegrationPluginAqi::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
}
|
}
|
||||||
QUuid requestId = m_aqiConnection->getDataByIp();
|
QUuid requestId = m_aqiConnection->getDataByIp();
|
||||||
m_asyncDiscovery.insert(requestId, info);
|
m_asyncDiscovery.insert(requestId, info);
|
||||||
connect(info, &ThingDiscoveryInfo::aborted, [=] {m_asyncDiscovery.remove(requestId);});
|
connect(info, &ThingDiscoveryInfo::aborted, this, [this, requestId] {
|
||||||
|
m_asyncDiscovery.remove(requestId);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginAqi::setupThing(ThingSetupInfo *info)
|
void IntegrationPluginAqi::setupThing(ThingSetupInfo *info)
|
||||||
@ -148,7 +152,7 @@ void IntegrationPluginAqi::setupThing(ThingSetupInfo *info)
|
|||||||
QUuid requestId = m_aqiConnection->getDataByGeolocation(latitude, longitude);
|
QUuid requestId = m_aqiConnection->getDataByGeolocation(latitude, longitude);
|
||||||
m_asyncSetups.insert(requestId, info);
|
m_asyncSetups.insert(requestId, info);
|
||||||
|
|
||||||
connect(info, &ThingSetupInfo::aborted, [requestId, this] {
|
connect(info, &ThingSetupInfo::aborted, this, [requestId, this] {
|
||||||
m_asyncSetups.remove(requestId);
|
m_asyncSetups.remove(requestId);
|
||||||
if (myThings().filterByThingClassId(airQualityIndexThingClassId).isEmpty()) {
|
if (myThings().filterByThingClassId(airQualityIndexThingClassId).isEmpty()) {
|
||||||
m_aqiConnection->deleteLater();
|
m_aqiConnection->deleteLater();
|
||||||
@ -219,6 +223,7 @@ double IntegrationPluginAqi::convertFromAQI(int aqi, const QList<QPair<int, doub
|
|||||||
il = map.at(index - 1).first;
|
il = map.at(index - 1).first;
|
||||||
vl = map.at(index - 1).second;
|
vl = map.at(index - 1).second;
|
||||||
}
|
}
|
||||||
|
|
||||||
ih = map.at(index).first;
|
ih = map.at(index).first;
|
||||||
vh = map.at(index).second;
|
vh = map.at(index).second;
|
||||||
double value = (aqi - il) * (vh - vl) / (ih - il) + vl;
|
double value = (aqi - il) * (vh - vl) / (ih - il) + vl;
|
||||||
@ -253,7 +258,6 @@ void IntegrationPluginAqi::onAirQualityDataReceived(QUuid requestId, AirQualityI
|
|||||||
if (!thing)
|
if (!thing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
||||||
thing->setStateValue(airQualityIndexConnectedStateTypeId, true);
|
thing->setStateValue(airQualityIndexConnectedStateTypeId, true);
|
||||||
thing->setStateValue(airQualityIndexHumidityStateTypeId, data.humidity);
|
thing->setStateValue(airQualityIndexHumidityStateTypeId, data.humidity);
|
||||||
thing->setStateValue(airQualityIndexTemperatureStateTypeId, data.temperature);
|
thing->setStateValue(airQualityIndexTemperatureStateTypeId, data.temperature);
|
||||||
@ -284,7 +288,6 @@ void IntegrationPluginAqi::onAirQualityStationsReceived(QUuid requestId, QList<A
|
|||||||
info->finish(Thing::ThingErrorNoError);
|
info->finish(Thing::ThingErrorNoError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (m_asyncRequests.contains(requestId)) {
|
if (m_asyncRequests.contains(requestId)) {
|
||||||
Thing * thing = myThings().findById(m_asyncRequests.value(requestId));
|
Thing * thing = myThings().findById(m_asyncRequests.value(requestId));
|
||||||
if (!thing) {
|
if (!thing) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,11 +31,11 @@
|
|||||||
#ifndef INTEGRATIONPLUGINAQI_H
|
#ifndef INTEGRATIONPLUGINAQI_H
|
||||||
#define INTEGRATIONPLUGINAQI_H
|
#define INTEGRATIONPLUGINAQI_H
|
||||||
|
|
||||||
#include "plugintimer.h"
|
#include <plugintimer.h>
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "network/networkaccessmanager.h"
|
#include <network/networkaccessmanager.h>
|
||||||
#include "airqualityindex.h"
|
|
||||||
|
|
||||||
|
#include "airqualityindex.h"
|
||||||
#include "extern-plugininfo.h"
|
#include "extern-plugininfo.h"
|
||||||
|
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@ -64,6 +64,7 @@ private:
|
|||||||
QHash<QUuid, ThingDiscoveryInfo *> m_asyncDiscovery;
|
QHash<QUuid, ThingDiscoveryInfo *> m_asyncDiscovery;
|
||||||
QHash<QUuid, ThingSetupInfo *> m_asyncSetups;
|
QHash<QUuid, ThingSetupInfo *> m_asyncSetups;
|
||||||
QHash<QUuid, ThingId> m_asyncRequests;
|
QHash<QUuid, ThingId> m_asyncRequests;
|
||||||
|
|
||||||
QString getApiKey();
|
QString getApiKey();
|
||||||
bool createAqiConnection();
|
bool createAqiConnection();
|
||||||
|
|
||||||
@ -74,6 +75,7 @@ private slots:
|
|||||||
void onRequestExecuted(QUuid requestId, bool success);
|
void onRequestExecuted(QUuid requestId, bool success);
|
||||||
void onAirQualityDataReceived(QUuid requestId, AirQualityIndex::AirQualityData data);
|
void onAirQualityDataReceived(QUuid requestId, AirQualityIndex::AirQualityData data);
|
||||||
void onAirQualityStationsReceived(QUuid requestId, QList<AirQualityIndex::Station> stations);
|
void onAirQualityStationsReceived(QUuid requestId, QList<AirQualityIndex::Station> stations);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINAQI_H
|
#endif // INTEGRATIONPLUGINAQI_H
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationpluginavahimonitor)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginavahimonitor.cpp
|
integrationpluginavahimonitor.cpp
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -30,10 +30,10 @@
|
|||||||
|
|
||||||
#include "integrationpluginavahimonitor.h"
|
#include "integrationpluginavahimonitor.h"
|
||||||
|
|
||||||
#include "integrations/thing.h"
|
#include <platform/platformzeroconfcontroller.h>
|
||||||
|
#include <integrations/thing.h>
|
||||||
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "platform/platformzeroconfcontroller.h"
|
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,12 +31,14 @@
|
|||||||
#ifndef INTEGRATIONPLUGINAVAHIMONITOR_H
|
#ifndef INTEGRATIONPLUGINAVAHIMONITOR_H
|
||||||
#define INTEGRATIONPLUGINAVAHIMONITOR_H
|
#define INTEGRATIONPLUGINAVAHIMONITOR_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
#include <network/zeroconf/zeroconfserviceentry.h>
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
#include "extern-plugininfo.h"
|
||||||
|
|
||||||
class IntegrationPluginAvahiMonitor : public IntegrationPlugin
|
class IntegrationPluginAvahiMonitor : public IntegrationPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -56,6 +58,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
ZeroConfServiceBrowser *m_serviceBrowser = nullptr;
|
ZeroConfServiceBrowser *m_serviceBrowser = nullptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINAVAHIMONITOR_H
|
#endif // INTEGRATIONPLUGINAVAHIMONITOR_H
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationpluginawattar)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginawattar.cpp
|
integrationpluginawattar.cpp
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -29,10 +29,11 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "integrationpluginawattar.h"
|
#include "integrationpluginawattar.h"
|
||||||
#include "integrations/thing.h"
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "hardwaremanager.h"
|
|
||||||
#include "network/networkaccessmanager.h"
|
#include <integrations/thing.h>
|
||||||
|
#include <hardwaremanager.h>
|
||||||
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
@ -73,7 +74,6 @@ void IntegrationPluginAwattar::setupThing(ThingSetupInfo *info)
|
|||||||
{
|
{
|
||||||
qCDebug(dcAwattar) << "Setup thing" << info->thing()->name() << info->thing()->params();
|
qCDebug(dcAwattar) << "Setup thing" << info->thing()->name() << info->thing()->params();
|
||||||
|
|
||||||
|
|
||||||
if (!m_pluginTimer) {
|
if (!m_pluginTimer) {
|
||||||
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(60 * 60);
|
m_pluginTimer = hardwareManager()->pluginTimerManager()->registerTimer(60 * 60);
|
||||||
connect(m_pluginTimer, &PluginTimer::timeout, this, &IntegrationPluginAwattar::onPluginTimer);
|
connect(m_pluginTimer, &PluginTimer::timeout, this, &IntegrationPluginAwattar::onPluginTimer);
|
||||||
@ -190,7 +190,7 @@ void IntegrationPluginAwattar::processPriceData(Thing *thing, const QVariantMap
|
|||||||
minPrice = price;
|
minPrice = price;
|
||||||
|
|
||||||
thing->setStateValue(m_currentMarketPriceStateTypeIds.value(thing->thingClassId()), currentPrice / 10.0);
|
thing->setStateValue(m_currentMarketPriceStateTypeIds.value(thing->thingClassId()), currentPrice / 10.0);
|
||||||
thing->setStateValue(m_validUntilStateTypeIds.value(thing->thingClassId()), endTime.toLocalTime().toTime_t());
|
thing->setStateValue(m_validUntilStateTypeIds.value(thing->thingClassId()), endTime.toLocalTime().toSecsSinceEpoch());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ void IntegrationPluginAwattar::processPriceData(Thing *thing, const QVariantMap
|
|||||||
thing->setStateValue(m_averageDeviationStateTypeIds.value(thing->thingClassId()), deviation);
|
thing->setStateValue(m_averageDeviationStateTypeIds.value(thing->thingClassId()), deviation);
|
||||||
|
|
||||||
qCDebug(dcAwattar()) << "AVG:" << averagePrice << "Min:" << minPrice << "Max:" << maxPrice << "Curr:" << currentPrice;
|
qCDebug(dcAwattar()) << "AVG:" << averagePrice << "Min:" << minPrice << "Max:" << maxPrice << "Curr:" << currentPrice;
|
||||||
qSort(prices.begin(), prices.end());
|
std::sort(prices.begin(), prices.end());
|
||||||
int rank = prices.indexOf(currentPrice);
|
int rank = prices.indexOf(currentPrice);
|
||||||
if (rank < 0) {
|
if (rank < 0) {
|
||||||
rank = 100;
|
rank = 100;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,8 +31,8 @@
|
|||||||
#ifndef INTEGRATIONPLUGINAWATTAR_H
|
#ifndef INTEGRATIONPLUGINAWATTAR_H
|
||||||
#define INTEGRATIONPLUGINAWATTAR_H
|
#define INTEGRATIONPLUGINAWATTAR_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "plugintimer.h"
|
#include <plugintimer.h>
|
||||||
|
|
||||||
#include <QHash>
|
#include <QHash>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|||||||
@ -38,9 +38,9 @@
|
|||||||
|
|
||||||
BluOS::BluOS(NetworkAccessManager *networkmanager, QHostAddress hostAddress, int port, QObject *parent) :
|
BluOS::BluOS(NetworkAccessManager *networkmanager, QHostAddress hostAddress, int port, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
m_networkManager(networkmanager),
|
||||||
m_hostAddress(hostAddress),
|
m_hostAddress(hostAddress),
|
||||||
m_port(port),
|
m_port(port)
|
||||||
m_networkManager(networkmanager)
|
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ QUuid BluOS::setVolume(uint volume)
|
|||||||
int volume = 0;
|
int volume = 0;
|
||||||
bool mute = false;
|
bool mute = false;
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "volume") {
|
if (xml.name() == QString("volume")) {
|
||||||
if(xml.attributes().hasAttribute("mute")) {
|
if(xml.attributes().hasAttribute("mute")) {
|
||||||
mute = xml.attributes().value("mute").toInt();
|
mute = xml.attributes().value("mute").toInt();
|
||||||
}
|
}
|
||||||
@ -277,7 +277,7 @@ QUuid BluOS::setRepeat(RepeatMode repeatMode)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "playlist") {
|
if (xml.name() == QString("playlist")) {
|
||||||
if (xml.attributes().hasAttribute("repeat")) {
|
if (xml.attributes().hasAttribute("repeat")) {
|
||||||
RepeatMode mode = RepeatMode(xml.attributes().value("repeat").toInt());
|
RepeatMode mode = RepeatMode(xml.attributes().value("repeat").toInt());
|
||||||
emit repeatModeReceived(mode);
|
emit repeatModeReceived(mode);
|
||||||
@ -323,9 +323,9 @@ QUuid BluOS::listPresets()
|
|||||||
}
|
}
|
||||||
QList<Preset> presetList;
|
QList<Preset> presetList;
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "presets") {
|
if (xml.name() == QString("presets")) {
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "preset"){
|
if(xml.name() == QString("preset")){
|
||||||
Preset preset;
|
Preset preset;
|
||||||
if (xml.attributes().hasAttribute("id")) {
|
if (xml.attributes().hasAttribute("id")) {
|
||||||
preset.Id = xml.attributes().value("id").toInt();
|
preset.Id = xml.attributes().value("id").toInt();
|
||||||
@ -417,9 +417,9 @@ QUuid BluOS::getSources()
|
|||||||
}
|
}
|
||||||
QList<Source> sourceList;
|
QList<Source> sourceList;
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "browse") {
|
if (xml.name() == QString("browse")) {
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "item"){
|
if(xml.name() == QString("item")){
|
||||||
Source source;
|
Source source;
|
||||||
if (xml.attributes().hasAttribute("text")) {
|
if (xml.attributes().hasAttribute("text")) {
|
||||||
source.Text = xml.attributes().value("text").toString();
|
source.Text = xml.attributes().value("text").toString();
|
||||||
@ -483,9 +483,9 @@ QUuid BluOS::browseSource(const QString &key)
|
|||||||
}
|
}
|
||||||
QList<Source> sourceList;
|
QList<Source> sourceList;
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "browse") {
|
if (xml.name() == QString("browse")) {
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "item"){
|
if(xml.name() == QString("item")){
|
||||||
Source source;
|
Source source;
|
||||||
if (xml.attributes().hasAttribute("text")) {
|
if (xml.attributes().hasAttribute("text")) {
|
||||||
source.Text = xml.attributes().value("text").toString();
|
source.Text = xml.attributes().value("text").toString();
|
||||||
@ -648,23 +648,23 @@ bool BluOS::parseState(const QByteArray &state)
|
|||||||
|
|
||||||
StatusResponse statusResponse;
|
StatusResponse statusResponse;
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "status") {
|
if (xml.name() == QString("status")) {
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "artist"){
|
if(xml.name() == QString("artist")){
|
||||||
statusResponse.Artist = xml.readElementText();
|
statusResponse.Artist = xml.readElementText();
|
||||||
} else if(xml.name() == "album"){
|
} else if(xml.name() == QString("album")){
|
||||||
statusResponse.Album = xml.readElementText();
|
statusResponse.Album = xml.readElementText();
|
||||||
} else if(xml.name() == "name"){
|
} else if(xml.name() == QString("name")){
|
||||||
statusResponse.Name = xml.readElementText();
|
statusResponse.Name = xml.readElementText();
|
||||||
} else if(xml.name() == "service"){
|
} else if(xml.name() == QString("service")){
|
||||||
statusResponse.Service = xml.readElementText();
|
statusResponse.Service = xml.readElementText();
|
||||||
} else if(xml.name() == "serviceIcon"){
|
} else if(xml.name() == QString("serviceIcon")){
|
||||||
statusResponse.ServiceIcon = xml.readElementText();
|
statusResponse.ServiceIcon = xml.readElementText();
|
||||||
} else if(xml.name() == "shuffle"){
|
} else if(xml.name() == QString("shuffle")){
|
||||||
statusResponse.Shuffle = xml.readElementText().toInt();
|
statusResponse.Shuffle = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "repeat"){
|
} else if(xml.name() == QString("repeat")){
|
||||||
statusResponse.Shuffle = xml.readElementText().toInt();
|
statusResponse.Shuffle = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "state"){
|
} else if(xml.name() == QString("state")){
|
||||||
QString playback = xml.readElementText();
|
QString playback = xml.readElementText();
|
||||||
if (playback == "play") {
|
if (playback == "play") {
|
||||||
statusResponse.State = PlaybackState::Playing;
|
statusResponse.State = PlaybackState::Playing;
|
||||||
@ -680,15 +680,15 @@ bool BluOS::parseState(const QByteArray &state)
|
|||||||
statusResponse.State = PlaybackState::Stopped;
|
statusResponse.State = PlaybackState::Stopped;
|
||||||
qCWarning(dcBluOS()) << "State response, unhandled playback mode" << playback;
|
qCWarning(dcBluOS()) << "State response, unhandled playback mode" << playback;
|
||||||
}
|
}
|
||||||
} else if(xml.name() == "volume"){
|
} else if(xml.name() == QString("volume")){
|
||||||
statusResponse.Volume = xml.readElementText().toInt();
|
statusResponse.Volume = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "mute"){
|
} else if(xml.name() == QString("mute")){
|
||||||
statusResponse.Mute = xml.readElementText().toInt();
|
statusResponse.Mute = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "image") {
|
} else if(xml.name() == QString("image")) {
|
||||||
statusResponse.Image = xml.readElementText();
|
statusResponse.Image = xml.readElementText();
|
||||||
} else if(xml.name() == "title1") {
|
} else if(xml.name() == QString("title1")) {
|
||||||
statusResponse.Title = xml.readElementText();
|
statusResponse.Title = xml.readElementText();
|
||||||
} else if(xml.name() == "group") {
|
} else if(xml.name() == QString("group")) {
|
||||||
statusResponse.Group = xml.readElementText();
|
statusResponse.Group = xml.readElementText();
|
||||||
} else {
|
} else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,13 +31,13 @@
|
|||||||
#ifndef BLUOS_H
|
#ifndef BLUOS_H
|
||||||
#define BLUOS_H
|
#define BLUOS_H
|
||||||
|
|
||||||
#include <QObject>
|
|
||||||
#include <QTimer>
|
|
||||||
#include <QHostAddress>
|
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QHostAddress>
|
||||||
|
|
||||||
#include "network/networkaccessmanager.h"
|
#include <integrations/thing.h>
|
||||||
#include "integrations/thing.h"
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
class BluOS : public QObject
|
class BluOS : public QObject
|
||||||
{
|
{
|
||||||
@ -67,20 +67,20 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct StatusResponse {
|
struct StatusResponse {
|
||||||
QString Album;
|
QString Album;
|
||||||
QString Artist;
|
QString Artist;
|
||||||
QString Name;
|
QString Name;
|
||||||
QString Title;
|
QString Title;
|
||||||
QString Service;
|
QString Service;
|
||||||
QUrl ServiceIcon;
|
QUrl ServiceIcon;
|
||||||
PlaybackState State;
|
PlaybackState State;
|
||||||
QUrl StationUrl;
|
QUrl StationUrl;
|
||||||
int Volume;
|
int Volume;
|
||||||
bool Mute;
|
bool Mute;
|
||||||
RepeatMode Repeat;
|
RepeatMode Repeat;
|
||||||
bool Shuffle;
|
bool Shuffle;
|
||||||
QUrl Image;
|
QUrl Image;
|
||||||
QString Group;
|
QString Group;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Preset {
|
struct Preset {
|
||||||
@ -98,6 +98,7 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
explicit BluOS(NetworkAccessManager *networkManager, QHostAddress hostAddress, int port, QObject *parent = nullptr);
|
explicit BluOS(NetworkAccessManager *networkManager, QHostAddress hostAddress, int port, QObject *parent = nullptr);
|
||||||
|
|
||||||
int port();
|
int port();
|
||||||
QHostAddress hostAddress();
|
QHostAddress hostAddress();
|
||||||
|
|
||||||
@ -130,24 +131,24 @@ public:
|
|||||||
QUuid removeGroupPlayer(QHostAddress address, int port);
|
QUuid removeGroupPlayer(QHostAddress address, int port);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
NetworkAccessManager *m_networkManager = nullptr;
|
||||||
QHostAddress m_hostAddress;
|
QHostAddress m_hostAddress;
|
||||||
int m_port;
|
int m_port;
|
||||||
NetworkAccessManager *m_networkManager = nullptr;
|
|
||||||
|
|
||||||
QUuid playBackControl(PlaybackCommand command);
|
QUuid playBackControl(PlaybackCommand command);
|
||||||
bool parseState(const QByteArray &state);
|
bool parseState(const QByteArray &state);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectionChanged(bool connected);
|
void connectionChanged(bool connected);
|
||||||
void actionExecuted(QUuid actionId, bool success);
|
void actionExecuted(const QUuid &actionId, bool success);
|
||||||
|
|
||||||
void statusReceived(const StatusResponse &status);
|
void statusReceived(const BluOS::StatusResponse &status);
|
||||||
void volumeReceived(int volume, bool mute);
|
void volumeReceived(int volume, bool mute);
|
||||||
void shuffleStateReceived(bool state);
|
void shuffleStateReceived(bool state);
|
||||||
void repeatModeReceived(RepeatMode mode);
|
void repeatModeReceived(BluOS::RepeatMode mode);
|
||||||
|
|
||||||
void presetsReceived(QUuid requestId, const QList<Preset> &presets);
|
void presetsReceived(const QUuid &requestId, const QList<BluOS::Preset> &presets);
|
||||||
void sourcesReceived(QUuid requestId, const QList<Source> &sources);
|
void sourcesReceived(const QUuid &requestId, const QList<BluOS::Source> &sources);
|
||||||
void browseResultReceived(QUuid requestId, const QList<Source> &sources);
|
void browseResultReceived(const QUuid &requestId, const QList<BluOS::Source> &sources);
|
||||||
};
|
};
|
||||||
#endif // BLUOS_H
|
#endif // BLUOS_H
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginbluos.cpp \
|
integrationpluginbluos.cpp \
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,10 +31,10 @@
|
|||||||
|
|
||||||
#include "integrationpluginbluos.h"
|
#include "integrationpluginbluos.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "integrations/thing.h"
|
|
||||||
#include "network/networkaccessmanager.h"
|
#include <integrations/thing.h>
|
||||||
#include "types/mediabrowseritem.h"
|
#include <types/mediabrowseritem.h>
|
||||||
#include "types/browseritem.h"
|
#include <types/browseritem.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -158,42 +158,42 @@ void IntegrationPluginBluOS::executeAction(ThingActionInfo *info)
|
|||||||
qCWarning(dcBluOS()) << "Unhandled Playback mode";
|
qCWarning(dcBluOS()) << "Unhandled Playback mode";
|
||||||
}
|
}
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerPlayActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerPlayActionTypeId) {
|
||||||
QUuid requestId = bluos->play();
|
QUuid requestId = bluos->play();
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerPauseActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerPauseActionTypeId) {
|
||||||
QUuid requestId = bluos->pause();
|
QUuid requestId = bluos->pause();
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerStopActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerStopActionTypeId) {
|
||||||
QUuid requestId = bluos->stop();
|
QUuid requestId = bluos->stop();
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerSkipNextActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerSkipNextActionTypeId) {
|
||||||
QUuid requestId = bluos->skip();
|
QUuid requestId = bluos->skip();
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerSkipBackActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerSkipBackActionTypeId) {
|
||||||
QUuid requestId = bluos->back();
|
QUuid requestId = bluos->back();
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerVolumeActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerVolumeActionTypeId) {
|
||||||
uint volume = action.param(bluosPlayerVolumeActionVolumeParamTypeId).value().toUInt();
|
uint volume = action.param(bluosPlayerVolumeActionVolumeParamTypeId).value().toUInt();
|
||||||
QUuid requestId = bluos->setVolume(volume);
|
QUuid requestId = bluos->setVolume(volume);
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerMuteActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerMuteActionTypeId) {
|
||||||
bool mute = action.param(bluosPlayerMuteActionMuteParamTypeId).value().toBool();
|
bool mute = action.param(bluosPlayerMuteActionMuteParamTypeId).value().toBool();
|
||||||
QUuid requestId = bluos->setMute(mute);
|
QUuid requestId = bluos->setMute(mute);
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerShuffleActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerShuffleActionTypeId) {
|
||||||
bool shuffle = action.param(bluosPlayerShuffleActionShuffleParamTypeId).value().toBool();
|
bool shuffle = action.param(bluosPlayerShuffleActionShuffleParamTypeId).value().toBool();
|
||||||
QUuid requestId = bluos->setShuffle(shuffle);
|
QUuid requestId = bluos->setShuffle(shuffle);
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerRepeatActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerRepeatActionTypeId) {
|
||||||
QString repeat = action.param(bluosPlayerRepeatActionRepeatParamTypeId).value().toString();
|
QString repeat = action.param(bluosPlayerRepeatActionRepeatParamTypeId).value().toString();
|
||||||
QUuid requestId;
|
QUuid requestId;
|
||||||
@ -207,17 +207,17 @@ void IntegrationPluginBluOS::executeAction(ThingActionInfo *info)
|
|||||||
qCWarning(dcBluOS()) << "Unhandled Repeat Mode";
|
qCWarning(dcBluOS()) << "Unhandled Repeat Mode";
|
||||||
}
|
}
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerIncreaseVolumeActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerIncreaseVolumeActionTypeId) {
|
||||||
uint step = action.param(bluosPlayerIncreaseVolumeActionStepParamTypeId).value().toUInt();
|
uint step = action.param(bluosPlayerIncreaseVolumeActionStepParamTypeId).value().toUInt();
|
||||||
QUuid requestId = bluos->setVolume(qMin<uint>(100, thing->stateValue(bluosPlayerVolumeStateTypeId).toUInt() + step));
|
QUuid requestId = bluos->setVolume(qMin<uint>(100, thing->stateValue(bluosPlayerVolumeStateTypeId).toUInt() + step));
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else if (action.actionTypeId() == bluosPlayerDecreaseVolumeActionTypeId) {
|
} else if (action.actionTypeId() == bluosPlayerDecreaseVolumeActionTypeId) {
|
||||||
uint step = action.param(bluosPlayerDecreaseVolumeActionStepParamTypeId).value().toUInt();
|
uint step = action.param(bluosPlayerDecreaseVolumeActionStepParamTypeId).value().toUInt();
|
||||||
QUuid requestId = bluos->setVolume(qMax<uint>(0, thing->stateValue(bluosPlayerVolumeStateTypeId).toUInt() - step));
|
QUuid requestId = bluos->setVolume(qMax<uint>(0, thing->stateValue(bluosPlayerVolumeStateTypeId).toUInt() - step));
|
||||||
m_asyncActions.insert(requestId, info);
|
m_asyncActions.insert(requestId, info);
|
||||||
connect(info, &ThingActionInfo::aborted, [this, requestId] {m_asyncActions.remove(requestId);});
|
connect(info, &ThingActionInfo::aborted, this, [this, requestId] {m_asyncActions.remove(requestId);});
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcBluOS()) << "Execute Action, unhandled action type id" << action.actionTypeId();
|
qCWarning(dcBluOS()) << "Execute Action, unhandled action type id" << action.actionTypeId();
|
||||||
return info->finish(Thing::ThingErrorThingClassNotFound);
|
return info->finish(Thing::ThingErrorThingClassNotFound);
|
||||||
@ -414,7 +414,7 @@ void IntegrationPluginBluOS::onActionExecuted(QUuid requestId, bool success)
|
|||||||
} else {
|
} else {
|
||||||
info->finish(Thing::ThingErrorHardwareFailure);
|
info->finish(Thing::ThingErrorHardwareFailure);
|
||||||
}
|
}
|
||||||
m_pluginTimer->timeout(); // get a status update
|
emit m_pluginTimer->timeout(); // get a status update
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -33,10 +33,10 @@
|
|||||||
|
|
||||||
#include "bluos.h"
|
#include "bluos.h"
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "platform/platformzeroconfcontroller.h"
|
#include <platform/platformzeroconfcontroller.h>
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
#include "plugintimer.h"
|
#include <plugintimer.h>
|
||||||
|
|
||||||
#include <QUdpSocket>
|
#include <QUdpSocket>
|
||||||
#include <QNetworkAccessManager>
|
#include <QNetworkAccessManager>
|
||||||
@ -86,5 +86,6 @@ private slots:
|
|||||||
void onPresetsReceived(QUuid requestId, const QList<BluOS::Preset> &presets);
|
void onPresetsReceived(QUuid requestId, const QList<BluOS::Preset> &presets);
|
||||||
void onSourcesReceived(QUuid requestId, const QList<BluOS::Source> &sources);
|
void onSourcesReceived(QUuid requestId, const QList<BluOS::Source> &sources);
|
||||||
void onBrowseResultReceived(QUuid requestId, const QList<BluOS::Source> &sources);
|
void onBrowseResultReceived(QUuid requestId, const QList<BluOS::Source> &sources);
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // INTEGRATIONPLUGINBLUOS_H
|
#endif // INTEGRATIONPLUGINBLUOS_H
|
||||||
|
|||||||
@ -1,10 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += \
|
QT *= network websockets
|
||||||
network \
|
|
||||||
websockets \
|
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationpluginbose)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginbose.cpp \
|
integrationpluginbose.cpp \
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -29,11 +29,12 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "integrationpluginbose.h"
|
#include "integrationpluginbose.h"
|
||||||
#include "integrations/thing.h"
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "platform/platformzeroconfcontroller.h"
|
|
||||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
#include <integrations/thing.h>
|
||||||
#include "types/mediabrowseritem.h"
|
#include <platform/platformzeroconfcontroller.h>
|
||||||
|
#include <network/zeroconf/zeroconfserviceentry.h>
|
||||||
|
#include <types/mediabrowseritem.h>
|
||||||
|
|
||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -545,7 +546,7 @@ void IntegrationPluginBose::onSourcesObjectReceived(QUuid requestId, SourcesObje
|
|||||||
if (m_asyncBrowseResults.contains(requestId)) {
|
if (m_asyncBrowseResults.contains(requestId)) {
|
||||||
BrowseResult *result = m_asyncBrowseResults.value(requestId);
|
BrowseResult *result = m_asyncBrowseResults.value(requestId);
|
||||||
foreach (SourceItemObject sourceItem, sources.sourceItems) {
|
foreach (SourceItemObject sourceItem, sources.sourceItems) {
|
||||||
qDebug(dcBose()) << "Source:" << sourceItem.source;
|
qCDebug(dcBose()) << "Source:" << sourceItem.source;
|
||||||
if (sourceItem.source == "BLUETOOTH") {
|
if (sourceItem.source == "BLUETOOTH") {
|
||||||
MediaBrowserItem item(sourceItem.source, sourceItem.source, false, true);
|
MediaBrowserItem item(sourceItem.source, sourceItem.source, false, true);
|
||||||
item.setDescription(sourceItem.sourceAccount);
|
item.setDescription(sourceItem.sourceAccount);
|
||||||
@ -591,15 +592,15 @@ void IntegrationPluginBose::onBassObjectReceived(QUuid requestId, BassObject bas
|
|||||||
void IntegrationPluginBose::onBassCapabilitiesObjectReceived(QUuid requestId, BassCapabilitiesObject bassCapabilities)
|
void IntegrationPluginBose::onBassCapabilitiesObjectReceived(QUuid requestId, BassCapabilitiesObject bassCapabilities)
|
||||||
{
|
{
|
||||||
Q_UNUSED(requestId);
|
Q_UNUSED(requestId);
|
||||||
qDebug(dcBose()) << "Bass capabilities (max, min, default):" << bassCapabilities.bassMax << bassCapabilities.bassMin << bassCapabilities.bassDefault;
|
qCDebug(dcBose()) << "Bass capabilities (max, min, default):" << bassCapabilities.bassMax << bassCapabilities.bassMin << bassCapabilities.bassDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginBose::onGroupObjectReceived(QUuid requestId, GroupObject group)
|
void IntegrationPluginBose::onGroupObjectReceived(QUuid requestId, GroupObject group)
|
||||||
{
|
{
|
||||||
Q_UNUSED(requestId);
|
Q_UNUSED(requestId);
|
||||||
qDebug(dcBose()) << "Group" << group.name << group.status;
|
qCDebug(dcBose()) << "Group" << group.name << group.status;
|
||||||
foreach (RolesObject role, group.roles) {
|
foreach (RolesObject role, group.roles) {
|
||||||
qDebug(dcBose()) << "-> member:" << role.groupRole.deviceID;
|
qCDebug(dcBose()) << "-> member:" << role.groupRole.deviceID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -607,7 +608,7 @@ void IntegrationPluginBose::onZoneObjectReceived(QUuid requestId, ZoneObject zon
|
|||||||
{
|
{
|
||||||
Q_UNUSED(requestId);
|
Q_UNUSED(requestId);
|
||||||
foreach (MemberObject member, zone.members) {
|
foreach (MemberObject member, zone.members) {
|
||||||
qDebug(dcBose()) << "-> member:" << member.deviceID;
|
qCDebug(dcBose()) << "-> member:" << member.deviceID;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,9 +31,10 @@
|
|||||||
#ifndef INTEGRATIONPLUGINBOSE_H
|
#ifndef INTEGRATIONPLUGINBOSE_H
|
||||||
#define INTEGRATIONPLUGINBOSE_H
|
#define INTEGRATIONPLUGINBOSE_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
#include "plugintimer.h"
|
#include <plugintimer.h>
|
||||||
|
|
||||||
#include "soundtouch.h"
|
#include "soundtouch.h"
|
||||||
#include "soundtouchtypes.h"
|
#include "soundtouchtypes.h"
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -29,9 +29,9 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "soundtouch.h"
|
#include "soundtouch.h"
|
||||||
#include "hardwaremanager.h"
|
|
||||||
#include "integrations/thing.h"
|
#include <hardwaremanager.h>
|
||||||
#include "network/networkaccessmanager.h"
|
#include <integrations/thing.h>
|
||||||
|
|
||||||
SoundTouch::SoundTouch(NetworkAccessManager *networkAccessManager, QString ipAddress, QObject *parent) :
|
SoundTouch::SoundTouch(NetworkAccessManager *networkAccessManager, QString ipAddress, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
@ -47,7 +47,7 @@ SoundTouch::SoundTouch(NetworkAccessManager *networkAccessManager, QString ipAdd
|
|||||||
//url.setHost(m_ipAddress);
|
//url.setHost(m_ipAddress);
|
||||||
//url.setScheme("ws");
|
//url.setScheme("ws");
|
||||||
//url.setPort(8080);
|
//url.setPort(8080);
|
||||||
//qDebug(dcBose) << "Connecting websocket to" << url;
|
//qCDebug(dcBose()) << "Connecting websocket to" << url;
|
||||||
//TODO missing websocket subprotocol "gabbo"
|
//TODO missing websocket subprotocol "gabbo"
|
||||||
//QWebsockets doesn't support subprotocols
|
//QWebsockets doesn't support subprotocols
|
||||||
//m_websocket->open(url);
|
//m_websocket->open(url);
|
||||||
@ -249,9 +249,10 @@ QUuid SoundTouch::setKey(KEY_VALUE keyValue, bool pressed)
|
|||||||
xml.writeCharacters("PRESET_6");
|
xml.writeCharacters("PRESET_6");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
qWarning(dcBose) << "key not yet implemented";
|
qCWarning(dcBose()) << "key not yet implemented";
|
||||||
return "0";
|
return QUuid();
|
||||||
}
|
}
|
||||||
|
|
||||||
xml.writeEndElement(); //key
|
xml.writeEndElement(); //key
|
||||||
xml.writeEndDocument();
|
xml.writeEndDocument();
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
@ -444,7 +445,7 @@ QUuid SoundTouch::setBass(int volume)
|
|||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
QUuid SoundTouch::setName(QString name)
|
QUuid SoundTouch::setName(const QString &name)
|
||||||
{
|
{
|
||||||
QUuid requestId = QUuid::createUuid();
|
QUuid requestId = QUuid::createUuid();
|
||||||
QUrl url;
|
QUrl url;
|
||||||
@ -454,7 +455,7 @@ QUuid SoundTouch::setName(QString name)
|
|||||||
url.setPath("/name");
|
url.setPath("/name");
|
||||||
QByteArray content = ("<?xml version=\"1.0\" ?>");
|
QByteArray content = ("<?xml version=\"1.0\" ?>");
|
||||||
content.append("<name>");
|
content.append("<name>");
|
||||||
content.append(name);
|
content.append(name.toUtf8());
|
||||||
content.append("</name>");
|
content.append("</name>");
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
|
request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml");
|
||||||
@ -498,13 +499,13 @@ QUuid SoundTouch::setSpeaker(PlayInfoObject playInfo)
|
|||||||
|
|
||||||
void SoundTouch::onWebsocketConnected()
|
void SoundTouch::onWebsocketConnected()
|
||||||
{
|
{
|
||||||
qDebug(dcBose) << "Bose websocket connected";
|
qCDebug(dcBose()) << "Bose websocket connected";
|
||||||
emit connectionChanged(true);
|
emit connectionChanged(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTouch::onWebsocketDisconnected()
|
void SoundTouch::onWebsocketDisconnected()
|
||||||
{
|
{
|
||||||
qDebug(dcBose) << "Bose websocket disconnected";
|
qCDebug(dcBose()) << "Bose websocket disconnected";
|
||||||
emit connectionChanged(false);
|
emit connectionChanged(false);
|
||||||
QTimer::singleShot(5000, this, [this](){
|
QTimer::singleShot(5000, this, [this](){
|
||||||
QUrl url;
|
QUrl url;
|
||||||
@ -517,7 +518,7 @@ void SoundTouch::onWebsocketDisconnected()
|
|||||||
|
|
||||||
void SoundTouch::onWebsocketMessageReceived(QString message)
|
void SoundTouch::onWebsocketMessageReceived(QString message)
|
||||||
{
|
{
|
||||||
qDebug(dcBose) << "Websocket message received:" << message;
|
qCDebug(dcBose()) << "Websocket message received:" << message;
|
||||||
//TODO as soon as QWebSocket supports sub-protocols
|
//TODO as soon as QWebSocket supports sub-protocols
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -529,7 +530,7 @@ QUuid SoundTouch::sendGetRequest(QString path)
|
|||||||
url.setScheme("http");
|
url.setScheme("http");
|
||||||
url.setPort(m_port);
|
url.setPort(m_port);
|
||||||
url.setPath(path);
|
url.setPath(path);
|
||||||
//qDebug(dcBose) << "Sending request" << url;
|
//qCDebug(dcBose()) << "Sending request" << url;
|
||||||
QNetworkRequest request = QNetworkRequest(url);
|
QNetworkRequest request = QNetworkRequest(url);
|
||||||
|
|
||||||
QNetworkReply *reply = m_networkAccessManager->get(request);
|
QNetworkReply *reply = m_networkAccessManager->get(request);
|
||||||
@ -563,7 +564,7 @@ QUuid SoundTouch::sendGetRequest(QString path)
|
|||||||
return requestId;
|
return requestId;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTouch::emitRequestStatus(QUuid requestId, QNetworkReply *reply)
|
void SoundTouch::emitRequestStatus(const QUuid &requestId, QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
int status = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
|
||||||
// Check HTTP status code
|
// Check HTTP status code
|
||||||
@ -584,17 +585,17 @@ void SoundTouch::emitRequestStatus(QUuid requestId, QNetworkReply *reply)
|
|||||||
xml.addData(data);
|
xml.addData(data);
|
||||||
|
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "status") {
|
if (xml.name() == QString("status")) {
|
||||||
//QString status = xml.readElementText();
|
//QString status = xml.readElementText();
|
||||||
emit requestExecuted(requestId, true);
|
emit requestExecuted(requestId, true);
|
||||||
} else if (xml.name() == "errors") {
|
} else if (xml.name() == QString("errors")) {
|
||||||
emit requestExecuted(requestId, false);
|
emit requestExecuted(requestId, false);
|
||||||
QString deviceId;
|
QString deviceId;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
deviceId = xml.attributes().value("deviceID").toString();
|
deviceId = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "error"){
|
if(xml.name() == QString("error")){
|
||||||
ErrorObject error;
|
ErrorObject error;
|
||||||
error.deviceId = deviceId;
|
error.deviceId = deviceId;
|
||||||
error.error = xml.readElementText();
|
error.error = xml.readElementText();
|
||||||
@ -614,36 +615,36 @@ void SoundTouch::emitRequestStatus(QUuid requestId, QNetworkReply *reply)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
void SoundTouch::parseData(const QUuid &requestId, const QByteArray &data)
|
||||||
{
|
{
|
||||||
QXmlStreamReader xml;
|
QXmlStreamReader xml;
|
||||||
xml.addData(data);
|
xml.addData(data);
|
||||||
|
|
||||||
if (xml.readNextStartElement()) {
|
if (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "info") {
|
if (xml.name() == QString("info")) {
|
||||||
InfoObject info;
|
InfoObject info;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
//qDebug(dcBose) << "Device ID" << xml.attributes().value("deviceID").toString();
|
//qCDebug(dcBose()) << "Device ID" << xml.attributes().value("deviceID").toString();
|
||||||
info.deviceID = xml.attributes().value("deviceID").toString();
|
info.deviceID = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "name"){
|
if(xml.name() == QString("name")){
|
||||||
//qDebug(dcBose) << "name" << xml.readElementText();
|
//qCDebug(dcBose()) << "name" << xml.readElementText();
|
||||||
info.name = xml.readElementText();
|
info.name = xml.readElementText();
|
||||||
} else if(xml.name() == "type"){
|
} else if(xml.name() == QString("type")){
|
||||||
//qDebug(dcBose) << "type" << xml.readElementText();
|
//qCDebug(dcBose()) << "type" << xml.readElementText();
|
||||||
info.type = xml.readElementText();
|
info.type = xml.readElementText();
|
||||||
} else if(xml.name() == "components"){
|
} else if(xml.name() == QString("components")){
|
||||||
//qDebug(dcBose) << "components element";
|
//qCDebug(dcBose()) << "components element";
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "component"){
|
if(xml.name() == QString("component")){
|
||||||
ComponentObject component;
|
ComponentObject component;
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "softwareVersion"){
|
if(xml.name() == QString("softwareVersion")){
|
||||||
//qDebug(dcBose) << "Software version" << xml.readElementText();
|
//qCDebug(dcBose()) << "Software version" << xml.readElementText();
|
||||||
component.softwareVersion = xml.readElementText();
|
component.softwareVersion = xml.readElementText();
|
||||||
} else if(xml.name() == "serialNumber") {
|
} else if(xml.name() == QString("serialNumber")) {
|
||||||
//qDebug(dcBose) << "Serialnumber" << xml.readElementText();
|
//qCDebug(dcBose()) << "Serialnumber" << xml.readElementText();
|
||||||
component.serialNumber = xml.readElementText();
|
component.serialNumber = xml.readElementText();
|
||||||
} else {
|
} else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
@ -654,11 +655,11 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(xml.name() == "networkInfo"){
|
} else if(xml.name() == QString("networkInfo")){
|
||||||
while (xml.readNextStartElement()) {
|
while (xml.readNextStartElement()) {
|
||||||
if (xml.name() == "macAddress") {
|
if (xml.name() == QString("macAddress")) {
|
||||||
info.networkInfo.macAddress = xml.readElementText();
|
info.networkInfo.macAddress = xml.readElementText();
|
||||||
} else if(xml.name() == "ipAddress") {
|
} else if(xml.name() == QString("ipAddress")) {
|
||||||
info.networkInfo.ipAddress = xml.readElementText();
|
info.networkInfo.ipAddress = xml.readElementText();
|
||||||
} else {
|
} else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
@ -669,45 +670,45 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit infoReceived(requestId, info);
|
emit infoReceived(requestId, info);
|
||||||
} else if (xml.name() == "nowPlaying") {
|
} else if (xml.name() == QString("nowPlaying")) {
|
||||||
NowPlayingObject nowPlaying;
|
NowPlayingObject nowPlaying;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
//qDebug(dcBose) << "Device ID" << xml.attributes().value("deviceID").toString();
|
//qCDebug(dcBose()) << "Device ID" << xml.attributes().value("deviceID").toString();
|
||||||
nowPlaying.deviceID = xml.attributes().value("deviceID").toString();
|
nowPlaying.deviceID = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
if(xml.attributes().hasAttribute("source")) {
|
if(xml.attributes().hasAttribute("source")) {
|
||||||
//qDebug(dcBose) << "Source" << xml.attributes().value("source").toString();
|
//qCDebug(dcBose()) << "Source" << xml.attributes().value("source").toString();
|
||||||
nowPlaying.source = xml.attributes().value("source").toString();
|
nowPlaying.source = xml.attributes().value("source").toString();
|
||||||
}
|
}
|
||||||
if(xml.attributes().hasAttribute("sourceAccount")) {
|
if(xml.attributes().hasAttribute("sourceAccount")) {
|
||||||
//qDebug(dcBose) << "Source Account" << xml.attributes().value("sourceAccount").toString();
|
//qCDebug(dcBose()) << "Source Account" << xml.attributes().value("sourceAccount").toString();
|
||||||
nowPlaying.sourceAccount = xml.attributes().value("sourceAccount").toString();
|
nowPlaying.sourceAccount = xml.attributes().value("sourceAccount").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if (xml.name() == "track") {
|
if (xml.name() == QString("track")) {
|
||||||
//qDebug(dcBose) << "track" << xml.readElementText();
|
//qCDebug(dcBose()) << "track" << xml.readElementText();
|
||||||
nowPlaying.track = xml.readElementText();
|
nowPlaying.track = xml.readElementText();
|
||||||
} else if(xml.name() == "artist") {
|
} else if(xml.name() == QString("artist")) {
|
||||||
//qDebug(dcBose) << "artist" << xml.readElementText();
|
//qCDebug(dcBose()) << "artist" << xml.readElementText();
|
||||||
nowPlaying.artist = xml.readElementText();
|
nowPlaying.artist = xml.readElementText();
|
||||||
} else if(xml.name() == "album") {
|
} else if(xml.name() == QString("album")) {
|
||||||
//qDebug(dcBose) << "album" << xml.readElementText();
|
//qCDebug(dcBose()) << "album" << xml.readElementText();
|
||||||
nowPlaying.album = xml.readElementText();
|
nowPlaying.album = xml.readElementText();
|
||||||
} else if(xml.name() == "genre") {
|
} else if(xml.name() == QString("genre")) {
|
||||||
//qDebug(dcBose) << "genre" << xml.readElementText();
|
//qCDebug(dcBose()) << "genre" << xml.readElementText();
|
||||||
nowPlaying.genre = xml.readElementText();
|
nowPlaying.genre = xml.readElementText();
|
||||||
} else if(xml.name() == "rating") {
|
} else if(xml.name() == QString("rating")) {
|
||||||
//qDebug(dcBose) << "rating" << xml.readElementText();
|
//qCDebug(dcBose()) << "rating" << xml.readElementText();
|
||||||
nowPlaying.rating = xml.readElementText();
|
nowPlaying.rating = xml.readElementText();
|
||||||
} else if(xml.name() == "stationName") {
|
} else if(xml.name() == QString("stationName")) {
|
||||||
//qDebug(dcBose) << "Station name" << xml.readElementText();
|
//qCDebug(dcBose()) << "Station name" << xml.readElementText();
|
||||||
nowPlaying.stationName = xml.readElementText();
|
nowPlaying.stationName = xml.readElementText();
|
||||||
} else if(xml.name() == "art") {
|
} else if(xml.name() == QString("art")) {
|
||||||
ArtObject art;
|
ArtObject art;
|
||||||
if(xml.attributes().hasAttribute("artImageStatus")) {
|
if(xml.attributes().hasAttribute("artImageStatus")) {
|
||||||
QString artStatus = xml.attributes().value("artImageStatus").toString().toUpper();
|
QString artStatus = xml.attributes().value("artImageStatus").toString().toUpper();
|
||||||
//ART_STATUS: INVALID, SHOW_DEFAULT_IMAGE, DOWNLOADING, IMAGE_PRESENT
|
//ART_STATUS: INVALID, SHOW_DEFAULT_IMAGE, DOWNLOADING, IMAGE_PRESENT
|
||||||
//qDebug(dcBose) << "Art Image status" << artStatus;
|
//qCDebug(dcBose()) << "Art Image status" << artStatus;
|
||||||
if (artStatus == "INVALID") {
|
if (artStatus == "INVALID") {
|
||||||
art.artStatus = ART_STATUS_INVALID;
|
art.artStatus = ART_STATUS_INVALID;
|
||||||
} else if (artStatus == "SHOW_DEFAULT_IMAGE") {
|
} else if (artStatus == "SHOW_DEFAULT_IMAGE") {
|
||||||
@ -719,9 +720,9 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
nowPlaying.art.url = xml.readElementText();
|
nowPlaying.art.url = xml.readElementText();
|
||||||
}else if(xml.name() == "playStatus") {
|
}else if(xml.name() == QString("playStatus")) {
|
||||||
QString playStatus = xml.readElementText();
|
QString playStatus = xml.readElementText();
|
||||||
//qDebug(dcBose) << "Play Status" << playStatus;
|
//qCDebug(dcBose()) << "Play Status" << playStatus;
|
||||||
//Modes: PLAY_STATE, PAUSE_STATE, STOP_STATE, BUFFERING_STATE
|
//Modes: PLAY_STATE, PAUSE_STATE, STOP_STATE, BUFFERING_STATE
|
||||||
if (playStatus == "PLAY_STATE") {
|
if (playStatus == "PLAY_STATE") {
|
||||||
nowPlaying.playStatus = PLAY_STATUS_PLAY_STATE;
|
nowPlaying.playStatus = PLAY_STATUS_PLAY_STATE;
|
||||||
@ -732,17 +733,17 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
} else if (playStatus == "BUFFERING_STATE") {
|
} else if (playStatus == "BUFFERING_STATE") {
|
||||||
nowPlaying.playStatus = PLAY_STATUS_BUFFERING_STATE;
|
nowPlaying.playStatus = PLAY_STATUS_BUFFERING_STATE;
|
||||||
}
|
}
|
||||||
} else if(xml.name() == "shuffleSetting") {
|
} else if(xml.name() == QString("shuffleSetting")) {
|
||||||
QString shuffle = xml.readElementText().toUpper();
|
QString shuffle = xml.readElementText().toUpper();
|
||||||
//qDebug(dcBose) << "Shuffle Setting" << shuffle;
|
//qCDebug(dcBose()) << "Shuffle Setting" << shuffle;
|
||||||
if (shuffle == "SHUFFLE_ON") {
|
if (shuffle == "SHUFFLE_ON") {
|
||||||
nowPlaying.shuffleSetting = SHUFFLE_STATUS_SHUFFLE_ON;
|
nowPlaying.shuffleSetting = SHUFFLE_STATUS_SHUFFLE_ON;
|
||||||
} else {
|
} else {
|
||||||
nowPlaying.shuffleSetting = SHUFFLE_STATUS_SHUFFLE_OFF;
|
nowPlaying.shuffleSetting = SHUFFLE_STATUS_SHUFFLE_OFF;
|
||||||
}
|
}
|
||||||
}else if(xml.name() == "repeatSetting") {
|
}else if(xml.name() == QString("repeatSetting")) {
|
||||||
QString repeat = xml.readElementText().toUpper();
|
QString repeat = xml.readElementText().toUpper();
|
||||||
//qDebug(dcBose) << "Repeat Setting" << repeat;
|
//qCDebug(dcBose()) << "Repeat Setting" << repeat;
|
||||||
//Modes: REPEAT_OFF, REPEAT_ALL, REPEAT_ONE
|
//Modes: REPEAT_OFF, REPEAT_ALL, REPEAT_ONE
|
||||||
if (repeat == "REPEAT_OFF") {
|
if (repeat == "REPEAT_OFF") {
|
||||||
nowPlaying.repeatSettings = REPEAT_STATUS_REPEAT_OFF;
|
nowPlaying.repeatSettings = REPEAT_STATUS_REPEAT_OFF;
|
||||||
@ -751,9 +752,9 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
} else if (repeat == "REPEAT_ALL") {
|
} else if (repeat == "REPEAT_ALL") {
|
||||||
nowPlaying.repeatSettings = REPEAT_STATUS_REPEAT_ALL;
|
nowPlaying.repeatSettings = REPEAT_STATUS_REPEAT_ALL;
|
||||||
}
|
}
|
||||||
} else if(xml.name() == "streamType") {
|
} else if(xml.name() == QString("streamType")) {
|
||||||
QString streamType = xml.readElementText().toUpper();
|
QString streamType = xml.readElementText().toUpper();
|
||||||
//qDebug(dcBose) << "Stream Type" << streamType;
|
//qCDebug(dcBose()) << "Stream Type" << streamType;
|
||||||
//Types: TRACK_ONDEMAND, RADIO_STREAMING, RADIO_TRACKS, NO_TRANSPORT_CONTROLS
|
//Types: TRACK_ONDEMAND, RADIO_STREAMING, RADIO_TRACKS, NO_TRANSPORT_CONTROLS
|
||||||
if (streamType == "RADIO_TRACKS") {
|
if (streamType == "RADIO_TRACKS") {
|
||||||
nowPlaying.streamType = STREAM_STATUS_RADIO_TRACKS;
|
nowPlaying.streamType = STREAM_STATUS_RADIO_TRACKS;
|
||||||
@ -764,54 +765,54 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
} else if (streamType == "NO_TRANSPORT_CONTROLS") {
|
} else if (streamType == "NO_TRANSPORT_CONTROLS") {
|
||||||
nowPlaying.streamType = STREAM_STATUS_NO_TRANSPORT_CONTROLS;
|
nowPlaying.streamType = STREAM_STATUS_NO_TRANSPORT_CONTROLS;
|
||||||
};
|
};
|
||||||
} else if(xml.name() == "stationLocation") {
|
} else if(xml.name() == QString("stationLocation")) {
|
||||||
nowPlaying.stationLocation = xml.readElementText();
|
nowPlaying.stationLocation = xml.readElementText();
|
||||||
} else {
|
} else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit nowPlayingReceived(requestId, nowPlaying);
|
emit nowPlayingReceived(requestId, nowPlaying);
|
||||||
} else if (xml.name() == "volume") {
|
} else if (xml.name() == QString("volume")) {
|
||||||
VolumeObject volumeObject;
|
VolumeObject volumeObject;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
//qDebug(dcBose) << "Device ID" << xml.attributes().value("deviceID").toString();
|
//qCDebug(dcBose()) << "Device ID" << xml.attributes().value("deviceID").toString();
|
||||||
volumeObject.deviceID = xml.attributes().value("deviceID").toString();
|
volumeObject.deviceID = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "targetvolume"){
|
if(xml.name() == QString("targetvolume")){
|
||||||
//qDebug(dcBose) << "Target volume" << xml.readElementText();
|
//qCDebug(dcBose()) << "Target volume" << xml.readElementText();
|
||||||
volumeObject.targetVolume = xml.readElementText().toInt();
|
volumeObject.targetVolume = xml.readElementText().toInt();
|
||||||
}else if(xml.name() == "actualvolume"){
|
}else if(xml.name() == QString("actualvolume")){
|
||||||
//qDebug(dcBose) << "Actual volume" << xml.readElementText();
|
//qCDebug(dcBose()) << "Actual volume" << xml.readElementText();
|
||||||
volumeObject.actualVolume = xml.readElementText().toInt();
|
volumeObject.actualVolume = xml.readElementText().toInt();
|
||||||
}else if(xml.name() == "muteenabled"){
|
}else if(xml.name() == QString("muteenabled")){
|
||||||
//qDebug(dcBose) << "Mute enabled" << xml.readElementText();
|
//qCDebug(dcBose()) << "Mute enabled" << xml.readElementText();
|
||||||
volumeObject.muteEnabled = ( xml.readElementText().toUpper() == "TRUE" ); //TODO convert from "false" to bool
|
volumeObject.muteEnabled = ( xml.readElementText().toUpper() == "TRUE" ); //TODO convert from "false" to bool
|
||||||
}else {
|
}else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit volumeReceived(requestId, volumeObject);
|
emit volumeReceived(requestId, volumeObject);
|
||||||
} else if (xml.name() == "sources") {
|
} else if (xml.name() == QString("sources")) {
|
||||||
SourcesObject sourcesObject;
|
SourcesObject sourcesObject;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
//qDebug(dcBose) << "Device ID" << xml.attributes().value("deviceID").toString();
|
//qCDebug(dcBose()) << "Device ID" << xml.attributes().value("deviceID").toString();
|
||||||
sourcesObject.deviceId = xml.attributes().value("deviceID").toString();
|
sourcesObject.deviceId = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "sourceItem"){
|
if(xml.name() == QString("sourceItem")){
|
||||||
SourceItemObject sourceItem;
|
SourceItemObject sourceItem;
|
||||||
if(xml.attributes().hasAttribute("source")) {
|
if(xml.attributes().hasAttribute("source")) {
|
||||||
//qDebug(dcBose) << "Source" << xml.attributes().value("source").toString();
|
//qCDebug(dcBose()) << "Source" << xml.attributes().value("source").toString();
|
||||||
sourceItem.source = xml.attributes().value("source").toString();
|
sourceItem.source = xml.attributes().value("source").toString();
|
||||||
}
|
}
|
||||||
if(xml.attributes().hasAttribute("sourceAccount")) {
|
if(xml.attributes().hasAttribute("sourceAccount")) {
|
||||||
//qDebug(dcBose) << "Source Account" << xml.attributes().value("sourceAccount").toString();
|
//qCDebug(dcBose()) << "Source Account" << xml.attributes().value("sourceAccount").toString();
|
||||||
sourceItem.sourceAccount = xml.attributes().value("sourceAccount").toString();
|
sourceItem.sourceAccount = xml.attributes().value("sourceAccount").toString();
|
||||||
}
|
}
|
||||||
if(xml.attributes().hasAttribute("status")) {
|
if(xml.attributes().hasAttribute("status")) {
|
||||||
QString status = xml.attributes().value("status").toString().toUpper(); //UNAVAILABLE, READY
|
QString status = xml.attributes().value("status").toString().toUpper(); //UNAVAILABLE, READY
|
||||||
//qDebug(dcBose) << "status" << status;
|
//qCDebug(dcBose()) << "status" << status;
|
||||||
if (status == "READY") {
|
if (status == "READY") {
|
||||||
sourceItem.status = SOURCE_STATUS_READY;
|
sourceItem.status = SOURCE_STATUS_READY;
|
||||||
} else {
|
} else {
|
||||||
@ -819,7 +820,7 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(xml.attributes().hasAttribute("isLocal")) {
|
if(xml.attributes().hasAttribute("isLocal")) {
|
||||||
//qDebug(dcBose) << "is Local" << xml.attributes().value("isLocal").toString();
|
//qCDebug(dcBose()) << "is Local" << xml.attributes().value("isLocal").toString();
|
||||||
sourceItem.isLocal = ( xml.attributes().value("isLocal").toString().toUpper() == "TRUE" );
|
sourceItem.isLocal = ( xml.attributes().value("isLocal").toString().toUpper() == "TRUE" );
|
||||||
}
|
}
|
||||||
if(xml.attributes().hasAttribute("multiroomallowed")) {
|
if(xml.attributes().hasAttribute("multiroomallowed")) {
|
||||||
@ -833,52 +834,52 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit sourcesReceived(requestId, sourcesObject);
|
emit sourcesReceived(requestId, sourcesObject);
|
||||||
} else if (xml.name() == "bass") {
|
} else if (xml.name() == QString("bass")) {
|
||||||
BassObject bassObject;
|
BassObject bassObject;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
//qDebug(dcBose) << "Device ID" << xml.attributes().value("deviceID").toString();
|
//qCDebug(dcBose()) << "Device ID" << xml.attributes().value("deviceID").toString();
|
||||||
bassObject.deviceID = xml.attributes().value("deviceID").toString();
|
bassObject.deviceID = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "targetbass"){
|
if(xml.name() == QString("targetbass")){
|
||||||
//qDebug(dcBose) << "Target bas" << xml.readElementText();
|
//qCDebug(dcBose()) << "Target bas" << xml.readElementText();
|
||||||
bassObject.targetBass = xml.readElementText().toInt();
|
bassObject.targetBass = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "actualbass"){
|
} else if(xml.name() == QString("actualbass")){
|
||||||
//qDebug(dcBose) << "Actual bass" << xml.readElementText();
|
//qCDebug(dcBose()) << "Actual bass" << xml.readElementText();
|
||||||
bassObject.actualBass = xml.readElementText().toInt();
|
bassObject.actualBass = xml.readElementText().toInt();
|
||||||
} else {
|
} else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit bassReceived(requestId, bassObject);
|
emit bassReceived(requestId, bassObject);
|
||||||
} else if (xml.name() == "bassCapabilities") {
|
} else if (xml.name() == QString("bassCapabilities")) {
|
||||||
BassCapabilitiesObject bassCapabilities;
|
BassCapabilitiesObject bassCapabilities;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
bassCapabilities.deviceID = xml.attributes().value("deviceID").toString();
|
bassCapabilities.deviceID = xml.attributes().value("deviceID").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "bassAvailable"){
|
if(xml.name() == QString("bassAvailable")){
|
||||||
//qDebug(dcBose) << "BassAvailable" << xml.readElementText();
|
//qCDebug(dcBose()) << "BassAvailable" << xml.readElementText();
|
||||||
bassCapabilities.bassAvailable = ( xml.readElementText().toUpper() == "TRUE" );
|
bassCapabilities.bassAvailable = ( xml.readElementText().toUpper() == "TRUE" );
|
||||||
} else if(xml.name() == "bassMin"){
|
} else if(xml.name() == QString("bassMin")){
|
||||||
//qDebug(dcBose) << "bass Min" << xml.readElementText();
|
//qCDebug(dcBose()) << "bass Min" << xml.readElementText();
|
||||||
bassCapabilities.bassMin = xml.readElementText().toInt();
|
bassCapabilities.bassMin = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "bassMax"){
|
} else if(xml.name() == QString("bassMax")){
|
||||||
//qDebug(dcBose) << "bass Max" << xml.readElementText();
|
//qCDebug(dcBose()) << "bass Max" << xml.readElementText();
|
||||||
bassCapabilities.bassMax = xml.readElementText().toInt();
|
bassCapabilities.bassMax = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "bassDefault"){
|
} else if(xml.name() == QString("bassDefault")){
|
||||||
//qDebug(dcBose) << "bass default" << xml.readElementText();
|
//qCDebug(dcBose()) << "bass default" << xml.readElementText();
|
||||||
bassCapabilities.bassDefault = xml.readElementText().toInt();
|
bassCapabilities.bassDefault = xml.readElementText().toInt();
|
||||||
}else {
|
}else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit bassCapabilitiesReceived(requestId, bassCapabilities);
|
emit bassCapabilitiesReceived(requestId, bassCapabilities);
|
||||||
} else if (xml.name() == "presets") {
|
} else if (xml.name() == QString("presets")) {
|
||||||
QList<PresetObject> presets;
|
QList<PresetObject> presets;
|
||||||
qDebug(dcBose) << "Presets";
|
qCDebug(dcBose()) << "Presets";
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "preset"){
|
if(xml.name() == QString("preset")){
|
||||||
PresetObject preset;
|
PresetObject preset;
|
||||||
if(xml.attributes().hasAttribute("id")) {
|
if(xml.attributes().hasAttribute("id")) {
|
||||||
preset.presetId = xml.attributes().value("id").toInt();
|
preset.presetId = xml.attributes().value("id").toInt();
|
||||||
@ -889,10 +890,10 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
if(xml.attributes().hasAttribute("updatedOn")) {
|
if(xml.attributes().hasAttribute("updatedOn")) {
|
||||||
preset.updatedOn = xml.attributes().value("updatedOn").toULong();
|
preset.updatedOn = xml.attributes().value("updatedOn").toULong();
|
||||||
}
|
}
|
||||||
qDebug(dcBose) << "Preset" << preset.presetId;
|
qCDebug(dcBose()) << "Preset" << preset.presetId;
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
|
|
||||||
if (xml.name() == "ContentItem") {
|
if (xml.name() == QString("ContentItem")) {
|
||||||
if(xml.attributes().hasAttribute("source")) {
|
if(xml.attributes().hasAttribute("source")) {
|
||||||
preset.ContentItem.source = xml.attributes().value("source").toString();
|
preset.ContentItem.source = xml.attributes().value("source").toString();
|
||||||
}
|
}
|
||||||
@ -904,9 +905,9 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if (xml.name() == "itemName") {
|
if (xml.name() == QString("itemName")) {
|
||||||
preset.ContentItem.itemName = xml.readElementText();
|
preset.ContentItem.itemName = xml.readElementText();
|
||||||
} else if (xml.name() == "containerArt"){
|
} else if (xml.name() == QString("containerArt")){
|
||||||
preset.ContentItem.containerArt = xml.readElementText();
|
preset.ContentItem.containerArt = xml.readElementText();
|
||||||
} else {
|
} else {
|
||||||
qCWarning(dcBose()) << "Presets: unhandled XML element" << xml.name();
|
qCWarning(dcBose()) << "Presets: unhandled XML element" << xml.name();
|
||||||
@ -927,35 +928,35 @@ void SoundTouch::parseData(QUuid requestId, const QByteArray &data)
|
|||||||
}
|
}
|
||||||
emit presetsReceived(requestId, presets);
|
emit presetsReceived(requestId, presets);
|
||||||
|
|
||||||
} else if (xml.name() == "group") {
|
} else if (xml.name() == QString("group")) {
|
||||||
GroupObject group;
|
GroupObject group;
|
||||||
if(xml.attributes().hasAttribute("deviceID")) {
|
if(xml.attributes().hasAttribute("deviceID")) {
|
||||||
group.id = xml.attributes().value("id").toString();
|
group.id = xml.attributes().value("id").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
if(xml.name() == "name") {
|
if(xml.name() == QString("name")) {
|
||||||
group.name = xml.readElementText();
|
group.name = xml.readElementText();
|
||||||
} else if(xml.name() == "masterDeviceId") {
|
} else if(xml.name() == QString("masterDeviceId")) {
|
||||||
group.masterDeviceId = xml.readElementText();
|
group.masterDeviceId = xml.readElementText();
|
||||||
} else if(xml.name() == "roles") {
|
} else if(xml.name() == QString("roles")) {
|
||||||
//group.roles = xml.readElementText().toInt();
|
//group.roles = xml.readElementText().toInt();
|
||||||
} else if(xml.name() == "status"){
|
} else if(xml.name() == QString("status")){
|
||||||
QString groupStatus = xml.readElementText();
|
QString groupStatus = xml.readElementText();
|
||||||
//qDebug(dcBose) << "Group role" << groupStatus;
|
//qCDebug(dcBose()) << "Group role" << groupStatus;
|
||||||
//group.status = xml.readElementText();
|
//group.status = xml.readElementText();
|
||||||
}else {
|
}else {
|
||||||
xml.skipCurrentElement();
|
xml.skipCurrentElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
emit groupReceived(requestId, group);
|
emit groupReceived(requestId, group);
|
||||||
} else if (xml.name() == "zone") {
|
} else if (xml.name() == QString("zone")) {
|
||||||
ZoneObject zone;
|
ZoneObject zone;
|
||||||
if(xml.attributes().hasAttribute("master")) {
|
if(xml.attributes().hasAttribute("master")) {
|
||||||
zone.deviceID = xml.attributes().value("master").toString();
|
zone.deviceID = xml.attributes().value("master").toString();
|
||||||
}
|
}
|
||||||
while(xml.readNextStartElement()){
|
while(xml.readNextStartElement()){
|
||||||
MemberObject member;
|
MemberObject member;
|
||||||
if(xml.name() == "member") {
|
if(xml.name() == QString("member")) {
|
||||||
if(xml.attributes().hasAttribute("ipaddress")) {
|
if(xml.attributes().hasAttribute("ipaddress")) {
|
||||||
member.ipAddress = xml.attributes().value("ipaddress").toString();
|
member.ipAddress = xml.attributes().value("ipaddress").toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -39,9 +39,7 @@
|
|||||||
#include "extern-plugininfo.h"
|
#include "extern-plugininfo.h"
|
||||||
#include "soundtouchtypes.h"
|
#include "soundtouchtypes.h"
|
||||||
|
|
||||||
#include "hardwaremanager.h"
|
#include <network/networkaccessmanager.h>
|
||||||
#include "network/networkaccessmanager.h"
|
|
||||||
|
|
||||||
|
|
||||||
class SoundTouch : public QObject
|
class SoundTouch : public QObject
|
||||||
{
|
{
|
||||||
@ -67,7 +65,7 @@ public:
|
|||||||
QUuid addZoneSlave(ZoneObject zone); //Add one or more slave product(s) to a multiroom zone.
|
QUuid addZoneSlave(ZoneObject zone); //Add one or more slave product(s) to a multiroom zone.
|
||||||
QUuid removeZoneSlave(ZoneObject zone); //Remove one or more slave product(s) from a multiroom zone.
|
QUuid removeZoneSlave(ZoneObject zone); //Remove one or more slave product(s) from a multiroom zone.
|
||||||
QUuid setBass(int volume); //Set the bass level of a product, if supported.*/
|
QUuid setBass(int volume); //Set the bass level of a product, if supported.*/
|
||||||
QUuid setName(QString name); //Set the products user-facing name.
|
QUuid setName(const QString &name); //Set the products user-facing name.
|
||||||
QUuid setSpeaker(PlayInfoObject playInfo); //initiate playback of a specified network-accessible audio file on a Bose SoundTouch product.
|
QUuid setSpeaker(PlayInfoObject playInfo); //initiate playback of a specified network-accessible audio file on a Bose SoundTouch product.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -82,23 +80,23 @@ private:
|
|||||||
QString m_ipAddress;
|
QString m_ipAddress;
|
||||||
int m_port = 8090;
|
int m_port = 8090;
|
||||||
QWebSocket *m_websocket = nullptr;
|
QWebSocket *m_websocket = nullptr;
|
||||||
void emitRequestStatus(QUuid requestId, QNetworkReply *reply); //returns the status, -1 in case of error
|
void emitRequestStatus(const QUuid &requestId, QNetworkReply *reply); //returns the status, -1 in case of error
|
||||||
void parseData(QUuid requestId, const QByteArray &data);
|
void parseData(const QUuid &requestId, const QByteArray &data);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void connectionChanged(bool connected);
|
void connectionChanged(bool connected);
|
||||||
|
|
||||||
void infoReceived(QUuid requestId, InfoObject info);
|
void infoReceived(const QUuid &requestId, InfoObject info);
|
||||||
void nowPlayingReceived(QUuid requestId, NowPlayingObject nowPlaying);
|
void nowPlayingReceived(const QUuid &requestId, NowPlayingObject nowPlaying);
|
||||||
void volumeReceived(QUuid requestId, VolumeObject volume);
|
void volumeReceived(const QUuid &requestId, VolumeObject volume);
|
||||||
void sourcesReceived(QUuid requestId, SourcesObject sources);
|
void sourcesReceived(const QUuid &requestId, SourcesObject sources);
|
||||||
void zoneReceived(QUuid requestId, ZoneObject);
|
void zoneReceived(const QUuid &requestId, ZoneObject);
|
||||||
void bassCapabilitiesReceived(QUuid requestId, BassCapabilitiesObject bassCapabilities);
|
void bassCapabilitiesReceived(const QUuid &requestId, BassCapabilitiesObject bassCapabilities);
|
||||||
void bassReceived(QUuid requestId, BassObject bass);
|
void bassReceived(const QUuid &requestId, BassObject bass);
|
||||||
void presetsReceived(QUuid requestId, QList<PresetObject> presets);
|
void presetsReceived(const QUuid &requestId, QList<PresetObject> presets);
|
||||||
void groupReceived(QUuid requestId, GroupObject group);
|
void groupReceived(const QUuid &requestId, GroupObject group);
|
||||||
|
|
||||||
void requestExecuted(QUuid requestId, bool success);
|
void requestExecuted(const QUuid &requestId, bool success);
|
||||||
void errorReceived(ErrorObject error);
|
void errorReceived(ErrorObject error);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginbosswerk.cpp \
|
integrationpluginbosswerk.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
integrationpluginbosswerk.h \
|
integrationpluginbosswerk.h
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2024, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -28,7 +28,6 @@
|
|||||||
*
|
*
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
|
|
||||||
#include "integrationpluginbosswerk.h"
|
#include "integrationpluginbosswerk.h"
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
@ -71,8 +70,7 @@ void IntegrationPluginBosswerk::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
|
|
||||||
QUrl url("http://" + address.toString() + "/status.html");
|
QUrl url("http://" + address.toString() + "/status.html");
|
||||||
QNetworkRequest request(url);
|
QNetworkRequest request(url);
|
||||||
|
QNetworkReply *probeReply = hardwareManager()->networkManager()->get(request);
|
||||||
QNetworkReply *probeReply = hardwareManager()->networkManager()->get(QNetworkRequest(url));
|
|
||||||
connect(probeReply, &QNetworkReply::finished, probeReply, &QNetworkReply::deleteLater);
|
connect(probeReply, &QNetworkReply::finished, probeReply, &QNetworkReply::deleteLater);
|
||||||
connect(probeReply, &QNetworkReply::finished, info, [probeReply, address, this](){
|
connect(probeReply, &QNetworkReply::finished, info, [probeReply, address, this](){
|
||||||
QByteArray data = probeReply->readAll();
|
QByteArray data = probeReply->readAll();
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2024, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,7 +31,7 @@
|
|||||||
#ifndef INTEGRATIONPLUGINMEROSS_H
|
#ifndef INTEGRATIONPLUGINMEROSS_H
|
||||||
#define INTEGRATIONPLUGINMEROSS_H
|
#define INTEGRATIONPLUGINMEROSS_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "extern-plugininfo.h"
|
#include "extern-plugininfo.h"
|
||||||
|
|
||||||
#include <QHostAddress>
|
#include <QHostAddress>
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationplugincoinmarketcap)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationplugincoinmarketcap.cpp \
|
integrationplugincoinmarketcap.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
integrationplugincoinmarketcap.h \
|
integrationplugincoinmarketcap.h
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -29,9 +29,10 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "integrationplugincoinmarketcap.h"
|
#include "integrationplugincoinmarketcap.h"
|
||||||
#include "network/networkaccessmanager.h"
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
IntegrationPluginCoinMarketCap::IntegrationPluginCoinMarketCap()
|
IntegrationPluginCoinMarketCap::IntegrationPluginCoinMarketCap()
|
||||||
@ -44,7 +45,7 @@ void IntegrationPluginCoinMarketCap::startPairing(ThingPairingInfo *info)
|
|||||||
NetworkAccessManager *network = hardwareManager()->networkManager();
|
NetworkAccessManager *network = hardwareManager()->networkManager();
|
||||||
QNetworkReply *reply = network->get(QNetworkRequest(QUrl("https://pro-api.coinmarketcap.com")));
|
QNetworkReply *reply = network->get(QNetworkRequest(QUrl("https://pro-api.coinmarketcap.com")));
|
||||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||||
connect(reply, &QNetworkReply::finished, this, [this, reply, info] {
|
connect(reply, &QNetworkReply::finished, this, [reply, info] {
|
||||||
|
|
||||||
if (reply->error() == QNetworkReply::NetworkError::HostNotFoundError) {
|
if (reply->error() == QNetworkReply::NetworkError::HostNotFoundError) {
|
||||||
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("CoinMarketCap server is not reachable."));
|
info->finish(Thing::ThingErrorHardwareNotAvailable, QT_TR_NOOP("CoinMarketCap server is not reachable."));
|
||||||
@ -175,31 +176,31 @@ void IntegrationPluginCoinMarketCap::onPriceCallFinished()
|
|||||||
qCDebug(dcCoinMarketCap()) << "Name" << elementMap.value("name").toString();
|
qCDebug(dcCoinMarketCap()) << "Name" << elementMap.value("name").toString();
|
||||||
price = elementMap.value("quote").toMap().value(fiatCurrency).toMap().value("price").toDouble();
|
price = elementMap.value("quote").toMap().value(fiatCurrency).toMap().value("price").toDouble();
|
||||||
if (elementMap.value("name").toString() == "Bitcoin") {
|
if (elementMap.value("name").toString() == "Bitcoin") {
|
||||||
qDebug(dcCoinMarketCap()) << "Bitcoin Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "Bitcoin Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesBtcStateTypeId, price);
|
thing->setStateValue(currentPricesBtcStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "Ethereum") {
|
} else if (elementMap.value("name").toString() == "Ethereum") {
|
||||||
qDebug(dcCoinMarketCap()) << "Etherium Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "Etherium Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesEthStateTypeId, price);
|
thing->setStateValue(currentPricesEthStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "XRP") {
|
} else if (elementMap.value("name").toString() == "XRP") {
|
||||||
qDebug(dcCoinMarketCap()) << "XRP Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "XRP Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesXrpStateTypeId, price);
|
thing->setStateValue(currentPricesXrpStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "Bitcoin Cash") {
|
} else if (elementMap.value("name").toString() == "Bitcoin Cash") {
|
||||||
qDebug(dcCoinMarketCap()) << "Bitcoin-cash Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "Bitcoin-cash Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesBchStateTypeId, price);
|
thing->setStateValue(currentPricesBchStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "Litecoin") {
|
} else if (elementMap.value("name").toString() == "Litecoin") {
|
||||||
qDebug(dcCoinMarketCap()) << "Litecoin Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "Litecoin Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesLtcStateTypeId, price);
|
thing->setStateValue(currentPricesLtcStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "NEM") {
|
} else if (elementMap.value("name").toString() == "NEM") {
|
||||||
qDebug(dcCoinMarketCap()) << "Nem Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "Nem Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesXemStateTypeId, price);
|
thing->setStateValue(currentPricesXemStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "Ethereum Classic") {
|
} else if (elementMap.value("name").toString() == "Ethereum Classic") {
|
||||||
qDebug(dcCoinMarketCap()) << "Ethereum Classic Price in" << fiatCurrency << price;
|
qCDebug(dcCoinMarketCap()) << "Ethereum Classic Price in" << fiatCurrency << price;
|
||||||
thing->setStateValue(currentPricesEtcStateTypeId, price);
|
thing->setStateValue(currentPricesEtcStateTypeId, price);
|
||||||
|
|
||||||
} else if (elementMap.value("name").toString() == "Dash") {
|
} else if (elementMap.value("name").toString() == "Dash") {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,8 +31,8 @@
|
|||||||
#ifndef INTEGRATIONPLUGINCOINMARKETCAP_H
|
#ifndef INTEGRATIONPLUGINCOINMARKETCAP_H
|
||||||
#define INTEGRATIONPLUGINCOINMARKETCAP_H
|
#define INTEGRATIONPLUGINCOINMARKETCAP_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "plugintimer.h"
|
#include <plugintimer.h>
|
||||||
|
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
#include <QHostInfo>
|
#include <QHostInfo>
|
||||||
|
|||||||
@ -1,7 +1,5 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationplugincommandlauncher)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationplugincommandlauncher.cpp
|
integrationplugincommandlauncher.cpp
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -29,11 +29,11 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "integrationplugincommandlauncher.h"
|
#include "integrationplugincommandlauncher.h"
|
||||||
|
|
||||||
#include "integrations/thing.h"
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <integrations/thing.h>
|
||||||
|
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
IntegrattionPluginCommandLauncher::IntegrattionPluginCommandLauncher()
|
IntegrattionPluginCommandLauncher::IntegrattionPluginCommandLauncher()
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ void IntegrattionPluginCommandLauncher::setupThing(ThingSetupInfo *info)
|
|||||||
|
|
||||||
// Script
|
// Script
|
||||||
if(info->thing()->thingClassId() == scriptThingClassId){
|
if(info->thing()->thingClassId() == scriptThingClassId){
|
||||||
QStringList scriptArguments = info->thing()->paramValue(scriptThingScriptParamTypeId).toString().split(QRegExp("[ \r\n][ \r\n]*"));
|
QStringList scriptArguments = info->thing()->paramValue(scriptThingScriptParamTypeId).toString().split(QRegularExpression("[ \r\n][ \r\n]*"));
|
||||||
// check if script exists and if it is executable
|
// check if script exists and if it is executable
|
||||||
QFileInfo fileInfo(scriptArguments.first());
|
QFileInfo fileInfo(scriptArguments.first());
|
||||||
if (!fileInfo.exists()) {
|
if (!fileInfo.exists()) {
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,7 +31,7 @@
|
|||||||
#ifndef INTEGRATIONPLUGINCOMMANDLAUNCHER_H
|
#ifndef INTEGRATIONPLUGINCOMMANDLAUNCHER_H
|
||||||
#define INTEGRATIONPLUGINCOMMANDLAUNCHER_H
|
#define INTEGRATIONPLUGINCOMMANDLAUNCHER_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
@ -52,8 +52,8 @@ public:
|
|||||||
void thingRemoved(Thing *thing) override;
|
void thingRemoved(Thing *thing) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHash<QProcess*,Thing*> m_scripts;
|
QHash<QProcess *,Thing *> m_scripts;
|
||||||
QHash<QProcess*,Thing*> m_applications;
|
QHash<QProcess *,Thing *> m_applications;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINCOMMANDLAUNCHER_H
|
#endif // INTEGRATIONPLUGINCOMMANDLAUNCHER_H
|
||||||
|
|||||||
@ -1,8 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationplugindatetime)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationplugindatetime.cpp \
|
integrationplugindatetime.cpp \
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -30,10 +30,10 @@
|
|||||||
|
|
||||||
#include "integrationplugindatetime.h"
|
#include "integrationplugindatetime.h"
|
||||||
|
|
||||||
#include "integrations/thing.h"
|
#include <integrations/thing.h>
|
||||||
#include "plugininfo.h"
|
#include <plugininfo.h>
|
||||||
#include "hardwaremanager.h"
|
#include <hardwaremanager.h>
|
||||||
#include "network/networkaccessmanager.h"
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
@ -416,13 +416,13 @@ void IntegrationPluginDateTime::updateTimes()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (m_dusk.isValid()) {
|
if (m_dusk.isValid()) {
|
||||||
m_todayDevice->setStateValue(todayDuskTimeStateTypeId, m_dusk.toTime_t());
|
m_todayDevice->setStateValue(todayDuskTimeStateTypeId, m_dusk.toSecsSinceEpoch());
|
||||||
} else {
|
} else {
|
||||||
m_todayDevice->setStateValue(todayDuskTimeStateTypeId, 0);
|
m_todayDevice->setStateValue(todayDuskTimeStateTypeId, 0);
|
||||||
}
|
}
|
||||||
if (m_sunrise.isValid() && m_sunset.isValid()) {
|
if (m_sunrise.isValid() && m_sunset.isValid()) {
|
||||||
m_todayDevice->setStateValue(todaySunriseTimeStateTypeId, m_sunrise.toTime_t());
|
m_todayDevice->setStateValue(todaySunriseTimeStateTypeId, m_sunrise.toSecsSinceEpoch());
|
||||||
m_todayDevice->setStateValue(todaySunsetTimeStateTypeId, m_sunset.toTime_t());
|
m_todayDevice->setStateValue(todaySunsetTimeStateTypeId, m_sunset.toSecsSinceEpoch());
|
||||||
m_todayDevice->setStateValue(todayDaylightStateTypeId, m_sunrise < m_currentDateTime && m_currentDateTime < m_sunset);
|
m_todayDevice->setStateValue(todayDaylightStateTypeId, m_sunrise < m_currentDateTime && m_currentDateTime < m_sunset);
|
||||||
} else {
|
} else {
|
||||||
m_todayDevice->setStateValue(todaySunriseTimeStateTypeId, 0);
|
m_todayDevice->setStateValue(todaySunriseTimeStateTypeId, 0);
|
||||||
@ -430,12 +430,12 @@ void IntegrationPluginDateTime::updateTimes()
|
|||||||
m_todayDevice->setStateValue(todayDaylightStateTypeId, false);
|
m_todayDevice->setStateValue(todayDaylightStateTypeId, false);
|
||||||
}
|
}
|
||||||
if (m_dusk.isValid()) {
|
if (m_dusk.isValid()) {
|
||||||
m_todayDevice->setStateValue(todayNoonTimeStateTypeId, m_noon.toTime_t());
|
m_todayDevice->setStateValue(todayNoonTimeStateTypeId, m_noon.toSecsSinceEpoch());
|
||||||
} else {
|
} else {
|
||||||
m_todayDevice->setStateValue(todayNoonTimeStateTypeId, 0);
|
m_todayDevice->setStateValue(todayNoonTimeStateTypeId, 0);
|
||||||
}
|
}
|
||||||
if (m_dusk.isValid()) {
|
if (m_dusk.isValid()) {
|
||||||
m_todayDevice->setStateValue(todayDawnTimeStateTypeId, m_dawn.toTime_t());
|
m_todayDevice->setStateValue(todayDawnTimeStateTypeId, m_dawn.toSecsSinceEpoch());
|
||||||
} else {
|
} else {
|
||||||
m_todayDevice->setStateValue(todayDawnTimeStateTypeId, 0);
|
m_todayDevice->setStateValue(todayDawnTimeStateTypeId, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,9 +31,7 @@
|
|||||||
#ifndef INTEGRATIONPLUGINDATETIME_H
|
#ifndef INTEGRATIONPLUGINDATETIME_H
|
||||||
#define INTEGRATIONPLUGINDATETIME_H
|
#define INTEGRATIONPLUGINDATETIME_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
#include "alarm.h"
|
|
||||||
#include "countdown.h"
|
|
||||||
|
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QTimeZone>
|
#include <QTimeZone>
|
||||||
@ -41,6 +39,9 @@
|
|||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
|
|
||||||
|
#include "alarm.h"
|
||||||
|
#include "countdown.h"
|
||||||
|
|
||||||
class IntegrationPluginDateTime : public IntegrationPlugin
|
class IntegrationPluginDateTime : public IntegrationPlugin
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@ -60,8 +61,8 @@ public:
|
|||||||
void startMonitoringAutoThings() override;
|
void startMonitoringAutoThings() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QTimer *m_timer;
|
QTimer *m_timer = nullptr;
|
||||||
Thing *m_todayDevice;
|
Thing *m_todayDevice = nullptr;
|
||||||
QTimeZone m_timeZone;
|
QTimeZone m_timeZone;
|
||||||
QDateTime m_currentDateTime;
|
QDateTime m_currentDateTime;
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,9 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
QT += network
|
QT *= network
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationplugindaylightsensor)
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationplugindaylightsensor.cpp \
|
integrationplugindaylightsensor.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
integrationplugindaylightsensor.h \
|
integrationplugindaylightsensor.h
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -30,7 +30,8 @@
|
|||||||
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "integrationplugindaylightsensor.h"
|
#include "integrationplugindaylightsensor.h"
|
||||||
#include "network/networkaccessmanager.h"
|
|
||||||
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
#include <QNetworkReply>
|
#include <QNetworkReply>
|
||||||
@ -56,7 +57,7 @@ void IntegrationPluginDaylightSensor::discoverThings(ThingDiscoveryInfo *info)
|
|||||||
QNetworkRequest request(QUrl("http://ip-api.com/json"));
|
QNetworkRequest request(QUrl("http://ip-api.com/json"));
|
||||||
QNetworkReply* reply = hardwareManager()->networkManager()->get(request);
|
QNetworkReply* reply = hardwareManager()->networkManager()->get(request);
|
||||||
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
connect(reply, &QNetworkReply::finished, reply, &QNetworkReply::deleteLater);
|
||||||
connect(reply, &QNetworkReply::finished, info, [this, reply, info]() {
|
connect(reply, &QNetworkReply::finished, info, [reply, info]() {
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
qCWarning(dcDaylightSensor()) << "Error fetching geolocation from ip-api:" << reply->error() << reply->errorString();
|
qCWarning(dcDaylightSensor()) << "Error fetching geolocation from ip-api:" << reply->error() << reply->errorString();
|
||||||
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Failed to fetch data from the internet."));
|
info->finish(Thing::ThingErrorHardwareFailure, QT_TR_NOOP("Failed to fetch data from the internet."));
|
||||||
@ -124,8 +125,8 @@ void IntegrationPluginDaylightSensor::updateDevice(Thing *thing)
|
|||||||
QDateTime sunrise = sunriseSunset.first.toTimeZone(tz);
|
QDateTime sunrise = sunriseSunset.first.toTimeZone(tz);
|
||||||
QDateTime sunset = sunriseSunset.second.toTimeZone(tz);
|
QDateTime sunset = sunriseSunset.second.toTimeZone(tz);
|
||||||
qCDebug(dcDaylightSensor()) << "Setting up daylight sensor:" << thing->name() << "Sunrise:" << sunrise.toString() << "Sunset:" << sunset.toString();
|
qCDebug(dcDaylightSensor()) << "Setting up daylight sensor:" << thing->name() << "Sunrise:" << sunrise.toString() << "Sunset:" << sunset.toString();
|
||||||
thing->setStateValue(daylightSensorSunriseTimeStateTypeId, sunrise.toTime_t());
|
thing->setStateValue(daylightSensorSunriseTimeStateTypeId, sunrise.toSecsSinceEpoch());
|
||||||
thing->setStateValue(daylightSensorSunsetTimeStateTypeId, sunset.toTime_t());
|
thing->setStateValue(daylightSensorSunsetTimeStateTypeId, sunset.toSecsSinceEpoch());
|
||||||
thing->setStateValue(daylightSensorDaylightStateTypeId, sunrise < now && sunset > now);
|
thing->setStateValue(daylightSensorDaylightStateTypeId, sunrise < now && sunset > now);
|
||||||
|
|
||||||
qint64 timeToNext = -1;
|
qint64 timeToNext = -1;
|
||||||
@ -228,5 +229,5 @@ QPair<QDateTime, QDateTime> IntegrationPluginDaylightSensor::calculateSunriseSun
|
|||||||
QDateTime sunrise(dateTime.date(), QTime(hourRise, minuteRise));
|
QDateTime sunrise(dateTime.date(), QTime(hourRise, minuteRise));
|
||||||
QDateTime sunset(dateTime.date(), QTime(hourSet, minuteSet));
|
QDateTime sunset(dateTime.date(), QTime(hourSet, minuteSet));
|
||||||
|
|
||||||
return qMakePair<QDateTime, QDateTime>(sunrise, sunset);
|
return QPair<QDateTime, QDateTime>(sunrise, sunset);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||||
*
|
*
|
||||||
* Copyright 2013 - 2020, nymea GmbH
|
* Copyright 2013 - 2025, nymea GmbH
|
||||||
* Contact: contact@nymea.io
|
* Contact: contact@nymea.io
|
||||||
*
|
*
|
||||||
* This file is part of nymea.
|
* This file is part of nymea.
|
||||||
@ -31,9 +31,8 @@
|
|||||||
#ifndef INTEGRATIONPLUGINDAYLIGHTSENSOR_H
|
#ifndef INTEGRATIONPLUGINDAYLIGHTSENSOR_H
|
||||||
#define INTEGRATIONPLUGINDAYLIGHTSENSOR_H
|
#define INTEGRATIONPLUGINDAYLIGHTSENSOR_H
|
||||||
|
|
||||||
|
#include <integrations/integrationplugin.h>
|
||||||
#include "integrations/integrationplugin.h"
|
#include <plugintimer.h>
|
||||||
#include "plugintimer.h"
|
|
||||||
|
|
||||||
class IntegrationPluginDaylightSensor: public IntegrationPlugin
|
class IntegrationPluginDaylightSensor: public IntegrationPlugin
|
||||||
{
|
{
|
||||||
@ -54,7 +53,7 @@ private slots:
|
|||||||
|
|
||||||
void updateDevice(Thing *thing);
|
void updateDevice(Thing *thing);
|
||||||
private:
|
private:
|
||||||
QHash<Thing*, PluginTimer*> m_timers;
|
QHash<Thing *, PluginTimer *> m_timers;
|
||||||
QPair<QDateTime, QDateTime> calculateSunriseSunset(qreal lat, qreal lon, const QDateTime &dateTime);
|
QPair<QDateTime, QDateTime> calculateSunriseSunset(qreal lat, qreal lon, const QDateTime &dateTime);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user