mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-19 16:41:53 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a5ee0aafc8 | ||
|
|
aed8ffa8d3 | ||
|
|
369e5a25e6 | ||
|
|
3fe19f5d4e | ||
|
|
5736bb92db | ||
|
|
b61f334826 | ||
|
|
556a5fef1c |
7
pom.xml
7
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>5.3.0RC7</version>
|
<version>5.3.0RC9</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
@@ -134,6 +134,11 @@
|
|||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.5</version>
|
<version>3.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jmdns</groupId>
|
||||||
|
<artifactId>jmdns</artifactId>
|
||||||
|
<version>3.5.5</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|||||||
@@ -186,9 +186,7 @@ public class DeviceRepository extends BackupHandler {
|
|||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
if (descriptors[i].getUniqueid() == null || descriptors[i].getUniqueid().length() == 0) {
|
if (descriptors[i].getUniqueid() == null || descriptors[i].getUniqueid().length() == 0) {
|
||||||
String hexValue = HexLibrary.encodeUsingBigIntegerToString(descriptors[i].getId());
|
descriptors[i].setUniqueid("00:17:88:5E:D3:" + hueUniqueId(Integer.valueOf(descriptors[i].getId())));
|
||||||
|
|
||||||
descriptors[i].setUniqueid("00:17:88:5E:D3:" + hexValue + "-" + hexValue);
|
|
||||||
}
|
}
|
||||||
put(descriptors[i].getId(), descriptors[i]);
|
put(descriptors[i].getId(), descriptors[i]);
|
||||||
theNames = theNames + " " + descriptors[i].getName() + ", ";
|
theNames = theNames + " " + descriptors[i].getName() + ", ";
|
||||||
@@ -203,8 +201,6 @@ public class DeviceRepository extends BackupHandler {
|
|||||||
Iterator<DeviceDescriptor> deviceIterator = list.iterator();
|
Iterator<DeviceDescriptor> deviceIterator = list.iterator();
|
||||||
Map<String, DeviceDescriptor> newdevices = new HashMap<String, DeviceDescriptor>();
|
Map<String, DeviceDescriptor> newdevices = new HashMap<String, DeviceDescriptor>();
|
||||||
List<String> lockedIds = new ArrayList<String>();
|
List<String> lockedIds = new ArrayList<String>();
|
||||||
String hexValue;
|
|
||||||
Integer newValue;
|
|
||||||
DeviceDescriptor theDevice;
|
DeviceDescriptor theDevice;
|
||||||
boolean findNext = true;
|
boolean findNext = true;
|
||||||
|
|
||||||
@@ -230,14 +226,7 @@ public class DeviceRepository extends BackupHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
theDevice.setId(String.valueOf(nextId));
|
theDevice.setId(String.valueOf(nextId));
|
||||||
newValue = nextId % 256;
|
theDevice.setUniqueid("00:17:88:5E:D3:" + hueUniqueId(nextId));
|
||||||
if (newValue <= 0)
|
|
||||||
newValue = 1;
|
|
||||||
else if (newValue > 255)
|
|
||||||
newValue = 255;
|
|
||||||
hexValue = HexLibrary.encodeUsingBigIntegerToString(newValue.toString());
|
|
||||||
|
|
||||||
theDevice.setUniqueid("00:17:88:5E:D3:" + hexValue + "-" + hexValue);
|
|
||||||
nextId++;
|
nextId++;
|
||||||
}
|
}
|
||||||
newdevices.put(theDevice.getId(), theDevice);
|
newdevices.put(theDevice.getId(), theDevice);
|
||||||
@@ -304,4 +293,29 @@ public class DeviceRepository extends BackupHandler {
|
|||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String hueUniqueId(Integer anId) {
|
||||||
|
String theUniqueId;
|
||||||
|
Integer newValue;
|
||||||
|
String hexValueLeft;
|
||||||
|
String hexValueRight;
|
||||||
|
|
||||||
|
newValue = anId % 256;
|
||||||
|
if (newValue <= 0)
|
||||||
|
newValue = 1;
|
||||||
|
else if (newValue > 255)
|
||||||
|
newValue = 255;
|
||||||
|
hexValueLeft = HexLibrary.byteToHex(newValue.byteValue());
|
||||||
|
newValue = anId / 256;
|
||||||
|
newValue = newValue % 256;
|
||||||
|
if (newValue < 0)
|
||||||
|
newValue = 0;
|
||||||
|
else if (newValue > 255)
|
||||||
|
newValue = 255;
|
||||||
|
hexValueRight = HexLibrary.byteToHex(newValue.byteValue());
|
||||||
|
|
||||||
|
theUniqueId = String.format("%s-%s", hexValueLeft, hexValueRight).toUpperCase();
|
||||||
|
|
||||||
|
return theUniqueId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,15 +19,20 @@ public class MozIotInstance {
|
|||||||
private JWT moziotToken;
|
private JWT moziotToken;
|
||||||
private NamedIP mozIotIP;
|
private NamedIP mozIotIP;
|
||||||
private NameValue[] headers;
|
private NameValue[] headers;
|
||||||
|
private HTTPHandler anHttpClient;
|
||||||
|
|
||||||
public MozIotInstance(NamedIP theNamedIp, HTTPHandler httpClient) {
|
public MozIotInstance(NamedIP theNamedIp, HTTPHandler httpClient) {
|
||||||
mozIotIP = theNamedIp;
|
mozIotIP = theNamedIp;
|
||||||
headers = null;
|
headers = null;
|
||||||
gatewayLogin(httpClient);
|
moziotToken = null;
|
||||||
|
anHttpClient = httpClient;
|
||||||
|
gatewayLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean callCommand(String deviceId, String aCommand, MozIotCommandDetail commandData, HTTPHandler httpClient) {
|
public Boolean callCommand(String deviceId, String aCommand, MozIotCommandDetail commandData,
|
||||||
log.debug("calling Mozilla IOT: {}:{}{}{}", mozIotIP.getIp(), mozIotIP.getPort(), aCommand, commandData.getBody());
|
HTTPHandler httpClient) {
|
||||||
|
log.debug("calling Mozilla IOT: {}:{}{}{}", mozIotIP.getIp(), mozIotIP.getPort(), aCommand,
|
||||||
|
commandData.getBody());
|
||||||
String aUrl = null;
|
String aUrl = null;
|
||||||
|
|
||||||
if (mozIotIP.getSecure() != null && mozIotIP.getSecure())
|
if (mozIotIP.getSecure() != null && mozIotIP.getSecure())
|
||||||
@@ -37,7 +42,8 @@ public class MozIotInstance {
|
|||||||
headers = getAuthHeader();
|
headers = getAuthHeader();
|
||||||
|
|
||||||
aUrl = aUrl + mozIotIP.getIp() + ":" + mozIotIP.getPort() + "/things/" + deviceId + "/" + aCommand;
|
aUrl = aUrl + mozIotIP.getIp() + ":" + mozIotIP.getPort() + "/things/" + deviceId + "/" + aCommand;
|
||||||
String theData = httpClient.doHttpRequest(aUrl, HttpPut.METHOD_NAME, "application/json", commandData.getBody(), headers);
|
String theData = httpClient.doHttpRequest(aUrl, HttpPut.METHOD_NAME, "application/json", commandData.getBody(),
|
||||||
|
headers);
|
||||||
log.debug("call Command return is: <<<{}>>>", theData);
|
log.debug("call Command return is: <<<{}>>>", theData);
|
||||||
if (theData.contains("error") || theData.contains("ERROR") || theData.contains("Error"))
|
if (theData.contains("error") || theData.contains("ERROR") || theData.contains("Error"))
|
||||||
return false;
|
return false;
|
||||||
@@ -77,7 +83,10 @@ public class MozIotInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NameValue[] getAuthHeader() {
|
private NameValue[] getAuthHeader() {
|
||||||
if (headers == null) {
|
if (moziotToken == null)
|
||||||
|
gatewayLogin();
|
||||||
|
|
||||||
|
if (headers == null && moziotToken != null) {
|
||||||
headers = new NameValue[3];
|
headers = new NameValue[3];
|
||||||
headers[0] = new NameValue();
|
headers[0] = new NameValue();
|
||||||
headers[0].setName("Authorization");
|
headers[0].setName("Authorization");
|
||||||
@@ -92,9 +101,10 @@ public class MozIotInstance {
|
|||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gatewayLogin(HTTPHandler httpClient) {
|
private void gatewayLogin() {
|
||||||
String aUrl = null;
|
String aUrl = null;
|
||||||
|
|
||||||
|
moziotToken = null;
|
||||||
if (mozIotIP.getSecure() != null && mozIotIP.getSecure())
|
if (mozIotIP.getSecure() != null && mozIotIP.getSecure())
|
||||||
aUrl = "https://";
|
aUrl = "https://";
|
||||||
else
|
else
|
||||||
@@ -112,13 +122,15 @@ public class MozIotInstance {
|
|||||||
String commandData = "{\"email\": \"" + mozIotIP.getUsername() + "\", \"password\":\"" + mozIotIP.getPassword()
|
String commandData = "{\"email\": \"" + mozIotIP.getUsername() + "\", \"password\":\"" + mozIotIP.getPassword()
|
||||||
+ "\"}";
|
+ "\"}";
|
||||||
log.debug("The login body: {}", commandData);
|
log.debug("The login body: {}", commandData);
|
||||||
String theData = httpClient.doHttpRequest(aUrl, HttpPost.METHOD_NAME, "application/json", commandData, headers);
|
String theData = anHttpClient.doHttpRequest(aUrl, HttpPost.METHOD_NAME, "application/json", commandData,
|
||||||
|
headers);
|
||||||
if (theData != null) {
|
if (theData != null) {
|
||||||
log.debug("GET Mozilla login - data: {}", theData);
|
log.debug("GET Mozilla login - data: {}", theData);
|
||||||
try {
|
try {
|
||||||
moziotToken = new Gson().fromJson(theData, JWT.class);
|
moziotToken = new Gson().fromJson(theData, JWT.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Cannot get login for Mozilla IOT {} Gson Parse Error.", mozIotIP.getName());
|
log.warn("Cannot get login for Mozilla IOT {} Gson Parse Error.", mozIotIP.getName());
|
||||||
|
moziotToken = null;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
log.warn("Could not login {} error: <<<{}>>>", mozIotIP.getName(), theData);
|
log.warn("Could not login {} error: <<<{}>>>", mozIotIP.getName(), theData);
|
||||||
|
|||||||
@@ -7,9 +7,9 @@ import com.google.gson.annotations.SerializedName;
|
|||||||
|
|
||||||
public class MozillaThing {
|
public class MozillaThing {
|
||||||
|
|
||||||
@SerializedName("name")
|
@SerializedName("title")
|
||||||
@Expose
|
@Expose
|
||||||
private String name;
|
private String title;
|
||||||
@SerializedName("type")
|
@SerializedName("type")
|
||||||
@Expose
|
@Expose
|
||||||
private String type;
|
private String type;
|
||||||
@@ -47,14 +47,6 @@ public class MozillaThing {
|
|||||||
@Expose
|
@Expose
|
||||||
private Object iconHref;
|
private Object iconHref;
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(String name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
@@ -151,4 +143,12 @@ public class MozillaThing {
|
|||||||
this.iconHref = iconHref;
|
this.iconHref = iconHref;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,13 +12,17 @@ import com.bwssystems.HABridge.util.UDPDatagramSender;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.*;
|
import java.net.*;
|
||||||
import java.time.Instant;
|
// import java.time.Instant;
|
||||||
import java.time.temporal.ChronoUnit;
|
// import java.time.temporal.ChronoUnit;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
|
|
||||||
import org.apache.http.conn.util.*;
|
import org.apache.http.conn.util.*;
|
||||||
|
import javax.jmdns.JmDNS;
|
||||||
|
import javax.jmdns.ServiceInfo;
|
||||||
|
|
||||||
public class UpnpListener {
|
public class UpnpListener {
|
||||||
private Logger log = LoggerFactory.getLogger(UpnpListener.class);
|
private Logger log = LoggerFactory.getLogger(UpnpListener.class);
|
||||||
|
private UDPDatagramSender theUDPDatagramSender;
|
||||||
private MulticastSocket upnpMulticastSocket;
|
private MulticastSocket upnpMulticastSocket;
|
||||||
private int httpServerPort;
|
private int httpServerPort;
|
||||||
private String upnpConfigIP;
|
private String upnpConfigIP;
|
||||||
@@ -31,41 +35,67 @@ public class UpnpListener {
|
|||||||
private String bridgeSNUUID;
|
private String bridgeSNUUID;
|
||||||
private HuePublicConfig aHueConfig;
|
private HuePublicConfig aHueConfig;
|
||||||
private Integer theUpnpSendDelay;
|
private Integer theUpnpSendDelay;
|
||||||
private String responseTemplateOriginal = "HTTP/1.1 200 OK\r\n" + "CACHE-CONTROL: max-age=86400\r\n" + "EXT:\r\n"
|
private String responseTemplate1 = "HTTP/1.1 200 OK\r\n" +
|
||||||
+ "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: FreeRTOS/6.0.5, UPnP/1.0, IpBridge/"
|
"HOST: %s:%s\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "ST: urn:schemas-upnp-org:device:basic:1\r\n" + "USN: uuid:"
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
+ HueConstants.UUID_PREFIX + "%s::urn:schemas-upnp-org:device:basic:1\r\n\r\n";
|
"EXT:\r\n" +
|
||||||
private String responseTemplate1 = "HTTP/1.1 200 OK\r\n" + "HOST: %s:%s\r\n" + "CACHE-CONTROL: max-age=100\r\n"
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
+ "EXT:\r\n" + "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/"
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "hue-bridgeid: %s\r\n" + "ST: upnp:rootdevice\r\n" + "USN: uuid:"
|
"HUE-BRIDGEID: %s\r\n" +
|
||||||
+ HueConstants.UUID_PREFIX + "%s::upnp:rootdevice\r\n\r\n";
|
"ST: upnp:rootdevice\r\n" +
|
||||||
private String responseTemplate2 = "HTTP/1.1 200 OK\r\n" + "HOST: %s:%s\r\n" + "CACHE-CONTROL: max-age=100\r\n"
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s::upnp:rootdevice\r\n\r\n";
|
||||||
+ "EXT:\r\n" + "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/"
|
private String responseTemplate2 = "HTTP/1.1 200 OK\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "hue-bridgeid: %s\r\n" + "ST: uuid:" + HueConstants.UUID_PREFIX
|
"HOST: %s:%s\r\n" +
|
||||||
+ "%s\r\n" + "USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
private String responseTemplate3 = "HTTP/1.1 200 OK\r\n" + "HOST: %s:%s\r\n" + "CACHE-CONTROL: max-age=100\r\n"
|
"EXT:\r\n" +
|
||||||
+ "EXT:\r\n" + "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/"
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "hue-bridgeid: %s\r\n" + "ST: urn:schemas-upnp-org:device:basic:1\r\n"
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
+ "USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
"HUE-BRIDGEID: %s\r\n" +
|
||||||
|
"ST: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n" +
|
||||||
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
||||||
|
private String responseTemplate3 = "HTTP/1.1 200 OK\r\n" +
|
||||||
|
"HOST: %s:%s\r\n" +
|
||||||
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
|
"EXT:\r\n" +
|
||||||
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
|
"HUE-BRIDGEID: %s\r\n" +
|
||||||
|
"ST: urn:schemas-upnp-org:device:basic:1\r\n" +
|
||||||
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
||||||
|
|
||||||
private String notifyTemplate = "NOTIFY * HTTP/1.1\r\n" + "HOST: %s:%s\r\n" + "CACHE-CONTROL: max-age=100\r\n"
|
private String notifyTemplate1 = "NOTIFY * HTTP/1.1\r\n" +
|
||||||
+ "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/"
|
"HOST: %s:%s\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "NTS: ssdp:alive\r\n" + "hue-bridgeid: %s\r\n" + "NT: uuid:"
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
+ HueConstants.UUID_PREFIX + "%s\r\n" + "USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
|
"NTS: ssdp:alive\r\n" +
|
||||||
|
"HUE-BRIDGEID: %s\r\n" +
|
||||||
|
"NT: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n" +
|
||||||
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
||||||
|
|
||||||
private String notifyTemplate2 = "NOTIFY * HTTP/1.1\r\n" + "HOST: %s:%s\r\n" + "CACHE-CONTROL: max-age=100\r\n"
|
private String notifyTemplate2 = "NOTIFY * HTTP/1.1\r\n" +
|
||||||
+ "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/"
|
"HOST: %s:%s\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "NTS: ssdp:alive\r\n" + "hue-bridgeid: %s\r\n"
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
+ "NT: upnp:rootdevice\r\n" + "USN: uuid:" + HueConstants.UUID_PREFIX + "%s::upnp:rootdevice\r\n\r\n";
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
|
"NTS: ssdp:alive\r\n" + "HUE-BRIDGEID: %s\r\n" +
|
||||||
|
"NT: upnp:rootdevice\r\n" +
|
||||||
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s::upnp:rootdevice\r\n\r\n";
|
||||||
|
|
||||||
private String notifyTemplate3 = "NOTIFY * HTTP/1.1\r\n" + "HOST: %s:%s\r\n" + "CACHE-CONTROL: max-age=100\r\n"
|
private String notifyTemplate3 = "NOTIFY * HTTP/1.1\r\n" +
|
||||||
+ "LOCATION: http://%s:%s/description.xml\r\n" + "SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/"
|
"HOST: %s:%s\r\n" +
|
||||||
+ HueConstants.API_VERSION + "\r\n" + "NTS: ssdp:alive\r\n" + "hue-bridgeid: %s\r\n"
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
+ "NT: urn:schemas-upnp-org:device:basic:1\r\n" + "USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
|
"NTS: ssdp:alive\r\n" +
|
||||||
|
"HUE-BRIDGEID: %s\r\n" +
|
||||||
|
"NT: urn:schemas-upnp-org:device:basic:1\r\n" +
|
||||||
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
||||||
|
|
||||||
public UpnpListener(BridgeSettingsDescriptor theSettings, BridgeControlDescriptor theControl,
|
public UpnpListener(BridgeSettingsDescriptor theSettings, BridgeControlDescriptor theControl,
|
||||||
UDPDatagramSender aUdpDatagramSender) throws IOException {
|
UDPDatagramSender aUdpDatagramSender) throws IOException {
|
||||||
super();
|
super();
|
||||||
|
theUDPDatagramSender = aUdpDatagramSender;
|
||||||
upnpMulticastSocket = null;
|
upnpMulticastSocket = null;
|
||||||
httpServerPort = Integer.valueOf(theSettings.getServerPort());
|
httpServerPort = Integer.valueOf(theSettings.getServerPort());
|
||||||
upnpConfigIP = theSettings.getUpnpConfigAddress();
|
upnpConfigIP = theSettings.getUpnpConfigAddress();
|
||||||
@@ -106,6 +136,7 @@ public class UpnpListener {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InetAddress theUpnpAddress = null;
|
||||||
while (ifs.hasMoreElements()) {
|
while (ifs.hasMoreElements()) {
|
||||||
NetworkInterface xface = ifs.nextElement();
|
NetworkInterface xface = ifs.nextElement();
|
||||||
Enumeration<InetAddress> addrs = xface.getInetAddresses();
|
Enumeration<InetAddress> addrs = xface.getInetAddresses();
|
||||||
@@ -126,6 +157,10 @@ public class UpnpListener {
|
|||||||
+ addr);
|
+ addr);
|
||||||
IPsPerNic++;
|
IPsPerNic++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (addr.getHostAddress().equals(upnpConfigIP)) {
|
||||||
|
theUpnpAddress = addr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
log.debug("Checking " + name + " to our interface set");
|
log.debug("Checking " + name + " to our interface set");
|
||||||
@@ -143,6 +178,22 @@ public class UpnpListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JmDNS jmdns = null;
|
||||||
|
if (theUpnpAddress != null) {
|
||||||
|
log.info("Create and run mDNS service.");
|
||||||
|
try {
|
||||||
|
// Create a JmDNS instance
|
||||||
|
jmdns = JmDNS.create(theUpnpAddress);
|
||||||
|
|
||||||
|
// Register a service - Defined TXT keys: bridgeid, modelid
|
||||||
|
ServiceInfo serviceInfo = ServiceInfo.create("_hue._tcp.local.", "hue", httpServerPort, "modelid=" + HueConstants.MODEL_ID + "\" \"bridgeid=" + bridgeId);
|
||||||
|
jmdns.registerService(serviceInfo);
|
||||||
|
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("Could not start mDNS service for hue api. {}", e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.info("UPNP Discovery Listener running and ready....");
|
log.info("UPNP Discovery Listener running and ready....");
|
||||||
boolean loopControl = true;
|
boolean loopControl = true;
|
||||||
boolean error = false;
|
boolean error = false;
|
||||||
@@ -151,8 +202,8 @@ public class UpnpListener {
|
|||||||
} catch (SocketException e1) {
|
} catch (SocketException e1) {
|
||||||
log.warn("Could not sent soTimeout on multi-cast socket");
|
log.warn("Could not sent soTimeout on multi-cast socket");
|
||||||
}
|
}
|
||||||
Instant current, previous;
|
// Instant current, previous;
|
||||||
previous = Instant.now();
|
// previous = Instant.now();
|
||||||
while (loopControl) { // trigger shutdown here
|
while (loopControl) { // trigger shutdown here
|
||||||
byte[] buf = new byte[1024];
|
byte[] buf = new byte[1024];
|
||||||
DatagramPacket packet = new DatagramPacket(buf, buf.length);
|
DatagramPacket packet = new DatagramPacket(buf, buf.length);
|
||||||
@@ -167,15 +218,28 @@ public class UpnpListener {
|
|||||||
log.debug("UpnpListener send upnp exception: ", e);
|
log.debug("UpnpListener send upnp exception: ", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
current = Instant.now();
|
current = Instant.now();
|
||||||
if (ChronoUnit.MILLIS.between(previous, current) > Configuration.UPNP_NOTIFY_TIMEOUT) {
|
if (ChronoUnit.MILLIS.between(previous, current) > Configuration.UPNP_NOTIFY_TIMEOUT) {
|
||||||
|
try {
|
||||||
sendUpnpNotify(socketAddress.getAddress());
|
sendUpnpNotify(socketAddress.getAddress());
|
||||||
previous = Instant.now();
|
} catch (IOException e) {
|
||||||
|
log.warn("UpnpListener encountered an error sending upnp notify packets. IP: "
|
||||||
|
+ packet.getAddress().getHostAddress() + " with message: " + e.getMessage());
|
||||||
|
log.debug("UpnpListener send upnp notify exception: ", e);
|
||||||
}
|
}
|
||||||
|
previous = Instant.now();
|
||||||
|
|
||||||
|
}
|
||||||
|
*/
|
||||||
} catch (SocketTimeoutException e) {
|
} catch (SocketTimeoutException e) {
|
||||||
|
try {
|
||||||
sendUpnpNotify(socketAddress.getAddress());
|
sendUpnpNotify(socketAddress.getAddress());
|
||||||
|
} catch (IOException en) {
|
||||||
|
log.warn("UpnpListener encountered an error sending upnp notify packets. IP: "
|
||||||
|
+ packet.getAddress().getHostAddress() + " with message: " + en.getMessage());
|
||||||
|
log.debug("UpnpListener send upnp notify exception: ", en);
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("UpnpListener encountered an error reading socket. Shutting down", e);
|
log.error("UpnpListener encountered an error reading socket. Shutting down", e);
|
||||||
error = true;
|
error = true;
|
||||||
@@ -190,6 +254,10 @@ public class UpnpListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
upnpMulticastSocket.close();
|
upnpMulticastSocket.close();
|
||||||
|
if(jmdns != null) {
|
||||||
|
// Unregister all services
|
||||||
|
jmdns.unregisterAllServices();
|
||||||
|
}
|
||||||
if (bridgeControl.isReinit())
|
if (bridgeControl.isReinit())
|
||||||
log.info("UPNP Discovery Listener - ended, restart found");
|
log.info("UPNP Discovery Listener - ended, restart found");
|
||||||
if (bridgeControl.isStop())
|
if (bridgeControl.isStop())
|
||||||
@@ -209,8 +277,9 @@ public class UpnpListener {
|
|||||||
String packetString = new String(packet.getData(), 0, packet.getLength());
|
String packetString = new String(packet.getData(), 0, packet.getLength());
|
||||||
if (packetString != null && packetString.startsWith("M-SEARCH * HTTP/1.1")
|
if (packetString != null && packetString.startsWith("M-SEARCH * HTTP/1.1")
|
||||||
&& packetString.contains("\"ssdp:discover\"")) {
|
&& packetString.contains("\"ssdp:discover\"")) {
|
||||||
if ((packetString.contains("ST: urn:schemas-upnp-org:device:basic:1")
|
if ((packetString.contains("ST: urn:schemas-upnp-org:device:basic:1") ||
|
||||||
|| packetString.contains("ST: upnp:rootdevice") || packetString.contains("ST: ssdp:all"))) {
|
packetString.contains("ST: upnp:rootdevice") ||
|
||||||
|
packetString.contains("ST: ssdp:all"))) {
|
||||||
if (traceupnp) {
|
if (traceupnp) {
|
||||||
log.info("Traceupnp: SSDP M-SEARCH packet from " + packet.getAddress().getHostAddress() + ":"
|
log.info("Traceupnp: SSDP M-SEARCH packet from " + packet.getAddress().getHostAddress() + ":"
|
||||||
+ packet.getPort());
|
+ packet.getPort());
|
||||||
@@ -248,31 +317,6 @@ public class UpnpListener {
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upnpOriginal) {
|
|
||||||
discoveryResponse = String.format(responseTemplateOriginal, Configuration.UPNP_MULTICAST_ADDRESS,
|
|
||||||
Configuration.UPNP_DISCOVERY_PORT, httpLocationAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
|
||||||
if (traceupnp) {
|
|
||||||
log.info("Traceupnp: send upnp discovery template Original with response address: "
|
|
||||||
+ httpLocationAddress + ":" + httpServerPort + " to address: " + requester + ":" + sourcePort);
|
|
||||||
}
|
|
||||||
log.debug("sendUpnpResponse to address: " + requester + ":" + sourcePort
|
|
||||||
+ " with discovery responseTemplateOriginal is <<<" + discoveryResponse + ">>>");
|
|
||||||
sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
|
||||||
} else {
|
|
||||||
discoveryResponse = String.format(responseTemplateOriginal, Configuration.UPNP_MULTICAST_ADDRESS,
|
|
||||||
Configuration.UPNP_DISCOVERY_PORT, httpLocationAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
|
||||||
if (traceupnp) {
|
|
||||||
log.info("Traceupnp: send upnp discovery template Original with response address: "
|
|
||||||
+ httpLocationAddress + ":" + httpServerPort + " to address: " + requester + ":" + sourcePort);
|
|
||||||
}
|
|
||||||
log.debug("sendUpnpResponse to address: " + requester + ":" + sourcePort
|
|
||||||
+ " with discovery responseTemplateOriginal is <<<" + discoveryResponse + ">>>");
|
|
||||||
sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
|
||||||
try {
|
|
||||||
Thread.sleep(theUpnpSendDelay);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
discoveryResponse = String.format(responseTemplate1, Configuration.UPNP_MULTICAST_ADDRESS,
|
discoveryResponse = String.format(responseTemplate1, Configuration.UPNP_MULTICAST_ADDRESS,
|
||||||
Configuration.UPNP_DISCOVERY_PORT, httpLocationAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
Configuration.UPNP_DISCOVERY_PORT, httpLocationAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
||||||
if (traceupnp) {
|
if (traceupnp) {
|
||||||
@@ -314,17 +358,20 @@ public class UpnpListener {
|
|||||||
+ " discovery responseTemplate3 is <<<" + discoveryResponse + ">>>");
|
+ " discovery responseTemplate3 is <<<" + discoveryResponse + ">>>");
|
||||||
sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
sendUDPResponse(discoveryResponse.getBytes(), requester, sourcePort);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void sendUDPResponse(byte[] udpMessage, InetAddress requester, int sourcePort) throws IOException {
|
private void sendUDPResponse(byte[] udpMessage, InetAddress requester, int sourcePort) throws IOException {
|
||||||
log.debug("Sending response string: <<<" + new String(udpMessage) + ">>>");
|
log.debug("Sending response string: <<<" + new String(udpMessage) + ">>>");
|
||||||
|
if(upnpOriginal) {
|
||||||
|
theUDPDatagramSender.sendUDPResponse(udpMessage, requester, sourcePort);
|
||||||
|
} else {
|
||||||
if (upnpMulticastSocket == null)
|
if (upnpMulticastSocket == null)
|
||||||
throw new IOException("Socket not initialized");
|
throw new IOException("Socket not initialized");
|
||||||
DatagramPacket response = new DatagramPacket(udpMessage, udpMessage.length, requester, sourcePort);
|
DatagramPacket response = new DatagramPacket(udpMessage, udpMessage.length, requester, sourcePort);
|
||||||
upnpMulticastSocket.send(response);
|
upnpMulticastSocket.send(response);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void sendUpnpNotify(InetAddress aSocketAddress) {
|
protected void sendUpnpNotify(InetAddress aSocketAddress) throws IOException {
|
||||||
String notifyData = null;
|
String notifyData = null;
|
||||||
try {
|
try {
|
||||||
Thread.sleep(theUpnpSendDelay);
|
Thread.sleep(theUpnpSendDelay);
|
||||||
@@ -332,9 +379,13 @@ public class UpnpListener {
|
|||||||
// noop
|
// noop
|
||||||
}
|
}
|
||||||
|
|
||||||
notifyData = String.format(notifyTemplate, Configuration.UPNP_MULTICAST_ADDRESS,
|
notifyData = String.format(notifyTemplate1, Configuration.UPNP_MULTICAST_ADDRESS,
|
||||||
Configuration.UPNP_DISCOVERY_PORT, upnpConfigIP, httpServerPort, bridgeId, bridgeSNUUID, bridgeSNUUID);
|
Configuration.UPNP_DISCOVERY_PORT, upnpConfigIP, httpServerPort, bridgeId, bridgeSNUUID, bridgeSNUUID);
|
||||||
sendNotifyDatagram(notifyData, aSocketAddress, "notifyTemplate1");
|
if (traceupnp) {
|
||||||
|
log.info("Traceupnp: sendUpnpNotify notifyTemplate1");
|
||||||
|
}
|
||||||
|
log.debug("sendUpnpNotify notifyTemplate1 is <<<{}>>>", notifyData);
|
||||||
|
sendUDPResponse(notifyData.getBytes(), aSocketAddress, Configuration.UPNP_DISCOVERY_PORT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(theUpnpSendDelay);
|
Thread.sleep(theUpnpSendDelay);
|
||||||
@@ -344,7 +395,11 @@ public class UpnpListener {
|
|||||||
|
|
||||||
notifyData = String.format(notifyTemplate2, Configuration.UPNP_MULTICAST_ADDRESS,
|
notifyData = String.format(notifyTemplate2, Configuration.UPNP_MULTICAST_ADDRESS,
|
||||||
Configuration.UPNP_DISCOVERY_PORT, upnpConfigIP, httpServerPort, bridgeId, bridgeSNUUID);
|
Configuration.UPNP_DISCOVERY_PORT, upnpConfigIP, httpServerPort, bridgeId, bridgeSNUUID);
|
||||||
sendNotifyDatagram(notifyData, aSocketAddress, "notifyTemplate2");
|
if (traceupnp) {
|
||||||
|
log.info("Traceupnp: sendUpnpNotify notifyTemplate2");
|
||||||
|
}
|
||||||
|
log.debug("sendUpnpNotify notifyTemplate2 is <<<{}>>>", notifyData);
|
||||||
|
sendUDPResponse(notifyData.getBytes(), aSocketAddress, Configuration.UPNP_DISCOVERY_PORT);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Thread.sleep(theUpnpSendDelay);
|
Thread.sleep(theUpnpSendDelay);
|
||||||
@@ -354,23 +409,11 @@ public class UpnpListener {
|
|||||||
|
|
||||||
notifyData = String.format(notifyTemplate3, Configuration.UPNP_MULTICAST_ADDRESS,
|
notifyData = String.format(notifyTemplate3, Configuration.UPNP_MULTICAST_ADDRESS,
|
||||||
Configuration.UPNP_DISCOVERY_PORT, upnpConfigIP, httpServerPort, bridgeId, bridgeSNUUID);
|
Configuration.UPNP_DISCOVERY_PORT, upnpConfigIP, httpServerPort, bridgeId, bridgeSNUUID);
|
||||||
sendNotifyDatagram(notifyData, aSocketAddress, "notifyTemplate3");
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendNotifyDatagram(String notifyData, InetAddress aSocketAddress, String templateNumber) {
|
|
||||||
if (traceupnp) {
|
if (traceupnp) {
|
||||||
log.info("Traceupnp: sendUpnpNotify {}", templateNumber);
|
log.info("Traceupnp: sendUpnpNotify notifyTemplate3");
|
||||||
}
|
|
||||||
log.debug("sendUpnpNotify {} is <<<{}>>>", templateNumber, notifyData);
|
|
||||||
DatagramPacket notifyPacket = new DatagramPacket(notifyData.getBytes(), notifyData.length(), aSocketAddress,
|
|
||||||
Configuration.UPNP_DISCOVERY_PORT);
|
|
||||||
try {
|
|
||||||
upnpMulticastSocket.send(notifyPacket);
|
|
||||||
} catch (IOException e1) {
|
|
||||||
log.warn("UpnpListener encountered an error sending upnp {}. IP: {} with message: {}", templateNumber,
|
|
||||||
notifyPacket.getAddress().getHostAddress(), e1.getMessage());
|
|
||||||
log.debug("UpnpListener send {} exception: ", templateNumber, e1);
|
|
||||||
}
|
}
|
||||||
|
log.debug("sendUpnpNotify notifyTemplate3 is <<<{}>>>", notifyData);
|
||||||
|
sendUDPResponse(notifyData.getBytes(), aSocketAddress, Configuration.UPNP_DISCOVERY_PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
// added by https://github.com/pvint
|
// added by https://github.com/pvint
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public class UpnpSettingsResource {
|
|||||||
private BridgeSettingsDescriptor theSettings;
|
private BridgeSettingsDescriptor theSettings;
|
||||||
private BridgeSettings bridgeSettings;
|
private BridgeSettings bridgeSettings;
|
||||||
|
|
||||||
private String hueTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
private String hueTemplate_pre = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
|
||||||
+ "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n"
|
+ "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n"
|
||||||
+ "<specVersion>\n"
|
+ "<specVersion>\n"
|
||||||
+ "<major>1</major>\n"
|
+ "<major>1</major>\n"
|
||||||
@@ -41,8 +41,9 @@ public class UpnpSettingsResource {
|
|||||||
+ "<modelNumber>" + HueConstants.MODEL_ID + "</modelNumber>\n"
|
+ "<modelNumber>" + HueConstants.MODEL_ID + "</modelNumber>\n"
|
||||||
+ "<modelURL>http://www.meethue.com</modelURL>\n"
|
+ "<modelURL>http://www.meethue.com</modelURL>\n"
|
||||||
+ "<serialNumber>%s</serialNumber>\n"
|
+ "<serialNumber>%s</serialNumber>\n"
|
||||||
+ "<UDN>uuid:" + HueConstants.UUID_PREFIX + "%s</UDN>\n"
|
+ "<UDN>uuid:" + HueConstants.UUID_PREFIX + "%s</UDN>\n";
|
||||||
+ "<presentationURL>index.html</presentationURL>\n"
|
|
||||||
|
private String hueTemplate_post = "<presentationURL>index.html</presentationURL>\n"
|
||||||
+ "<iconList>\n"
|
+ "<iconList>\n"
|
||||||
+ "<icon>\n"
|
+ "<icon>\n"
|
||||||
+ "<mimetype>image/png</mimetype>\n"
|
+ "<mimetype>image/png</mimetype>\n"
|
||||||
@@ -62,6 +63,17 @@ public class UpnpSettingsResource {
|
|||||||
+ "</device>\n"
|
+ "</device>\n"
|
||||||
+ "</root>\n";
|
+ "</root>\n";
|
||||||
|
|
||||||
|
private String hueTemplate_mid_orig = "<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";
|
||||||
|
|
||||||
|
|
||||||
public UpnpSettingsResource(BridgeSettings theBridgeSettings) {
|
public UpnpSettingsResource(BridgeSettings theBridgeSettings) {
|
||||||
super();
|
super();
|
||||||
this.bridgeSettings = theBridgeSettings;
|
this.bridgeSettings = theBridgeSettings;
|
||||||
@@ -80,7 +92,16 @@ public class UpnpSettingsResource {
|
|||||||
|
|
||||||
String portNumber = Integer.toString(request.port());
|
String portNumber = Integer.toString(request.port());
|
||||||
String filledTemplate = null;
|
String filledTemplate = null;
|
||||||
String httpLocationAddr = getOutboundAddress(request.ip(), request.port()).getHostAddress();
|
String httpLocationAddr = null;
|
||||||
|
String hueTemplate = null;
|
||||||
|
if(theSettings.isUpnporiginal()) {
|
||||||
|
httpLocationAddr = theSettings.getUpnpConfigAddress();
|
||||||
|
hueTemplate = hueTemplate_pre + hueTemplate_mid_orig + hueTemplate_post;
|
||||||
|
} else {
|
||||||
|
httpLocationAddr = getOutboundAddress(request.ip(), request.port()).getHostAddress();
|
||||||
|
hueTemplate = hueTemplate_pre + hueTemplate_post;
|
||||||
|
}
|
||||||
|
|
||||||
String bridgeIdMac = HuePublicConfig.createConfig("temp", httpLocationAddr, HueConstants.HUB_VERSION, theSettings.getHubmac()).getSNUUIDFromMac();
|
String bridgeIdMac = HuePublicConfig.createConfig("temp", httpLocationAddr, HueConstants.HUB_VERSION, theSettings.getHubmac()).getSNUUIDFromMac();
|
||||||
filledTemplate = String.format(hueTemplate, httpLocationAddr, portNumber, httpLocationAddr, bridgeIdMac, bridgeIdMac);
|
filledTemplate = String.format(hueTemplate, httpLocationAddr, portNumber, httpLocationAddr, bridgeIdMac, bridgeIdMac);
|
||||||
if(theSettings.isTraceupnp())
|
if(theSettings.isTraceupnp())
|
||||||
|
|||||||
BIN
src/main/resources/public/hue_logo_0.png
Normal file
BIN
src/main/resources/public/hue_logo_0.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.6 KiB |
BIN
src/main/resources/public/hue_logo_3.png
Normal file
BIN
src/main/resources/public/hue_logo_3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
@@ -3667,7 +3667,7 @@ app.controller('HassController', function ($scope, $location, bridgeService, ngD
|
|||||||
dimpayload = "{\"entityId\":\"" + hassdevice.deviceState.entity_id + "\",\"hassName\":\"" + hassdevice.hassname + "\",\"state\":\"on\"}";
|
dimpayload = "{\"entityId\":\"" + hassdevice.deviceState.entity_id + "\",\"hassName\":\"" + hassdevice.hassname + "\",\"state\":\"on\"}";
|
||||||
offpayload = "{\"entityId\":\"" + hassdevice.deviceState.entity_id + "\",\"hassName\":\"" + hassdevice.hassname + "\",\"state\":\"off\"}";
|
offpayload = "{\"entityId\":\"" + hassdevice.deviceState.entity_id + "\",\"hassName\":\"" + hassdevice.hassname + "\",\"state\":\"off\"}";
|
||||||
|
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, hassdevice.hassname + "-" + hassdevice.deviceState.entity_id, hassdevice.deviceState.entity_id, hassdevice.hassname, hassdevice.domain, "hassDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, hassdevice.hassname + "-" + hassdevice.deviceState.entity_id, hassdevice.deviceState.entity_id, hassdevice.hassname, "switch", "hassDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -3797,7 +3797,7 @@ app.controller('HomeWizardController', function ($scope, $location, bridgeServic
|
|||||||
onpayload = "{\"deviceid\":\"" + homewizarddevice.id + "\",\"action\":\"on\"}";
|
onpayload = "{\"deviceid\":\"" + homewizarddevice.id + "\",\"action\":\"on\"}";
|
||||||
offpayload = "{\"deviceid\":\"" + homewizarddevice.id + "\",\"action\":\"off\"}";
|
offpayload = "{\"deviceid\":\"" + homewizarddevice.id + "\",\"action\":\"off\"}";
|
||||||
|
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, homewizarddevice.id, homewizarddevice.name, homewizarddevice.gateway, null, "homewizardDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, homewizarddevice.id, homewizarddevice.name, homewizarddevice.gateway, "switch", "homewizardDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
|
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
@@ -4091,7 +4091,7 @@ app.controller('LifxController', function ($scope, $location, bridgeService, ngD
|
|||||||
dimpayload = angular.toJson(lifxdevice);
|
dimpayload = angular.toJson(lifxdevice);
|
||||||
onpayload = angular.toJson(lifxdevice);
|
onpayload = angular.toJson(lifxdevice);
|
||||||
offpayload = angular.toJson(lifxdevice);
|
offpayload = angular.toJson(lifxdevice);
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, lifxdevice.name, lifxdevice.name, lifxdevice.name, null, "lifxDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, true, lifxdevice.name, lifxdevice.name, lifxdevice.name, "switch", "lifxDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -4392,7 +4392,7 @@ app.controller('OpenHABController', function ($scope, $location, bridgeService,
|
|||||||
else
|
else
|
||||||
colorpayload = null;
|
colorpayload = null;
|
||||||
}
|
}
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, openhabdevice.item.name + "-" + openhabdevice.name, openhabdevice.item.name, openhabdevice.name, openhabdevice.item.type, "openhabDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, openhabdevice.item.name + "-" + openhabdevice.name, openhabdevice.item.name, openhabdevice.name, "switch", "openhabDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -4534,7 +4534,7 @@ app.controller('MozIotController', function ($scope, $location, bridgeService, n
|
|||||||
else if (coloraction !== undefined && coloraction !== null && coloraction !== '')
|
else if (coloraction !== undefined && coloraction !== null && coloraction !== '')
|
||||||
colorpayload = "{\"url\":\"" + preCmd + "color\",\"command\":{\"color\":\"" + coloraction + "\"}}";
|
colorpayload = "{\"url\":\"" + preCmd + "color\",\"command\":{\"color\":\"" + coloraction + "\"}}";
|
||||||
|
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, moziotdevice.deviceDetail.name + "-" + moziotdevice.deviceDetail.type, moziotdevice.deviceDetail.name, moziotdevice.gatewayName, "Switch", "moziotDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, moziotdevice.deviceDetail.title + "-" + moziotdevice.deviceDetail.type, moziotdevice.deviceDetail.title, moziotdevice.gatewayName, "switch", "moziotDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -4678,7 +4678,7 @@ app.controller('FhemController', function ($scope, $location, bridgeService, ngD
|
|||||||
colorpayload = null;
|
colorpayload = null;
|
||||||
onpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"on\"}";
|
onpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"on\"}";
|
||||||
offpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"off\"}";
|
offpayload = "{\"url\":\"http://" + fhemdevice.address + preCmd + "\",\"command\":\"off\"}";
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, fhemdevice.item.Name + "-" + fhemdevice.name, fhemdevice.item.Name, fhemdevice.name, fhemdevice.item.type, "fhemDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, fhemdevice.item.Name + "-" + fhemdevice.name, fhemdevice.item.Name, fhemdevice.name, "switch", "fhemDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -4837,7 +4837,7 @@ app.controller('BroadlinkController', function ($scope, $location, bridgeService
|
|||||||
else
|
else
|
||||||
colorpayload = null;
|
colorpayload = null;
|
||||||
}
|
}
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, broadlinkdevice.id, broadlinkdevice.name, broadlinkdevice.id, broadlinkdevice.desc, "broadlinkDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, broadlinkdevice.id, broadlinkdevice.name, broadlinkdevice.id, "switch", "broadlinkDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -4977,7 +4977,7 @@ app.controller('HomeGenieController', function ($scope, $location, bridgeService
|
|||||||
// else if (coloraction !== undefined && coloraction !== null && coloraction !== '')
|
// else if (coloraction !== undefined && coloraction !== null && coloraction !== '')
|
||||||
// colorpayload = "{\"url\":\"" + preCmd + "color\",\"command\":{\"color\":\"" + coloraction + "\"}}";
|
// colorpayload = "{\"url\":\"" + preCmd + "color\",\"command\":{\"color\":\"" + coloraction + "\"}}";
|
||||||
|
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, homegeniedevice.deviceDetail.Name + "-" + homegeniedevice.deviceDetail.DeviceType, homegeniedevice.deviceDetail.Name, homegeniedevice.gatewayName, homegeniedevice.deviceDetail.DeviceType, "homegenieDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, colorpayload, true, homegeniedevice.deviceDetail.Name + "-" + homegeniedevice.deviceDetail.DeviceType, homegeniedevice.deviceDetail.Name, homegeniedevice.gatewayName, "switch", "homegenieDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
if (!buildonly) {
|
if (!buildonly) {
|
||||||
bridgeService.editNewDevice($scope.device);
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
|||||||
@@ -57,6 +57,7 @@
|
|||||||
<option value="button">Button</option>
|
<option value="button">Button</option>
|
||||||
<option value="thermo">Thermo</option>
|
<option value="thermo">Thermo</option>
|
||||||
<option value="passthru">Pass Thru</option>
|
<option value="passthru">Pass Thru</option>
|
||||||
|
<option value="home">Home</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -144,6 +144,7 @@
|
|||||||
<option value="button">Button</option>
|
<option value="button">Button</option>
|
||||||
<option value="thermo">Thermo</option>
|
<option value="thermo">Thermo</option>
|
||||||
<option value="passthru">Pass Thru</option>
|
<option value="passthru">Pass Thru</option>
|
||||||
|
<option value="home">Home</option>
|
||||||
</select></td>
|
</select></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|||||||
@@ -19,7 +19,7 @@
|
|||||||
<li ng-if="bridge.showHomeWizard" role="presentation"><a href="#!/homewizarddevices">HomeWizard Devices</a></li>
|
<li ng-if="bridge.showHomeWizard" role="presentation"><a href="#!/homewizarddevices">HomeWizard Devices</a></li>
|
||||||
<li ng-if="bridge.showOpenHAB" role="presentation"><a href="#!/openhabdevices">OpenHAB Devices</a></li>
|
<li ng-if="bridge.showOpenHAB" role="presentation"><a href="#!/openhabdevices">OpenHAB Devices</a></li>
|
||||||
<li ng-if="bridge.showFHEM" role="presentation"><a href="#!/fhemdevices">FHEM Devices</a></li>
|
<li ng-if="bridge.showFHEM" role="presentation"><a href="#!/fhemdevices">FHEM Devices</a></li>
|
||||||
<li ng-if="bridge.showMozIot" role="presentation"><a href="#!/homegeniedevices">HomeGenie Devices</a></li>
|
<li ng-if="bridge.showMozIot" role="presentation"><a href="#!/moziotdevices">Mozilla IOT Devices</a></li>
|
||||||
<li ng-if="bridge.showBroadlink" role="presentation"><a href="#!/broadlinkdevices">Broadlink Devices</a></li>
|
<li ng-if="bridge.showBroadlink" role="presentation"><a href="#!/broadlinkdevices">Broadlink Devices</a></li>
|
||||||
<li ng-if="bridge.showHomeGenie" role="presentation" class="active"><a href="#!/homegeniedevices">HomeGenie
|
<li ng-if="bridge.showHomeGenie" role="presentation" class="active"><a href="#!/homegeniedevices">HomeGenie
|
||||||
Devices</a></li>
|
Devices</a></li>
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h2 class="panel-title">HomeGenie show Device List
|
<h2 class="panel-title">HomeGenie show device List
|
||||||
({{bridge.homegeniedevices.length}})</h2>
|
({{bridge.homegeniedevices.length}})</h2>
|
||||||
</div>
|
</div>
|
||||||
<div class="panel-body">
|
<div class="panel-body">
|
||||||
@@ -96,7 +96,7 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h2 class="panel-title">
|
<h2 class="panel-title">
|
||||||
Already Configured OpenHAB Devices <a ng-click="toggleButtons()"><span class={{imgButtonsUrl}}
|
Already Configured HomeGenie Devices <a ng-click="toggleButtons()"><span class={{imgButtonsUrl}}
|
||||||
aria-hidden="true"></span></a></a>
|
aria-hidden="true"></span></a></a>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -19,10 +19,9 @@
|
|||||||
<li ng-if="bridge.showHomeWizard" role="presentation"><a href="#!/homewizarddevices">HomeWizard Devices</a></li>
|
<li ng-if="bridge.showHomeWizard" role="presentation"><a href="#!/homewizarddevices">HomeWizard Devices</a></li>
|
||||||
<li ng-if="bridge.showOpenHAB" role="presentation"><a href="#!/openhabdevices">OpenHAB Devices</a></li>
|
<li ng-if="bridge.showOpenHAB" role="presentation"><a href="#!/openhabdevices">OpenHAB Devices</a></li>
|
||||||
<li ng-if="bridge.showFHEM" role="presentation"><a href="#!/fhemdevices">FHEM Devices</a></li>
|
<li ng-if="bridge.showFHEM" role="presentation"><a href="#!/fhemdevices">FHEM Devices</a></li>
|
||||||
<li ng-if="bridge.showHomeGenie" role="presentation"><a href="#!/homegeniedevices">HomeGenie Devices</a></li>
|
<li ng-if="bridge.showMozIot" role="presentation" class="active"><a href="#!/moziotdevices">Mozilla IOT Devices</a></li>
|
||||||
<li ng-if="bridge.showMozIot" role="presentation" class="active"><a href="#!/moziotdevices">Mozilla IOT Devices</a>
|
|
||||||
</li>
|
|
||||||
<li ng-if="bridge.showBroadlink" role="presentation"><a href="#!/broadlinkdevices">Broadlink Devices</a></li>
|
<li ng-if="bridge.showBroadlink" role="presentation"><a href="#!/broadlinkdevices">Broadlink Devices</a></li>
|
||||||
|
<li ng-if="bridge.showHomeGenie" role="presentation"><a href="#!/homegeniedevices">HomeGenie Devices</a></li>
|
||||||
<li role="presentation"><a href="#!/editdevice">Add/Edit</a></li>
|
<li role="presentation"><a href="#!/editdevice">Add/Edit</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@@ -72,10 +71,10 @@
|
|||||||
</thead>
|
</thead>
|
||||||
<tr ng-repeat="moziotdevice in bridge.moziotdevices">
|
<tr ng-repeat="moziotdevice in bridge.moziotdevices">
|
||||||
<td>{{$index+1}}</td>
|
<td>{{$index+1}}</td>
|
||||||
<td><input type="checkbox" name="bulk.devices[]" value="{{moziotdevice.deviceDetail.name}}"
|
<td><input type="checkbox" name="bulk.devices[]" value="{{moziotdevice.deviceDetail.title}}"
|
||||||
ng-checked="bulk.devices.indexOf(moziotdevice.deviceDetail.name) > -1"
|
ng-checked="bulk.devices.indexOf(moziotdevice.deviceDetail.title) > -1"
|
||||||
ng-click="toggleSelection(moziotdevice.deviceDetail.name)">
|
ng-click="toggleSelection(moziotdevice.deviceDetail.title)">
|
||||||
{{moziotdevice.deviceDetail.name}}</td>
|
{{moziotdevice.deviceDetail.title}}</td>
|
||||||
<td>{{moziotdevice.deviceDetail.type}}</td>
|
<td>{{moziotdevice.deviceDetail.type}}</td>
|
||||||
<td>{{moziotdevice.gatewayName}}</td>
|
<td>{{moziotdevice.gatewayName}}</td>
|
||||||
<td>
|
<td>
|
||||||
@@ -104,7 +103,7 @@
|
|||||||
<div class="panel panel-default">
|
<div class="panel panel-default">
|
||||||
<div class="panel-heading">
|
<div class="panel-heading">
|
||||||
<h2 class="panel-title">
|
<h2 class="panel-title">
|
||||||
Already Configured OpenHAB Devices <a ng-click="toggleButtons()"><span class={{imgButtonsUrl}}
|
Already Configured Mozilla IOT Devices <a ng-click="toggleButtons()"><span class={{imgButtonsUrl}}
|
||||||
aria-hidden="true"></span></a></a>
|
aria-hidden="true"></span></a></a>
|
||||||
</h2>
|
</h2>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -699,7 +699,7 @@
|
|||||||
<td><input type="checkbox" ng-model="newmoziotsecure" ng-true-value=true
|
<td><input type="checkbox" ng-model="newmoziotsecure" ng-true-value=true
|
||||||
ng-false-value=false></td>
|
ng-false-value=false></td>
|
||||||
<td><button class="btn btn-success" type="submit"
|
<td><button class="btn btn-success" type="submit"
|
||||||
ng-click="addMozIottoSettings(newmoziotname, newmoziotip, newmoziotport, newsmoziotusername, newmoziotpassword, newmoziotwebhook, newmoziotsecure)">Add</button>
|
ng-click="addMozIottoSettings(newmoziotname, newmoziotip, newmoziotport, newmoziotusername, newmoziotpassword, newmoziotwebhook, newmoziotsecure)">Add</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user