From d071ef800a4af94954bdb16a52187dc15870a913 Mon Sep 17 00:00:00 2001 From: Duane May Date: Fri, 2 Oct 2015 21:30:31 -0400 Subject: [PATCH 01/12] clarifications to the README --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) mode change 100755 => 100644 README.md diff --git a/README.md b/README.md old mode 100755 new mode 100644 index cbd2e10..329056a --- a/README.md +++ b/README.md @@ -24,8 +24,13 @@ After the application is started and running, you can access the configurator by Input your devices using the form at the bottom of the page, add command URLs to parse (useful if you use a system like OpenHAB), and save. -Instruct your Amazon Echo to take control of your devices by saying "Alexa, discover my devices" and your all set! +Instruct your Amazon Echo to learn about your devices by saying "Alexa, discover my devices" and your all set! +## Using + +You can now control devices with your Amazon Echo by saying "Alexa, Turn on the office light" or other names you have given your configured devices. + +To view or remove devices that Alexa knows about, you can use the mobile app Menu / Settings / Connected Home, This is needed if you remove a device from the Amazon Echo Bridge. ## Build @@ -49,7 +54,7 @@ To build the jar file yourself, make your changes and simply run Maven like this mvn install ``` -Then locate the jar and start the server using the instructions above. +Then locate the jar and start the server using the instructions above. By default maven will put the jar file in the target directory. ```java -jar target/amazon-echo-bridge-*.jar``` ## POST/PUT REST API From 939dd4a2dd2708e417db66b7cb35e85dcc6a8e1f Mon Sep 17 00:00:00 2001 From: Duane May Date: Fri, 2 Oct 2015 22:13:28 -0400 Subject: [PATCH 02/12] update versions of spring-boot and httpclient to latest RELEASE --- pom.xml | 115 +++++++++++++++++++++++++++----------------------------- 1 file changed, 56 insertions(+), 59 deletions(-) mode change 100644 => 100755 pom.xml diff --git a/pom.xml b/pom.xml old mode 100644 new mode 100755 index 574a7c8..8d34158 --- a/pom.xml +++ b/pom.xml @@ -1,67 +1,64 @@ - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 - com.armzilla.ha - amazon-echo-bridge - 0.2.1 - jar + com.armzilla.ha + amazon-echo-bridge + 0.2.1 + jar - Amazon Echo Bridge - Emulates a Philips Hue bridge to allow the Amazon Echo to integrate seamlessly into various home automation systems. + Amazon Echo Bridge + Emulates a Philips Hue bridge to allow the Amazon Echo to integrate seamlessly into various home + automation systems. + - - org.springframework.boot - spring-boot-starter-parent - 1.2.3.RELEASE - - + + org.springframework.boot + spring-boot-starter-parent + 1.2.6.RELEASE + + + - - UTF-8 - com.armzilla.ha.SpringbootEntry - 1.8 - + + UTF-8 + com.armzilla.ha.SpringbootEntry + 1.8 + 4.5.1 + - - - org.springframework.boot - spring-boot-starter-actuator - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.data - spring-data-elasticsearch - - - - org.springframework.boot - spring-boot-starter-test - test - - - org.apache.httpcomponents - httpclient - 4.3.6 - - - - - - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.data + spring-data-elasticsearch + + + org.springframework.boot + spring-boot-starter-test + test + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + - + + + + org.springframework.boot + spring-boot-maven-plugin + + + + \ No newline at end of file From 42023a487cdf63900fb15889e4607106bcb1ff31 Mon Sep 17 00:00:00 2001 From: jlippold Date: Thu, 31 Dec 2015 19:31:39 -0500 Subject: [PATCH 03/12] Adds option to disable upnp listener this is needed so the echo does not discover devices when you dont tell it to. useful if you want to run multiple ha-bridges on one server --- src/main/java/com/armzilla/ha/upnp/UpnpListener.java | 8 ++++++++ src/main/resources/application.properties | 1 + 2 files changed, 9 insertions(+) diff --git a/src/main/java/com/armzilla/ha/upnp/UpnpListener.java b/src/main/java/com/armzilla/ha/upnp/UpnpListener.java index 00e59ec..686bc2e 100644 --- a/src/main/java/com/armzilla/ha/upnp/UpnpListener.java +++ b/src/main/java/com/armzilla/ha/upnp/UpnpListener.java @@ -32,11 +32,19 @@ public class UpnpListener { @Value("${upnp.config.address}") private String responseAddress; + @Value("${upnp.disable}") + private boolean disable; + @Autowired private ApplicationContext applicationContext; @Scheduled(fixedDelay = Integer.MAX_VALUE) public void startListening(){ + + if (disable) { + return; + } + log.info("Starting UPNP Discovery Listener"); try (DatagramSocket responseSocket = new DatagramSocket(upnpResponsePort); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ed8db7f..fec7dba 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,4 @@ upnp.response.port=50000 server.port=8080 upnp.config.address=192.168.1.1 +upnp.disable=false From 158c587878917693ee7bbce76d34760ebed84403 Mon Sep 17 00:00:00 2001 From: 1activegeek Date: Tue, 5 Jan 2016 11:34:43 -0500 Subject: [PATCH 04/12] Excess Memory Limit Adding in the `-Xmx256M` parameter per the suggestion in Issue #26. --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 5801fb6..4ffeab6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,4 +8,4 @@ RUN mvn install EXPOSE 8080 -CMD ["bash", "-c", "java -jar target/amazon-echo-bridge-*.jar --upnp.config.address=$(ip route get 8.8.8.8 | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\s*$')"] +CMD ["bash", "-c", "java -Xmx256M -jar target/amazon-echo-bridge-*.jar --upnp.config.address=$(ip route get 8.8.8.8 | egrep -o '[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\s*$')"] From c3c679009312503a1caa79262b7463c2c1b3b622 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Fri, 16 Sep 2016 00:10:19 -0500 Subject: [PATCH 05/12] add support for more than 25 devices by starting up multiple connectors. See applicatons.properties for how many ports to open --- .../java/com/armzilla/ha/SpringbootEntry.java | 9 ++++ .../com/armzilla/ha/TomcatConnectorBean.java | 45 +++++++++++++++++++ .../java/com/armzilla/ha/hue/HueMulator.java | 15 +++++-- .../com/armzilla/ha/upnp/UpnpListener.java | 20 ++++++--- .../ha/upnp/UpnpSettingsResource.java | 10 +++-- src/main/resources/application.properties | 4 +- 6 files changed, 89 insertions(+), 14 deletions(-) create mode 100644 src/main/java/com/armzilla/ha/TomcatConnectorBean.java diff --git a/src/main/java/com/armzilla/ha/SpringbootEntry.java b/src/main/java/com/armzilla/ha/SpringbootEntry.java index 304201e..5835e35 100644 --- a/src/main/java/com/armzilla/ha/SpringbootEntry.java +++ b/src/main/java/com/armzilla/ha/SpringbootEntry.java @@ -1,10 +1,17 @@ package com.armzilla.ha; +import org.apache.catalina.connector.Connector; +import org.apache.coyote.http11.Http11NioProtocol; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; +import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; +import java.io.IOException; + @SpringBootApplication @EnableScheduling @ComponentScan @@ -13,4 +20,6 @@ public class SpringbootEntry { public static void main(String[] args) { SpringApplication.run(SpringbootEntry.class, args); } + + } diff --git a/src/main/java/com/armzilla/ha/TomcatConnectorBean.java b/src/main/java/com/armzilla/ha/TomcatConnectorBean.java new file mode 100644 index 0000000..e802566 --- /dev/null +++ b/src/main/java/com/armzilla/ha/TomcatConnectorBean.java @@ -0,0 +1,45 @@ +package com.armzilla.ha; + +import org.apache.catalina.connector.Connector; +import org.apache.coyote.http11.Http11NioProtocol; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; +import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.stereotype.Component; + +import java.util.Set; + +/** + * Created by arm on 9/12/15. + */ +@Component + +public class TomcatConnectorBean { + @Value("${emulator.portbase}") + private int portBase; + @Value("${emulator.portcount}") + private int portCount; + @Bean + public EmbeddedServletContainerFactory servletContainer() { + TomcatEmbeddedServletContainerFactory tomcat = null; + for(int i = 0; i < portCount; i ++) { + if(tomcat == null){ + tomcat = new TomcatEmbeddedServletContainerFactory(portBase + i); + }else{ + tomcat.addAdditionalTomcatConnectors(createConnector(portBase + i)); + } + } + return tomcat; + } + + private Connector createConnector(int portNumber) { + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + Http11NioProtocol protocol = (Http11NioProtocol) connector.getProtocolHandler(); + connector.setScheme("http"); + connector.setPort(portNumber); + return connector; + } +} diff --git a/src/main/java/com/armzilla/ha/hue/HueMulator.java b/src/main/java/com/armzilla/ha/hue/HueMulator.java index 35af355..f15b197 100644 --- a/src/main/java/com/armzilla/ha/hue/HueMulator.java +++ b/src/main/java/com/armzilla/ha/hue/HueMulator.java @@ -19,6 +19,7 @@ import org.apache.http.util.EntityUtils; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.http.HttpHeaders; @@ -50,6 +51,10 @@ public class HueMulator { private HttpClient httpClient; private ObjectMapper mapper; + @Value("${emulator.portbase}") + private int portBase; + @Value("${emulator.portcount}") + private int portCount; public HueMulator(){ httpClient = HttpClients.createDefault(); //patched for now, moving away from HueMulator doing work @@ -60,8 +65,10 @@ public HueMulator(){ @RequestMapping(value = "/{userId}/lights", method = RequestMethod.GET, produces = "application/json") public ResponseEntity> getUpnpConfiguration(@PathVariable(value = "userId") String userId, HttpServletRequest request) { - log.info("hue lights list requested: " + userId + " from " + request.getRemoteAddr()); - Page deviceList = repository.findByDeviceType("switch", new PageRequest(0,100)); + log.info("hue lights list requested: " + userId + " from " + request.getRemoteAddr() + request.getLocalPort()); + + int pageNumber = request.getLocalPort()-portBase; + Page deviceList = repository.findByDeviceType("switch", new PageRequest(pageNumber, 25)); Map deviceResponseMap = new HashMap<>(); for (DeviceDescriptor device : deviceList) { deviceResponseMap.put(device.getId(), device.getName()); @@ -71,13 +78,15 @@ public ResponseEntity> getUpnpConfiguration(@PathVariable(va @RequestMapping(value = "/*", method = RequestMethod.POST, produces = "application/json") public ResponseEntity postAPI(HttpServletRequest request) { + log.info("registered device: " + request.toString()); return new ResponseEntity("[{\"success\":{\"username\":\"lights\"}}]", HttpStatus.OK); } @RequestMapping(value = "/{userId}", method = RequestMethod.GET, produces = "application/json") public ResponseEntity getApi(@PathVariable(value = "userId") String userId, HttpServletRequest request) { log.info("hue api root requested: " + userId + " from " + request.getRemoteAddr()); - Page descriptorList = repository.findByDeviceType("switch", new PageRequest(0, 100)); + int pageNumber = request.getLocalPort()-portBase; + Page descriptorList = repository.findByDeviceType("switch", new PageRequest(pageNumber, 25)); if (descriptorList == null) { return new ResponseEntity<>(null, null, HttpStatus.NOT_FOUND); } diff --git a/src/main/java/com/armzilla/ha/upnp/UpnpListener.java b/src/main/java/com/armzilla/ha/upnp/UpnpListener.java index 00e59ec..b169946 100644 --- a/src/main/java/com/armzilla/ha/upnp/UpnpListener.java +++ b/src/main/java/com/armzilla/ha/upnp/UpnpListener.java @@ -1,5 +1,6 @@ package com.armzilla.ha.upnp; +import com.armzilla.ha.PortsConfiguration; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -26,12 +27,17 @@ public class UpnpListener { @Value("${upnp.response.port}") private int upnpResponsePort; - @Value("${server.port}") - private int httpServerPort; + @Autowired + private PortsConfiguration portsConfiguration; @Value("${upnp.config.address}") private String responseAddress; + @Value("${emulator.portbase}") + private int portBase; + @Value("${emulator.portcount}") + private int portCount; + @Autowired private ApplicationContext applicationContext; @@ -71,7 +77,9 @@ public void startListening(){ String packetString = new String(packet.getData()); if(isSSDPDiscovery(packetString)){ log.debug("Got SSDP Discovery packet from " + packet.getAddress().getHostAddress() + ":" + packet.getPort()); - sendUpnpResponse(responseSocket, packet.getAddress(), packet.getPort()); + for(int i = 0; i < portCount; i ++) { + sendUpnpResponse(responseSocket, packet.getAddress(), packet.getPort(), portBase+i, i); + } } } @@ -100,13 +108,13 @@ protected boolean isSSDPDiscovery(String body){ String discoveryTemplate = "HTTP/1.1 200 OK\r\n" + "CACHE-CONTROL: max-age=86400\r\n" + "EXT:\r\n" + - "LOCATION: http://%s:%s/upnp/amazon-ha-bridge/setup.xml\r\n" + + "LOCATION: http://%s:%s/upnp/%s/setup.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 = String.format(discoveryTemplate, responseAddress, httpServerPort, getRandomUUIDString()); + protected void sendUpnpResponse(DatagramSocket socket, InetAddress requester, int sourcePort, int gatewayPort, int emulatorId) throws IOException { + String discoveryResponse = String.format(discoveryTemplate, responseAddress, gatewayPort, "amazon-ha-bridge" + emulatorId, "D1710C33-328D-4152-A5FA-5382541A92FF"); DatagramPacket response = new DatagramPacket(discoveryResponse.getBytes(), discoveryResponse.length(), requester, sourcePort); socket.send(response); } diff --git a/src/main/java/com/armzilla/ha/upnp/UpnpSettingsResource.java b/src/main/java/com/armzilla/ha/upnp/UpnpSettingsResource.java index b8fbcc6..dd90b01 100644 --- a/src/main/java/com/armzilla/ha/upnp/UpnpSettingsResource.java +++ b/src/main/java/com/armzilla/ha/upnp/UpnpSettingsResource.java @@ -1,6 +1,7 @@ package com.armzilla.ha.upnp; import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Value; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Controller; @@ -16,8 +17,9 @@ @Controller @RequestMapping("/upnp") public class UpnpSettingsResource { - private Logger log = Logger.getLogger(UpnpSettingsResource.class); + @Value("${emulator.portcount}") + private int portCount; private String hueTemplate = "\n" + "\n" + @@ -35,8 +37,8 @@ public class UpnpSettingsResource { "Philips hue bridge 2012\n" + "929000226503\n" + "http://www.armzilla.com/amazon-echo-ha-bridge\n" + - "01189998819991197253\n" + - "uuid:88f6698f-2c83-4393-bd03-cd54a9f8595\n" + + "%s\n" + + "uuid:%s\n" + "\n" + "\n" + "(null)\n" + @@ -72,7 +74,7 @@ public ResponseEntity getUpnpConfiguration(@PathVariable(value="deviceId log.info("upnp device settings requested: " + deviceId + " from " + request.getRemoteAddr()); String hostName = request.getLocalAddr(); String portNumber = Integer.toString(request.getLocalPort()); - String filledTemplate = String.format(hueTemplate, hostName, portNumber, hostName); + String filledTemplate = String.format(hueTemplate, hostName, request.getLocalPort(), hostName, deviceId, deviceId); return new ResponseEntity<>(filledTemplate, null, HttpStatus.OK); } diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index ed8db7f..f0dec91 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,3 +1,5 @@ upnp.response.port=50000 -server.port=8080 upnp.config.address=192.168.1.1 +devices.per.gateway=5 +portBase=8080 +portCount=3 From e52783b1b072d9c252cb2201c2212d5fed3e1c10 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Fri, 16 Sep 2016 00:14:37 -0500 Subject: [PATCH 06/12] removed old ref to experimental port class --- src/main/java/com/armzilla/ha/upnp/UpnpListener.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/armzilla/ha/upnp/UpnpListener.java b/src/main/java/com/armzilla/ha/upnp/UpnpListener.java index b169946..6523f50 100644 --- a/src/main/java/com/armzilla/ha/upnp/UpnpListener.java +++ b/src/main/java/com/armzilla/ha/upnp/UpnpListener.java @@ -1,6 +1,5 @@ package com.armzilla.ha.upnp; -import com.armzilla.ha.PortsConfiguration; import org.apache.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -27,9 +26,6 @@ public class UpnpListener { @Value("${upnp.response.port}") private int upnpResponsePort; - @Autowired - private PortsConfiguration portsConfiguration; - @Value("${upnp.config.address}") private String responseAddress; From df39d549701a53885a972ede2cf2a0795dc48c15 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Fri, 16 Sep 2016 00:19:53 -0500 Subject: [PATCH 07/12] fixed oopsies in app.properties, tired --- src/main/resources/application.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index f0dec91..7bef4b0 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -1,5 +1,5 @@ upnp.response.port=50000 upnp.config.address=192.168.1.1 devices.per.gateway=5 -portBase=8080 -portCount=3 +emulator.portbase=8080 +emulator.portcount=3 From 2717fb7d8e0e4a90f61b091ede6c684580d96516 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Fri, 16 Sep 2016 16:26:55 -0500 Subject: [PATCH 08/12] fixed 'tests' --- src/main/java/com/armzilla/ha/SpringbootEntry.java | 2 +- src/test/java/demo/DemoApplicationTests.java | 2 ++ src/test/resources/test.properties | 5 +++++ 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/test.properties diff --git a/src/main/java/com/armzilla/ha/SpringbootEntry.java b/src/main/java/com/armzilla/ha/SpringbootEntry.java index 08907b9..93009c1 100644 --- a/src/main/java/com/armzilla/ha/SpringbootEntry.java +++ b/src/main/java/com/armzilla/ha/SpringbootEntry.java @@ -21,5 +21,5 @@ public class SpringbootEntry { public static void main(String[] args) { SpringApplication.run(SpringbootEntry.class, args); } - + } diff --git a/src/test/java/demo/DemoApplicationTests.java b/src/test/java/demo/DemoApplicationTests.java index 8ca1356..2f51058 100644 --- a/src/test/java/demo/DemoApplicationTests.java +++ b/src/test/java/demo/DemoApplicationTests.java @@ -3,12 +3,14 @@ import com.armzilla.ha.SpringbootEntry; import org.junit.Test; import org.junit.runner.RunWith; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.web.WebAppConfiguration; import org.springframework.boot.test.SpringApplicationConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; @RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = SpringbootEntry.class) +@TestPropertySource(locations="classpath:test.properties") @WebAppConfiguration public class DemoApplicationTests { diff --git a/src/test/resources/test.properties b/src/test/resources/test.properties new file mode 100644 index 0000000..841379d --- /dev/null +++ b/src/test/resources/test.properties @@ -0,0 +1,5 @@ +upnp.response.port=50000 +upnp.config.address=192.168.1.1 +emulator.portbase=8080 +emulator.portcount=3 +upnp.disable=false From 0f2b4980aa6b9cd08298a6f7c9b19eae538cd2af Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Fri, 16 Sep 2016 16:50:22 -0500 Subject: [PATCH 09/12] readme update --- README.md | 11 +++++++++++ pom.xml | 4 ++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 329056a..eef0706 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,17 @@ Amazon Echo Bridge allows you to quickly emulate a Phillips Hue bridge, bringing Also, with an easy to use POST/PUT REST API, it's never been easier before to get your devices up and running with the Amazon Echo with your own embedded applications! +## Release notes: +v0.4.0 +change log: + +* require --upnp.config.address= to be specified during startup +* support more than 25 emulated devices currently set to 75, can be increased at 25 device increments by specifying --emulator.portcount= default is 3 thus 3*25 = 75 total devices. Works by taking emulator.baseport and opening n number of ports sequentially from baseport to baseport+portcount +* relaxed http response codes to anything in the 200 to less than 300 http response codes to support misbehaving resources + +other notes: +Ive seen some folks able to run this but not able to discover devices. I would recommend checking for duplicated devices names as i have seen this to cause the echo to reject all devices. The lazy way would be to delete the /data directory and start over. + ## Quick Start There are currently three different ways to run the pre-built jar file: diff --git a/pom.xml b/pom.xml index 8d34158..52dab98 100755 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.armzilla.ha amazon-echo-bridge - 0.2.1 + 0.4.0 jar Amazon Echo Bridge @@ -61,4 +61,4 @@ - \ No newline at end of file + From ecf2db21fc3311d5d57398c8dc79252208a291b6 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Fri, 16 Sep 2016 16:52:04 -0500 Subject: [PATCH 10/12] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index eef0706..884f24c 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ change log: * relaxed http response codes to anything in the 200 to less than 300 http response codes to support misbehaving resources other notes: -Ive seen some folks able to run this but not able to discover devices. I would recommend checking for duplicated devices names as i have seen this to cause the echo to reject all devices. The lazy way would be to delete the /data directory and start over. +Ive seen some folks able to run this but not able to discover devices. I would recommend checking for devices with duplicate names as i have seen this to cause the echo to reject all devices. The lazy way would be to delete the /data directory and start over. ## Quick Start From 266ab2e27132a4bbf943b198ce5fb5805076ded3 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Sun, 23 Feb 2020 22:48:15 -0600 Subject: [PATCH 11/12] switch to h2 for store, cleanup imports --- pom.xml | 10 ++++++++-- src/main/java/com/armzilla/ha/SpringbootEntry.java | 10 ---------- src/main/java/com/armzilla/ha/TomcatConnectorBean.java | 4 ---- .../java/com/armzilla/ha/api/hue/HueApiResponse.java | 2 -- .../java/com/armzilla/ha/dao/DeviceDescriptor.java | 9 ++++++--- .../java/com/armzilla/ha/dao/DeviceRepository.java | 5 ++--- src/main/resources/application.properties | 7 +++++++ 7 files changed, 23 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 52dab98..6950b74 100755 --- a/pom.xml +++ b/pom.xml @@ -38,8 +38,8 @@ spring-boot-starter-web - org.springframework.data - spring-data-elasticsearch + org.springframework.boot + spring-boot-starter-data-jpa org.springframework.boot @@ -51,6 +51,12 @@ httpclient ${httpclient.version} + + + com.h2database + h2 + runtime + diff --git a/src/main/java/com/armzilla/ha/SpringbootEntry.java b/src/main/java/com/armzilla/ha/SpringbootEntry.java index 93009c1..c965ca5 100644 --- a/src/main/java/com/armzilla/ha/SpringbootEntry.java +++ b/src/main/java/com/armzilla/ha/SpringbootEntry.java @@ -1,21 +1,11 @@ package com.armzilla.ha; -import org.apache.catalina.connector.Connector; -import org.apache.coyote.http11.Http11NioProtocol; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; -import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.ComponentScan; import org.springframework.scheduling.annotation.EnableScheduling; -import java.io.IOException; - @SpringBootApplication @EnableScheduling -@ComponentScan public class SpringbootEntry { public static void main(String[] args) { diff --git a/src/main/java/com/armzilla/ha/TomcatConnectorBean.java b/src/main/java/com/armzilla/ha/TomcatConnectorBean.java index e802566..2fc132f 100644 --- a/src/main/java/com/armzilla/ha/TomcatConnectorBean.java +++ b/src/main/java/com/armzilla/ha/TomcatConnectorBean.java @@ -2,16 +2,12 @@ import org.apache.catalina.connector.Connector; import org.apache.coyote.http11.Http11NioProtocol; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory; import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory; -import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Bean; import org.springframework.stereotype.Component; -import java.util.Set; - /** * Created by arm on 9/12/15. */ diff --git a/src/main/java/com/armzilla/ha/api/hue/HueApiResponse.java b/src/main/java/com/armzilla/ha/api/hue/HueApiResponse.java index 67e360e..d7d996b 100644 --- a/src/main/java/com/armzilla/ha/api/hue/HueApiResponse.java +++ b/src/main/java/com/armzilla/ha/api/hue/HueApiResponse.java @@ -1,7 +1,5 @@ package com.armzilla.ha.api.hue; -import com.armzilla.ha.api.hue.DeviceResponse; - import java.util.Map; /** diff --git a/src/main/java/com/armzilla/ha/dao/DeviceDescriptor.java b/src/main/java/com/armzilla/ha/dao/DeviceDescriptor.java index 30e0fb5..d92e31f 100644 --- a/src/main/java/com/armzilla/ha/dao/DeviceDescriptor.java +++ b/src/main/java/com/armzilla/ha/dao/DeviceDescriptor.java @@ -1,12 +1,15 @@ package com.armzilla.ha.dao; -import org.springframework.data.annotation.Id; -import org.springframework.data.elasticsearch.annotations.Document; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; /** * Created by arm on 4/13/15. */ -@Document(indexName = "device", type = "devicedescriptor", shards = 1, replicas = 0, refreshInterval = "-1") +@Entity +@Table(name = "devices") + public class DeviceDescriptor{ @Id private String id; diff --git a/src/main/java/com/armzilla/ha/dao/DeviceRepository.java b/src/main/java/com/armzilla/ha/dao/DeviceRepository.java index 3b0a80d..83d1f48 100644 --- a/src/main/java/com/armzilla/ha/dao/DeviceRepository.java +++ b/src/main/java/com/armzilla/ha/dao/DeviceRepository.java @@ -1,16 +1,15 @@ package com.armzilla.ha.dao; import org.springframework.data.domain.Page; -import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; -import org.springframework.data.elasticsearch.repository.ElasticsearchRepository; +import org.springframework.data.repository.CrudRepository; import java.util.List; /** * Created by arm on 4/13/15. */ -public interface DeviceRepository extends ElasticsearchRepository { +public interface DeviceRepository extends CrudRepository { Page findByDeviceType(String type, Pageable request); List findAll(); DeviceDescriptor findOne(String id); diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index cc21dfe..731a84f 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -3,3 +3,10 @@ upnp.config.address= emulator.portbase=8080 emulator.portcount=3 upnp.disable=false + + +spring.datasource.driverClassName=org.h2.Driver +spring.datasource.username=echo +spring.datasource.password=echo +spring.jpa.database-platform=org.hibernate.dialect.H2Dialect +spring.datasource.url=jdbc:h2:file:./store From 1862f76b0441ce1b555fbdc05b2083224a9ae517 Mon Sep 17 00:00:00 2001 From: Arm Suwarnaratana Date: Sun, 23 Feb 2020 23:12:01 -0600 Subject: [PATCH 12/12] thanks stackoverflow! persist db instead of creating new file --- src/main/resources/application.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties index 731a84f..2fe75d1 100644 --- a/src/main/resources/application.properties +++ b/src/main/resources/application.properties @@ -10,3 +10,4 @@ spring.datasource.username=echo spring.datasource.password=echo spring.jpa.database-platform=org.hibernate.dialect.H2Dialect spring.datasource.url=jdbc:h2:file:./store +spring.jpa.hibernate.ddl-auto=update