philipshue: Add Qt6 support
This commit is contained in:
parent
ab2588db07
commit
6c104c018a
@ -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,7 +39,7 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "typeutils.h"
|
#include <typeutils.h>
|
||||||
#include "huedevice.h"
|
#include "huedevice.h"
|
||||||
|
|
||||||
class HueLight : public HueDevice
|
class HueLight : public HueDevice
|
||||||
|
|||||||
@ -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.
|
||||||
@ -37,7 +37,7 @@
|
|||||||
#include <QNetworkRequest>
|
#include <QNetworkRequest>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
|
||||||
#include "typeutils.h"
|
#include <typeutils.h>
|
||||||
#include "huedevice.h"
|
#include "huedevice.h"
|
||||||
|
|
||||||
class HueRemote : public HueDevice
|
class HueRemote : public HueDevice
|
||||||
|
|||||||
@ -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,21 +29,22 @@
|
|||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
#include "integrationpluginphilipshue.h"
|
#include "integrationpluginphilipshue.h"
|
||||||
|
|
||||||
#include "integrations/thing.h"
|
|
||||||
#include "types/param.h"
|
|
||||||
#include "plugininfo.h"
|
#include "plugininfo.h"
|
||||||
#include "network/upnp/upnpdiscovery.h"
|
|
||||||
#include "network/upnp/upnpdiscoveryreply.h"
|
|
||||||
|
|
||||||
#include "platform/platformzeroconfcontroller.h"
|
#include <integrations/thing.h>
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
#include <types/param.h>
|
||||||
|
#include <network/upnp/upnpdiscovery.h>
|
||||||
|
#include <network/upnp/upnpdiscoveryreply.h>
|
||||||
|
#include <platform/platformzeroconfcontroller.h>
|
||||||
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
|
#include <network/networkaccessmanager.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QRegularExpression>
|
||||||
|
|
||||||
IntegrationPluginPhilipsHue::IntegrationPluginPhilipsHue()
|
IntegrationPluginPhilipsHue::IntegrationPluginPhilipsHue()
|
||||||
{
|
{
|
||||||
@ -409,7 +410,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
|
|||||||
ParamList migratedParams;
|
ParamList migratedParams;
|
||||||
foreach (const Param &oldParam, thing->params()) {
|
foreach (const Param &oldParam, thing->params()) {
|
||||||
QString oldId = oldParam.paramTypeId().toString();
|
QString oldId = oldParam.paramTypeId().toString();
|
||||||
oldId.remove(QRegExp("[{}]"));
|
oldId.remove(QRegularExpression("[{}]"));
|
||||||
if (migrationMap.contains(oldId)) {
|
if (migrationMap.contains(oldId)) {
|
||||||
ParamTypeId newId = migrationMap.value(oldId);
|
ParamTypeId newId = migrationMap.value(oldId);
|
||||||
QVariant oldValue = oldParam.value();
|
QVariant oldValue = oldParam.value();
|
||||||
@ -470,7 +471,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
|
|||||||
ParamList migratedParams;
|
ParamList migratedParams;
|
||||||
foreach (const Param &oldParam, thing->params()) {
|
foreach (const Param &oldParam, thing->params()) {
|
||||||
QString oldId = oldParam.paramTypeId().toString();
|
QString oldId = oldParam.paramTypeId().toString();
|
||||||
oldId.remove(QRegExp("[{}]"));
|
oldId.remove(QRegularExpression("[{}]"));
|
||||||
if (migrationMap.contains(oldId)) {
|
if (migrationMap.contains(oldId)) {
|
||||||
ParamTypeId newId = migrationMap.value(oldId);
|
ParamTypeId newId = migrationMap.value(oldId);
|
||||||
QVariant oldValue = oldParam.value();
|
QVariant oldValue = oldParam.value();
|
||||||
@ -1557,7 +1558,7 @@ void IntegrationPluginPhilipsHue::onMotionSensorPresenceChanged(bool presence)
|
|||||||
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
|
||||||
Thing *sensorDevice = m_motionSensors.value(sensor);
|
Thing *sensorDevice = m_motionSensors.value(sensor);
|
||||||
sensorDevice->setStateValue(sensor->isPresentStateTypeId(), presence);
|
sensorDevice->setStateValue(sensor->isPresentStateTypeId(), presence);
|
||||||
if (presence) sensorDevice->setStateValue(sensor->lastSeenTimeStateTypeId(), QDateTime::currentDateTime().toTime_t());
|
if (presence) sensorDevice->setStateValue(sensor->lastSeenTimeStateTypeId(), QDateTime::currentDateTime().toSecsSinceEpoch());
|
||||||
}
|
}
|
||||||
|
|
||||||
void IntegrationPluginPhilipsHue::onMotionSensorLightIntensityChanged(double lightIntensity)
|
void IntegrationPluginPhilipsHue::onMotionSensorLightIntensityChanged(double lightIntensity)
|
||||||
|
|||||||
@ -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,21 +31,19 @@
|
|||||||
#ifndef INTEGRATIONPLUGINPHILIPSHUE_H
|
#ifndef INTEGRATIONPLUGINPHILIPSHUE_H
|
||||||
#define INTEGRATIONPLUGINPHILIPSHUE_H
|
#define INTEGRATIONPLUGINPHILIPSHUE_H
|
||||||
|
|
||||||
#include "integrations/integrationplugin.h"
|
#include <integrations/integrationplugin.h>
|
||||||
|
#include <plugintimer.h>
|
||||||
|
#include <network/zeroconf/zeroconfservicebrowser.h>
|
||||||
|
#include <network/zeroconf/zeroconfserviceentry.h>
|
||||||
|
|
||||||
#include "huebridge.h"
|
#include "huebridge.h"
|
||||||
#include "huelight.h"
|
#include "huelight.h"
|
||||||
#include "hueremote.h"
|
#include "hueremote.h"
|
||||||
#include "huemotionsensor.h"
|
#include "huemotionsensor.h"
|
||||||
#include "huetapdial.h"
|
#include "huetapdial.h"
|
||||||
|
|
||||||
#include "plugintimer.h"
|
|
||||||
#include "network/networkaccessmanager.h"
|
|
||||||
#include "network/upnp/upnpdiscovery.h"
|
|
||||||
#include "network/zeroconf/zeroconfservicebrowser.h"
|
|
||||||
#include "network/zeroconf/zeroconfserviceentry.h"
|
|
||||||
|
|
||||||
|
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
class UpnpDiscoveryReply;
|
||||||
|
|
||||||
class IntegrationPluginPhilipsHue: public IntegrationPlugin
|
class IntegrationPluginPhilipsHue: public IntegrationPlugin
|
||||||
{
|
{
|
||||||
@ -99,9 +97,9 @@ private:
|
|||||||
private:
|
private:
|
||||||
class DiscoveryJob {
|
class DiscoveryJob {
|
||||||
public:
|
public:
|
||||||
UpnpDiscoveryReply* upnpReply;
|
UpnpDiscoveryReply *upnpReply;
|
||||||
bool upnpDone = false;
|
bool upnpDone = false;
|
||||||
QNetworkReply* nUpnpReply;
|
QNetworkReply *nUpnpReply;
|
||||||
bool nUpnpDone = false;
|
bool nUpnpDone = false;
|
||||||
ThingDescriptors results;
|
ThingDescriptors results;
|
||||||
};
|
};
|
||||||
@ -109,7 +107,7 @@ private:
|
|||||||
|
|
||||||
void startUpnPDiscovery(ThingDiscoveryInfo *info, DiscoveryJob *discovery);
|
void startUpnPDiscovery(ThingDiscoveryInfo *info, DiscoveryJob *discovery);
|
||||||
void startNUpnpDiscovery(ThingDiscoveryInfo *info, DiscoveryJob *discovery);
|
void startNUpnpDiscovery(ThingDiscoveryInfo *info, DiscoveryJob *discovery);
|
||||||
void finishDiscovery(ThingDiscoveryInfo *info, DiscoveryJob* job);
|
void finishDiscovery(ThingDiscoveryInfo *info, DiscoveryJob *job);
|
||||||
|
|
||||||
PluginTimer *m_pluginTimer1Sec = nullptr;
|
PluginTimer *m_pluginTimer1Sec = nullptr;
|
||||||
PluginTimer *m_pluginTimer5Sec = nullptr;
|
PluginTimer *m_pluginTimer5Sec = nullptr;
|
||||||
@ -154,14 +152,14 @@ private:
|
|||||||
|
|
||||||
void bridgeReachableChanged(Thing *thing, bool reachable);
|
void bridgeReachableChanged(Thing *thing, bool reachable);
|
||||||
|
|
||||||
Thing* bridgeForBridgeId(const QString &id);
|
Thing *bridgeForBridgeId(const QString &id);
|
||||||
bool lightAlreadyAdded(const QString &uuid);
|
bool lightAlreadyAdded(const QString &uuid);
|
||||||
bool sensorAlreadyAdded(const QString &uuid);
|
bool sensorAlreadyAdded(const QString &uuid);
|
||||||
|
|
||||||
int brightnessToPercentage(int brightness);
|
int brightnessToPercentage(int brightness);
|
||||||
int percentageToBrightness(int percentage);
|
int percentageToBrightness(int percentage);
|
||||||
|
|
||||||
void abortRequests(QHash<QNetworkReply *, Thing *> requestList, Thing* thing);
|
void abortRequests(QHash<QNetworkReply *, Thing *> requestList, Thing *thing);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INTEGRATIONPLUGINPHILIPSHUE_H
|
#endif // INTEGRATIONPLUGINPHILIPSHUE_H
|
||||||
@ -1,8 +1,6 @@
|
|||||||
include(../plugins.pri)
|
include(../plugins.pri)
|
||||||
|
|
||||||
TARGET = $$qtLibraryTarget(nymea_integrationpluginphilipshue)
|
QT *= network
|
||||||
|
|
||||||
QT += network
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
integrationpluginphilipshue.cpp \
|
integrationpluginphilipshue.cpp \
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user