Dim/brighten rework.

This commit is contained in:
Admin
2016-12-07 15:53:14 -06:00
parent 9c252a61ba
commit 2b1b70cf4f
2 changed files with 13 additions and 16 deletions

View File

@@ -5,7 +5,7 @@
<groupId>com.bwssystems.HABridge</groupId> <groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId> <artifactId>ha-bridge</artifactId>
<version>3.5.1d</version> <version>3.5.1e</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HA Bridge</name> <name>HA Bridge</name>

View File

@@ -697,10 +697,7 @@ public class HueMulator implements HueErrorStringSet {
} }
if (request.body().contains("\"bri\"")) { if (request.body().contains("\"bri\"")) {
if (theStateChanges.isOn() && theStateChanges.getBri() == 0) stateHasBri = true;
stateHasBri = false;
else
stateHasBri = true;
} }
if (request.body().contains("\"bri_inc\"")) if (request.body().contains("\"bri_inc\""))
stateHasBriInc = true; stateHasBriInc = true;
@@ -721,7 +718,7 @@ public class HueMulator implements HueErrorStringSet {
theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class); theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class);
if (stateHasBri) { if (stateHasBri) {
if (theStateChanges.getBri() > 0 && !state.isOn()) if(!state.isOn())
state.setOn(true); state.setOn(true);
url = device.getDimUrl(); url = device.getDimUrl();
@@ -729,10 +726,10 @@ public class HueMulator implements HueErrorStringSet {
if (url == null || url.length() == 0) if (url == null || url.length() == 0)
url = device.getOnUrl(); url = device.getOnUrl();
} else if (stateHasBriInc) { } else if (stateHasBriInc) {
if ((state.getBri() + theStateChanges.getBri_inc()) > 0 && !state.isOn()) if(!state.isOn())
state.setOn(true); state.setOn(true);
else if ((state.getBri() + theStateChanges.getBri_inc()) <= 0 && state.isOn()) if ((state.getBri() + theStateChanges.getBri_inc()) <= 0)
state.setOn(false); state.setBri(theStateChanges.getBri_inc());
url = device.getDimUrl(); url = device.getDimUrl();
@@ -742,12 +739,12 @@ public class HueMulator implements HueErrorStringSet {
if (theStateChanges.isOn()) { if (theStateChanges.isOn()) {
url = device.getOnUrl(); url = device.getOnUrl();
state.setOn(true); state.setOn(true);
if (state.getBri() <= 0) // if (state.getBri() <= 0)
state.setBri(255); // state.setBri(255);
} else { } else if (!theStateChanges.isOn()) {
url = device.getOffUrl(); url = device.getOffUrl();
state.setOn(false); state.setOn(false);
state.setBri(0); // state.setBri(0);
} }
} }
@@ -1167,10 +1164,10 @@ public class HueMulator implements HueErrorStringSet {
if (hasBri) { if (hasBri) {
setIntensity = theChanges.getBri(); setIntensity = theChanges.getBri();
} else if (hasBriInc) { } else if (hasBriInc) {
if ((setIntensity + theChanges.getBri_inc()) < 0) if ((setIntensity + theChanges.getBri_inc()) <= 0)
setIntensity = 0; setIntensity = theChanges.getBri_inc();
else if ((setIntensity + theChanges.getBri_inc()) > 255) else if ((setIntensity + theChanges.getBri_inc()) > 255)
setIntensity = 255; setIntensity = theChanges.getBri_inc();
else else
setIntensity = setIntensity + theChanges.getBri_inc(); setIntensity = setIntensity + theChanges.getBri_inc();
} }