();
String mathDescriptor = null;
@@ -68,6 +73,17 @@ public static String replaceIntensityValue(String request, int intensity, boolea
percentBrightness = 1;
}
+ if(previous_intensity > 0) {
+ previousDecimalBrightness = (float) (previous_intensity / 255.0);
+ if(previous_intensity > 0 && previous_intensity < 5)
+ previousPercentBrightness = 1;
+ else
+ previousPercentBrightness = (int) Math.round(previous_intensity / 255.0 * 100);
+ } else {
+ previousDecimalBrightness = (float) 1.0;
+ previousPercentBrightness = 1;
+ }
+
while(notDone) {
notDone = false;
if (request.contains(INTENSITY_BYTE)) {
@@ -78,6 +94,14 @@ public static String replaceIntensityValue(String request, int intensity, boolea
}
replaceTarget = INTENSITY_BYTE;
notDone = true;
+ } else if (request.contains(INTENSITY_PREVIOUS_BYTE)) {
+ if (isHex) {
+ replaceValue = convertToHex(previous_intensity);
+ } else {
+ replaceValue = String.valueOf(previous_intensity);
+ }
+ replaceTarget = INTENSITY_PREVIOUS_BYTE;
+ notDone = true;
} else if (request.contains(INTENSITY_BYTE_HEX)) {
replaceValue = convertToHex(intensity);
replaceTarget = INTENSITY_BYTE_HEX;
@@ -90,6 +114,14 @@ public static String replaceIntensityValue(String request, int intensity, boolea
}
replaceTarget = INTENSITY_PERCENT;
notDone = true;
+ } else if (request.contains(INTENSITY_PREVIOUS_PERCENT)) {
+ if (isHex) {
+ replaceValue = convertToHex(previousPercentBrightness);
+ } else {
+ replaceValue = String.valueOf(previousPercentBrightness);
+ }
+ replaceTarget = INTENSITY_PREVIOUS_PERCENT;
+ notDone = true;
} else if (request.contains(INTENSITY_PERCENT_HEX)) {
replaceValue = convertToHex(percentBrightness);
replaceTarget = INTENSITY_PERCENT_HEX;
@@ -98,6 +130,10 @@ public static String replaceIntensityValue(String request, int intensity, boolea
replaceValue = String.format(Locale.ROOT, "%1.2f", decimalBrightness);
replaceTarget = INTENSITY_DECIMAL_PERCENT;
notDone = true;
+ } else if (request.contains(INTENSITY_PREVIOUS_DECIMAL_PERCENT)) {
+ replaceValue = String.format(Locale.ROOT, "%1.2f", previousDecimalBrightness);
+ replaceTarget = INTENSITY_PREVIOUS_DECIMAL_PERCENT;
+ notDone = true;
} else if (request.contains(INTENSITY_MATH_CLOSE)) {
mathDescriptor = request.substring(request.indexOf(INTENSITY_MATH) + INTENSITY_MATH.length(),
request.indexOf(INTENSITY_MATH_CLOSE));
@@ -135,7 +171,7 @@ public static String replaceIntensityValue(String request, int intensity, boolea
// Helper Method
public static String calculateReplaceIntensityValue(String request, int theIntensity, Integer targetBri, Integer targetBriInc, boolean isHex) {
- return replaceIntensityValue(request, calculateIntensity(theIntensity, targetBri, targetBriInc), isHex);
+ return replaceIntensityValue(request, theIntensity, calculateIntensity(theIntensity, targetBri, targetBriInc), isHex);
}
// Apache Commons Conversion utils likes little endian too much
diff --git a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
index a136a388..283892fb 100644
--- a/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
+++ b/src/main/java/com/bwssystems/HABridge/hue/HueMulator.java
@@ -1250,6 +1250,9 @@ private String changeState(String userId, String lightId, String body, String ip
}
}
+ if(isColorRequest && isDimRequest && !device.isDimOnColor()) {
+ isDimRequest = false;
+ }
/* Old code supperceded by the above block
if (!device.isOnFirstDim() && device.isOnWhenDimPresent() && isDimRequest && !isOnRequest) {
diff --git a/src/main/java/com/bwssystems/HABridge/plugins/hass/HassHome.java b/src/main/java/com/bwssystems/HABridge/plugins/hass/HassHome.java
index 090f45d1..ca8e863a 100644
--- a/src/main/java/com/bwssystems/HABridge/plugins/hass/HassHome.java
+++ b/src/main/java/com/bwssystems/HABridge/plugins/hass/HassHome.java
@@ -139,8 +139,7 @@ public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String
hassCommand = aGsonHandler.fromJson(anItem.getItem(), HassCommand.class);
else
hassCommand = aGsonHandler.fromJson(anItem.getItem().getAsString().replaceAll("^\"|\"$", ""), HassCommand.class);
- hassCommand.setBri(BrightnessDecode.replaceIntensityValue(hassCommand.getBri(),
- BrightnessDecode.calculateIntensity(intensity, targetBri, targetBriInc), false));
+ hassCommand.setBri(BrightnessDecode.calculateReplaceIntensityValue(hassCommand.getBri(), intensity, targetBri, targetBriInc, false));
HomeAssistant homeAssistant = getHomeAssistant(hassCommand.getHassName());
if (homeAssistant == null) {
log.warn("Should not get here, no HomeAssistants available");
diff --git a/src/main/resources/public/scripts/app.js b/src/main/resources/public/scripts/app.js
index a67ea1b1..f53175f1 100644
--- a/src/main/resources/public/scripts/app.js
+++ b/src/main/resources/public/scripts/app.js
@@ -479,7 +479,7 @@ app.service('bridgeService', function ($rootScope, $http, $base64, $location, ng
this.pushLinkButton = function () {
return $http.put(this.state.systemsbase + "/presslinkbutton").then(
function (response) {
- self.displayTimer("Link your device", 30000);
+ self.displayTimer("Link your device", self.state.settings.linkbuttontimeout * 1000);
},
function (error) {
if (error.status === 401)
diff --git a/src/main/resources/public/views/editdevice.html b/src/main/resources/public/views/editdevice.html
index 9630f4ae..f6474a7a 100644
--- a/src/main/resources/public/views/editdevice.html
+++ b/src/main/resources/public/views/editdevice.html
@@ -120,6 +120,12 @@ Edit/Copy a device
ng-model="device.dimNoOn" ng-true-value=true
ng-false-value=false> {{device.dimNoOn}}
+
+ |
+ {{device.dimOnColor}} |
+
|
Bridge Settings
| |
+
+ Link Button Timeout (seconds) |
+ |
+
ID Seed (start numbering from this value) |
|