Skip to content

Commit

Permalink
Update rest_lights.cpp
Browse files Browse the repository at this point in the history
Support `state.ontime` in combination with setting `state.alert` to `lselect` or (for Warning Devices) to `blink`.  The default duration of the warning (300s) or identification (15s) can be overwritten using `state.ontime` (in seconds).
See ebaauw/homebridge-hue#614.
  • Loading branch information
ebaauw authored and manup committed Feb 8, 2020
1 parent dcf7b65 commit a6e5799
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions rest_lights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1350,16 +1350,12 @@ int DeRestPluginPrivate::setLightState(const ApiRequest &req, ApiResponse &rsp)
}
else if (alert == "select")
{
if (isWarningDevice && isSmokeDetector)
{
task.taskType = TaskWarning;
task.options = 0x12; // Warning mode 2 (fire), strobe
task.duration = 1;
}
else if (isWarningDevice)
if (isWarningDevice)
{
task.taskType = TaskWarning;
task.options = 0x14; // Warning mode 1 (burglar), Strobe
task.options = isSmokeDetector
? 0x12 // Warning mode 2 (fire), Strobe
: 0x14; // Warning mode 1 (burglar), Strobe
task.duration = 1;
}
else
Expand All @@ -1370,22 +1366,18 @@ int DeRestPluginPrivate::setLightState(const ApiRequest &req, ApiResponse &rsp)
}
else if (alert == "lselect")
{
if (isWarningDevice && isSmokeDetector)
{
task.taskType = TaskWarning;
task.options = 0x12; // Warning mode 2 (fire), strobe
task.duration = 300;
}
else if (isWarningDevice)
if (isWarningDevice)
{
task.taskType = TaskWarning;
task.options = 0x14; // Warning mode 1 (burglar), Strobe
task.duration = 300;
task.options = isSmokeDetector
? 0x12 // Warning mode 2 (fire), Strobe
: 0x14; // Warning mode 1 (burglar), Strobe
task.duration = taskRef.onTime > 0 ? taskRef.onTime : 300;
}
else
{
task.taskType = TaskIdentify;
task.identifyTime = 15; // Default for Philips Hue bridge
task.identifyTime = taskRef.onTime > 0 ? taskRef.onTime : 15; // Default for Philips Hue bridge
}
}
else if (alert == "blink")
Expand All @@ -1394,7 +1386,7 @@ int DeRestPluginPrivate::setLightState(const ApiRequest &req, ApiResponse &rsp)
{
task.taskType = TaskWarning;
task.options = 0x04; // Warning mode 0 (no warning), Strobe
task.duration = 300;
task.duration = taskRef.onTime > 0 ? taskRef.onTime : 300;
}
else
{
Expand Down

0 comments on commit a6e5799

Please sign in to comment.