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.
|
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
|
## 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.
|
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
|
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:~ $ mkdir ha-bridge
|
||||||
pi@raspberrypi:~ $ cd 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:
|
Create the ha-bridge.service unit file:
|
||||||
@@ -89,7 +89,7 @@ After=network.target
|
|||||||
Type=simple
|
Type=simple
|
||||||
|
|
||||||
WorkingDirectory=/home/pi/ha-bridge
|
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]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>5.3.1RC4-java11</version>
|
<version>5.3.1RC5-java11</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -200,7 +200,10 @@ public class BridgeSettings extends BackupHandler {
|
|||||||
theBridgeSettings.setNumberoflogmessages(Integer.valueOf(Configuration.NUMBER_OF_LOG_MESSAGES));
|
theBridgeSettings.setNumberoflogmessages(Integer.valueOf(Configuration.NUMBER_OF_LOG_MESSAGES));
|
||||||
|
|
||||||
if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0)
|
if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0)
|
||||||
theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP));
|
theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP));
|
||||||
|
|
||||||
|
if(theBridgeSettings.getLinkbuttontimeout() < 30)
|
||||||
|
theBridgeSettings.setLinkbuttontimeout(Configuration.LINK_BUTTON_TIMEOUT);
|
||||||
|
|
||||||
theBridgeSettings.setVeraconfigured(theBridgeSettings.isValidVera());
|
theBridgeSettings.setVeraconfigured(theBridgeSettings.isValidVera());
|
||||||
theBridgeSettings.setFibaroconfigured(theBridgeSettings.isValidFibaro());
|
theBridgeSettings.setFibaroconfigured(theBridgeSettings.isValidFibaro());
|
||||||
|
|||||||
@@ -135,6 +135,10 @@ public class BridgeSettingsDescriptor {
|
|||||||
@SerializedName("upnpadvanced")
|
@SerializedName("upnpadvanced")
|
||||||
@Expose
|
@Expose
|
||||||
private boolean upnpadvanced;
|
private boolean upnpadvanced;
|
||||||
|
@SerializedName("linkbuttontimeout")
|
||||||
|
@Expose
|
||||||
|
private Integer linkbuttontimeout;
|
||||||
|
|
||||||
// @SerializedName("activeloggers")
|
// @SerializedName("activeloggers")
|
||||||
// @Expose
|
// @Expose
|
||||||
// private List<NameValue> activeloggers;
|
// private List<NameValue> activeloggers;
|
||||||
@@ -197,6 +201,7 @@ public class BridgeSettingsDescriptor {
|
|||||||
this.haaddressessecured = false;
|
this.haaddressessecured = false;
|
||||||
this.configfile = Configuration.CONFIG_FILE;
|
this.configfile = Configuration.CONFIG_FILE;
|
||||||
this.upnpadvanced = false;
|
this.upnpadvanced = false;
|
||||||
|
this.linkbuttontimeout = Configuration.LINK_BUTTON_TIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUpnpConfigAddress() {
|
public String getUpnpConfigAddress() {
|
||||||
@@ -860,4 +865,12 @@ public class BridgeSettingsDescriptor {
|
|||||||
public void setUpnpadvanced(boolean upnpadvanced) {
|
public void setUpnpadvanced(boolean upnpadvanced) {
|
||||||
this.upnpadvanced = 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 UPNP_SEND_DELAY = 650;
|
||||||
public static final int BROADLINK_DISCOVER_PORT = 40000;
|
public static final int BROADLINK_DISCOVER_PORT = 40000;
|
||||||
public static final int BROADLINK_DISCONVER_TIMEOUT = 5000;
|
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()) {
|
if(!request.body().isEmpty()) {
|
||||||
linkParams = new Gson().fromJson(request.body(), LinkParams.class);
|
linkParams = new Gson().fromJson(request.body(), LinkParams.class);
|
||||||
if(linkParams.getSeconds() <= 0)
|
if(linkParams.getSeconds() <= 0)
|
||||||
linkParams.setSeconds(1);
|
linkParams.setSeconds(3);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
linkParams = new LinkParams();
|
linkParams = new LinkParams();
|
||||||
linkParams.setSilent(false);
|
linkParams.setSilent(false);
|
||||||
linkParams.setSeconds(30);
|
linkParams.setSeconds(bridgeSettings.getBridgeSettingsDescriptor().getLinkbuttontimeout());
|
||||||
}
|
}
|
||||||
if(!linkParams.isSilent())
|
if(!linkParams.isSilent())
|
||||||
log.info("Link button pressed....");
|
log.info("Link button pressed....");
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ public class DeviceDescriptor{
|
|||||||
@SerializedName("dimNoOn")
|
@SerializedName("dimNoOn")
|
||||||
@Expose
|
@Expose
|
||||||
private boolean dimNoOn;
|
private boolean dimNoOn;
|
||||||
|
@SerializedName("dimOnColor")
|
||||||
|
@Expose
|
||||||
|
private boolean dimOnColor;
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return name;
|
return name;
|
||||||
@@ -366,4 +369,12 @@ public class DeviceDescriptor{
|
|||||||
public void setDimNoOn(boolean dimNoOn) {
|
public void setDimNoOn(boolean dimNoOn) {
|
||||||
this.dimNoOn = 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_MATH_CLOSE_HEX = ").hex}";
|
||||||
private static final String INTENSITY_PERCENT_HEX = "${intensity.percent.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_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) {
|
public static int calculateIntensity(int setIntensity, Integer targetBri, Integer targetBriInc) {
|
||||||
if (targetBri != null) {
|
if (targetBri != null) {
|
||||||
@@ -45,7 +48,7 @@ public class BrightnessDecode {
|
|||||||
* intensity.math(X*1) : where X is the value from the interface call and
|
* intensity.math(X*1) : where X is the value from the interface call and
|
||||||
* can use net.java.dev.eval math
|
* 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) {
|
if (request == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -54,6 +57,8 @@ public class BrightnessDecode {
|
|||||||
String replaceTarget = null;
|
String replaceTarget = null;
|
||||||
int percentBrightness = 0;
|
int percentBrightness = 0;
|
||||||
float decimalBrightness = (float) 1.0;
|
float decimalBrightness = (float) 1.0;
|
||||||
|
int previousPercentBrightness = 0;
|
||||||
|
float previousDecimalBrightness = (float) 1.0;
|
||||||
Map<String, BigDecimal> variables = new HashMap<String, BigDecimal>();
|
Map<String, BigDecimal> variables = new HashMap<String, BigDecimal>();
|
||||||
String mathDescriptor = null;
|
String mathDescriptor = null;
|
||||||
|
|
||||||
@@ -68,6 +73,17 @@ public class BrightnessDecode {
|
|||||||
percentBrightness = 1;
|
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) {
|
while(notDone) {
|
||||||
notDone = false;
|
notDone = false;
|
||||||
if (request.contains(INTENSITY_BYTE)) {
|
if (request.contains(INTENSITY_BYTE)) {
|
||||||
@@ -78,6 +94,14 @@ public class BrightnessDecode {
|
|||||||
}
|
}
|
||||||
replaceTarget = INTENSITY_BYTE;
|
replaceTarget = INTENSITY_BYTE;
|
||||||
notDone = true;
|
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)) {
|
} else if (request.contains(INTENSITY_BYTE_HEX)) {
|
||||||
replaceValue = convertToHex(intensity);
|
replaceValue = convertToHex(intensity);
|
||||||
replaceTarget = INTENSITY_BYTE_HEX;
|
replaceTarget = INTENSITY_BYTE_HEX;
|
||||||
@@ -90,6 +114,14 @@ public class BrightnessDecode {
|
|||||||
}
|
}
|
||||||
replaceTarget = INTENSITY_PERCENT;
|
replaceTarget = INTENSITY_PERCENT;
|
||||||
notDone = true;
|
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)) {
|
} else if (request.contains(INTENSITY_PERCENT_HEX)) {
|
||||||
replaceValue = convertToHex(percentBrightness);
|
replaceValue = convertToHex(percentBrightness);
|
||||||
replaceTarget = INTENSITY_PERCENT_HEX;
|
replaceTarget = INTENSITY_PERCENT_HEX;
|
||||||
@@ -98,6 +130,10 @@ public class BrightnessDecode {
|
|||||||
replaceValue = String.format(Locale.ROOT, "%1.2f", decimalBrightness);
|
replaceValue = String.format(Locale.ROOT, "%1.2f", decimalBrightness);
|
||||||
replaceTarget = INTENSITY_DECIMAL_PERCENT;
|
replaceTarget = INTENSITY_DECIMAL_PERCENT;
|
||||||
notDone = true;
|
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)) {
|
} else if (request.contains(INTENSITY_MATH_CLOSE)) {
|
||||||
mathDescriptor = request.substring(request.indexOf(INTENSITY_MATH) + INTENSITY_MATH.length(),
|
mathDescriptor = request.substring(request.indexOf(INTENSITY_MATH) + INTENSITY_MATH.length(),
|
||||||
request.indexOf(INTENSITY_MATH_CLOSE));
|
request.indexOf(INTENSITY_MATH_CLOSE));
|
||||||
@@ -135,7 +171,7 @@ public class BrightnessDecode {
|
|||||||
|
|
||||||
// Helper Method
|
// Helper Method
|
||||||
public static String calculateReplaceIntensityValue(String request, int theIntensity, Integer targetBri, Integer targetBriInc, boolean isHex) {
|
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
|
// 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
|
/* Old code supperceded by the above block
|
||||||
if (!device.isOnFirstDim() && device.isOnWhenDimPresent() && isDimRequest && !isOnRequest) {
|
if (!device.isOnFirstDim() && device.isOnWhenDimPresent() && isDimRequest && !isOnRequest) {
|
||||||
|
|||||||
@@ -139,8 +139,7 @@ public class HassHome implements Home {
|
|||||||
hassCommand = aGsonHandler.fromJson(anItem.getItem(), HassCommand.class);
|
hassCommand = aGsonHandler.fromJson(anItem.getItem(), HassCommand.class);
|
||||||
else
|
else
|
||||||
hassCommand = aGsonHandler.fromJson(anItem.getItem().getAsString().replaceAll("^\"|\"$", ""), HassCommand.class);
|
hassCommand = aGsonHandler.fromJson(anItem.getItem().getAsString().replaceAll("^\"|\"$", ""), HassCommand.class);
|
||||||
hassCommand.setBri(BrightnessDecode.replaceIntensityValue(hassCommand.getBri(),
|
hassCommand.setBri(BrightnessDecode.calculateReplaceIntensityValue(hassCommand.getBri(), intensity, targetBri, targetBriInc, false));
|
||||||
BrightnessDecode.calculateIntensity(intensity, targetBri, targetBriInc), false));
|
|
||||||
HomeAssistant homeAssistant = getHomeAssistant(hassCommand.getHassName());
|
HomeAssistant homeAssistant = getHomeAssistant(hassCommand.getHassName());
|
||||||
if (homeAssistant == null) {
|
if (homeAssistant == null) {
|
||||||
log.warn("Should not get here, no HomeAssistants available");
|
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 () {
|
this.pushLinkButton = function () {
|
||||||
return $http.put(this.state.systemsbase + "/presslinkbutton").then(
|
return $http.put(this.state.systemsbase + "/presslinkbutton").then(
|
||||||
function (response) {
|
function (response) {
|
||||||
self.displayTimer("Link your device", 30000);
|
self.displayTimer("Link your device", self.state.settings.linkbuttontimeout * 1000);
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
if (error.status === 401)
|
if (error.status === 401)
|
||||||
|
|||||||
@@ -120,6 +120,12 @@
|
|||||||
ng-model="device.dimNoOn" ng-true-value=true
|
ng-model="device.dimNoOn" ng-true-value=true
|
||||||
ng-false-value=false> {{device.dimNoOn}}</td>
|
ng-false-value=false> {{device.dimNoOn}}</td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td><label>Filter Address (comma separated list)</label></td>
|
<td><label>Filter Address (comma separated list)</label></td>
|
||||||
<td><input type="text" class="form-control" id="device-requester-addr"
|
<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"
|
<td><input id="bridge-settings-upnpsenddelay" class="form-control" type="number"
|
||||||
ng-model="bridge.settings.upnpsenddelay" min="100" max="15000"></td>
|
ng-model="bridge.settings.upnpsenddelay" min="100" max="15000"></td>
|
||||||
</tr>
|
</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>
|
<tr>
|
||||||
<td>ID Seed (start numbering from this value)</td>
|
<td>ID Seed (start numbering from this value)</td>
|
||||||
<td><input id="bridge-settings-seedid" class="form-control" type="number"
|
<td><input id="bridge-settings-seedid" class="form-control" type="number"
|
||||||
|
|||||||
Reference in New Issue
Block a user