Skip to content

Commit

Permalink
Merge pull request #914 from bwssytems/NewFeaturesfor5.1
Browse files Browse the repository at this point in the history
New featuresfor5.1

Fixes #896 Incorrect examples in documentation for color. enhancement

Fixes #910 Order of data description fields seems to be hard-coded bug question

Fixes #891 Color replacement control in MQTT bug

Fixes #886 Exception every minute after linking harmony hub enhancement question

Fixes #879 Intensity.math(x).hex does not deliver hex values bug question

Fixes #809 Scanning Fibaro devices or scenes not working with 5.0.0 Informational bug

Fixes #236 Support for Broadlink Rm2/pro enhancement question

Fixes #874 Error on calling URL - Nanoleaf Aurora bug question

Fixes #808 In 5.0.0, colour UDP URLs not issued to milight hub enhancement question

Fixes #846 [5.1.0] Harmony commands not being split into on/dim enhancement question

Fixes #851 non-dimmable device enhancement question

Fixes #853 Turn Logging off enhancement question

Fixes #850 HB[5.1.0] Fibaro HomeCenter2: Devices "Build Item" not working bug question

Fixes #860 Discovery issues from Echo Dot 2nd Gen - potential fix enhancement

Fixes #675 FHEM home automation integration enhancement question

Fixes #516 OpenHAB integration enhancement
  • Loading branch information
bwssytems authored Mar 8, 2018
2 parents dc49de4 + 82788f1 commit 5c1f1f5
Show file tree
Hide file tree
Showing 114 changed files with 4,938 additions and 986 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ data
/.classpath

sftp-config\.json
/bin/
51 changes: 34 additions & 17 deletions README.md

Large diffs are not rendered by default.

19 changes: 12 additions & 7 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.bwssystems.HABridge</groupId>
<artifactId>ha-bridge</artifactId>
<version>5.1.0</version>
<version>5.2.0</version>
<packaging>jar</packaging>

<name>HA Bridge</name>
Expand Down Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>com.github.bwssytems</groupId>
<artifactId>harmony-java-client</artifactId>
<version>1.1.5</version>
<version>master-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
Expand Down Expand Up @@ -84,12 +84,12 @@
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<version>1.7.24</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.1.5</version>
<version>1.2.1</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand All @@ -104,12 +104,12 @@
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>4.0-beta4</version>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.igniterealtime.smack</groupId>
<artifactId>smack-core</artifactId>
<version>4.0.7</version>
<version>4.2.0</version>
</dependency>
<dependency>
<groupId>org.eclipse.paho</groupId>
Expand All @@ -119,13 +119,18 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<version>4.12</version>
</dependency>
<dependency>
<groupId>com.github.bwssytems</groupId>
<artifactId>lifx-sdk-java</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>com.github.bwssytems</groupId>
<artifactId>broadlink-java-api</artifactId>
<version>1.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/com/bwssystems/HABridge/BridgeSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public void buildSettings() {
theBridgeSettings.setDomoticzconfigured(theBridgeSettings.isValidDomoticz());
theBridgeSettings.setSomfyconfigured(theBridgeSettings.isValidSomfy());
theBridgeSettings.setHomeWizardConfigured(theBridgeSettings.isValidHomeWizard());
theBridgeSettings.setOpenhabconfigured(theBridgeSettings.isValidOpenhab());
theBridgeSettings.setFhemconfigured(theBridgeSettings.isValidFhem());
// Lifx is either configured or not, so it does not need an update.
if(serverPortOverride != null)
theBridgeSettings.setServerPort(serverPortOverride);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.Map;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;

//import com.bwssystems.HABridge.api.NameValue;
import com.bwssystems.HABridge.api.hue.HueConstants;
import com.bwssystems.HABridge.api.hue.WhitelistEntry;

Expand Down Expand Up @@ -87,6 +87,9 @@ public class BridgeSettingsDescriptor {
@SerializedName("somfyaddress")
@Expose
private IpList somfyaddress;
@SerializedName("openhabaddress")
@Expose
private IpList openhabaddress;
@SerializedName("hubversion")
@Expose
private String hubversion;
Expand All @@ -99,6 +102,21 @@ public class BridgeSettingsDescriptor {
@SerializedName("homewizardaddress")
@Expose
private IpList homewizardaddress;
@SerializedName("upnpsenddelay")
@Expose
private Integer upnpsenddelay;
@SerializedName("fhemaddress")
@Expose
private IpList fhemaddress;
@SerializedName("lifxconfigured")
@Expose
private boolean lifxconfigured;
@SerializedName("broadlinkconfigured")
@Expose
private boolean broadlinkconfigured;
// @SerializedName("activeloggers")
// @Expose
// private List<NameValue> activeloggers;

private boolean settingsChanged;
private boolean veraconfigured;
Expand All @@ -111,8 +129,9 @@ public class BridgeSettingsDescriptor {
private boolean hassconfigured;
private boolean domoticzconfigured;
private boolean somfyconfigured;
private boolean lifxconfigured;
private boolean homewizardconfigured;
private boolean openhabconfigured;
private boolean fhemconfigured;

// Deprecated settings
private String haltoken;
Expand All @@ -136,13 +155,17 @@ public BridgeSettingsDescriptor() {
this.domoticzconfigured = false;
this.homewizardconfigured = false;
this.lifxconfigured = false;
this.openhabconfigured = false;
this.farenheit = true;
this.securityData = null;
this.settingsChanged = false;
this.myechourl = "alexa.amazon.com/spa/index.html#cards";
this.webaddress = "0.0.0.0";
this.hubversion = HueConstants.HUB_VERSION;
this.hubmac = null;
// this.activeloggers = null;
this.upnpsenddelay = Configuration.UPNP_SEND_DELAY;
this.broadlinkconfigured = false;
}
public String getUpnpConfigAddress() {
return upnpconfigaddress;
Expand Down Expand Up @@ -384,6 +407,18 @@ public boolean isHassconfigured() {
public void setHassconfigured(boolean hassconfigured) {
this.hassconfigured = hassconfigured;
}
public IpList getOpenhabaddress() {
return openhabaddress;
}
public void setOpenhabaddress(IpList openhabaddress) {
this.openhabaddress = openhabaddress;
}
public boolean isOpenhabconfigured() {
return openhabconfigured;
}
public void setOpenhabconfigured(boolean openhabconfigured) {
this.openhabconfigured = openhabconfigured;
}
public String getHubversion() {
return hubversion;
}
Expand Down Expand Up @@ -420,6 +455,36 @@ public String getSecurityData() {
public void setSecurityData(String securityData) {
this.securityData = securityData;
}
public Integer getUpnpsenddelay() {
return upnpsenddelay;
}
public void setUpnpsenddelay(Integer upnpsenddelay) {
this.upnpsenddelay = upnpsenddelay;
}
public IpList getFhemaddress() {
return fhemaddress;
}
public void setFhemaddress(IpList fhemaddress) {
this.fhemaddress = fhemaddress;
}
public boolean isFhemconfigured() {
return fhemconfigured;
}
public void setFhemconfigured(boolean fhemconfigured) {
this.fhemconfigured = fhemconfigured;
}
// public List<NameValue> getActiveloggers() {
// return activeloggers;
// }
// public void setActiveloggers(List<NameValue> activeloggers) {
// this.activeloggers = activeloggers;
// }
public boolean isBroadlinkconfigured() {
return broadlinkconfigured;
}
public void setBroadlinkconfigured(boolean broadlinkconfigured) {
this.broadlinkconfigured = broadlinkconfigured;
}
public Boolean isValidVera() {
if(this.getVeraAddress() == null || this.getVeraAddress().getDevices().size() <= 0)
return false;
Expand Down Expand Up @@ -527,4 +592,27 @@ public Boolean isValidHomeWizard() {

return true;
}
public Boolean isValidOpenhab() {
if(this.getOpenhabaddress() == null || this.getOpenhabaddress().getDevices().size() <= 0)
return false;

List<NamedIP> devicesList = this.getOpenhabaddress().getDevices();
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
return false;

return true;
}
public Boolean isValidFhem() {
if(this.getFhemaddress() == null || this.getFhemaddress().getDevices().size() <= 0)
return false;

List<NamedIP> devicesList = this.getFhemaddress().getDevices();
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
return false;

return true;
}
public Boolean isValidBroadlink() {
return this.isBroadlinkconfigured();
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/bwssystems/HABridge/Configuration.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ public class Configuration {
public static final String CONFIG_FILE = "data/habridge.config";
public static final int NUMBER_OF_LOG_MESSAGES = 512;
public static final long UPNP_NOTIFY_TIMEOUT = 20000;
public static final int UPNP_SEND_DELAY = 650;
public static final int BROADLINK_DISCOVER_PORT = 40000;
public static final int BROADLINK_DISCONVER_TIMEOUT = 5000;
}
7 changes: 6 additions & 1 deletion src/main/java/com/bwssystems/HABridge/DeviceMapTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ public class DeviceMapTypes {
public final static String[] DOMOTICZ_DEVICE = { "domoticzDevice", "Domoticz Device"};
public final static String[] SOMFY_DEVICE = { "somfyDevice", "Somfy Device"};
public final static String[] LIFX_DEVICE = { "lifxDevice", "LIFX Device"};
public final static String[] OPENHAB_DEVICE = { "openhabDevice", "OpenHAB Device"};
public final static String[] FHEM_DEVICE = { "fhemDevice", "FHEM Device"};
public final static String[] BROADLINK_DEVICE = { "broadlinkDevice", "Broadlink Device"};

public final static int typeIndex = 0;
public final static int displayIndex = 1;
Expand All @@ -56,14 +59,16 @@ public DeviceMapTypes() {
deviceMapTypes.add(MQTT_MESSAGE);
deviceMapTypes.add(NEST_HOMEAWAY);
deviceMapTypes.add(NEST_THERMO_SET);
deviceMapTypes.add(SOMFY_DEVICE);
deviceMapTypes.add(TCP_DEVICE);
deviceMapTypes.add(UDP_DEVICE);
deviceMapTypes.add(VERA_DEVICE);
deviceMapTypes.add(VERA_SCENE);
deviceMapTypes.add(FIBARO_DEVICE);
deviceMapTypes.add(FIBARO_SCENE);
deviceMapTypes.add(SOMFY_DEVICE);
deviceMapTypes.add(OPENHAB_DEVICE);
deviceMapTypes.add(FHEM_DEVICE);
deviceMapTypes.add(BROADLINK_DEVICE);
}
public static int getTypeIndex() {
return typeIndex;
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/com/bwssystems/HABridge/HABridge.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,17 @@ public static void main(String[] args) {
@SuppressWarnings("unused")
HttpClientPool thePool;

log.info("HA Bridge startup sequence...");
theVersion = new Version();
// Singleton initialization
thePool = new HttpClientPool();

log.info("HA Bridge (v" + theVersion.getVersion() + ") starting....");

bridgeSettings = new BridgeSettings();
// sparkjava config directive to set html static file location for Jetty
while(!bridgeSettings.getBridgeControl().isStop()) {
bridgeSettings.buildSettings();
bridgeSettings.getBridgeSecurity().removeTestUsers();
log.info("HA Bridge initializing....");
log.info("HA Bridge (v" + theVersion.getVersion() + ") initializing....");
// sparkjava config directive to set ip address for the web server to listen on
ipAddress(bridgeSettings.getBridgeSettingsDescriptor().getWebaddress());
// sparkjava config directive to set port for the web server to listen on
Expand Down Expand Up @@ -91,7 +90,7 @@ public static void main(String[] args) {
bridgeSettings.getBridgeSettingsDescriptor().isUseupnpiface() + " on web server: " +
bridgeSettings.getBridgeSettingsDescriptor().getWebaddress() + ":" + bridgeSettings.getBridgeSettingsDescriptor().getServerPort());
// setup the class to handle the upnp response rest api
theSettingResponder = new UpnpSettingsResource(bridgeSettings.getBridgeSettingsDescriptor());
theSettingResponder = new UpnpSettingsResource(bridgeSettings);
theSettingResponder.setupServer();

// start the upnp ssdp discovery listener
Expand Down Expand Up @@ -127,12 +126,12 @@ public static void main(String[] args) {
bridgeSettings.updateConfigFile();
try {
HttpClientPool.shutdown();
thePool = null;
} catch (InterruptedException e) {
log.warn("Error shutting down http pool: " + e.getMessage());;
} catch (IOException e) {
log.warn("Error shutting down http pool: " + e.getMessage());;
}
thePool = null;
log.info("HA Bridge (v" + theVersion.getVersion() + ") exiting....");
System.exit(0);
}
Expand Down
33 changes: 24 additions & 9 deletions src/main/java/com/bwssystems/HABridge/HomeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@

import com.bwssystems.HABridge.devicemanagmeent.ResourceHandler;
import com.bwssystems.HABridge.plugins.NestBridge.NestHome;
import com.bwssystems.HABridge.plugins.broadlink.BroadlinkHome;
import com.bwssystems.HABridge.plugins.domoticz.DomoticzHome;
import com.bwssystems.HABridge.plugins.exec.CommandHome;
import com.bwssystems.HABridge.plugins.fhem.FHEMHome;
import com.bwssystems.HABridge.plugins.hal.HalHome;
import com.bwssystems.HABridge.plugins.harmony.HarmonyHome;
import com.bwssystems.HABridge.plugins.hass.HassHome;
Expand All @@ -19,6 +21,7 @@
import com.bwssystems.HABridge.plugins.hue.HueHome;
import com.bwssystems.HABridge.plugins.lifx.LifxHome;
import com.bwssystems.HABridge.plugins.mqtt.MQTTHome;
import com.bwssystems.HABridge.plugins.openhab.OpenHABHome;
import com.bwssystems.HABridge.plugins.somfy.SomfyHome;
import com.bwssystems.HABridge.plugins.tcp.TCPHome;
import com.bwssystems.HABridge.plugins.udp.UDPHome;
Expand All @@ -39,6 +42,14 @@ public HomeManager() {
// factory method
public void buildHomes(BridgeSettings bridgeSettings, UDPDatagramSender aUdpDatagramSender) {
Home aHome = null;
//setup the http handler Home - This must be the first home created for devMode
aHome = new HTTPHome(bridgeSettings);
homeList.put(DeviceMapTypes.HTTP_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.FIBARO_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.FIBARO_SCENE[DeviceMapTypes.typeIndex], aHome);
//setup the harmony connection if available
aHome = new HarmonyHome(bridgeSettings);
resourceList.put(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex], aHome);
Expand Down Expand Up @@ -77,14 +88,6 @@ public void buildHomes(BridgeSettings bridgeSettings, UDPDatagramSender aUdpData
aHome = new CommandHome(bridgeSettings);
homeList.put(DeviceMapTypes.EXEC_DEVICE_COMPAT[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.CMD_DEVICE[DeviceMapTypes.typeIndex], aHome);
//setup the http handler Home
aHome = new HTTPHome(bridgeSettings);
homeList.put(DeviceMapTypes.HTTP_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.FIBARO_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.FIBARO_SCENE[DeviceMapTypes.typeIndex], aHome);
//setup the tcp handler Home
aHome = new TCPHome(bridgeSettings);
homeList.put(DeviceMapTypes.TCP_DEVICE[DeviceMapTypes.typeIndex], aHome);
Expand All @@ -105,14 +108,26 @@ public void buildHomes(BridgeSettings bridgeSettings, UDPDatagramSender aUdpData
aHome = new DomoticzHome(bridgeSettings);
homeList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
resourceList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
//setup the Somfy configuration if available
//setup the Somfy configuration if availableOPENHAB
aHome = new SomfyHome(bridgeSettings);
homeList.put(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex], aHome);
resourceList.put(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex], aHome);
//setup the Lifx configuration if available
aHome = new LifxHome(bridgeSettings);
resourceList.put(DeviceMapTypes.LIFX_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.LIFX_DEVICE[DeviceMapTypes.typeIndex], aHome);
//setup the OpenHAB configuration if available
aHome = new OpenHABHome(bridgeSettings);
resourceList.put(DeviceMapTypes.OPENHAB_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.OPENHAB_DEVICE[DeviceMapTypes.typeIndex], aHome);
//setup the OpenHAB configuration if available
aHome = new FHEMHome(bridgeSettings);
resourceList.put(DeviceMapTypes.FHEM_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.FHEM_DEVICE[DeviceMapTypes.typeIndex], aHome);
//setup the Broadlink configuration if available
aHome = new BroadlinkHome(bridgeSettings);
resourceList.put(DeviceMapTypes.BROADLINK_DEVICE[DeviceMapTypes.typeIndex], aHome);
homeList.put(DeviceMapTypes.BROADLINK_DEVICE[DeviceMapTypes.typeIndex], aHome);
}

public Home findHome(String type) {
Expand Down
Loading

0 comments on commit 5c1f1f5

Please sign in to comment.