mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Add switch for dim when color request is present and other items
This commit is contained in:
@@ -57,20 +57,20 @@ Then locate the jar and start the server with:
|
||||
ATTENTION: Due to port 80 being the default, Linux restricts this to super user. Use the instructions below.
|
||||
|
||||
```
|
||||
java -jar ha-bridge-5.3.1RC3.jar
|
||||
java -jar ha-bridge-5.3.1RC5.jar
|
||||
```
|
||||
|
||||
## Manual installation of ha-bridge and setup of systemd service
|
||||
Next gen Linux systems (this includes the Raspberry Pi), use systemd to run and manage services.
|
||||
Here is a link on how to use systemd: https://www.digitalocean.com/community/tutorials/how-to-use-systemctl-to-manage-systemd-services-and-units
|
||||
|
||||
Create the directory and make sure that ha-bridge-5.3.1RC3.jar is in your /home/pi/ha-bridge directory.
|
||||
Create the directory and make sure that ha-bridge-5.3.1RC5.jar is in your /home/pi/ha-bridge directory.
|
||||
|
||||
```
|
||||
pi@raspberrypi:~ $ mkdir ha-bridge
|
||||
pi@raspberrypi:~ $ cd ha-bridge
|
||||
|
||||
pi@raspberrypi:~/ha-bridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v5.3.1RC3/ha-bridge-5.3.1RC3.jar
|
||||
pi@raspberrypi:~/ha-bridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v5.3.1RC5/ha-bridge-5.3.1RC5.jar
|
||||
```
|
||||
|
||||
Create the ha-bridge.service unit file:
|
||||
@@ -89,7 +89,7 @@ After=network.target
|
||||
Type=simple
|
||||
|
||||
WorkingDirectory=/home/pi/ha-bridge
|
||||
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/ha-bridge/data/habridge.config /home/pi/ha-bridge/ha-bridge-5.3.1RC3.jar
|
||||
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/ha-bridge/data/habridge.config /home/pi/ha-bridge/ha-bridge-5.3.1RC5.jar
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>5.3.1RC4-java11</version>
|
||||
<version>5.3.1RC5-java11</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
|
||||
@@ -202,6 +202,9 @@ public class BridgeSettings extends BackupHandler {
|
||||
if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0)
|
||||
theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP));
|
||||
|
||||
if(theBridgeSettings.getLinkbuttontimeout() < 30)
|
||||
theBridgeSettings.setLinkbuttontimeout(Configuration.LINK_BUTTON_TIMEOUT);
|
||||
|
||||
theBridgeSettings.setVeraconfigured(theBridgeSettings.isValidVera());
|
||||
theBridgeSettings.setFibaroconfigured(theBridgeSettings.isValidFibaro());
|
||||
theBridgeSettings.setHarmonyconfigured(theBridgeSettings.isValidHarmony());
|
||||
|
||||
@@ -135,6 +135,10 @@ public class BridgeSettingsDescriptor {
|
||||
@SerializedName("upnpadvanced")
|
||||
@Expose
|
||||
private boolean upnpadvanced;
|
||||
@SerializedName("linkbuttontimeout")
|
||||
@Expose
|
||||
private Integer linkbuttontimeout;
|
||||
|
||||
// @SerializedName("activeloggers")
|
||||
// @Expose
|
||||
// private List<NameValue> activeloggers;
|
||||
@@ -197,6 +201,7 @@ public class BridgeSettingsDescriptor {
|
||||
this.haaddressessecured = false;
|
||||
this.configfile = Configuration.CONFIG_FILE;
|
||||
this.upnpadvanced = false;
|
||||
this.linkbuttontimeout = Configuration.LINK_BUTTON_TIMEOUT;
|
||||
}
|
||||
|
||||
public String getUpnpConfigAddress() {
|
||||
@@ -860,4 +865,12 @@ public class BridgeSettingsDescriptor {
|
||||
public void setUpnpadvanced(boolean upnpadvanced) {
|
||||
this.upnpadvanced = upnpadvanced;
|
||||
}
|
||||
|
||||
public Integer getLinkbuttontimeout() {
|
||||
return linkbuttontimeout;
|
||||
}
|
||||
|
||||
public void setLinkbuttontimeout(Integer linkbuttontimeout) {
|
||||
this.linkbuttontimeout = linkbuttontimeout;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,4 +17,5 @@ public class Configuration {
|
||||
public static final int UPNP_SEND_DELAY = 650;
|
||||
public static final int BROADLINK_DISCOVER_PORT = 40000;
|
||||
public static final int BROADLINK_DISCONVER_TIMEOUT = 5000;
|
||||
public static final int LINK_BUTTON_TIMEOUT = 45;
|
||||
}
|
||||
|
||||
@@ -276,12 +276,12 @@ public class SystemControl {
|
||||
if(!request.body().isEmpty()) {
|
||||
linkParams = new Gson().fromJson(request.body(), LinkParams.class);
|
||||
if(linkParams.getSeconds() <= 0)
|
||||
linkParams.setSeconds(1);
|
||||
linkParams.setSeconds(3);
|
||||
}
|
||||
else {
|
||||
linkParams = new LinkParams();
|
||||
linkParams.setSilent(false);
|
||||
linkParams.setSeconds(30);
|
||||
linkParams.setSeconds(bridgeSettings.getBridgeSettingsDescriptor().getLinkbuttontimeout());
|
||||
}
|
||||
if(!linkParams.isSilent())
|
||||
log.info("Link button pressed....");
|
||||
|
||||
@@ -95,6 +95,9 @@ public class DeviceDescriptor{
|
||||
@SerializedName("dimNoOn")
|
||||
@Expose
|
||||
private boolean dimNoOn;
|
||||
@SerializedName("dimOnColor")
|
||||
@Expose
|
||||
private boolean dimOnColor;
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
@@ -366,4 +369,12 @@ public class DeviceDescriptor{
|
||||
public void setDimNoOn(boolean dimNoOn) {
|
||||
this.dimNoOn = dimNoOn;
|
||||
}
|
||||
|
||||
public boolean isDimOnColor() {
|
||||
return dimOnColor;
|
||||
}
|
||||
|
||||
public void setDimOnColor(boolean dimOnColor) {
|
||||
this.dimOnColor = dimOnColor;
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,9 @@ public class BrightnessDecode {
|
||||
private static final String INTENSITY_MATH_CLOSE_HEX = ").hex}";
|
||||
private static final String INTENSITY_PERCENT_HEX = "${intensity.percent.hex}";
|
||||
private static final String INTENSITY_BYTE_HEX = "${intensity.byte.hex}";
|
||||
private static final String INTENSITY_PREVIOUS_PERCENT = "${intensity.previous_percent}";
|
||||
private static final String INTENSITY_PREVIOUS_DECIMAL_PERCENT = "${intensity.previous_decimal_percent}";
|
||||
private static final String INTENSITY_PREVIOUS_BYTE = "${intensity.previous_byte}";
|
||||
|
||||
public static int calculateIntensity(int setIntensity, Integer targetBri, Integer targetBriInc) {
|
||||
if (targetBri != null) {
|
||||
@@ -45,7 +48,7 @@ public class BrightnessDecode {
|
||||
* intensity.math(X*1) : where X is the value from the interface call and
|
||||
* can use net.java.dev.eval math
|
||||
*/
|
||||
public static String replaceIntensityValue(String request, int intensity, boolean isHex) {
|
||||
private static String replaceIntensityValue(String request, int previous_intensity, int intensity, boolean isHex) {
|
||||
if (request == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -54,6 +57,8 @@ public class BrightnessDecode {
|
||||
String replaceTarget = null;
|
||||
int percentBrightness = 0;
|
||||
float decimalBrightness = (float) 1.0;
|
||||
int previousPercentBrightness = 0;
|
||||
float previousDecimalBrightness = (float) 1.0;
|
||||
Map<String, BigDecimal> variables = new HashMap<String, BigDecimal>();
|
||||
String mathDescriptor = null;
|
||||
|
||||
@@ -68,6 +73,17 @@ public class BrightnessDecode {
|
||||
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 class BrightnessDecode {
|
||||
}
|
||||
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 class BrightnessDecode {
|
||||
}
|
||||
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 class BrightnessDecode {
|
||||
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 class BrightnessDecode {
|
||||
|
||||
// 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
|
||||
|
||||
@@ -1250,6 +1250,9 @@ public class HueMulator {
|
||||
}
|
||||
}
|
||||
|
||||
if(isColorRequest && isDimRequest && !device.isDimOnColor()) {
|
||||
isDimRequest = false;
|
||||
}
|
||||
|
||||
/* Old code supperceded by the above block
|
||||
if (!device.isOnFirstDim() && device.isOnWhenDimPresent() && isDimRequest && !isOnRequest) {
|
||||
|
||||
@@ -139,8 +139,7 @@ public class HassHome implements Home {
|
||||
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");
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -120,6 +120,12 @@
|
||||
ng-model="device.dimNoOn" ng-true-value=true
|
||||
ng-false-value=false> {{device.dimNoOn}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label>Send dim when color request present and dim present</label></td>
|
||||
<td><input type="checkbox"
|
||||
ng-model="device.dimOnColor" ng-true-value=true
|
||||
ng-false-value=false> {{device.dimOnColor}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><label>Filter Address (comma separated list)</label></td>
|
||||
<td><input type="text" class="form-control" id="device-requester-addr"
|
||||
|
||||
@@ -844,6 +844,11 @@
|
||||
<td><input id="bridge-settings-upnpsenddelay" class="form-control" type="number"
|
||||
ng-model="bridge.settings.upnpsenddelay" min="100" max="15000"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Link Button Timeout (seconds)</td>
|
||||
<td><input id="bridge-settings-linkbuttontimeout" class="form-control" type="number"
|
||||
ng-model="bridge.settings.linkbuttontimeout" min="30"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ID Seed (start numbering from this value)</td>
|
||||
<td><input id="bridge-settings-seedid" class="form-control" type="number"
|
||||
|
||||
Reference in New Issue
Block a user