mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 00:10:20 +00:00
Update application from amazon-echo-bridge-compact to ha-bridge.
Try to remove most code naming away from amazon. Fix package names being incorrect. Added Vera query functionality, needs some fine tuning.
This commit is contained in:
88
pom.xml
88
pom.xml
@@ -3,13 +3,13 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>com.bwssytems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>amazon-echo-bridge-compact</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>0.2.1</version>
|
<version>0.3.0</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>Amazon Echo Bridge Compact</name>
|
<name>HA Bridge</name>
|
||||||
<description>Emulates a Philips Hue bridge to allow the Amazon Echo to hook up to other HA 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, using lightweight frameworks</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
@@ -49,43 +49,47 @@
|
|||||||
<version>4.1.6</version>
|
<version>4.1.6</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.3</version>
|
<version>2.3</version>
|
||||||
<configuration>
|
<executions>
|
||||||
<createDependencyReducedPom>true</createDependencyReducedPom>
|
<execution>
|
||||||
<filters>
|
<phase>package</phase>
|
||||||
<filter>
|
<goals>
|
||||||
<artifact>*:*</artifact>
|
<goal>shade</goal>
|
||||||
<excludes>
|
</goals>
|
||||||
<exclude>META-INF/*.SF</exclude>
|
<configuration>
|
||||||
<exclude>META-INF/*.DSA</exclude>
|
<minimizeJar>true</minimizeJar>
|
||||||
<exclude>META-INF/*.RSA</exclude>
|
<filters>
|
||||||
</excludes>
|
<filter>
|
||||||
</filter>
|
<artifact>*:*</artifact>
|
||||||
</filters>
|
<excludes>
|
||||||
</configuration>
|
<exclude>META-INF/*.SF</exclude>
|
||||||
<executions>
|
<exclude>META-INF/*.DSA</exclude>
|
||||||
<execution>
|
<exclude>META-INF/*.RSA</exclude>
|
||||||
<phase>package</phase>
|
<exclude>META-INF/*.txt</exclude>
|
||||||
<goals>
|
<exclude>META-INF/maven/**</exclude>
|
||||||
<goal>shade</goal>
|
<exclude>META-INF/services/**</exclude>
|
||||||
</goals>
|
<exclude>META-INF/DEPENDENCIES</exclude>
|
||||||
<configuration>
|
<exclude>about_files/**</exclude>
|
||||||
<transformers>
|
<exclude>*.properties</exclude>
|
||||||
<transformer
|
</excludes>
|
||||||
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
</filter>
|
||||||
<mainClass>com.bwssytems.HABridge.AmazonEchoBridge</mainClass>
|
</filters>
|
||||||
</transformer>
|
<transformers>
|
||||||
</transformers>
|
<transformer
|
||||||
</configuration>
|
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
|
||||||
</execution>
|
<mainClass>com.bwssystems.HABridge.HABridge</mainClass>
|
||||||
</executions>
|
</transformer>
|
||||||
</plugin>
|
</transformers>
|
||||||
</plugins>
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge;
|
package com.bwssystems.HABridge;
|
||||||
|
|
||||||
import static spark.Spark.*;
|
import static spark.Spark.*;
|
||||||
|
|
||||||
@@ -8,12 +8,13 @@ import java.net.UnknownHostException;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.bwssytems.HABridge.devicemanagmeent.*;
|
import com.bwssystems.HABridge.devicemanagmeent.*;
|
||||||
import com.bwssytems.HABridge.hue.HueMulator;
|
import com.bwssystems.HABridge.hue.HueMulator;
|
||||||
import com.bwssytems.HABridge.upnp.UpnpListener;
|
import com.bwssystems.HABridge.upnp.UpnpListener;
|
||||||
import com.bwssytems.HABridge.upnp.UpnpSettingsResource;
|
import com.bwssystems.HABridge.upnp.UpnpSettingsResource;
|
||||||
|
import com.bwssystems.vera.VeraInfo;
|
||||||
|
|
||||||
public class AmazonEchoBridge {
|
public class HABridge {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This program is based on the work of armzilla from this github repository:
|
* This program is based on the work of armzilla from this github repository:
|
||||||
@@ -31,15 +32,16 @@ public class AmazonEchoBridge {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Logger log = LoggerFactory.getLogger(AmazonEchoBridge.class);
|
Logger log = LoggerFactory.getLogger(HABridge.class);
|
||||||
DeviceResource theResources;
|
DeviceResource theResources;
|
||||||
HueMulator theHueMulator;
|
HueMulator theHueMulator;
|
||||||
UpnpSettingsResource theSettingResponder;
|
UpnpSettingsResource theSettingResponder;
|
||||||
UpnpListener theUpnpListener;
|
UpnpListener theUpnpListener;
|
||||||
|
VeraInfo theVera;
|
||||||
InetAddress address;
|
InetAddress address;
|
||||||
String addressString;
|
String addressString;
|
||||||
String upnpAddressString;
|
BridgeSettings bridgeSettings;
|
||||||
String serverPort;
|
|
||||||
//get ip address for upnp requests
|
//get ip address for upnp requests
|
||||||
try {
|
try {
|
||||||
address = InetAddress.getLocalHost();
|
address = InetAddress.getLocalHost();
|
||||||
@@ -49,27 +51,33 @@ public class AmazonEchoBridge {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
upnpAddressString = System.getProperty("upnp.config.address", addressString);
|
bridgeSettings = new BridgeSettings();
|
||||||
|
bridgeSettings.setUpnpConfigAddress(System.getProperty("upnp.config.address", addressString));
|
||||||
|
bridgeSettings.setUpnpDeviceDb(System.getProperty("upnp.device.db", "data/device.db"));
|
||||||
|
bridgeSettings.setUpnpResponsePort(System.getProperty("upnp.response.port", "50000"));
|
||||||
|
bridgeSettings.setVeraAddress(System.getProperty("vera.address", "192.168.1.100"));
|
||||||
|
|
||||||
// sparkjava config directive to set ip address for the web server to listen on
|
// sparkjava config directive to set ip address for the web server to listen on
|
||||||
// ipAddress("0.0.0.0"); // not used
|
// ipAddress("0.0.0.0"); // not used
|
||||||
// sparkjava config directive to set port for the web server to listen on
|
// sparkjava config directive to set port for the web server to listen on
|
||||||
serverPort = System.getProperty("server.port", "8080");
|
bridgeSettings.setServerPort(System.getProperty("server.port", "8080"));
|
||||||
port(Integer.valueOf(serverPort));
|
port(Integer.valueOf(bridgeSettings.getServerPort()));
|
||||||
// sparkjava config directive to set html static file location for Jetty
|
// sparkjava config directive to set html static file location for Jetty
|
||||||
staticFileLocation("/public");
|
staticFileLocation("/public");
|
||||||
log.info("Starting setup....");
|
log.info("Starting setup....");
|
||||||
|
theVera = new VeraInfo(bridgeSettings.getVeraAddress());
|
||||||
|
theVera.getSdata();
|
||||||
// setup the class to handle the resource setup rest api
|
// setup the class to handle the resource setup rest api
|
||||||
theResources = new DeviceResource();
|
theResources = new DeviceResource(bridgeSettings);
|
||||||
// setup the class to handle the hue emulator rest api
|
// setup the class to handle the hue emulator rest api
|
||||||
theHueMulator = new HueMulator(theResources.getDeviceRepository());
|
theHueMulator = new HueMulator(theResources.getDeviceRepository());
|
||||||
// setup the class to handle the upnp response rest api
|
// setup the class to handle the upnp response rest api
|
||||||
theSettingResponder = new UpnpSettingsResource(upnpAddressString);
|
theSettingResponder = new UpnpSettingsResource(bridgeSettings);
|
||||||
// wait for the sparkjava initialization of the rest api classes to be complete
|
// wait for the sparkjava initialization of the rest api classes to be complete
|
||||||
awaitInitialization();
|
awaitInitialization();
|
||||||
|
|
||||||
// start the upnp ssdp discovery listener
|
// start the upnp ssdp discovery listener
|
||||||
theUpnpListener = new UpnpListener(upnpAddressString, serverPort);
|
theUpnpListener = new UpnpListener(bridgeSettings);
|
||||||
log.info("Done setup, application to run....");
|
log.info("Done setup, application to run....");
|
||||||
theUpnpListener.startListening();
|
theUpnpListener.startListening();
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge;
|
package com.bwssystems.HABridge;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import spark.ResponseTransformer;
|
import spark.ResponseTransformer;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge.api;
|
package com.bwssystems.HABridge.api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by arm on 4/13/15.
|
* Created by arm on 4/13/15.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge.api.hue;
|
package com.bwssystems.HABridge.api.hue;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge.api.hue;
|
package com.bwssystems.HABridge.api.hue;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package com.bwssytems.HABridge.api.hue;
|
package com.bwssystems.HABridge.api.hue;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.bwssytems.HABridge.api.hue.DeviceResponse;
|
import com.bwssystems.HABridge.api.hue.DeviceResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by arm on 4/14/15.
|
* Created by arm on 4/14/15.
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge.dao;
|
package com.bwssystems.HABridge.dao;
|
||||||
/*
|
/*
|
||||||
* Object to handle the device configuration
|
* Object to handle the device configuration
|
||||||
*/
|
*/
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.bwssytems.HABridge.dao;
|
package com.bwssystems.HABridge.dao;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -14,8 +14,8 @@ import java.util.Random;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.bwssytems.HABridge.JsonTransformer;
|
import com.bwssystems.HABridge.JsonTransformer;
|
||||||
import com.bwssytems.HABridge.dao.DeviceDescriptor;
|
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -30,9 +30,9 @@ public class DeviceRepository {
|
|||||||
final Random random = new Random();
|
final Random random = new Random();
|
||||||
final Logger log = LoggerFactory.getLogger(DeviceRepository.class);
|
final Logger log = LoggerFactory.getLogger(DeviceRepository.class);
|
||||||
|
|
||||||
public DeviceRepository() {
|
public DeviceRepository(String deviceDb) {
|
||||||
super();
|
super();
|
||||||
repositoryPath = Paths.get(System.getProperty("upnp.device.db", "data/device.db"));
|
repositoryPath = Paths.get(deviceDb);
|
||||||
String jsonContent = repositoryReader(repositoryPath);
|
String jsonContent = repositoryReader(repositoryPath);
|
||||||
devices = new HashMap<String, DeviceDescriptor>();
|
devices = new HashMap<String, DeviceDescriptor>();
|
||||||
if(jsonContent != null)
|
if(jsonContent != null)
|
||||||
@@ -1,8 +1,4 @@
|
|||||||
package com.bwssytems.HABridge.devicemanagmeent;
|
package com.bwssystems.HABridge.devicemanagmeent;
|
||||||
|
|
||||||
import com.bwssytems.HABridge.JsonTransformer;
|
|
||||||
import com.bwssytems.HABridge.dao.DeviceDescriptor;
|
|
||||||
import com.bwssytems.HABridge.dao.DeviceRepository;
|
|
||||||
|
|
||||||
import static spark.Spark.get;
|
import static spark.Spark.get;
|
||||||
import static spark.Spark.post;
|
import static spark.Spark.post;
|
||||||
@@ -14,6 +10,12 @@ import java.util.List;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.bwssystems.HABridge.BridgeSettings;
|
||||||
|
import com.bwssystems.HABridge.JsonTransformer;
|
||||||
|
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||||
|
import com.bwssystems.HABridge.dao.DeviceRepository;
|
||||||
|
import com.bwssystems.luupRequests.Sdata;
|
||||||
|
import com.bwssystems.vera.VeraInfo;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -24,11 +26,13 @@ public class DeviceResource {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(DeviceResource.class);
|
private static final Logger log = LoggerFactory.getLogger(DeviceResource.class);
|
||||||
|
|
||||||
private DeviceRepository deviceRepository;
|
private DeviceRepository deviceRepository;
|
||||||
|
private VeraInfo veraInfo;
|
||||||
|
|
||||||
|
|
||||||
public DeviceResource() {
|
public DeviceResource(BridgeSettings theSettings) {
|
||||||
super();
|
super();
|
||||||
deviceRepository = new DeviceRepository();
|
deviceRepository = new DeviceRepository(theSettings.getUpnpDeviceDb());
|
||||||
|
veraInfo = new VeraInfo(theSettings.getVeraAddress());
|
||||||
setupEndpoints();
|
setupEndpoints();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -102,5 +106,24 @@ public class DeviceResource {
|
|||||||
deviceRepository.delete(deleted);
|
deviceRepository.delete(deleted);
|
||||||
return null;
|
return null;
|
||||||
}, new JsonTransformer());
|
}, new JsonTransformer());
|
||||||
|
|
||||||
|
get (API_CONTEXT + "/vera/devices", "application/json", (request, response) -> {
|
||||||
|
log.debug("Get vera devices");
|
||||||
|
Sdata sData = veraInfo.getSdata();
|
||||||
|
if(sData == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return sData.getDevices();
|
||||||
|
}, new JsonTransformer());
|
||||||
|
|
||||||
|
get (API_CONTEXT + "/vera/scenes", "application/json", (request, response) -> {
|
||||||
|
log.debug("Get vera scenes");
|
||||||
|
Sdata sData = veraInfo.getSdata();
|
||||||
|
if(sData == null){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return sData.getScenes();
|
||||||
|
}, new JsonTransformer());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,10 @@
|
|||||||
package com.bwssytems.HABridge.hue;
|
package com.bwssystems.HABridge.hue;
|
||||||
|
|
||||||
import com.bwssytems.HABridge.api.hue.DeviceResponse;
|
|
||||||
import com.bwssytems.HABridge.api.hue.DeviceState;
|
|
||||||
import com.bwssytems.HABridge.api.hue.HueApiResponse;
|
|
||||||
import com.bwssytems.HABridge.dao.*;
|
|
||||||
import com.bwssytems.HABridge.JsonTransformer;
|
|
||||||
|
|
||||||
|
import com.bwssystems.HABridge.JsonTransformer;
|
||||||
|
import com.bwssystems.HABridge.api.hue.DeviceResponse;
|
||||||
|
import com.bwssystems.HABridge.api.hue.DeviceState;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueApiResponse;
|
||||||
|
import com.bwssystems.HABridge.dao.*;
|
||||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
package com.bwssytems.HABridge.upnp;
|
package com.bwssystems.HABridge.upnp;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.bwssystems.HABridge.BridgeSettings;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
|
|
||||||
@@ -21,11 +23,11 @@ public class UpnpListener {
|
|||||||
|
|
||||||
private String responseAddress;
|
private String responseAddress;
|
||||||
|
|
||||||
public UpnpListener(String upnpAddress, String upnpServerPort) {
|
public UpnpListener(BridgeSettings theSettings) {
|
||||||
super();
|
super();
|
||||||
upnpResponsePort = Integer.valueOf(System.getProperty("upnp.response.port", "50000"));
|
upnpResponsePort = Integer.valueOf(theSettings.getUpnpResponsePort());
|
||||||
httpServerPort = Integer.valueOf(upnpServerPort);
|
httpServerPort = Integer.valueOf(theSettings.getServerPort());
|
||||||
responseAddress = upnpAddress;
|
responseAddress = theSettings.getUpnpConfigAddress();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void startListening(){
|
public void startListening(){
|
||||||
@@ -1,8 +1,11 @@
|
|||||||
package com.bwssytems.HABridge.upnp;
|
package com.bwssystems.HABridge.upnp;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import com.bwssystems.HABridge.BridgeSettings;
|
||||||
|
import com.bwssystems.HABridge.JsonTransformer;
|
||||||
|
|
||||||
import static spark.Spark.get;
|
import static spark.Spark.get;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -17,12 +20,12 @@ public class UpnpSettingsResource {
|
|||||||
+ "<specVersion>\n" + "<major>1</major>\n" + "<minor>0</minor>\n" + "</specVersion>\n"
|
+ "<specVersion>\n" + "<major>1</major>\n" + "<minor>0</minor>\n" + "</specVersion>\n"
|
||||||
+ "<URLBase>http://%s:%s/</URLBase>\n" + // hostname string
|
+ "<URLBase>http://%s:%s/</URLBase>\n" + // hostname string
|
||||||
"<device>\n" + "<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>\n"
|
"<device>\n" + "<deviceType>urn:schemas-upnp-org:device:Basic:1</deviceType>\n"
|
||||||
+ "<friendlyName>Amazon-Echo-HA-Bridge (%s)</friendlyName>\n"
|
+ "<friendlyName>HA-Bridge (%s)</friendlyName>\n"
|
||||||
+ "<manufacturer>Royal Philips Electronics</manufacturer>\n"
|
+ "<manufacturer>Royal Philips Electronics</manufacturer>\n"
|
||||||
+ "<manufacturerURL>http://www.bwssystems..com</manufacturerURL>\n"
|
+ "<manufacturerURL>http://www.bwssystems.com</manufacturerURL>\n"
|
||||||
+ "<modelDescription>Hue Emulator for Amazon Echo bridge</modelDescription>\n"
|
+ "<modelDescription>Hue Emulator for HA bridge</modelDescription>\n"
|
||||||
+ "<modelName>Philips hue bridge 2012</modelName>\n" + "<modelNumber>929000226503</modelNumber>\n"
|
+ "<modelName>Philips hue bridge 2012</modelName>\n" + "<modelNumber>929000226503</modelNumber>\n"
|
||||||
+ "<modelURL>http://www.bwssystems.com/amazon-echo-bridge-compact</modelURL>\n"
|
+ "<modelURL>http://www.bwssystems.com/ha-bridge</modelURL>\n"
|
||||||
+ "<serialNumber>01189998819991197253</serialNumber>\n"
|
+ "<serialNumber>01189998819991197253</serialNumber>\n"
|
||||||
+ "<UDN>uuid:88f6698f-2c83-4393-bd03-cd54a9f8595</UDN>\n" + "<serviceList>\n" + "<service>\n"
|
+ "<UDN>uuid:88f6698f-2c83-4393-bd03-cd54a9f8595</UDN>\n" + "<serviceList>\n" + "<service>\n"
|
||||||
+ "<serviceType>(null)</serviceType>\n" + "<serviceId>(null)</serviceId>\n"
|
+ "<serviceType>(null)</serviceType>\n" + "<serviceId>(null)</serviceId>\n"
|
||||||
@@ -35,29 +38,30 @@ public class UpnpSettingsResource {
|
|||||||
+ "<depth>24</depth>\n" + "<url>hue_logo_3.png</url>\n" + "</icon>\n" + "</iconList>\n" + "</device>\n"
|
+ "<depth>24</depth>\n" + "<url>hue_logo_3.png</url>\n" + "</icon>\n" + "</iconList>\n" + "</device>\n"
|
||||||
+ "</root>\n";
|
+ "</root>\n";
|
||||||
|
|
||||||
public UpnpSettingsResource(String upnpAddress) {
|
public UpnpSettingsResource(BridgeSettings theSettings) {
|
||||||
super();
|
super();
|
||||||
setupListener(upnpAddress);
|
setupListener(theSettings);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setupListener (String hostName) {
|
private void setupListener (BridgeSettings theSettings) {
|
||||||
// http://ip_address:port/upnp/:id/setup.xml which returns the xml configuration for the location of the hue emulator
|
// http://ip_address:port/upnp/:id/setup.xml which returns the xml configuration for the location of the hue emulator
|
||||||
get(UPNP_CONTEXT + "/:id/setup.xml", "application/xml", (request, response) -> {
|
get(UPNP_CONTEXT + "/:id/setup.xml", "application/xml", (request, response) -> {
|
||||||
log.info("upnp device settings requested: " + request.params(":id") + " from " + request.ip());
|
log.info("upnp device settings requested: " + request.params(":id") + " from " + request.ip());
|
||||||
String portNumber = Integer.toString(request.port());
|
String portNumber = Integer.toString(request.port());
|
||||||
String filledTemplate = String.format(hueTemplate, hostName, portNumber, hostName);
|
String filledTemplate = String.format(hueTemplate, theSettings.getUpnpConfigAddress(), portNumber, theSettings.getUpnpConfigAddress());
|
||||||
log.debug("upnp device settings response: " + filledTemplate);
|
log.debug("upnp device settings response: " + filledTemplate);
|
||||||
response.status(201);
|
response.status(201);
|
||||||
|
|
||||||
return filledTemplate;
|
return filledTemplate;
|
||||||
} );
|
} );
|
||||||
|
|
||||||
get(UPNP_CONTEXT + "/configaddress", "application/xml", (request, response) -> {
|
// http://ip_address:port/upnp/settings which returns the bridge configuration settings
|
||||||
log.info("upnp config address requested: from " + request.ip());
|
get(UPNP_CONTEXT + "/settings", "application/xml", (request, response) -> {
|
||||||
|
log.debug("bridge settings requested from " + request.ip());
|
||||||
|
|
||||||
response.status(201);
|
response.status(201);
|
||||||
|
|
||||||
return hostName;
|
return theSettings;
|
||||||
} );
|
}, new JsonTransformer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
upnp.response.port=50000
|
|
||||||
server.port=8080
|
|
||||||
upnp.config.address=192.168.4.136
|
|
||||||
@@ -4,65 +4,112 @@
|
|||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>Amazon Echo Bridge Configuration</title>
|
<title>HA Bridge Configuration</title>
|
||||||
<style>
|
<style>
|
||||||
body {
|
body {
|
||||||
padding-top: 60px;
|
padding-top: 60px;
|
||||||
padding-bottom: 20px;
|
padding-bottom: 20px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet">
|
<link href="css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
|
<script type="text/javascript" src="js/html5shiv.min.js"></script>
|
||||||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
<script type="text/javascript" src="js/respond.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
|
|
||||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
<script type="text/javascript" src="js/jquery-1.11.3.min.js"></script>
|
||||||
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.js"></script>
|
<script type="text/javascript" src="js/angular.min.js"></script>
|
||||||
|
<script type="text/javascript" src="js/bootstrap.min.js"></script>
|
||||||
<script type="text/javascript" src="scripts/app.js"></script>
|
<script type="text/javascript" src="scripts/app.js"></script>
|
||||||
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
|
|
||||||
</head>
|
</head>
|
||||||
<body ng-app="amazonechobridge">
|
<body ng-app="habridge">
|
||||||
|
|
||||||
<nav class="navbar navbar-inverse navbar-fixed-top">
|
<nav class="navbar navbar-inverse navbar-fixed-top">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="navbar-header">
|
<div class="navbar-header">
|
||||||
<a class="navbar-brand" href="#">Amazon Echo Bridge Configuration</a>
|
<button type="button" class="navbar-toggle collapsed"
|
||||||
</div>
|
data-toggle="collapse" data-target="#navbar" aria-expanded="false"
|
||||||
</div>
|
aria-controls="navbar">
|
||||||
</nav>
|
<span class="sr-only">Toggle navigation</span> <span
|
||||||
|
class="icon-bar"></span> <span class="icon-bar"></span>
|
||||||
|
</button>
|
||||||
|
<a class="navbar-brand" href="#">HA Bridge</a>
|
||||||
|
</div>
|
||||||
|
<div id="navbar" class="navbar-collapse collapse">
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li class="active"><a href="#">Home</a></li>
|
||||||
|
<li><a href="http://echo.amazon.com/#cards" target="_blank">My Echo</a></li>
|
||||||
|
<li class="dropdown">
|
||||||
|
<a id="dropdownMenu1" href="#" class="dropdown-toggle"
|
||||||
|
data-toggle="dropdown" role="button" aria-haspopup="true"
|
||||||
|
aria-expanded="false">About <span class="caret"></span></a>
|
||||||
|
<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>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<!--/.nav-collapse -->
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div ng-controller="ViewingController">
|
<div ng-controller="ViewingController">
|
||||||
|
|
||||||
<div class="panel panel-default bridgeServer">
|
<div class="page-header">
|
||||||
|
<h1>Configuration</h1>
|
||||||
|
</div>
|
||||||
|
<div class="panel panel-default bridgeServer">
|
||||||
<div class="panel-heading"><h1 class="panel-title">Bridge settings</h1></div>
|
<div class="panel-heading"><h1 class="panel-title">Bridge settings</h1></div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
|
|
||||||
<form class="form-horizontal">
|
<form class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-xs-12 col-sm-3 control-label" for="bridge-base">Bridge server</label>
|
<label class="col-xs-12 col-sm-3 control-label" for="bridge-base">Bridge
|
||||||
|
server</label>
|
||||||
<div class="col-xs-8 col-sm-7">
|
|
||||||
<input id="bridge-base" class="form-control" type="text" ng-model="bridge.base"
|
<div class="col-xs-8 col-sm-7">
|
||||||
placeholder="URL to bridge">
|
<input id="bridge-base" class="form-control" type="text"
|
||||||
</div>
|
ng-model="bridge.base" placeholder="URL to bridge">
|
||||||
<button type="submit" class="col-xs-2 col-sm-1 btn btn-primary"
|
</div>
|
||||||
ng-click="setBridgeUrl(bridge.base)">Load
|
<button type="submit" class="col-xs-2 col-sm-1 btn btn-primary"
|
||||||
</button>
|
ng-click="setBridgeUrl(bridge.base)">Load</button>
|
||||||
<button type="submit" class="col-xs-2 col-sm-1 btn btn-primary" ng-click="testUrl(bridge.base)">Go
|
<button type="submit" class="col-xs-2 col-sm-1 btn btn-primary"
|
||||||
</button>
|
ng-click="testUrl(bridge.base)">Go</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
</form>
|
||||||
<label class="col-xs-12 col-sm-3 control-label" for="bridge-base">upnp.config.address</label>
|
<table class="table table-bordered table-striped table-hover">
|
||||||
<div class="col-xs-8 col-sm-7">
|
<thead>
|
||||||
<input id="bridge-base" class="form-control" type="text" ng-model="bridge.upnpconfigaddress"
|
<tr>
|
||||||
placeholder="upnp config address setting" readonly>
|
<th>Setting</th>
|
||||||
</div>
|
<th>Value</th>
|
||||||
</div>
|
</tr>
|
||||||
</form>
|
</thead>
|
||||||
</div>
|
<tr>
|
||||||
</div>
|
<td>upnp.config.address</td>
|
||||||
|
<td>{{bridge.upnpconfigaddress}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>server.port</td>
|
||||||
|
<td>{{bridge.serverport}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>upnp.devices.db</td>
|
||||||
|
<td>{{bridge.upnpdevicedb}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>upnp.response.port</td>
|
||||||
|
<td>{{bridge.upnpresponseport}}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>vera.address</td>
|
||||||
|
<td>{{bridge.veraaddress}}</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div ng-controller="ErrorsController">
|
<div ng-controller="ErrorsController">
|
||||||
<div ng-if="bridge.error" class="alert alert-warning alert-dismissible" role="alert">
|
<div ng-if="bridge.error" class="alert alert-warning alert-dismissible" role="alert">
|
||||||
@@ -95,17 +142,85 @@
|
|||||||
<td>
|
<td>
|
||||||
<button class="btn btn-info" type="submit" ng-click="testUrl(device.onUrl)">Test ON</button>
|
<button class="btn btn-info" type="submit" ng-click="testUrl(device.onUrl)">Test ON</button>
|
||||||
<button class="btn btn-info" type="submit" ng-click="testUrl(device.offUrl)">Test OFF</button>
|
<button class="btn btn-info" type="submit" ng-click="testUrl(device.offUrl)">Test OFF</button>
|
||||||
<button class="btn btn-danger" type="submit" ng-click="editDevice(device)">Edit</button>
|
<button class="btn btn-warning" type="submit" ng-click="editDevice(device)">Edit</button>
|
||||||
<button class="btn btn-danger" type="submit" ng-click="deleteDevice(device)">Delete</button>
|
<button class="btn btn-danger" type="submit" ng-click="deleteDevice(device)">Delete</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<div ng-controller="AddingController">
|
<div ng-controller="AddingController">
|
||||||
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
|
<div class="page-header">
|
||||||
<div class="panel-heading"><h2 class="panel-title">Add a new device</h2></div>
|
<h1>Editor</h1>
|
||||||
|
</div>
|
||||||
|
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h2 class="panel-title">Vera Device List</h2>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<p class="text-muted">You can select a Vera device and
|
||||||
|
generate the add device box selections automatically.</p>
|
||||||
|
|
||||||
|
<table class="table table-bordered table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Category</th>
|
||||||
|
<th>Room</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr ng-repeat="veradevice in bridge.veradevices">
|
||||||
|
<td>{{veradevice.name}}</td>
|
||||||
|
<td>{{veradevice.id}}</td>
|
||||||
|
<td>{{veradevice.category}}</td>
|
||||||
|
<td>{{veradevice.room}}</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-success" type="submit"
|
||||||
|
ng-click="buildDeviceUrls(veradevice, bridge.veraaddress)">Generate Device URLs</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h2 class="panel-title">Vera Scene List</h2>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group">
|
||||||
|
<li class="list-group-item">
|
||||||
|
<p class="text-muted">You can select a Vera scene and
|
||||||
|
generate the add device box selections automatically.</p>
|
||||||
|
|
||||||
|
<table class="table table-bordered table-striped table-hover">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Name</th>
|
||||||
|
<th>Id</th>
|
||||||
|
<th>Room</th>
|
||||||
|
<th>Actions</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tr ng-repeat="verascene in bridge.verascenes">
|
||||||
|
<td>{{verascene.name}}</td>
|
||||||
|
<td>{{verascene.id}}</td>
|
||||||
|
<td>{{verascene.room}}</td>
|
||||||
|
<td>
|
||||||
|
<button class="btn btn-success" type="submit"
|
||||||
|
ng-click="buildSceneUrls(verascene, bridge.veraaddress)">Generate Device URLs</button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h2 class="panel-title">Generate a new device</h2>
|
||||||
|
</div>
|
||||||
<ul class="list-group">
|
<ul class="list-group">
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<p class="text-muted">You can generate on/off URLs by filling in the Vera server URL, port, and
|
<p class="text-muted">You can generate on/off URLs by filling in the Vera server URL, port, and
|
||||||
@@ -115,10 +230,14 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-xs-12 col-sm-2 control-label" for="vera-base">Vera Server URL </label>
|
<label class="col-xs-12 col-sm-2 control-label" for="vera-base">Vera Server URL </label>
|
||||||
|
|
||||||
<div class="col-xs-12 col-sm-10">
|
<div class="col-xs-8 col-sm-7">
|
||||||
<input type="text" class="form-control" id="vera-base" ng-model="vera.base"
|
<input type="text" class="form-control" id="vera-base" ng-model="vera.base"
|
||||||
placeholder="Vera URL (e.g. http://192.168.1.100)">
|
placeholder="Vera URL (e.g. http://192.168.1.100)">
|
||||||
</div>
|
</div>
|
||||||
|
<button type="submit" ng-click="setVeraAddress(bridge.veraaddress)"
|
||||||
|
class="col-xs-4 col-sm-2 btn btn-success">
|
||||||
|
Use vera.address
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label class="col-xs-2 col-sm-2 control-label" for="vera-port">Vera Request Port </label>
|
<label class="col-xs-2 col-sm-2 control-label" for="vera-port">Vera Request Port </label>
|
||||||
@@ -135,12 +254,19 @@
|
|||||||
placeholder="ID">
|
placeholder="ID">
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" ng-click="buildUrls()"
|
<button type="submit" ng-click="buildUrls()"
|
||||||
class="col-xs-offset-2 col-sm-offset-1 col-xs-4 col-sm-2 btn btn-success">
|
class="col-xs-4 col-sm-2 btn btn-success">
|
||||||
Generate URLs
|
Generate Device URLs
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</li>
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
<div class="panel panel-default bridgeServer" ng-if="!bridge.error">
|
||||||
|
<div class="panel-heading">
|
||||||
|
<h2 class="panel-title">Add a new device</h2>
|
||||||
|
</div>
|
||||||
|
<ul class="list-group">
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<form class="form-horizontal" ng-submit="addDevice()">
|
<form class="form-horizontal" ng-submit="addDevice()">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
@@ -181,8 +307,8 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
angular.module('amazonechobridge', [])
|
angular.module('habridge', [])
|
||||||
.service('bridgeService', ["$http", function ($http) {
|
.service('bridgeService', ["$http", function ($http) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/configaddress", devices: [], error: ""};
|
this.state = {base: window.location.origin + "/api/devices", upnpbase: window.location.origin + "/upnp/settings", devices: [], error: ""};
|
||||||
|
|
||||||
this.viewDevices = function () {
|
this.viewDevices = function () {
|
||||||
this.state.error = "";
|
this.state.error = "";
|
||||||
@@ -21,11 +21,51 @@ angular.module('amazonechobridge', [])
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.viewConfigAddress = function () {
|
this.viewBridgeSettings = function () {
|
||||||
this.state.error = "";
|
this.state.error = "";
|
||||||
return $http.get(this.state.upnpbase).then(
|
return $http.get(this.state.upnpbase).then(
|
||||||
function (response) {
|
function (response) {
|
||||||
self.state.upnpconfigaddress = response.data;
|
self.state.upnpconfigaddress = response.data.upnpconfigaddress;
|
||||||
|
self.state.serverport = response.data.serverport;
|
||||||
|
self.state.upnpdevicedb = response.data.upnpdevicedb;
|
||||||
|
self.state.upnpresponseport = response.data.upnpresponseport;
|
||||||
|
self.state.veraaddress = response.data.veraaddress;
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
if (error.data) {
|
||||||
|
self.state.error = error.data.message;
|
||||||
|
} else {
|
||||||
|
self.state.error = "If you're not seeing any address, you may be running into problems with CORS. " +
|
||||||
|
"You can work around this by running a fresh launch of Chrome with the --disable-web-security flag.";
|
||||||
|
}
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.viewVeraDevices = function () {
|
||||||
|
this.state.error = "";
|
||||||
|
return $http.get(this.state.base + "/vera/devices").then(
|
||||||
|
function (response) {
|
||||||
|
self.state.veradevices = response.data;
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
if (error.data) {
|
||||||
|
self.state.error = error.data.message;
|
||||||
|
} else {
|
||||||
|
self.state.error = "If you're not seeing any address, you may be running into problems with CORS. " +
|
||||||
|
"You can work around this by running a fresh launch of Chrome with the --disable-web-security flag.";
|
||||||
|
}
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.viewVeraScenes = function () {
|
||||||
|
this.state.error = "";
|
||||||
|
return $http.get(this.state.base + "/vera/scenes").then(
|
||||||
|
function (response) {
|
||||||
|
self.state.verascenes = response.data;
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
if (error.data) {
|
if (error.data) {
|
||||||
@@ -105,7 +145,9 @@ angular.module('amazonechobridge', [])
|
|||||||
|
|
||||||
.controller('ViewingController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
.controller('ViewingController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
||||||
bridgeService.viewDevices();
|
bridgeService.viewDevices();
|
||||||
bridgeService.viewConfigAddress();
|
bridgeService.viewBridgeSettings();
|
||||||
|
bridgeService.viewVeraDevices();
|
||||||
|
bridgeService.viewVeraScenes();
|
||||||
$scope.bridge = bridgeService.state;
|
$scope.bridge = bridgeService.state;
|
||||||
$scope.deleteDevice = function (device) {
|
$scope.deleteDevice = function (device) {
|
||||||
bridgeService.deleteDevice(device.id);
|
bridgeService.deleteDevice(device.id);
|
||||||
@@ -123,12 +165,10 @@ angular.module('amazonechobridge', [])
|
|||||||
}])
|
}])
|
||||||
|
|
||||||
.controller('AddingController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
.controller('AddingController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
||||||
|
|
||||||
$scope.bridge = bridgeService.state;
|
|
||||||
$scope.device = {id: "", name: "", type: "switch", onUrl: "", offUrl: ""};
|
$scope.device = {id: "", name: "", type: "switch", onUrl: "", offUrl: ""};
|
||||||
$scope.vera = {base: "", port: "3480", id: ""};
|
$scope.vera = {base: "", port: "3480", id: ""};
|
||||||
bridgeService.device = $scope.device;
|
bridgeService.device = $scope.device;
|
||||||
|
|
||||||
$scope.buildUrls = function () {
|
$scope.buildUrls = function () {
|
||||||
if ($scope.vera.base.indexOf("http") < 0) {
|
if ($scope.vera.base.indexOf("http") < 0) {
|
||||||
$scope.vera.base = "http://" + $scope.vera.base;
|
$scope.vera.base = "http://" + $scope.vera.base;
|
||||||
@@ -141,6 +181,36 @@ angular.module('amazonechobridge', [])
|
|||||||
+ $scope.vera.id;
|
+ $scope.vera.id;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.buildDeviceUrls = function (veradevice, veraaddr) {
|
||||||
|
if ($scope.vera.base.indexOf("http") < 0) {
|
||||||
|
$scope.vera.base = "http://" + veraaddr;
|
||||||
|
}
|
||||||
|
$scope.device.name = veradevice.name;
|
||||||
|
$scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||||
|
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum="
|
||||||
|
+ veradevice.id;
|
||||||
|
$scope.device.offUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||||
|
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum="
|
||||||
|
+ veradevice.id;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.buildSceneUrls = function (verascene, veraaddr) {
|
||||||
|
if ($scope.vera.base.indexOf("http") < 0) {
|
||||||
|
$scope.vera.base = "http://" + veraaddr;
|
||||||
|
}
|
||||||
|
$scope.device.name = verascene.name;
|
||||||
|
$scope.device.onUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||||
|
+ "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="
|
||||||
|
+ verascene.id;
|
||||||
|
$scope.device.offUrl = $scope.vera.base + ":" + $scope.vera.port
|
||||||
|
+ "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="
|
||||||
|
+ verascene.id;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.setVeraAddress = function (anAddress) {
|
||||||
|
$scope.vera.base = "http://" + anAddress;
|
||||||
|
};
|
||||||
|
|
||||||
$scope.testUrl = function (url) {
|
$scope.testUrl = function (url) {
|
||||||
window.open(url, "_blank");
|
window.open(url, "_blank");
|
||||||
};
|
};
|
||||||
@@ -157,6 +227,7 @@ angular.module('amazonechobridge', [])
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}])
|
}])
|
||||||
|
|
||||||
.controller('ErrorsController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
.controller('ErrorsController', ["$scope", "bridgeService", function ($scope, bridgeService) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package demo;
|
package demo;
|
||||||
|
|
||||||
import com.bwssytems.HABridge.AmazonEchoBridge;
|
import com.bwssystems.HABridge.HABridge;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Dummy test holder
|
* Dummy test holder
|
||||||
|
|||||||
Reference in New Issue
Block a user