Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
linuxmce
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
255
Issues
255
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
linuxmce
linuxmce
Commits
4d22a919
Commit
4d22a919
authored
Feb 13, 2018
by
Langston Ball
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ref
#2794
- Adds support for hue motion /temp sensor.
parent
b445d7ac
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
251 additions
and
97 deletions
+251
-97
HueController.cpp
src/Hue_Controller/HueController.cpp
+147
-92
HueController.h
src/Hue_Controller/HueController.h
+4
-1
huemotionsensor.cpp
src/Hue_Controller/HueController/huemotionsensor.cpp
+75
-3
huemotionsensor.h
src/Hue_Controller/HueController/huemotionsensor.h
+25
-1
No files found.
src/Hue_Controller/HueController.cpp
View file @
4d22a919
This diff is collapsed.
Click to expand it.
src/Hue_Controller/HueController.h
View file @
4d22a919
...
...
@@ -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 */
...
...
src/Hue_Controller/HueController/huemotionsensor.cpp
View file @
4d22a919
...
...
@@ -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
;
}
src/Hue_Controller/HueController/huemotionsensor.h
View file @
4d22a919
...
...
@@ -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
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment