mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Finalized handling for barmony. Added a version call for use in api.
Updated version handling in the pom.xml and code. Removed vtwocompatibility as it should not be used.
This commit is contained in:
11
README.md
11
README.md
@@ -1,5 +1,5 @@
|
||||
# ha-bridge
|
||||
Emulates Philips Hue api to other home automation gateways such as an Amazon Echo. The Bridge has helpers to build devices for the gateway for the Vera, Vera Lite or Vera Edge. Alternatively the Bridge supports custom calls as well. The Bridge handles basic commands such as "On", "Off" and "brightness" commands of the hue protocol.
|
||||
Emulates Philips Hue api to other home automation gateways such as an Amazon Echo. The Bridge has helpers to build devices for the gateway for the Logitech Harmony Hub, Vera, Vera Lite or Vera Edge. Alternatively the Bridge supports custom calls as well. The Bridge handles basic commands such as "On", "Off" and "brightness" commands of the hue protocol.
|
||||
## Build
|
||||
To customize and build it yourself, build a new jar with maven:
|
||||
```
|
||||
@@ -9,7 +9,7 @@ Otherwise, downloads are available at https://github.com/bwssytems/ha-bridge/rel
|
||||
## Run
|
||||
Then locate the jar and start the server with:
|
||||
```
|
||||
java -jar -Dvera.address=X.Y.Z.A ha-bridge-0.X.Y.jar
|
||||
java -jar -Dvera.address=X.Y.Z.A -Dharmony.address=X.Y.Z.A -Dharmony.user=myself -Dharmony.pwd=passwd ha-bridge-0.X.Y.jar
|
||||
```
|
||||
## Available Arguments
|
||||
### -Dvera.address=`<ip address>`
|
||||
@@ -32,8 +32,6 @@ The password for the user name of the MyHarmony.com account for the Harmony Hub.
|
||||
Upnp has been very closed on this platform to try and respond as a hue and there is now a setting to control if it is more open or strict, Add -Dupnp.strict=`<true|false>` to your command line to have the emulator respond to what it thinks is an echo to a hue or any other device. The default is upnp.strict=true.
|
||||
### -Dtrace.upnp=`<true|false>`
|
||||
Turn on tracing for upnp discovery messages. The default is false.
|
||||
### -Dvtwo.compatibility=`<true|false>`
|
||||
Turns on compatibility for upnp detection and response as it was in the original version of amazon-echo-ha-bridge. The default is false.
|
||||
## Web Config
|
||||
Configure by going to the url for the host you are running on or localhost with port you have assigned:
|
||||
```
|
||||
@@ -105,3 +103,8 @@ To turn on debugging for the bridge, use the following extra parm in the command
|
||||
```
|
||||
-Dorg.slf4j.simpleLogger.defaultLogLevel=DEBUG
|
||||
```
|
||||
## Development Mode
|
||||
To turn on development mode so that it will not need an Harmony Hub for testing, use the following extra parm in the command line and the harmony ip and login info will not be needed:
|
||||
```
|
||||
java -jar -Ddev.mode=true ha-bridge-0.X.Y.jar
|
||||
```
|
||||
45
pom.xml
45
pom.xml
@@ -5,11 +5,11 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>1.0.3</version>
|
||||
<version>1.0.5</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
<description>Emulates a Philips Hue bridge to allow the Amazon Echo to hook up to other HA systems, i.e. Vera, using lightweight frameworks</description>
|
||||
<description>Emulates a Philips Hue bridge to allow the Amazon Echo to hook up to other HA systems, i.e. Vera or Harmony Hub, using lightweight frameworks</description>
|
||||
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
@@ -88,6 +88,22 @@
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<includes>
|
||||
<include>version.properties</include>
|
||||
</includes>
|
||||
<filtering>true</filtering>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<excludes>
|
||||
<exclude>version.properties</exclude>
|
||||
</excludes>
|
||||
<filtering>false</filtering>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -113,21 +129,20 @@
|
||||
<exclude>META-INF/services/**</exclude>
|
||||
<exclude>META-INF/DEPENDENCIES</exclude>
|
||||
<exclude>about_files/**</exclude>
|
||||
<exclude>*.properties</exclude>
|
||||
</excludes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>org.slf4j:*</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>commons-logging:commons-logging</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>org.slf4j:*</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
<filter>
|
||||
<artifact>commons-logging:commons-logging</artifact>
|
||||
<includes>
|
||||
<include>**</include>
|
||||
</includes>
|
||||
</filter>
|
||||
</filters>
|
||||
<transformers>
|
||||
<transformer
|
||||
|
||||
@@ -11,7 +11,6 @@ public class BridgeSettings {
|
||||
private String harmonypwd;
|
||||
private boolean upnpstrict;
|
||||
private boolean traceupnp;
|
||||
private boolean vtwocompatibility;
|
||||
private boolean devmode;
|
||||
|
||||
public String getUpnpConfigAddress() {
|
||||
@@ -44,7 +43,6 @@ public class BridgeSettings {
|
||||
public void setVeraAddress(String veraAddress) {
|
||||
this.veraaddress = veraAddress;
|
||||
}
|
||||
|
||||
public String getHarmonyAddress() {
|
||||
return harmonyaddress;
|
||||
}
|
||||
@@ -75,14 +73,6 @@ public class BridgeSettings {
|
||||
public void setTraceupnp(boolean traceupnp) {
|
||||
this.traceupnp = traceupnp;
|
||||
}
|
||||
|
||||
public boolean isVtwocompatibility() {
|
||||
return vtwocompatibility;
|
||||
}
|
||||
public void setVtwocompatibility(boolean vtwocompatibility) {
|
||||
this.vtwocompatibility = vtwocompatibility;
|
||||
}
|
||||
|
||||
public boolean isDevMode() {
|
||||
return devmode;
|
||||
}
|
||||
|
||||
@@ -41,8 +41,11 @@ public class HABridge {
|
||||
InetAddress address;
|
||||
String addressString;
|
||||
BridgeSettings bridgeSettings;
|
||||
Version theVersion;
|
||||
|
||||
log.info("HA Bridge (v1.0.3) starting setup....");
|
||||
theVersion = new Version();
|
||||
|
||||
log.info("HA Bridge (v" + theVersion.getVersion() + ") starting setup....");
|
||||
//get ip address for upnp requests
|
||||
try {
|
||||
address = InetAddress.getLocalHost();
|
||||
@@ -53,6 +56,7 @@ public class HABridge {
|
||||
}
|
||||
|
||||
bridgeSettings = new BridgeSettings();
|
||||
bridgeSettings.setServerPort(System.getProperty("server.port", Configuration.DFAULT_WEB_PORT));
|
||||
bridgeSettings.setUpnpConfigAddress(System.getProperty("upnp.config.address", addressString));
|
||||
bridgeSettings.setUpnpDeviceDb(System.getProperty("upnp.device.db", Configuration.DEVICE_DB_DIRECTORY));
|
||||
bridgeSettings.setUpnpResponsePort(System.getProperty("upnp.response.port", Configuration.UPNP_RESPONSE_PORT));
|
||||
@@ -62,13 +66,11 @@ public class HABridge {
|
||||
bridgeSettings.setHarmonyPwd(System.getProperty("harmony.pwd", Configuration.DEFAULT_HARMONY_PWD));
|
||||
bridgeSettings.setUpnpStrict(Boolean.parseBoolean(System.getProperty("upnp.strict", "true")));
|
||||
bridgeSettings.setTraceupnp(Boolean.parseBoolean(System.getProperty("trace.upnp", "false")));
|
||||
bridgeSettings.setVtwocompatibility(Boolean.parseBoolean(System.getProperty("vtwo.compatibility", "false")));
|
||||
bridgeSettings.setDevMode(Boolean.parseBoolean(System.getProperty("dev.mode", "false")));
|
||||
|
||||
// sparkjava config directive to set ip address for the web server to listen on
|
||||
// ipAddress("0.0.0.0"); // not used
|
||||
// sparkjava config directive to set port for the web server to listen on
|
||||
bridgeSettings.setServerPort(System.getProperty("server.port", Configuration.DFAULT_WEB_PORT));
|
||||
port(Integer.valueOf(bridgeSettings.getServerPort()));
|
||||
// sparkjava config directive to set html static file location for Jetty
|
||||
staticFileLocation("/public");
|
||||
@@ -80,7 +82,7 @@ public class HABridge {
|
||||
return;
|
||||
}
|
||||
// setup the class to handle the resource setup rest api
|
||||
theResources = new DeviceResource(bridgeSettings, myHarmonyServer.getMyHarmony());
|
||||
theResources = new DeviceResource(bridgeSettings, theVersion, myHarmonyServer.getMyHarmony());
|
||||
// setup the class to handle the hue emulator rest api
|
||||
theHueMulator = new HueMulator(theResources.getDeviceRepository(), myHarmonyServer.getMyHarmony());
|
||||
theHueMulator.setupServer();
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.HABridge.BridgeSettings;
|
||||
import com.bwssystems.HABridge.JsonTransformer;
|
||||
import com.bwssystems.HABridge.Version;
|
||||
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||
import com.bwssystems.HABridge.dao.DeviceRepository;
|
||||
import com.bwssystems.harmony.HarmonyHandler;
|
||||
@@ -32,14 +33,16 @@ public class DeviceResource {
|
||||
|
||||
private DeviceRepository deviceRepository;
|
||||
private VeraInfo veraInfo;
|
||||
private Version version;
|
||||
private HarmonyHandler myHarmonyHandler;
|
||||
private static final Set<String> supportedVerbs = new HashSet<>(Arrays.asList("get", "put", "post"));
|
||||
|
||||
public DeviceResource(BridgeSettings theSettings, HarmonyHandler myHarmony) {
|
||||
public DeviceResource(BridgeSettings theSettings, Version theVersion, HarmonyHandler myHarmony) {
|
||||
super();
|
||||
deviceRepository = new DeviceRepository(theSettings.getUpnpDeviceDb());
|
||||
veraInfo = new VeraInfo(theSettings.getVeraAddress(), theSettings.isValidVera());
|
||||
myHarmonyHandler = myHarmony;
|
||||
this.deviceRepository = new DeviceRepository(theSettings.getUpnpDeviceDb());
|
||||
this.veraInfo = new VeraInfo(theSettings.getVeraAddress(), theSettings.isValidVera());
|
||||
this.myHarmonyHandler = myHarmony;
|
||||
this.version = theVersion;
|
||||
setupEndpoints();
|
||||
}
|
||||
|
||||
@@ -130,6 +133,12 @@ public class DeviceResource {
|
||||
return null;
|
||||
}, new JsonTransformer());
|
||||
|
||||
get (API_CONTEXT + "/habridge/version", "application/json", (request, response) -> {
|
||||
log.debug("Get HA Bridge version: v" + version.getVersion());
|
||||
response.status(HttpStatus.SC_OK);
|
||||
return "{\"version\":\"" + version.getVersion() + "\"}";
|
||||
});
|
||||
|
||||
get (API_CONTEXT + "/vera/devices", "application/json", (request, response) -> {
|
||||
log.debug("Get vera devices");
|
||||
Sdata sData = veraInfo.getSdata();
|
||||
|
||||
@@ -27,8 +27,6 @@ public class UpnpListener {
|
||||
|
||||
private boolean traceupnp;
|
||||
|
||||
private boolean vTwoCompatibility;
|
||||
|
||||
public UpnpListener(BridgeSettings theSettings) {
|
||||
super();
|
||||
upnpResponsePort = Integer.valueOf(theSettings.getUpnpResponsePort());
|
||||
@@ -36,7 +34,6 @@ public class UpnpListener {
|
||||
responseAddress = theSettings.getUpnpConfigAddress();
|
||||
strict = theSettings.isUpnpStrict();
|
||||
traceupnp = theSettings.isTraceupnp();
|
||||
vTwoCompatibility = theSettings.isVtwocompatibility();
|
||||
}
|
||||
|
||||
public void startListening(){
|
||||
@@ -113,18 +110,18 @@ public class UpnpListener {
|
||||
if(strict && body.startsWith("M-SEARCH * HTTP/1.1") && body.contains("MAN: \"ssdp:discover\"") && (body.contains("ST: urn:schemas-upnp-org:device:basic:1") || body.contains("ST: upnp:rootdevice") || body.contains("ST: ssdp:all")))
|
||||
{
|
||||
if(traceupnp)
|
||||
log.info("Traceupnp: isSSDPDiscovery found message to be valid under strict rules - strict: " + strict + ", vTwo.Compatibility: " + vTwoCompatibility);
|
||||
log.info("Traceupnp: isSSDPDiscovery found message to be valid under strict rules - strict: " + strict);
|
||||
return true;
|
||||
}
|
||||
else if (!strict || vTwoCompatibility)
|
||||
else if (!strict)
|
||||
{
|
||||
if(traceupnp)
|
||||
log.info("Traceupnp: isSSDPDiscovery found message to be valid under loose rules - strict: " + strict + ", vTwo.Compatibility: " + vTwoCompatibility);
|
||||
log.info("Traceupnp: isSSDPDiscovery found message to be valid under loose rules - strict: " + strict);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(traceupnp)
|
||||
log.info("Traceupnp: isSSDPDiscovery found message to not be valid - strict: " + strict + ", vTwo.Compatibility: " + vTwoCompatibility);
|
||||
log.info("Traceupnp: isSSDPDiscovery found message to not be valid - strict: " + strict);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -135,20 +132,9 @@ public class UpnpListener {
|
||||
"SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/0.1\r\n" +
|
||||
"ST: urn:schemas-upnp-org:device:basic:1\r\n" +
|
||||
"USN: uuid:Socket-1_0-221438K0100073::urn:schemas-upnp-org:device:basic:1\r\n\r\n";
|
||||
String discoveryTemplateVTwo = "HTTP/1.1 200 OK\r\n" +
|
||||
"CACHE-CONTROL: max-age=86400\r\n" +
|
||||
"EXT:\r\n" +
|
||||
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||
"OPT: \"http://schemas.upnp.org/upnp/1/0/\"; ns=01\r\n" +
|
||||
"01-NLS: %s\r\n" +
|
||||
"ST: urn:schemas-upnp-org:device:basic:1\r\n" +
|
||||
"USN: uuid:Socket-1_0-221438K0100073::urn:Belkin:device:**\r\n\r\n";
|
||||
protected void sendUpnpResponse(DatagramSocket socket, InetAddress requester, int sourcePort) throws IOException {
|
||||
String discoveryResponse = null;
|
||||
if(vTwoCompatibility)
|
||||
discoveryResponse = String.format(discoveryTemplateVTwo, responseAddress, httpServerPort, getRandomUUIDString());
|
||||
else
|
||||
discoveryResponse = String.format(discoveryTemplate, responseAddress, httpServerPort, getRandomUUIDString());
|
||||
discoveryResponse = String.format(discoveryTemplate, responseAddress, httpServerPort, getRandomUUIDString());
|
||||
if(traceupnp)
|
||||
log.info("Traceupnp: sendUpnpResponse: " + discoveryResponse);
|
||||
else
|
||||
|
||||
@@ -40,53 +40,6 @@ public class UpnpSettingsResource {
|
||||
+ "<depth>24</depth>\n" + "<url>hue_logo_3.png</url>\n" + "</icon>\n" + "</iconList>\n" + "</device>\n"
|
||||
+ "</root>\n";
|
||||
|
||||
private String hueTemplateVTwo = "<?xml version=\"1.0\"?>\n" +
|
||||
"<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n" +
|
||||
"<specVersion>\n" +
|
||||
"<major>1</major>\n" +
|
||||
"<minor>0</minor>\n" +
|
||||
"</specVersion>\n" +
|
||||
"<URLBase>http://%s:%s/</URLBase>\n" + //hostname string
|
||||
"<device>\n" +
|
||||
"<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>\n" +
|
||||
"<friendlyName>Amazon-Echo-HA-Bridge (%s)</friendlyName>\n" +
|
||||
"<manufacturer>Royal Philips Electronics</manufacturer>\n" +
|
||||
"<manufacturerURL>http://www.bwssystems.com</manufacturerURL>\n" +
|
||||
"<modelDescription>Hue Emulator for Amazon Echo bridge</modelDescription>\n" +
|
||||
"<modelName>Philips hue bridge 2012</modelName>\n" +
|
||||
"<modelNumber>929000226503</modelNumber>\n" +
|
||||
"<modelURL>http://www.bwssystems.com/apps.html</modelURL>\n" +
|
||||
"<serialNumber>01189998819991197253</serialNumber>\n" +
|
||||
"<UDN>uuid:88f6698f-2c83-4393-bd03-cd54a9f8595</UDN>\n" +
|
||||
"<serviceList>\n" +
|
||||
"<service>\n" +
|
||||
"<serviceType>(null)</serviceType>\n" +
|
||||
"<serviceId>(null)</serviceId>\n" +
|
||||
"<controlURL>(null)</controlURL>\n" +
|
||||
"<eventSubURL>(null)</eventSubURL>\n" +
|
||||
"<SCPDURL>(null)</SCPDURL>\n" +
|
||||
"</service>\n" +
|
||||
"</serviceList>\n" +
|
||||
"<presentationURL>index.html</presentationURL>\n" +
|
||||
"<iconList>\n" +
|
||||
"<icon>\n" +
|
||||
"<mimetype>image/png</mimetype>\n" +
|
||||
"<height>48</height>\n" +
|
||||
"<width>48</width>\n" +
|
||||
"<depth>24</depth>\n" +
|
||||
"<url>hue_logo_0.png</url>\n" +
|
||||
"</icon>\n" +
|
||||
"<icon>\n" +
|
||||
"<mimetype>image/png</mimetype>\n" +
|
||||
"<height>120</height>\n" +
|
||||
"<width>120</width>\n" +
|
||||
"<depth>24</depth>\n" +
|
||||
"<url>hue_logo_3.png</url>\n" +
|
||||
"</icon>\n" +
|
||||
"</iconList>\n" +
|
||||
"</device>\n" +
|
||||
"</root>\n";
|
||||
|
||||
public UpnpSettingsResource(BridgeSettings theSettings) {
|
||||
super();
|
||||
this.theSettings = theSettings;
|
||||
@@ -102,10 +55,7 @@ public class UpnpSettingsResource {
|
||||
log.debug("upnp device settings requested: " + request.params(":id") + " from " + request.ip() + ":" + request.port());
|
||||
String portNumber = Integer.toString(request.port());
|
||||
String filledTemplate = null;
|
||||
if(theSettings.isVtwocompatibility())
|
||||
filledTemplate = String.format(hueTemplateVTwo, theSettings.getUpnpConfigAddress(), portNumber, theSettings.getUpnpConfigAddress());
|
||||
else
|
||||
filledTemplate = String.format(hueTemplate, theSettings.getUpnpConfigAddress(), portNumber, theSettings.getUpnpConfigAddress());
|
||||
filledTemplate = String.format(hueTemplate, theSettings.getUpnpConfigAddress(), portNumber, theSettings.getUpnpConfigAddress());
|
||||
if(theSettings.isTraceupnp())
|
||||
log.info("Traceupnp: upnp device settings response: " + filledTemplate);
|
||||
else
|
||||
|
||||
@@ -35,9 +35,11 @@ public class HarmonyServer {
|
||||
return new HarmonyServer();
|
||||
}
|
||||
Injector injector = null;
|
||||
injector = Guice.createInjector(new HarmonyClientModule());
|
||||
if(!bridgeSettings.isDevMode())
|
||||
injector = Guice.createInjector(new HarmonyClientModule());
|
||||
HarmonyServer mainObject = new HarmonyServer();
|
||||
injector.injectMembers(mainObject);
|
||||
if(!bridgeSettings.isDevMode())
|
||||
injector.injectMembers(mainObject);
|
||||
mainObject.execute(bridgeSettings);
|
||||
return mainObject;
|
||||
}
|
||||
|
||||
1
src/main/resources/config.data
Normal file
1
src/main/resources/config.data
Normal file
File diff suppressed because one or more lines are too long
@@ -16,7 +16,7 @@
|
||||
<body>
|
||||
|
||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||
<div class="container">
|
||||
<div class="container" ng-controller="VersionController">
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
@@ -36,7 +36,7 @@
|
||||
<ul class="dropdown-menu" aria-labelledby="dropdownMenu1">
|
||||
<li><a href="http://www.bwssystems.com" target="_blank">Developed by BWS Systems</a></li>
|
||||
<li><a href="http://www.amazon.com/echo" target="_blank">Amazon Echo</a></li>
|
||||
<li><a href="">HA Bridge Version 1.0.3</a></li>
|
||||
<li><a href="">HA Bridge Version {{bridge.habridgeversion}}</a></li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
@@ -36,6 +36,8 @@ app.config(function ($routeProvider) {
|
||||
app.run( function (bridgeService) {
|
||||
bridgeService.loadBridgeSettings();
|
||||
bridgeService.updateShowVera();
|
||||
bridgeService.updateShowHarmony();
|
||||
bridgeService.getHABridgeVersion();
|
||||
});
|
||||
|
||||
app.factory('BridgeSettings', function() {
|
||||
@@ -49,7 +51,7 @@ app.factory('BridgeSettings', function() {
|
||||
BridgeSettings.harmonyaddress = "";
|
||||
BridgeSettings.upnpstrict = "";
|
||||
BridgeSettings.traceupnp = "";
|
||||
BridgeSettings.vtwocompatibility = "";
|
||||
BridgeSettings.devmode = "";
|
||||
|
||||
BridgeSettings.setupnpconfigaddress = function(aconfigaddress){
|
||||
BridgeSettings.upnpconfigaddress = aconfigaddress;
|
||||
@@ -79,8 +81,8 @@ app.factory('BridgeSettings', function() {
|
||||
BridgeSettings.settraceupnp = function(atraceupnp){
|
||||
BridgeSettings.traceupnp = atraceupnp;
|
||||
};
|
||||
BridgeSettings.setvtwocompatibility = function(avtwocompatibility){
|
||||
BridgeSettings.vtwocompatibility = avtwocompatibility;
|
||||
BridgeSettings.setdevmode = function(adevmode){
|
||||
BridgeSettings.devmode = adevmode;
|
||||
};
|
||||
|
||||
return BridgeSettings;
|
||||
@@ -89,7 +91,7 @@ app.factory('BridgeSettings', function() {
|
||||
app.service('bridgeService', function ($http, $window, BridgeSettings) {
|
||||
var self = this;
|
||||
self.BridgeSettings = BridgeSettings;
|
||||
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", devices: [], device: [], error: "", showVera: false, showHarmony: false};
|
||||
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", huebase: window.location.origin + "/api", devices: [], device: [], error: "", showVera: false, showHarmony: false, habridgeversion: ""};
|
||||
|
||||
this.viewDevices = function () {
|
||||
this.state.error = "";
|
||||
@@ -109,6 +111,23 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) {
|
||||
);
|
||||
};
|
||||
|
||||
this.getHABridgeVersion = function () {
|
||||
this.state.error = "";
|
||||
return $http.get(this.state.base + "/habridge/version").then(
|
||||
function (response) {
|
||||
self.state.habridgeversion = response.data.version;
|
||||
},
|
||||
function (error) {
|
||||
if (error.data) {
|
||||
self.state.error = error.data.message;
|
||||
} else {
|
||||
self.state.error = "cannot get version";
|
||||
}
|
||||
console.log(error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
this.loadBridgeSettings = function () {
|
||||
this.state.error = "";
|
||||
return $http.get(this.state.upnpbase).then(
|
||||
@@ -121,7 +140,7 @@ app.service('bridgeService', function ($http, $window, BridgeSettings) {
|
||||
self.BridgeSettings.setharmonyaddress(response.data.harmonyaddress);
|
||||
self.BridgeSettings.settraceupnp(response.data.traceupnp);
|
||||
self.BridgeSettings.setupnpstrict(response.data.upnpstrict);
|
||||
self.BridgeSettings.setvtwocompatibility(response.data.vtwocompatibility);
|
||||
self.BridgeSettings.setdevmode(response.data.devmode);
|
||||
if(self.BridgeSettings.veraaddress == "1.1.1.1" || self.BridgeSettings.veraaddress == "")
|
||||
self.state.showVera = false;
|
||||
else
|
||||
@@ -600,3 +619,7 @@ app.controller('AddingController', function ($scope, $location, $http, bridgeSer
|
||||
app.controller('ErrorsController', function ($scope, bridgeService) {
|
||||
$scope.bridge = bridgeService.state;
|
||||
});
|
||||
|
||||
app.controller('VersionController', function ($scope, bridgeService) {
|
||||
$scope.bridge = bridgeService.state;
|
||||
});
|
||||
@@ -120,8 +120,8 @@
|
||||
<td>{{BridgeSettings.traceupnp}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>vtwo.compatibility</td>
|
||||
<td>{{BridgeSettings.vtwocompatibility}}</td>
|
||||
<td>dev.mode</td>
|
||||
<td>{{BridgeSettings.devmode}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
3
src/main/resources/version.properties
Normal file
3
src/main/resources/version.properties
Normal file
@@ -0,0 +1,3 @@
|
||||
version=${project.version}
|
||||
groupId=${project.groupId}
|
||||
artifactId=${project.artifactId}
|
||||
Reference in New Issue
Block a user