Skip to content

Commit dc49de4

Browse files
authored
Merge pull request #843 from bwssytems/FixesForV5
Fixes for v5 Fixes #842 Show and manage linked devices to the ha-bridge enhancement Fixes #797 harmony hub not pairing bug question Fixes #817 Log full of error: The requested route [/(null)] has not been mapped in Spark bug question Fixes #821 Support HEX-Formatted RGB Values for color enhancement question Fixes #837 -Dexec.garden breaks script execution with trailing slash enhancement question Fixes #800 5.0.0 no longer connects to the vera enhancement question Fixes #801 Fibaro scenes are not created bug question Fixes #805 Fibaro HomeCenter2: Devices "Build Item" broken bug question Fixes #841 add support for timestamp http URL variable Fixes #836 Add support for cheap HomeWizard SmartPlugs (Smartwares Smarthome Controller)
2 parents 71c4447 + 9d07fac commit dc49de4

38 files changed

+1171
-34
lines changed

README.md

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ THe Harmony Hub Path looks like this:
3939

4040
**FAQ: Please look here for the current FAQs! https://github.com/bwssytems/ha-bridge/wiki/HA-Bridge-FAQs**
4141

42-
In the cases of systems that require authorization and/or have APIs that cannot be handled in the current method, a module may need to be built. The Harmony Hub is such a module and so is the Nest module. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge, Nest, Somfy Tahoma and the ability to proxy all of your real Hue bridges behind this bridge.
42+
In the cases of systems that require authorization and/or have APIs that cannot be handled in the current method, a module may need to be built. The Harmony Hub is such a module and so is the Nest module. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge, Nest, Somfy Tahoma, Home Assistant, Domoticz, HAL, Fibaro, HomeWizard and the ability to proxy all of your real Hue bridges behind this bridge.
4343

4444
Alternatively the Bridge supports custom calls as well using http/https/udp and tcp such as the LimitlessLED/MiLight bulbs using the UDP protocol. Binary data is supported with UDP/TCP.
4545

@@ -61,17 +61,17 @@ ATTENTION: This requires JDK 1.8 to run
6161
ATTENTION: Due to port 80 being the default, Linux restricts this to super user. Use the instructions below.
6262

6363
```
64-
java -jar ha-bridge-5.0.0.jar
64+
java -jar ha-bridge-5.1.0.jar
6565
```
6666
### Automation on Linux systems
6767
To have this configured and running automatically there are a few resources to use. One is using Docker and a docker container has been built for this and can be gotten here: https://github.com/aptalca/docker-ha-bridge
6868

69-
Create the directory and make sure that ha-bridge-5.0.0.jar is in your /home/pi/habridge directory.
69+
Create the directory and make sure that ha-bridge-5.1.0.jar is in your /home/pi/habridge directory.
7070
```
7171
pi@raspberrypi:~ $ mkdir habridge
7272
pi@raspberrypi:~ $ cd habridge
7373
74-
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v5.0.0/ha-bridge-5.0.0.jar
74+
pi@raspberrypi:~/habridge $ wget https://github.com/bwssytems/ha-bridge/releases/download/v5.1.0/ha-bridge-5.1.0.jar
7575
```
7676

7777
#### System Control Setup on a pi (preferred)
@@ -92,7 +92,7 @@ After=network.target
9292
[Service]
9393
Type=simple
9494
WorkingDirectory=/home/pi/habridge
95-
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-5.0.0.jar
95+
ExecStart=/usr/bin/java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-5.1.0.jar
9696
9797
[Install]
9898
WantedBy=multi-user.target
@@ -127,7 +127,7 @@ Then cut and past this, modify any locations that are not correct
127127
```
128128
cd /home/pi/habridge
129129
rm /home/pi/habridge/habridge-log.txt
130-
nohup java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-5.0.0.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
130+
nohup java -jar -Dconfig.file=/home/pi/habridge/data/habridge.config /home/pi/habridge/ha-bridge-5.1.0.jar > /home/pi/habridge/habridge-log.txt 2>&1 &
131131
132132
chmod 777 /home/pi/habridge/habridge-log.txt
133133
```
@@ -257,6 +257,8 @@ The default location for the db to contain the devices as they are added is "dat
257257
The server defaults to the first available address on the host if this is not given. This default may NOT be the correct IP that is your public IP for your host on the network. It is best to set this parameter to not have discovery issues. Replace this value with the server ipv4 address you would like to use as the address that any upnp device will call after discovery.
258258
#### Use UPNP Address Interface
259259
The server tries to bind to all interfaces to respond to UPNP request. Setting this to `true` will make the binding to the interface that has the `UPNP IP Address`. The default is to be all interfaces which is set as false.
260+
#### Use Rooms for Alexa
261+
This setting controls rooms for Alexa. If it is set to true, any device ID abaove 10000 is treated as a special group. The default is set as false.
260262
#### Web Server IP Address
261263
The server defaults to all interfaces on the machine (0.0.0.0). Replace this value with the server ipv4 address you would like to use as the address that will bind to a specific ip address on an interface if you would like. This is only necessary if you want to isolate how access is handled to the web UI.
262264
#### Web Server Port
@@ -358,7 +360,7 @@ The Add/Edit tab will show you the fields to fill in for the above in a form, wh
358360
The format of the item can be the default HTTP request which executes the URLs formatted as `http://<your stuff here>` as a GET. Other options to this are to select the HTTP Verb and add the data type and add a body that is passed with the request. Secure https is supported as well, just use `https://<your secure call here>`. When using POST and PUT, you have the ability to specify the body that will be sent with the request as well as the application type for the http call.
359361

360362
The valid device types are: "custom", "veraDevice", "veraScene", "harmonyActivity", "harmonyButton", "nestHomeAway", "nestThermoSet", "hueDevice", "halDevice",
361-
"halButton", "halHome", "halThermoSet", "mqttMessage", "cmdDevice", "hassDevice", "tcpDevice", "udpDevice", "httpDevice", "domoticzDevice", "somfyDevice"
363+
"halButton", "halHome", "halThermoSet", "mqttMessage", "cmdDevice", "hassDevice", "homewizardDevice", "tcpDevice", "udpDevice", "httpDevice", "domoticzDevice", "somfyDevice"
362364

363365
Filter Ip example:
364366
```
@@ -378,7 +380,7 @@ Headers can be added as well using a Json construct [{"name":"header type name",
378380

379381
Another option that is detected by the bridge is to use UDP or TCP direct calls such as `udp://<ip_address>:<port>/<your stuff here>` to send a UDP request. TCP calls are handled the same way as `tcp://<ip_address>:<port>/<your stuff here>`. If your data for the UDP or TCP request is formatted as "0x00F009B9" lexical hex format, the bridge will convert the data into a binary stream to send.
380382

381-
You can also use the value replacement constructs within these statements. Such as using the expressions "${time.format(Java time format string)}" for inserting a date/time stamp, ${intensity.percent} or ${intensity.percent.hex} for 0-100 or ${intensity.decimal_percent} for 0.00-1.00 or ${intensity.byte} or ${intensity.byte.hex} for 0-255 for straight pass through of the value or items that require special calculated values using ${intensity.math()} i.e. "${intensity.math(X/4)}" or "${intensity.math(X/4).hex}". See Value Passing Controls Below.
383+
You can also use the value replacement constructs within these statements. Such as using the expressions "${time.format(Java time format string)}" for inserting a date/time stamp, "${time.millis}" for inserting a pure timestamp (milliseconds from 1.1.1970), ${intensity.percent} or ${intensity.percent.hex} for 0-100 or ${intensity.decimal_percent} for 0.00-1.00 or ${intensity.byte} or ${intensity.byte.hex} for 0-255 for straight pass through of the value or items that require special calculated values using ${intensity.math()} i.e. "${intensity.math(X/4)}" or "${intensity.math(X/4).hex}". See Value Passing Controls Below.
382384
Examples:
383385
```
384386
@@ -432,7 +434,12 @@ There are multiple replacement constructs available to be put into any of the ca
432434

433435
You can control items that require special calculated values using ${intensity.math(<your expression using "X" as the value to operate on>)} i.e. "${intensity.math(X/4)}".
434436

435-
For the items that want to have a date time put into the message, utilize ${time.format(yyyy-MM-ddTHH:mm:ssXXX)} where "yyyy-MM-ddTHH:mm:ssXXX" can be any format from the Java SimpleDateFormat documented here: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html
437+
For the items that want to have a date time put into the message, utilize ${time.format(yyyy-MM-ddTHH:mm:ssXXX)} where "yyyy-MM-ddTHH:mm:ssXXX" can be any format from the Java SimpleDateFormat documented here: https://docs.oracle.com/javase/8/docs/api/java/text/SimpleDateFormat.html. Also, there is a $(time.millis) which will put the millis timestamp where this replacement control is located.
438+
439+
Color has been added as a replacement control and the available values are $(color.r), $(color.g), $(color.b) which are representations of each color as 0 - 255. There are hex equivalents as well as $(color.rx), $(color.gx), $(color.bx) and $(color.rgbx) as 2 place hex representations except for rgbx which is a six place hex representation.
440+
441+
Special handling for milights is included and is handled by $(color.milight:x). The usage for that is as follows: udp://ip:port/0x${color.milight:x} where x is a number between 0 and 4 (0 all groups, 1-4 specific group). The group is necessary in case the color turns out to be white. The correct group on must of course be sent before that udp packet.
442+
Note that milight can only use 255 colors and white is handled completely separate for the rgbw strips, so setting temperature via ct with milight does something but not really the desired result
436443

437444
Also, device data can be inserted into your payloads by the use of "${device.name}", "${device.id}", "${device.uniqueid}", "${device.targetDevice}", "${device.mapId}", "${device.mapType}", "${device.deviceType}", "${device.requesterAddress}", "${device.description}" and "${device.comments}". These work just like the dimming value replacements.
438445
e.g.

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.bwssystems.HABridge</groupId>
77
<artifactId>ha-bridge</artifactId>
8-
<version>5.0.0</version>
8+
<version>5.1.0</version>
99
<packaging>jar</packaging>
1010

1111
<name>HA Bridge</name>

src/main/java/com/bwssystems/HABridge/BridgeSecurity.java

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,12 @@ public Map<String, WhitelistEntry> getWhitelist() {
205205
return securityDescriptor.getWhitelist();
206206
}
207207

208+
public void setWhitelist(Map<String, WhitelistEntry> aWhitelist) {
209+
securityDescriptor.setWhitelist(aWhitelist);
210+
settingsChanged = true;
211+
return;
212+
}
213+
208214
public HueError[] validateWhitelistUser(String aUser, String userDescription, boolean strict) {
209215
String validUser = null;
210216
boolean found = false;
@@ -238,6 +244,31 @@ public HueError[] validateWhitelistUser(String aUser, String userDescription, bo
238244
return null;
239245
}
240246

247+
public String findWhitelistUserByDeviceType(String aDeviceType) {
248+
String validUser = null;
249+
boolean found = false;
250+
WhitelistEntry anEntry = null;
251+
if (aDeviceType != null) {
252+
if (securityDescriptor.getWhitelist() != null) {
253+
Set<String> theUserIds = securityDescriptor.getWhitelist().keySet();
254+
Iterator<String> userIterator = theUserIds.iterator();
255+
while (!found && userIterator.hasNext()) {
256+
validUser = userIterator.next();
257+
anEntry = securityDescriptor.getWhitelist().get(validUser);
258+
if (anEntry.getName().equals(aDeviceType)) {
259+
found = true;
260+
log.debug("findWhitelistUserByDeviceType: found a user <" + validUser + "> for device type <" + aDeviceType + ">");
261+
}
262+
}
263+
}
264+
}
265+
266+
if(!found)
267+
validUser = null;
268+
269+
return validUser;
270+
}
271+
241272
private void newWhitelistUser(String aUser, String userDescription) {
242273
if (securityDescriptor.getWhitelist() == null) {
243274
securityDescriptor.setWhitelist(new HashMap<>());
@@ -250,8 +281,14 @@ private void newWhitelistUser(String aUser, String userDescription) {
250281
}
251282

252283
public String createWhitelistUser(String userDescription) {
253-
String aUser = getNewUserID();
254-
newWhitelistUser(aUser, userDescription);
284+
String aUser = null;
285+
String theEntry = findWhitelistUserByDeviceType(userDescription);
286+
if(theEntry == null) {
287+
aUser = getNewUserID();
288+
newWhitelistUser(aUser, userDescription);
289+
} else {
290+
aUser = theEntry;
291+
}
255292
return aUser;
256293
}
257294

src/main/java/com/bwssystems/HABridge/BridgeSettings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ public void buildSettings() {
209209
theBridgeSettings.setHassconfigured(theBridgeSettings.isValidHass());
210210
theBridgeSettings.setDomoticzconfigured(theBridgeSettings.isValidDomoticz());
211211
theBridgeSettings.setSomfyconfigured(theBridgeSettings.isValidSomfy());
212+
theBridgeSettings.setHomeWizardConfigured(theBridgeSettings.isValidHomeWizard());
212213
// Lifx is either configured or not, so it does not need an update.
213214
if(serverPortOverride != null)
214215
theBridgeSettings.setServerPort(serverPortOverride);

src/main/java/com/bwssystems/HABridge/BridgeSettingsDescriptor.java

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ public class BridgeSettingsDescriptor {
1515
@SerializedName("useupnpiface")
1616
@Expose
1717
private boolean useupnpiface;
18+
@SerializedName("userooms")
19+
@Expose
20+
private boolean userooms;
1821
@SerializedName("serverport")
1922
@Expose
2023
private Integer serverport;
@@ -93,7 +96,9 @@ public class BridgeSettingsDescriptor {
9396
@SerializedName("securityData")
9497
@Expose
9598
private String securityData;
96-
99+
@SerializedName("homewizardaddress")
100+
@Expose
101+
private IpList homewizardaddress;
97102

98103
private boolean settingsChanged;
99104
private boolean veraconfigured;
@@ -107,7 +112,8 @@ public class BridgeSettingsDescriptor {
107112
private boolean domoticzconfigured;
108113
private boolean somfyconfigured;
109114
private boolean lifxconfigured;
110-
115+
private boolean homewizardconfigured;
116+
111117
// Deprecated settings
112118
private String haltoken;
113119
private boolean upnpstrict;
@@ -116,6 +122,7 @@ public BridgeSettingsDescriptor() {
116122
super();
117123
this.upnpstrict = true;
118124
this.useupnpiface = false;
125+
this.userooms = false;
119126
this.traceupnp = false;
120127
this.nestconfigured = false;
121128
this.veraconfigured = false;
@@ -127,7 +134,7 @@ public BridgeSettingsDescriptor() {
127134
this.mqttconfigured = false;
128135
this.hassconfigured = false;
129136
this.domoticzconfigured = false;
130-
this.somfyconfigured = false;
137+
this.homewizardconfigured = false;
131138
this.lifxconfigured = false;
132139
this.farenheit = true;
133140
this.securityData = null;
@@ -149,6 +156,12 @@ public boolean isUseupnpiface() {
149156
public void setUseupnpiface(boolean useupnpiface) {
150157
this.useupnpiface = useupnpiface;
151158
}
159+
public boolean isUserooms() {
160+
return userooms;
161+
}
162+
public void setUserooms(boolean userooms) {
163+
this.userooms = userooms;
164+
}
152165
public Integer getServerPort() {
153166
return serverport;
154167
}
@@ -188,6 +201,9 @@ public IpList getFibaroAddress() {
188201
public IpList getSomfyAddress() {
189202
return somfyaddress;
190203
}
204+
public IpList getHomeWizardAddress() {
205+
return homewizardaddress;
206+
}
191207
public void setVeraAddress(IpList veraAddress) {
192208
this.veraaddress = veraAddress;
193209
}
@@ -197,6 +213,9 @@ public void setFibaroAddress(IpList fibaroAddress) {
197213
public void setSomfyAddress(IpList somfyAddress) {
198214
this.somfyaddress = somfyAddress;
199215
}
216+
public void setHomeWizardAddress(IpList homewizardaddress) {
217+
this.homewizardaddress = homewizardaddress;
218+
}
200219
public IpList getHarmonyAddress() {
201220
return harmonyaddress;
202221
}
@@ -236,6 +255,9 @@ public boolean isFibaroconfigured() {
236255
public boolean isSomfyconfigured() {
237256
return somfyconfigured;
238257
}
258+
public boolean isHomeWizardConfigured() {
259+
return homewizardconfigured;
260+
}
239261
public void setVeraconfigured(boolean veraconfigured) {
240262
this.veraconfigured = veraconfigured;
241263
}
@@ -245,6 +267,9 @@ public void setFibaroconfigured(boolean fibaroconfigured) {
245267
public void setSomfyconfigured(boolean somfyconfigured) {
246268
this.somfyconfigured = somfyconfigured;
247269
}
270+
public void setHomeWizardConfigured(boolean homewizardconfigured) {
271+
this.homewizardconfigured = homewizardconfigured;
272+
}
248273
public boolean isHarmonyconfigured() {
249274
return harmonyconfigured;
250275
}
@@ -492,4 +517,14 @@ public void updateHue(NamedIP aHue) {
492517
this.setSettingsChanged(true);
493518
}
494519
}
520+
public Boolean isValidHomeWizard() {
521+
if(this.getHomeWizardAddress() == null || this.getHomeWizardAddress().getDevices().size() <= 0)
522+
return false;
523+
524+
List<NamedIP> devicesList = this.getHomeWizardAddress().getDevices();
525+
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
526+
return false;
527+
528+
return true;
529+
}
495530
}

src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public class DeviceMapTypes {
2222
public final static String[] EXEC_DEVICE_COMPAT = { "exec", "Execute Script/Program"};
2323
public final static String[] CMD_DEVICE = { "cmdDevice", "Execute Command/Script/Program"};
2424
public final static String[] HASS_DEVICE = { "hassDevice", "HomeAssistant Device"};
25+
public final static String[] HOMEWIZARD_DEVICE = { "homewizardDevice", "HomeWizard Device"};
2526
public final static String[] TCP_DEVICE = { "tcpDevice", "TCP Device"};
2627
public final static String[] TCP_DEVICE_COMPAT = { "TCP", "TCP Device"};
2728
public final static String[] UDP_DEVICE = { "udpDevice", "UDP Device"};
@@ -48,6 +49,7 @@ public DeviceMapTypes() {
4849
deviceMapTypes.add(HARMONY_ACTIVITY);
4950
deviceMapTypes.add(HARMONY_BUTTON);
5051
deviceMapTypes.add(HASS_DEVICE);
52+
deviceMapTypes.add(HOMEWIZARD_DEVICE);
5153
deviceMapTypes.add(HTTP_DEVICE);
5254
deviceMapTypes.add(HUE_DEVICE);
5355
deviceMapTypes.add(LIFX_DEVICE);

src/main/java/com/bwssystems/HABridge/HomeManager.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import com.bwssystems.HABridge.plugins.hal.HalHome;
1515
import com.bwssystems.HABridge.plugins.harmony.HarmonyHome;
1616
import com.bwssystems.HABridge.plugins.hass.HassHome;
17+
import com.bwssystems.HABridge.plugins.homewizard.HomeWizardHome;
1718
import com.bwssystems.HABridge.plugins.http.HTTPHome;
1819
import com.bwssystems.HABridge.plugins.hue.HueHome;
1920
import com.bwssystems.HABridge.plugins.lifx.LifxHome;
@@ -68,6 +69,10 @@ public void buildHomes(BridgeSettings bridgeSettings, UDPDatagramSender aUdpData
6869
aHome = new HassHome(bridgeSettings);
6970
resourceList.put(DeviceMapTypes.HASS_DEVICE[DeviceMapTypes.typeIndex], aHome);
7071
homeList.put(DeviceMapTypes.HASS_DEVICE[DeviceMapTypes.typeIndex], aHome);
72+
// Setup the HomeWizard configuration if available
73+
aHome = new HomeWizardHome(bridgeSettings);
74+
resourceList.put(DeviceMapTypes.HOMEWIZARD_DEVICE[DeviceMapTypes.typeIndex], aHome);
75+
homeList.put(DeviceMapTypes.HOMEWIZARD_DEVICE[DeviceMapTypes.typeIndex], aHome);
7176
//setup the command execution Home
7277
aHome = new CommandHome(bridgeSettings);
7378
homeList.put(DeviceMapTypes.EXEC_DEVICE_COMPAT[DeviceMapTypes.typeIndex], aHome);
@@ -96,7 +101,7 @@ public void buildHomes(BridgeSettings bridgeSettings, UDPDatagramSender aUdpData
96101
aHome = new FibaroHome(bridgeSettings);
97102
resourceList.put(DeviceMapTypes.FIBARO_DEVICE[DeviceMapTypes.typeIndex], aHome);
98103
resourceList.put(DeviceMapTypes.FIBARO_SCENE[DeviceMapTypes.typeIndex], aHome);
99-
//setup the Domoticz configuration if available
104+
//setup the Domoticz configuration if available
100105
aHome = new DomoticzHome(bridgeSettings);
101106
homeList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
102107
resourceList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);

0 commit comments

Comments
 (0)