Commit 4d22a919 authored by Langston Ball's avatar Langston Ball

ref #2794 - Adds support for hue motion /temp sensor.

parent b445d7ac
This diff is collapsed.
......@@ -216,6 +216,8 @@ private slots:
void updateDevice(AbstractWirelessBulb *b, int d);
void checkLightInformation();
void handleCheckLightInformation(QNetworkReply * reply);
void checkSensorInformation();
void handleCheckSensorInformation(QNetworkReply * reply);
private:
......@@ -239,7 +241,8 @@ private:
QNetworkAccessManager * linkButtonManager;
QNetworkAccessManager * commandManager;
QNetworkAccessManager * poller;
QNetworkAccessManager * lightRequestManager;
QNetworkAccessManager * sensorRequestManager;
HueDayNightSensor * m_dayNightSensor;
static const char getGroups[]; /*!< Get all groups \note get */
......
......@@ -5,12 +5,14 @@
#include "QVariantMap"
#include "Gen_Devices/AllCommandsRequests.h"
#include "huecontrollerhardware.h"
#include <qdebug.h>
HueMotionSensor::HueMotionSensor(HueControllerHardware *p_controller, QObject *parent) :
QObject(parent), m_controller(p_controller)
QObject(parent), m_controller(p_controller), m_linuxmceId(0), useCelsius(false)
{
connect(&tempSensor, SIGNAL(notifyEvent(DCE::Message*)), this, SIGNAL(notifyEvent(DCE::Message*)));
connect(&lightSensor, SIGNAL(notifyEvent(DCE::Message*)), this, SIGNAL(notifyEvent(DCE::Message*)));
}
QString HueMotionSensor::status() const
......@@ -110,6 +112,8 @@ bool HueMotionSensor::presenceDetected() const
void HueMotionSensor::setPresenceDetected(bool presenceDetected)
{
if(m_presenceDetected == presenceDetected) return;
m_presenceDetected = presenceDetected;
emit presenceDetectedChanged(m_presenceDetected);
DCE::Message * m = new DCE::Message(
......@@ -203,6 +207,39 @@ void HueMotionSensor::setLightSensor(int id, QVariantMap obj)
lightSensor.setThresholdOffset(obj.value("config").toMap().value("tholdoffset").toInt());
}
void HueMotionSensor::setPresenceData(QVariantMap data)
{
setPresenceDetected(data.value("state").toMap().value("presence").toBool());
setBatteryLevel(data.value("config").toMap().value("battery").toInt());
}
void HueMotionSensor::setTempData(QVariantMap data)
{
int t = data.value("state").toMap().value("temperature").toInt()*.01;
if(!useCelsius) {
t = (t *9.0) / 5.0+32;
}
tempsensor()->setTemp(t );
}
void HueMotionSensor::setLightLevelData(QVariantMap data)
{
}
bool HueMotionSensor::getUseCelsius() const
{
return useCelsius;
}
void HueMotionSensor::setUseCelsius(bool value)
{
useCelsius = value;
}
HueControllerHardware *HueMotionSensor::controller() const
{
return m_controller;
......@@ -241,7 +278,22 @@ int ZLLTemp::temp() const
void ZLLTemp::setTemp(int temp)
{
m_temp = ( (temp*.01) * 9.0) / 5.0 + 32;
if(m_temp == temp) return;
m_temp = temp;
DCE::Message * m = new DCE::Message(
id(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
EVENT_Temperature_Changed_CONST,
1,
EVENTPARAMETER_Value_CONST,
StringUtils::itos(m_temp).c_str() );
emit notifyEvent(m);
}
int ZLLTemp::id() const
......@@ -254,6 +306,16 @@ void ZLLTemp::setId(int id)
m_id = id;
}
int ZLLTemp::linuxmceId() const
{
return m_linuxmceId;
}
void ZLLTemp::setLinuxmceId(int linuxmceId)
{
m_linuxmceId = linuxmceId;
}
int ZLLLightLevel::id() const
{
return m_id;
......@@ -314,5 +376,15 @@ void ZLLLightLevel::setDaylight(bool daylight)
m_daylight = daylight;
}
int ZLLLightLevel::linuxmceId() const
{
return m_linuxmceId;
}
void ZLLLightLevel::setLinuxmceId(int linuxmceId)
{
m_linuxmceId = linuxmceId;
}
......@@ -3,7 +3,7 @@
#include <QObject>
#include <QVariantMap>
#include "Gen_Devices/AllCommandsRequests.h"
class HueControllerHardware;
namespace DCE {
......@@ -20,11 +20,19 @@ public:
void setTemp(int temp);
int id() const;
void setId(int id);
int linuxmceId() const;
void setLinuxmceId(int linuxmceId);
signals:
void notifyEvent(DCE::Message * m);
private:
int m_temp;
int m_id;
int m_linuxmceId;
};
......@@ -53,8 +61,15 @@ public:
bool daylight() const;
void setDaylight(bool daylight);
int linuxmceId() const;
void setLinuxmceId(int linuxmceId);
signals:
void notifyEvent(DCE::Message * m);
private:
int m_id;
int m_linuxmceId;
int m_darkThreshold;
int m_thresholdOffset;
int m_lightLevel;
......@@ -75,6 +90,9 @@ public:
HueControllerHardware *controller() const;
void setController(HueControllerHardware *controller);
bool getUseCelsius() const;
void setUseCelsius(bool value);
signals:
void batteryLevelChanged(int batteryLevel);
void enabledChanged(bool enabled);
......@@ -136,8 +154,13 @@ public slots:
void setLastUpdated(const QString &lastUpdated);
void setTempSensor(int id, QVariantMap obj);
ZLLTemp *tempsensor() {return &tempSensor; }
void setLightSensor(int id, QVariantMap obj);
void setPresenceData(QVariantMap data);
void setTempData(QVariantMap data);
void setLightLevelData(QVariantMap data);
protected:
QString m_status;
......@@ -163,6 +186,7 @@ protected:
ZLLLightLevel lightSensor;
ZLLTemp tempSensor;
HueControllerHardware * m_controller;
bool useCelsius;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment