mirror of https://github.com/nymea/nymea.git
87 lines
3.3 KiB
C++
87 lines
3.3 KiB
C++
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
|
* *
|
|
* Copyright (C) 2014 Michael Zanetti <michael_zanetti@gmx.net> *
|
|
* *
|
|
* This file is part of guh. *
|
|
* *
|
|
* Guh is free software: you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation, version 2 of the License. *
|
|
* *
|
|
* Guh is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with guh. If not, see <http://www.gnu.org/licenses/>. *
|
|
* *
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
#ifndef DEVICEPLUGINPHILIPSHUE_H
|
|
#define DEVICEPLUGINPHILIPSHUE_H
|
|
|
|
#include "plugin/deviceplugin.h"
|
|
#include "huebridgeconnection.h"
|
|
#include "light.h"
|
|
|
|
class QNetworkReply;
|
|
|
|
class DevicePluginPhilipsHue: public DevicePlugin
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PLUGIN_METADATA(IID "guru.guh.DevicePlugin" FILE "devicepluginphilipshue.json")
|
|
Q_INTERFACES(DevicePlugin)
|
|
|
|
public:
|
|
explicit DevicePluginPhilipsHue();
|
|
|
|
DeviceManager::HardwareResources requiredHardware() const override;
|
|
|
|
void startMonitoringAutoDevices() override;
|
|
|
|
QList<ParamType> configurationDescription() const override;
|
|
DeviceManager::DeviceError discoverDevices(const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
|
|
|
DeviceManager::DeviceSetupStatus setupDevice(Device *device) override;
|
|
void deviceRemoved(Device *device) override;
|
|
void upnpDiscoveryFinished(const QList<UpnpDeviceDescriptor> &upnpDeviceDescriptorList) override;
|
|
|
|
DeviceManager::DeviceSetupStatus confirmPairing(const PairingTransactionId &pairingTransactionId, const DeviceClassId &deviceClassId, const ParamList ¶ms) override;
|
|
|
|
void guhTimer() override;
|
|
|
|
public slots:
|
|
DeviceManager::DeviceError executeAction(Device *device, const Action &action);
|
|
|
|
private slots:
|
|
void createUserFinished(int id, const QVariant ¶ms);
|
|
void getLightsFinished(int id, const QVariant ¶ms);
|
|
void getFinished(int id, const QVariant ¶ms);
|
|
|
|
void lightStateChanged();
|
|
|
|
private:
|
|
|
|
class PairingInfo {
|
|
public:
|
|
PairingTransactionId pairingTransactionId;
|
|
Param ipParam;
|
|
Param usernameParam;
|
|
};
|
|
|
|
QHash<int, PairingInfo> m_pairings;
|
|
HueBridgeConnection *m_bridge;
|
|
|
|
QList<Light*> m_unconfiguredLights;
|
|
QHash<Light*, Device*> m_lights;
|
|
|
|
QHash<Light*, Device*> m_asyncSetups;
|
|
|
|
int brightnessToPercentage(int brightness);
|
|
int percentageToBrightness(int percentage);
|
|
};
|
|
|
|
#endif // DEVICEPLUGINBOBLIGHT_H
|