Commit 99cee425 authored by Langston Ball's avatar Langston Ball

refs # 2794 - Motion sensor now reports status for temp and light level.

parent 7b5865b1
This diff is collapsed.
......@@ -147,8 +147,25 @@ int HueMotionSensor::batteryLevel() const
void HueMotionSensor::setBatteryLevel(int batteryLevel)
{
if(m_batteryLevel == batteryLevel) return;
m_batteryLevel = batteryLevel;
emit batteryLevelChanged(m_batteryLevel);
DCE::Message *status = new DCE::Message(
linuxmceId(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
EVENT_Battery_Level_Changed_CONST,
1 /* number of parameter's pairs (id, value) */,
EVENTPARAMETER_Value_CONST,
QString(m_batteryLevel).toStdString().c_str()
);
emit notifyEvent(status);
}
QString HueMotionSensor::alert() const
......@@ -227,6 +244,9 @@ void HueMotionSensor::setTempData(QVariantMap data)
void HueMotionSensor::setLightLevelData(QVariantMap data)
{
lightSensor.setLightLevel(data["state"].toMap().value("lightlevel").toInt());
lightSensor.setDark(data["state"].toMap().value("dark").toBool());
lightSensor.setDaylight(data["state"].toMap().value("daylight").toBool());
}
......@@ -240,6 +260,49 @@ void HueMotionSensor::setUseCelsius(bool value)
useCelsius = value;
}
void HueMotionSensor::initValues()
{
DCE::Message * m = new DCE::Message(
tempsensor()->linuxmceId(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
EVENT_Temperature_Changed_CONST,
1,
EVENTPARAMETER_Value_CONST,
StringUtils::itos(tempSensor.temp()).c_str() );
emit notifyEvent(m);
DCE::Message *status = new DCE::Message(
lightsensor()->linuxmceId(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
EVENT_Brightness_Changed_CONST,
1 /* number of parameter's pairs (id, value) */,
EVENTPARAMETER_Value_CONST,
StringUtils::itos(lightsensor()->lightLevel()).c_str()
);
emit notifyEvent(status);
status = new DCE::Message(
linuxmceId(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
EVENT_Battery_Level_Changed_CONST,
1 /* number of parameter's pairs (id, value) */,
EVENTPARAMETER_Value_CONST,
QString(m_batteryLevel).toStdString().c_str()
);
emit notifyEvent(status);
}
HueControllerHardware *HueMotionSensor::controller() const
{
return m_controller;
......@@ -283,7 +346,7 @@ void ZLLTemp::setTemp(int temp)
DCE::Message * m = new DCE::Message(
id(),
linuxmceId(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
......@@ -291,7 +354,7 @@ void ZLLTemp::setTemp(int temp)
1,
EVENTPARAMETER_Value_CONST,
StringUtils::itos(m_temp).c_str() );
if(linuxmceId() != 0)
emit notifyEvent(m);
}
......@@ -351,9 +414,25 @@ int ZLLLightLevel::lightLevel() const
return m_lightLevel;
}
void ZLLLightLevel::setLightLevel(long lightLevel)
void ZLLLightLevel::setLightLevel(int lightLevel)
{
if(m_lightLevel== lightLevel) return;
m_lightLevel = lightLevel;
qDebug() << Q_FUNC_INFO;
DCE::Message *status = new DCE::Message(
linuxmceId(),
DEVICEID_EVENTMANAGER,
DCE::PRIORITY_NORMAL,
DCE::MESSAGETYPE_EVENT,
EVENT_Brightness_Changed_CONST,
1 /* number of parameter's pairs (id, value) */,
EVENTPARAMETER_Value_CONST,
StringUtils::itos(m_lightLevel).c_str()
);
if(linuxmceId() != 0)
emit notifyEvent(status);
}
bool ZLLLightLevel::dark() const
......@@ -384,6 +463,7 @@ int ZLLLightLevel::linuxmceId() const
void ZLLLightLevel::setLinuxmceId(int linuxmceId)
{
m_linuxmceId = linuxmceId;
qDebug() << Q_FUNC_INFO << linuxmceId;
}
......
......@@ -28,6 +28,7 @@ public:
signals:
void notifyEvent(DCE::Message * m);
void dataEvent(DCE::PreformedCommand *cmd );
private:
int m_temp;
......@@ -53,7 +54,7 @@ public:
void setThresholdOffset(long thresholdOffset);
int lightLevel() const;
void setLightLevel(long lightLevel);
void setLightLevel(int lightLevel);
bool dark() const;
void setDark(bool dark);
......@@ -66,6 +67,7 @@ public:
signals:
void notifyEvent(DCE::Message * m);
void dataEvent(DCE::PreformedCommand *cmd );
private:
int m_id;
......@@ -98,10 +100,13 @@ signals:
void enabledChanged(bool enabled);
void presenceDetectedChanged(bool presenceDetected);
void notifyEvent(DCE::Message * m);
void dataEvent(DCE::PreformedCommand *cmd );
public slots:
void initValues();
int linuxmceId() const;
void setLinuxmceId(int linuxmceId);
......@@ -155,6 +160,7 @@ public slots:
void setTempSensor(int id, QVariantMap obj);
ZLLTemp *tempsensor() {return &tempSensor; }
ZLLLightLevel * lightsensor(){ return &lightSensor;}
void setLightSensor(int id, QVariantMap obj);
void setPresenceData(QVariantMap data);
......
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