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