Fix small issues and add pct check for FHEM

This commit is contained in:
bsamuels
2018-01-26 13:41:57 -06:00
parent 47074ff60f
commit c843e8d1ac
10 changed files with 73 additions and 45 deletions

View File

@@ -3,6 +3,7 @@ package com.bwssystems.HABridge.upnp;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.bwssystems.HABridge.BridgeSettings;
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
import com.bwssystems.HABridge.api.hue.HueConstants;
import com.bwssystems.HABridge.api.hue.HuePublicConfig;
@@ -16,6 +17,7 @@ public class UpnpSettingsResource {
private Logger log = LoggerFactory.getLogger(UpnpSettingsResource.class);
private BridgeSettingsDescriptor theSettings;
private BridgeSettings bridgeSettings;
private String hueTemplate = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n"
+ "<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n"
@@ -55,15 +57,22 @@ public class UpnpSettingsResource {
+ "</device>\n"
+ "</root>\n";
public UpnpSettingsResource(BridgeSettingsDescriptor theBridgeSettings) {
public UpnpSettingsResource(BridgeSettings theBridgeSettings) {
super();
this.theSettings = theBridgeSettings;
this.bridgeSettings = theBridgeSettings;
this.theSettings = theBridgeSettings.getBridgeSettingsDescriptor();
}
public void setupServer() {
log.info("Description xml service started....");
// http://ip_adress:port/description.xml which returns the xml configuration for the hue emulator
get("/description.xml", "application/xml; charset=utf-8", (request, response) -> {
if(bridgeSettings.getBridgeControl().isReinit() || bridgeSettings.getBridgeControl().isStop()) {
log.info("Get description.xml called while in re-init or stop state");
response.status(503);
return null;
}
String portNumber = Integer.toString(request.port());
String filledTemplate = null;
String bridgeIdMac = HuePublicConfig.createConfig("temp", theSettings.getUpnpConfigAddress(), HueConstants.HUB_VERSION, theSettings.getHubmac()).getSNUUIDFromMac();