mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Done testing HomeAssistant, refactoring HueMulator, fixed MQTT dim
control.
This commit is contained in:
2
pom.xml
2
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>3.5.1j</version>
|
<version>3.5.1k</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package com.bwssystems.HABridge;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueConstants;
|
||||||
import com.bwssystems.HABridge.api.hue.WhitelistEntry;
|
import com.bwssystems.HABridge.api.hue.WhitelistEntry;
|
||||||
|
|
||||||
public class BridgeSettingsDescriptor {
|
public class BridgeSettingsDescriptor {
|
||||||
@@ -36,6 +37,7 @@ public class BridgeSettingsDescriptor {
|
|||||||
private boolean mqttconfigured;
|
private boolean mqttconfigured;
|
||||||
private IpList hassaddress;
|
private IpList hassaddress;
|
||||||
private boolean hassconfigured;
|
private boolean hassconfigured;
|
||||||
|
private String hubversion;
|
||||||
|
|
||||||
public BridgeSettingsDescriptor() {
|
public BridgeSettingsDescriptor() {
|
||||||
super();
|
super();
|
||||||
@@ -53,6 +55,7 @@ public class BridgeSettingsDescriptor {
|
|||||||
this.settingsChanged = false;
|
this.settingsChanged = false;
|
||||||
this.myechourl = "echo.amazon.com/#cards";
|
this.myechourl = "echo.amazon.com/#cards";
|
||||||
this.webaddress = "0.0.0.0";
|
this.webaddress = "0.0.0.0";
|
||||||
|
this.hubversion = HueConstants.HUB_VERSION;
|
||||||
}
|
}
|
||||||
public String getUpnpConfigAddress() {
|
public String getUpnpConfigAddress() {
|
||||||
return upnpconfigaddress;
|
return upnpconfigaddress;
|
||||||
@@ -240,6 +243,12 @@ public class BridgeSettingsDescriptor {
|
|||||||
public void setHassconfigured(boolean hassconfigured) {
|
public void setHassconfigured(boolean hassconfigured) {
|
||||||
this.hassconfigured = hassconfigured;
|
this.hassconfigured = hassconfigured;
|
||||||
}
|
}
|
||||||
|
public String getHubversion() {
|
||||||
|
return hubversion;
|
||||||
|
}
|
||||||
|
public void setHubversion(String hubversion) {
|
||||||
|
this.hubversion = hubversion;
|
||||||
|
}
|
||||||
public Boolean isValidVera() {
|
public Boolean isValidVera() {
|
||||||
if(this.getVeraAddress() == null || this.getVeraAddress().getDevices().size() <= 0)
|
if(this.getVeraAddress() == null || this.getVeraAddress().getDevices().size() <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ public class HueApiResponse {
|
|||||||
private Map<String, JsonObject> rules;
|
private Map<String, JsonObject> rules;
|
||||||
private HueConfig config;
|
private HueConfig config;
|
||||||
|
|
||||||
public HueApiResponse(String name, String ipaddress, Map<String, WhitelistEntry> awhitelist) {
|
public HueApiResponse(String name, String ipaddress, Map<String, WhitelistEntry> awhitelist, String emulateHubVersion) {
|
||||||
super();
|
super();
|
||||||
this.setConfig(HueConfig.createConfig(name, ipaddress, awhitelist));
|
this.setConfig(HueConfig.createConfig(name, ipaddress, awhitelist, emulateHubVersion));
|
||||||
this.setRules(new HashMap<>());
|
this.setRules(new HashMap<>());
|
||||||
this.setSensors(new HashMap<>());
|
this.setSensors(new HashMap<>());
|
||||||
this.setSchedules(new HashMap<>());
|
this.setSchedules(new HashMap<>());
|
||||||
|
|||||||
@@ -34,16 +34,16 @@ public class HueConfig
|
|||||||
private String replacesbridgeid;
|
private String replacesbridgeid;
|
||||||
private Map<String, WhitelistEntry> whitelist;
|
private Map<String, WhitelistEntry> whitelist;
|
||||||
|
|
||||||
public static HueConfig createConfig(String name, String ipaddress, Map<String, WhitelistEntry> awhitelist) {
|
public static HueConfig createConfig(String name, String ipaddress, Map<String, WhitelistEntry> awhitelist, String emulateHubVersion) {
|
||||||
HueConfig aConfig = new HueConfig();
|
HueConfig aConfig = new HueConfig();
|
||||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
SimpleDateFormat dateFormatGmt = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
|
||||||
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("UTC"));
|
dateFormatGmt.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||||
aConfig.setMac(HueConfig.getMacAddress(ipaddress));
|
aConfig.setMac(HueConfig.getMacAddress(ipaddress));
|
||||||
aConfig.setApiversion("1.15.0");
|
aConfig.setApiversion(HueConstants.API_VERSION);
|
||||||
aConfig.setPortalservices(false);
|
aConfig.setPortalservices(false);
|
||||||
aConfig.setGateway(ipaddress);
|
aConfig.setGateway(ipaddress);
|
||||||
aConfig.setSwversion("01035934");
|
aConfig.setSwversion(emulateHubVersion);
|
||||||
aConfig.setLinkbutton(true);
|
aConfig.setLinkbutton(true);
|
||||||
aConfig.setIpaddress(ipaddress);
|
aConfig.setIpaddress(ipaddress);
|
||||||
aConfig.setProxyport(0);
|
aConfig.setProxyport(0);
|
||||||
@@ -56,8 +56,8 @@ public class HueConfig
|
|||||||
aConfig.setLocaltime(dateFormat.format(new Date()));
|
aConfig.setLocaltime(dateFormat.format(new Date()));
|
||||||
aConfig.setTimezone(TimeZone.getDefault().getID());
|
aConfig.setTimezone(TimeZone.getDefault().getID());
|
||||||
aConfig.setZigbeechannel("6");
|
aConfig.setZigbeechannel("6");
|
||||||
aConfig.setBridgeid(HuePublicConfig.createConfig(name, ipaddress).getHueBridgeIdFromMac());
|
aConfig.setBridgeid(HuePublicConfig.createConfig(name, ipaddress, emulateHubVersion).getHueBridgeIdFromMac());
|
||||||
aConfig.setModelid("BSB002");
|
aConfig.setModelid(HueConstants.MODEL_ID);
|
||||||
aConfig.setFactorynew(false);
|
aConfig.setFactorynew(false);
|
||||||
aConfig.setReplacesbridgeid(null);
|
aConfig.setReplacesbridgeid(null);
|
||||||
aConfig.setWhitelist(awhitelist);
|
aConfig.setWhitelist(awhitelist);
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
package com.bwssystems.HABridge.api.hue;
|
||||||
|
|
||||||
|
public class HueConstants {
|
||||||
|
public final static String HUB_VERSION = "01036562";
|
||||||
|
public final static String API_VERSION = "1.15.0";
|
||||||
|
public final static String MODEL_ID = "BSB002";
|
||||||
|
public final static String UUID_PREFIX = "2f402f80-da50-11e1-9b23-";
|
||||||
|
}
|
||||||
@@ -5,6 +5,11 @@ import java.util.ArrayList;
|
|||||||
public class HueErrorResponse {
|
public class HueErrorResponse {
|
||||||
private ArrayList<HueError> theErrors;
|
private ArrayList<HueError> theErrors;
|
||||||
|
|
||||||
|
public static HueErrorResponse createResponse(String type, String address, String description, String method_name, String resource_name, String value) {
|
||||||
|
HueErrorResponse theErrorResp = new HueErrorResponse();
|
||||||
|
theErrorResp.addError(new HueError(new HueErrorDetails(type, address, description, method_name, resource_name, value)));
|
||||||
|
return theErrorResp;
|
||||||
|
}
|
||||||
public HueErrorResponse() {
|
public HueErrorResponse() {
|
||||||
super();
|
super();
|
||||||
theErrors = new ArrayList<HueError>();
|
theErrors = new ArrayList<HueError>();
|
||||||
|
|||||||
@@ -18,14 +18,14 @@ public class HuePublicConfig
|
|||||||
private Boolean factorynew;
|
private Boolean factorynew;
|
||||||
private String modelid;
|
private String modelid;
|
||||||
|
|
||||||
public static HuePublicConfig createConfig(String name, String ipaddress) {
|
public static HuePublicConfig createConfig(String name, String ipaddress, String emulateHubVersion) {
|
||||||
HuePublicConfig aConfig = new HuePublicConfig();
|
HuePublicConfig aConfig = new HuePublicConfig();
|
||||||
aConfig.setMac(HuePublicConfig.getMacAddress(ipaddress));
|
aConfig.setMac(HuePublicConfig.getMacAddress(ipaddress));
|
||||||
aConfig.setApiversion("1.15.0");
|
aConfig.setApiversion(HueConstants.API_VERSION);
|
||||||
aConfig.setSwversion("01035934");
|
aConfig.setSwversion(emulateHubVersion);
|
||||||
aConfig.setName(name);
|
aConfig.setName(name);
|
||||||
aConfig.setBridgeid(aConfig.getHueBridgeIdFromMac());
|
aConfig.setBridgeid(aConfig.getHueBridgeIdFromMac());
|
||||||
aConfig.setModelid("BSB002");
|
aConfig.setModelid(HueConstants.MODEL_ID);
|
||||||
aConfig.setFactorynew(false);
|
aConfig.setFactorynew(false);
|
||||||
aConfig.setReplacesbridgeid(null);
|
aConfig.setReplacesbridgeid(null);
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -6,6 +6,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import com.bwssystems.HABridge.BridgeControlDescriptor;
|
import com.bwssystems.HABridge.BridgeControlDescriptor;
|
||||||
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
|
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
|
||||||
import com.bwssystems.HABridge.Configuration;
|
import com.bwssystems.HABridge.Configuration;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueConstants;
|
||||||
import com.bwssystems.HABridge.api.hue.HuePublicConfig;
|
import com.bwssystems.HABridge.api.hue.HuePublicConfig;
|
||||||
import com.bwssystems.util.UDPDatagramSender;
|
import com.bwssystems.util.UDPDatagramSender;
|
||||||
|
|
||||||
@@ -29,28 +30,28 @@ public class UpnpListener {
|
|||||||
"CACHE-CONTROL: max-age=100\r\n" +
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
"EXT:\r\n" +
|
"EXT:\r\n" +
|
||||||
"LOCATION: http://%s:%s/description.xml\r\n" +
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.15.0\r\n" +
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
"hue-bridgeid: %s\r\n" +
|
"hue-bridgeid: %s\r\n" +
|
||||||
"ST: upnp:rootdevice\r\n" +
|
"ST: upnp:rootdevice\r\n" +
|
||||||
"USN: uuid:2f402f80-da50-11e1-9b23-%s::upnp:rootdevice\r\n\r\n";
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s::upnp:rootdevice\r\n\r\n";
|
||||||
private String responseTemplate2 = "HTTP/1.1 200 OK\r\n" +
|
private String responseTemplate2 = "HTTP/1.1 200 OK\r\n" +
|
||||||
"HOST: %s:%s\r\n" +
|
"HOST: %s:%s\r\n" +
|
||||||
"CACHE-CONTROL: max-age=100\r\n" +
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
"EXT:\r\n" +
|
"EXT:\r\n" +
|
||||||
"LOCATION: http://%s:%s/description.xml\r\n" +
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.15.0\r\n" +
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
"hue-bridgeid: %s\r\n" +
|
"hue-bridgeid: %s\r\n" +
|
||||||
"ST: uuid:2f402f80-da50-11e1-9b23-%s\r\n" +
|
"ST: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n" +
|
||||||
"USN: uuid:2f402f80-da50-11e1-9b23-%s\r\n\r\n";
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
||||||
private String responseTemplate3 = "HTTP/1.1 200 OK\r\n" +
|
private String responseTemplate3 = "HTTP/1.1 200 OK\r\n" +
|
||||||
"HOST: %s:%s\r\n" +
|
"HOST: %s:%s\r\n" +
|
||||||
"CACHE-CONTROL: max-age=100\r\n" +
|
"CACHE-CONTROL: max-age=100\r\n" +
|
||||||
"EXT:\r\n" +
|
"EXT:\r\n" +
|
||||||
"LOCATION: http://%s:%s/description.xml\r\n" +
|
"LOCATION: http://%s:%s/description.xml\r\n" +
|
||||||
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/1.15.0\r\n" +
|
"SERVER: Linux/3.14.0 UPnP/1.0 IpBridge/" + HueConstants.API_VERSION + "\r\n" +
|
||||||
"hue-bridgeid: %s\r\n" +
|
"hue-bridgeid: %s\r\n" +
|
||||||
"ST: urn:schemas-upnp-org:device:basic:1\r\n" +
|
"ST: urn:schemas-upnp-org:device:basic:1\r\n" +
|
||||||
"USN: uuid:2f402f80-da50-11e1-9b23-%s\r\n\r\n";
|
"USN: uuid:" + HueConstants.UUID_PREFIX + "%s\r\n\r\n";
|
||||||
|
|
||||||
public UpnpListener(BridgeSettingsDescriptor theSettings, BridgeControlDescriptor theControl, UDPDatagramSender aUdpDatagramSender) {
|
public UpnpListener(BridgeSettingsDescriptor theSettings, BridgeControlDescriptor theControl, UDPDatagramSender aUdpDatagramSender) {
|
||||||
super();
|
super();
|
||||||
@@ -199,7 +200,7 @@ public class UpnpListener {
|
|||||||
String discoveryResponse = null;
|
String discoveryResponse = null;
|
||||||
String bridgeId = null;
|
String bridgeId = null;
|
||||||
String bridgeSNUUID = null;
|
String bridgeSNUUID = null;
|
||||||
HuePublicConfig aHueConfig = HuePublicConfig.createConfig("temp", responseAddress);
|
HuePublicConfig aHueConfig = HuePublicConfig.createConfig("temp", responseAddress, HueConstants.HUB_VERSION);
|
||||||
bridgeId = aHueConfig.getBridgeid();
|
bridgeId = aHueConfig.getBridgeid();
|
||||||
bridgeSNUUID = aHueConfig.getSNUUIDFromMac();
|
bridgeSNUUID = aHueConfig.getSNUUIDFromMac();
|
||||||
discoveryResponse = String.format(responseTemplate1, Configuration.UPNP_MULTICAST_ADDRESS, Configuration.UPNP_DISCOVERY_PORT, responseAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
discoveryResponse = String.format(responseTemplate1, Configuration.UPNP_MULTICAST_ADDRESS, Configuration.UPNP_DISCOVERY_PORT, responseAddress, httpServerPort, bridgeId, bridgeSNUUID);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
|
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueConstants;
|
||||||
import com.bwssystems.HABridge.api.hue.HuePublicConfig;
|
import com.bwssystems.HABridge.api.hue.HuePublicConfig;
|
||||||
|
|
||||||
import static spark.Spark.get;
|
import static spark.Spark.get;
|
||||||
@@ -30,10 +31,10 @@ public class UpnpSettingsResource {
|
|||||||
+ "<manufacturerURL>http://www.philips.com</manufacturerURL>\n"
|
+ "<manufacturerURL>http://www.philips.com</manufacturerURL>\n"
|
||||||
+ "<modelDescription>Philips hue Personal Wireless Lighting</modelDescription>\n"
|
+ "<modelDescription>Philips hue Personal Wireless Lighting</modelDescription>\n"
|
||||||
+ "<modelName>Philips hue bridge 2015</modelName>\n"
|
+ "<modelName>Philips hue bridge 2015</modelName>\n"
|
||||||
+ "<modelNumber>BSB002</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:2f402f80-da50-11e1-9b23-%s</UDN>\n"
|
+ "<UDN>uuid:" + HueConstants.UUID_PREFIX + "%s</UDN>\n"
|
||||||
+ "<serviceList>\n"
|
+ "<serviceList>\n"
|
||||||
+ "<service>\n"
|
+ "<service>\n"
|
||||||
+ "<serviceType>(null)</serviceType>\n"
|
+ "<serviceType>(null)</serviceType>\n"
|
||||||
@@ -78,7 +79,7 @@ public class UpnpSettingsResource {
|
|||||||
log.debug("upnp device settings requested: " + " from " + request.ip() + ":" + request.port());
|
log.debug("upnp device settings requested: " + " from " + request.ip() + ":" + request.port());
|
||||||
String portNumber = Integer.toString(request.port());
|
String portNumber = Integer.toString(request.port());
|
||||||
String filledTemplate = null;
|
String filledTemplate = null;
|
||||||
String bridgeIdMac = HuePublicConfig.createConfig("temp", theSettings.getUpnpConfigAddress()).getSNUUIDFromMac();
|
String bridgeIdMac = HuePublicConfig.createConfig("temp", theSettings.getUpnpConfigAddress(), HueConstants.HUB_VERSION).getSNUUIDFromMac();
|
||||||
filledTemplate = String.format(hueTemplate, theSettings.getUpnpConfigAddress(), portNumber, theSettings.getUpnpConfigAddress(), bridgeIdMac, bridgeIdMac);
|
filledTemplate = String.format(hueTemplate, theSettings.getUpnpConfigAddress(), portNumber, theSettings.getUpnpConfigAddress(), bridgeIdMac, bridgeIdMac);
|
||||||
if(theSettings.isTraceupnp())
|
if(theSettings.isTraceupnp())
|
||||||
log.info("Traceupnp: upnp device settings template filled with address: " + theSettings.getUpnpConfigAddress() + " and port: " + portNumber);
|
log.info("Traceupnp: upnp device settings template filled with address: " + theSettings.getUpnpConfigAddress() + " and port: " + portNumber);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ public class HassCommand {
|
|||||||
private String entityId;
|
private String entityId;
|
||||||
private String hassName;
|
private String hassName;
|
||||||
private String state;
|
private String state;
|
||||||
private Integer bri;
|
private String bri;
|
||||||
public String getEntityId() {
|
public String getEntityId() {
|
||||||
return entityId;
|
return entityId;
|
||||||
}
|
}
|
||||||
@@ -23,11 +23,10 @@ public class HassCommand {
|
|||||||
public void setState(String state) {
|
public void setState(String state) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
public Integer getBri() {
|
public String getBri() {
|
||||||
return bri;
|
return bri;
|
||||||
}
|
}
|
||||||
public void setBri(Integer bri) {
|
public void setBri(String bri) {
|
||||||
this.bri = bri;
|
this.bri = bri;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ public class HomeAssistant {
|
|||||||
}
|
}
|
||||||
if(aCommand.getState().equalsIgnoreCase("on")) {
|
if(aCommand.getState().equalsIgnoreCase("on")) {
|
||||||
aUrl = aUrl + "/turn_on";
|
aUrl = aUrl + "/turn_on";
|
||||||
if(aCommand.getBri() != null && aCommand.getBri() > 0)
|
if(aCommand.getBri() != null)
|
||||||
aBody = aBody + ",\"state\":\"on\",\"attributes\":{\"brightness\":" + aCommand.getBri() + "}}";
|
aBody = aBody + ",\"state\":\"on\",\"attributes\":{\"brightness\":" + aCommand.getBri() + "}}";
|
||||||
else
|
else
|
||||||
aBody = aBody + "}";
|
aBody = aBody + "}";
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
package com.bwssystems.hue;
|
|
||||||
|
|
||||||
public interface HueErrorStringSet {
|
|
||||||
public void setErrorString(String anError);
|
|
||||||
}
|
|
||||||
@@ -15,7 +15,7 @@ import com.bwssystems.HABridge.api.hue.HueApiResponse;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
|
|
||||||
public class HueInfo implements HueErrorStringSet {
|
public class HueInfo {
|
||||||
private static final Logger log = LoggerFactory.getLogger(HueInfo.class);
|
private static final Logger log = LoggerFactory.getLogger(HueInfo.class);
|
||||||
private HttpClient httpClient;
|
private HttpClient httpClient;
|
||||||
private NamedIP hueAddress;
|
private NamedIP hueAddress;
|
||||||
@@ -50,7 +50,7 @@ public class HueInfo implements HueErrorStringSet {
|
|||||||
log.debug("GET HueApiResponse - data: " + theData);
|
log.debug("GET HueApiResponse - data: " + theData);
|
||||||
if(theData.contains("[{\"error\":")) {
|
if(theData.contains("[{\"error\":")) {
|
||||||
if(theData.contains("unauthorized user")) {
|
if(theData.contains("unauthorized user")) {
|
||||||
theUser = HueUtil.registerWithHue(httpClient, hueAddress.getIp(), hueAddress.getName(), theHueHome.getTheHUERegisteredUser(), this);
|
theUser = HueUtil.registerWithHue(httpClient, hueAddress.getIp(), hueAddress.getName(), theHueHome.getTheHUERegisteredUser());
|
||||||
if(theUser == null) {
|
if(theUser == null) {
|
||||||
log.warn("Register to Hue for " + hueAddress.getName() + " returned error: " + errorString);
|
log.warn("Register to Hue for " + hueAddress.getName() + " returned error: " + errorString);
|
||||||
return null;
|
return null;
|
||||||
@@ -103,9 +103,4 @@ public class HueInfo implements HueErrorStringSet {
|
|||||||
public void setHueAddress(NamedIP hueAddress) {
|
public void setHueAddress(NamedIP hueAddress) {
|
||||||
this.hueAddress = hueAddress;
|
this.hueAddress = hueAddress;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setErrorString(String anError) {
|
|
||||||
errorString = anError;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class HueUtil {
|
|||||||
private static final Logger log = LoggerFactory.getLogger(HueUtil.class);
|
private static final Logger log = LoggerFactory.getLogger(HueUtil.class);
|
||||||
public static final String HUE_REQUEST = "/api";
|
public static final String HUE_REQUEST = "/api";
|
||||||
|
|
||||||
public static final String registerWithHue(HttpClient anHttpClient, String ipAddress, String aName, String theUser, HueErrorStringSet errorStringSet) {
|
public static final String registerWithHue(HttpClient anHttpClient, String ipAddress, String aName, String theUser) {
|
||||||
UserCreateRequest theLogin = new UserCreateRequest();
|
UserCreateRequest theLogin = new UserCreateRequest();
|
||||||
theLogin.setDevicetype("HABridge#MyMachine");
|
theLogin.setDevicetype("HABridge#MyMachine");
|
||||||
HttpPost postRequest = new HttpPost("http://" + ipAddress + HUE_REQUEST);
|
HttpPost postRequest = new HttpPost("http://" + ipAddress + HUE_REQUEST);
|
||||||
@@ -39,7 +39,6 @@ public class HueUtil {
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
log.warn("registerWithHue returned an unexpected error: " + theBody);
|
log.warn("registerWithHue returned an unexpected error: " + theBody);
|
||||||
errorStringSet.setErrorString(theBody);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
SuccessUserResponse[] theResponses = new Gson().fromJson(theBody, SuccessUserResponse[].class); //read content for data, SuccessUserResponse[].class);
|
SuccessUserResponse[] theResponses = new Gson().fromJson(theBody, SuccessUserResponse[].class); //read content for data, SuccessUserResponse[].class);
|
||||||
|
|||||||
@@ -41,7 +41,6 @@
|
|||||||
<th sortable-header col="name">Name</th>
|
<th sortable-header col="name">Name</th>
|
||||||
<th sortable-header col="deviceType">Type</th>
|
<th sortable-header col="deviceType">Type</th>
|
||||||
<th sortable-header col="targetDevice">Target</th>
|
<th sortable-header col="targetDevice">Target</th>
|
||||||
<th sortable-header col="requesterAddress">Requester Address</th>
|
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -51,7 +50,6 @@
|
|||||||
<td>{{device.name}}</td>
|
<td>{{device.name}}</td>
|
||||||
<td>{{device.deviceType}}</td>
|
<td>{{device.deviceType}}</td>
|
||||||
<td>{{device.targetDevice}}</td>
|
<td>{{device.targetDevice}}</td>
|
||||||
<td>{{device.requesterAddress}}</td>
|
|
||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
<button class="btn btn-info" type="submit"
|
<button class="btn btn-info" type="submit"
|
||||||
|
|||||||
@@ -325,6 +325,12 @@
|
|||||||
ng-model="bridge.settings.farenheit" ng-true-value=true
|
ng-model="bridge.settings.farenheit" ng-true-value=true
|
||||||
ng-false-value=false> {{bridge.settings.farenheit}}</td>
|
ng-false-value=false> {{bridge.settings.farenheit}}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Emulate Hue Hub Version</td>
|
||||||
|
<td><input id="bridge-settings-hubversion" class="form-control"
|
||||||
|
type="text" ng-model="bridge.settings.hubversion"
|
||||||
|
placeholder="01036562"></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Button Press/Call Item Loop Sleep Interval (ms)</td>
|
<td>Button Press/Call Item Loop Sleep Interval (ms)</td>
|
||||||
<td><input id="bridge-settings-buttonsleep"
|
<td><input id="bridge-settings-buttonsleep"
|
||||||
|
|||||||
Reference in New Issue
Block a user