philipshue: Add Qt6 support

master
Simon Stürz 2025-08-08 15:50:56 +02:00
parent ab2588db07
commit 6c104c018a
5 changed files with 31 additions and 34 deletions

View File

@ -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,7 +39,7 @@
#include <QNetworkRequest>
#include <QJsonDocument>
#include "typeutils.h"
#include <typeutils.h>
#include "huedevice.h"
class HueLight : public HueDevice

View File

@ -1,6 +1,6 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* Copyright 2013 - 2020, nymea GmbH
* Copyright 2013 - 2025, nymea GmbH
* Contact: contact@nymea.io
*
* This file is part of nymea.
@ -37,7 +37,7 @@
#include <QNetworkRequest>
#include <QJsonDocument>
#include "typeutils.h"
#include <typeutils.h>
#include "huedevice.h"
class HueRemote : public HueDevice

View File

@ -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,21 +29,22 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include "integrationpluginphilipshue.h"
#include "integrations/thing.h"
#include "types/param.h"
#include "plugininfo.h"
#include "network/upnp/upnpdiscovery.h"
#include "network/upnp/upnpdiscoveryreply.h"
#include "platform/platformzeroconfcontroller.h"
#include "network/zeroconf/zeroconfservicebrowser.h"
#include <integrations/thing.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 <QColor>
#include <QDateTime>
#include <QStringList>
#include <QJsonDocument>
#include <QRegularExpression>
IntegrationPluginPhilipsHue::IntegrationPluginPhilipsHue()
{
@ -409,7 +410,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
ParamList migratedParams;
foreach (const Param &oldParam, thing->params()) {
QString oldId = oldParam.paramTypeId().toString();
oldId.remove(QRegExp("[{}]"));
oldId.remove(QRegularExpression("[{}]"));
if (migrationMap.contains(oldId)) {
ParamTypeId newId = migrationMap.value(oldId);
QVariant oldValue = oldParam.value();
@ -470,7 +471,7 @@ void IntegrationPluginPhilipsHue::setupThing(ThingSetupInfo *info)
ParamList migratedParams;
foreach (const Param &oldParam, thing->params()) {
QString oldId = oldParam.paramTypeId().toString();
oldId.remove(QRegExp("[{}]"));
oldId.remove(QRegularExpression("[{}]"));
if (migrationMap.contains(oldId)) {
ParamTypeId newId = migrationMap.value(oldId);
QVariant oldValue = oldParam.value();
@ -1557,7 +1558,7 @@ void IntegrationPluginPhilipsHue::onMotionSensorPresenceChanged(bool presence)
HueMotionSensor *sensor = static_cast<HueMotionSensor *>(sender());
Thing *sensorDevice = m_motionSensors.value(sensor);
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)
@ -2539,4 +2540,4 @@ void IntegrationPluginPhilipsHue::abortRequests(QHash<QNetworkReply *, Thing *>
reply->abort();
}
}
}
}

View File

@ -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,21 +31,19 @@
#ifndef 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 "huelight.h"
#include "hueremote.h"
#include "huemotionsensor.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 UpnpDiscoveryReply;
class IntegrationPluginPhilipsHue: public IntegrationPlugin
{
@ -99,9 +97,9 @@ private:
private:
class DiscoveryJob {
public:
UpnpDiscoveryReply* upnpReply;
UpnpDiscoveryReply *upnpReply;
bool upnpDone = false;
QNetworkReply* nUpnpReply;
QNetworkReply *nUpnpReply;
bool nUpnpDone = false;
ThingDescriptors results;
};
@ -109,7 +107,7 @@ private:
void startUpnPDiscovery(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_pluginTimer5Sec = nullptr;
@ -154,14 +152,14 @@ private:
void bridgeReachableChanged(Thing *thing, bool reachable);
Thing* bridgeForBridgeId(const QString &id);
Thing *bridgeForBridgeId(const QString &id);
bool lightAlreadyAdded(const QString &uuid);
bool sensorAlreadyAdded(const QString &uuid);
int brightnessToPercentage(int brightness);
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

View File

@ -1,8 +1,6 @@
include(../plugins.pri)
TARGET = $$qtLibraryTarget(nymea_integrationpluginphilipshue)
QT += network
QT *= network
SOURCES += \
integrationpluginphilipshue.cpp \