mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c1dc89704d | ||
|
|
f97c718568 | ||
|
|
d05b6bea5c | ||
|
|
2f567cd604 | ||
|
|
ce97e928ad | ||
|
|
df67980bd6 |
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>5.2.2RC</version>
|
||||
<version>5.2.2</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
|
||||
@@ -198,7 +198,7 @@ public class BridgeSettings extends BackupHandler {
|
||||
theBridgeSettings.setUpnpGroupDb(Configuration.GROUP_DB_DIRECTORY);
|
||||
|
||||
if(theBridgeSettings.getNumberoflogmessages() == null || theBridgeSettings.getNumberoflogmessages() <= 0)
|
||||
theBridgeSettings.setNumberoflogmessages(new Integer(Configuration.NUMBER_OF_LOG_MESSAGES));
|
||||
theBridgeSettings.setNumberoflogmessages(Integer.valueOf(Configuration.NUMBER_OF_LOG_MESSAGES));
|
||||
|
||||
if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0)
|
||||
theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP));
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.bwssystems.HABridge.dao;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.file.FileSystems;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@@ -13,8 +12,6 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -25,6 +22,7 @@ import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||
import com.bwssystems.HABridge.plugins.hue.HueHome;
|
||||
import com.bwssystems.HABridge.util.BackupHandler;
|
||||
import com.bwssystems.HABridge.util.JsonTransformer;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonSyntaxException;
|
||||
@@ -180,9 +178,7 @@ public class DeviceRepository extends BackupHandler {
|
||||
descriptors[i].setId(String.valueOf(nextId));
|
||||
}
|
||||
if(descriptors[i].getUniqueid() == null || descriptors[i].getUniqueid().length() == 0) {
|
||||
BigInteger bigInt = BigInteger.valueOf(Integer.decode(descriptors[i].getId()));
|
||||
byte[] theBytes = bigInt.toByteArray();
|
||||
String hexValue = DatatypeConverter.printHexBinary(theBytes);
|
||||
String hexValue = HexLibrary.encodeUsingBigIntegerToString(descriptors[i].getId());
|
||||
|
||||
descriptors[i].setUniqueid("00:17:88:5E:D3:" + hexValue + "-" + hexValue);
|
||||
}
|
||||
@@ -204,9 +200,7 @@ public class DeviceRepository extends BackupHandler {
|
||||
nextId++;
|
||||
DeviceDescriptor theDevice = deviceIterator.next();
|
||||
theDevice.setId(String.valueOf(nextId));
|
||||
BigInteger bigInt = BigInteger.valueOf(nextId);
|
||||
byte[] theBytes = bigInt.toByteArray();
|
||||
String hexValue = DatatypeConverter.printHexBinary(theBytes);
|
||||
String hexValue = HexLibrary.encodeUsingBigIntegerToString(nextId.toString());
|
||||
|
||||
theDevice.setUniqueid("00:17:88:5E:D3:" + hexValue + "-" + hexValue);
|
||||
newdevices.put(theDevice.getId(), theDevice);
|
||||
|
||||
@@ -62,7 +62,7 @@ public class BrightnessDecode {
|
||||
if(intensity > 0 && intensity < 5)
|
||||
percentBrightness = 1;
|
||||
else
|
||||
percentBrightness = (int) Math.round(intensity / 255.0 * 100)
|
||||
percentBrightness = (int) Math.round(intensity / 255.0 * 100);
|
||||
} else {
|
||||
decimalBrightness = (float) 0.0;
|
||||
percentBrightness = 0;
|
||||
|
||||
@@ -1073,9 +1073,9 @@ public class HueMulator {
|
||||
}
|
||||
|
||||
if (body.contains("\"bri_inc\""))
|
||||
targetBriInc = new Integer(theStateChanges.getBri_inc());
|
||||
targetBriInc = Integer.valueOf(theStateChanges.getBri_inc());
|
||||
else if (body.contains("\"bri\"")) {
|
||||
targetBri = new Integer(theStateChanges.getBri());
|
||||
targetBri =Integer.valueOf(theStateChanges.getBri());
|
||||
}
|
||||
|
||||
state = device.getDeviceState();
|
||||
@@ -1153,11 +1153,11 @@ public class HueMulator {
|
||||
}
|
||||
|
||||
if (body.contains("\"bri_inc\"")) {
|
||||
targetBriInc = new Integer(theStateChanges.getBri_inc());
|
||||
targetBriInc = Integer.valueOf(theStateChanges.getBri_inc());
|
||||
isDimRequest = true;
|
||||
}
|
||||
else if (body.contains("\"bri\"")) {
|
||||
targetBri = new Integer(theStateChanges.getBri());
|
||||
targetBri = Integer.valueOf(theStateChanges.getBri());
|
||||
isDimRequest = true;
|
||||
}
|
||||
|
||||
@@ -1343,10 +1343,10 @@ public class HueMulator {
|
||||
|
||||
if (group != null) {
|
||||
if (body.contains("\"bri_inc\"")) {
|
||||
targetBriInc = new Integer(theStateChanges.getBri_inc());
|
||||
targetBriInc = Integer.valueOf(theStateChanges.getBri_inc());
|
||||
}
|
||||
else if (body.contains("\"bri\"")) {
|
||||
targetBri = new Integer(theStateChanges.getBri());
|
||||
targetBri = Integer.valueOf(theStateChanges.getBri());
|
||||
}
|
||||
|
||||
state = group.getAction();
|
||||
|
||||
@@ -11,8 +11,6 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -28,6 +26,7 @@ import com.bwssystems.HABridge.hue.ColorDecode;
|
||||
import com.bwssystems.HABridge.hue.DeviceDataDecode;
|
||||
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
||||
import com.bwssystems.HABridge.hue.TimeDecode;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
import com.github.mob41.blapi.BLDevice;
|
||||
import com.github.mob41.blapi.MP1Device;
|
||||
import com.github.mob41.blapi.SP1Device;
|
||||
@@ -118,7 +117,7 @@ public class BroadlinkHome implements Home {
|
||||
|
||||
if (theDevice == null) {
|
||||
if(broadlinkCommand.hasIpAndMac()) {
|
||||
byte[] intBytes = DatatypeConverter.parseHexBinary(broadlinkCommand.getType());
|
||||
byte[] intBytes = HexLibrary.decodeHexString(broadlinkCommand.getType());
|
||||
BigInteger theBig = new BigInteger(intBytes);
|
||||
int theType = theBig.intValue();
|
||||
try {
|
||||
@@ -218,13 +217,13 @@ public class BroadlinkHome implements Home {
|
||||
}
|
||||
theStringData = DeviceDataDecode.replaceDeviceData(theStringData, device);
|
||||
theStringData = TimeDecode.replaceTimeValue(theStringData);
|
||||
byte[] theData = DatatypeConverter.parseHexBinary(theStringData);
|
||||
byte[] theData = HexLibrary.decodeHexString(theStringData);
|
||||
SendDataCmdPayload thePayload = new SendDataCmdPayload(theData);
|
||||
|
||||
DatagramPacket thePacket = theDevice.sendCmdPkt(Configuration.BROADLINK_DISCONVER_TIMEOUT, thePayload);
|
||||
String returnData = null;
|
||||
if(thePacket != null)
|
||||
returnData = DatatypeConverter.printHexBinary(thePacket.getData());
|
||||
returnData = HexLibrary.encodeHexString(thePacket.getData());
|
||||
else
|
||||
returnData = "No Data - null";
|
||||
log.debug("RM2 Device data return: <<<" + returnData + ">>>");
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -33,7 +33,7 @@ public class TestBLDevice extends BLDevice {
|
||||
}
|
||||
|
||||
public DatagramPacket sendCmdPkt(int timeout, CmdPayload aCmd) {
|
||||
log.info("sendCmdPkt called with " + DatatypeConverter.printHexBinary(aCmd.getPayload().getData()));
|
||||
log.info("sendCmdPkt called with " + HexLibrary.encodeHexString(aCmd.getPayload().getData()));
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.bwssystems.HABridge.plugins.broadlink;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -23,7 +23,7 @@ public class TestMP1Device extends MP1Device {
|
||||
}
|
||||
|
||||
public DatagramPacket sendCmdPkt(int timeout, CmdPayload aCmd) {
|
||||
log.info("sendCmdPkt called with " + DatatypeConverter.printHexBinary(aCmd.getPayload().getData()));
|
||||
log.info("sendCmdPkt called with " + HexLibrary.encodeHexString(aCmd.getPayload().getData()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bwssystems.HABridge.plugins.broadlink;
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -21,7 +21,7 @@ public class TestRM2Device extends RM2Device {
|
||||
}
|
||||
|
||||
public DatagramPacket sendCmdPkt(int timeout, CmdPayload aCmd) {
|
||||
log.info("sendCmdPkt called with " + DatatypeConverter.printHexBinary(((SendDataCmdPayload)aCmd).getData()));
|
||||
log.info("sendCmdPkt called with " + HexLibrary.encodeHexString(((SendDataCmdPayload)aCmd).getData()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bwssystems.HABridge.plugins.broadlink;
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -24,7 +24,7 @@ public class TestSP1Device extends SP1Device {
|
||||
}
|
||||
|
||||
public DatagramPacket sendCmdPkt(int timeout, CmdPayload aCmd) {
|
||||
log.info("sendCmdPkt called with " + DatatypeConverter.printHexBinary(aCmd.getPayload().getData()));
|
||||
log.info("sendCmdPkt called with " + HexLibrary.encodeHexString(aCmd.getPayload().getData()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.bwssystems.HABridge.plugins.broadlink;
|
||||
import java.io.IOException;
|
||||
import java.net.DatagramPacket;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -24,7 +24,7 @@ public class TestSP2Device extends SP2Device {
|
||||
}
|
||||
|
||||
public DatagramPacket sendCmdPkt(int timeout, CmdPayload aCmd) {
|
||||
log.info("sendCmdPkt called with " + DatatypeConverter.printHexBinary(aCmd.getPayload().getData()));
|
||||
log.info("sendCmdPkt called with " + HexLibrary.encodeHexString(aCmd.getPayload().getData()));
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.bwssystems.HABridge.plugins.http.HTTPHandler;
|
||||
import com.bwssystems.HABridge.plugins.http.HTTPHome;
|
||||
import com.bwssystems.HABridge.plugins.http.HttpTestHandler;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
public class FHEMHome implements Home {
|
||||
private static final Logger log = LoggerFactory.getLogger(FHEMHome.class);
|
||||
@@ -47,7 +48,8 @@ public class FHEMHome implements Home {
|
||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||
Integer targetBri, Integer targetBriInc, ColorData colorData, DeviceDescriptor device, String body) {
|
||||
|
||||
String theUrl = anItem.getItem().getAsString();
|
||||
JsonElement jsonUrl = anItem.getItem();
|
||||
String theUrl = jsonUrl.toString();
|
||||
String responseString = null;
|
||||
|
||||
if(theUrl != null && !theUrl.isEmpty()) {
|
||||
|
||||
@@ -43,6 +43,7 @@ public class HarmonyHandler {
|
||||
listOfActivities = harmonyClient.getConfig().getActivities();
|
||||
} catch (RuntimeException e) {
|
||||
handleExceptionError(e);
|
||||
return null;
|
||||
}
|
||||
|
||||
return listOfActivities;
|
||||
@@ -59,6 +60,7 @@ public class HarmonyHandler {
|
||||
listOfDevices = harmonyClient.getConfig().getDevices();
|
||||
} catch (RuntimeException e) {
|
||||
handleExceptionError(e);
|
||||
return null;
|
||||
}
|
||||
return listOfDevices;
|
||||
}
|
||||
@@ -73,6 +75,7 @@ public class HarmonyHandler {
|
||||
aConfig = harmonyClient.getConfig();
|
||||
} catch (RuntimeException e) {
|
||||
handleExceptionError(e);
|
||||
return null;
|
||||
}
|
||||
return aConfig;
|
||||
}
|
||||
@@ -87,6 +90,7 @@ public class HarmonyHandler {
|
||||
anActivity = harmonyClient.getCurrentActivity();
|
||||
} catch (RuntimeException e) {
|
||||
handleExceptionError(e);
|
||||
return null;
|
||||
}
|
||||
return anActivity;
|
||||
}
|
||||
@@ -112,16 +116,14 @@ public class HarmonyHandler {
|
||||
harmonyClient.startActivityByName(anActivity.getName());
|
||||
} catch (IllegalArgumentException ei) {
|
||||
log.error("Error in finding activity: " + anActivity.getName() + " for a hub: " + anActivity.getHub());
|
||||
return false;
|
||||
} catch (RuntimeException e1) {
|
||||
handleExceptionError(e1);
|
||||
return handleExceptionError(e1);
|
||||
}
|
||||
} catch (RuntimeException e1) {
|
||||
handleExceptionError(e1);
|
||||
return handleExceptionError(e1);
|
||||
}
|
||||
} else {
|
||||
log.error("Error in finding activity: " + anActivity.getName() + " for a hub: " + anActivity.getHub());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -147,40 +149,45 @@ public class HarmonyHandler {
|
||||
harmonyClient.pressButton(aDeviceButton.getDevice(), aDeviceButton.getButton());
|
||||
} catch (IllegalArgumentException ei) {
|
||||
log.error("Error in finding device: " + aDeviceButton.getDevice() +" and a button: " + aDeviceButton.getButton() + " for a hub: " + aDeviceButton.getHub());
|
||||
return false;
|
||||
} catch (RuntimeException e1) {
|
||||
handleExceptionError(e1);
|
||||
return handleExceptionError(e1);
|
||||
}
|
||||
} catch (RuntimeException e1) {
|
||||
handleExceptionError(e1);
|
||||
return handleExceptionError(e1);
|
||||
}
|
||||
} else {
|
||||
log.error("Error in finding device: " + aDeviceButton.getDevice() +" and a button: " + aDeviceButton.getButton() + " for a hub: " + aDeviceButton.getHub());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean handleExceptionError(Exception e) {
|
||||
if(e.getMessage().contains("Failed communicating with Harmony Hub") || e.getMessage().contains("Send heartbeat failed")) {
|
||||
log.warn("Issue in communcicating with Harmony Hub, retrying connect....");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void handleExceptionError(Exception e) {
|
||||
if(e.getMessage().equalsIgnoreCase("Failed communicating with Harmony Hub")) {
|
||||
log.warn("Issue in communcicating with Harmony Hub, retrying connect....");
|
||||
try {
|
||||
harmonyClient.disconnect();
|
||||
} catch(Exception e1) {
|
||||
log.warn("Hub disconnect failed, continuing....");
|
||||
}
|
||||
harmonyClient.connect(myNameAndIP.getIp());
|
||||
}
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
log.debug("Harmony api shutdown requested.");
|
||||
if(devMode)
|
||||
return;
|
||||
|
||||
harmonyClient.disconnect();
|
||||
try {
|
||||
harmonyClient.disconnect();
|
||||
} catch(Exception e)
|
||||
{
|
||||
// noop
|
||||
}
|
||||
harmonyClient = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the myNameAndIP
|
||||
*/
|
||||
public NamedIP getMyNameAndIP() {
|
||||
return myNameAndIP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import net.whistlingfish.harmony.config.Activity;
|
||||
import net.whistlingfish.harmony.config.Device;
|
||||
|
||||
public class HarmonyHome implements Home {
|
||||
private static final Logger log = LoggerFactory.getLogger(HarmonyHome.class);
|
||||
private static final Logger log = LoggerFactory.getLogger(HarmonyHome.class);
|
||||
private Map<String, HarmonyServer> hubs;
|
||||
private Boolean isDevMode;
|
||||
private Boolean validHarmony;
|
||||
@@ -43,91 +43,136 @@ public class HarmonyHome implements Home {
|
||||
|
||||
@Override
|
||||
public void closeHome() {
|
||||
if(!validHarmony)
|
||||
if (!validHarmony)
|
||||
return;
|
||||
log.debug("Closing Home.");
|
||||
if(closed) {
|
||||
if (closed) {
|
||||
log.debug("Home is already closed....");
|
||||
return;
|
||||
}
|
||||
if(isDevMode || hubs == null)
|
||||
if (isDevMode || hubs == null)
|
||||
return;
|
||||
Iterator<String> keys = hubs.keySet().iterator();
|
||||
while(keys.hasNext()) {
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
hubs.get(key).getMyHarmony().shutdown();
|
||||
}
|
||||
|
||||
|
||||
hubs = null;
|
||||
closed = true;
|
||||
}
|
||||
|
||||
public HarmonyHandler getHarmonyHandler(String aName) {
|
||||
if(!validHarmony)
|
||||
if (!validHarmony)
|
||||
return null;
|
||||
HarmonyHandler aHandler = null;
|
||||
if(aName == null || aName.equals("")) {
|
||||
if (aName == null || aName.equals("")) {
|
||||
aName = "default";
|
||||
}
|
||||
|
||||
if(hubs.get(aName) == null) {
|
||||
if (hubs.get(aName) == null) {
|
||||
Set<String> keys = hubs.keySet();
|
||||
if(!keys.isEmpty()) {
|
||||
if (!keys.isEmpty()) {
|
||||
aHandler = hubs.get(keys.toArray()[0]).getMyHarmony();
|
||||
}
|
||||
else
|
||||
} else
|
||||
aHandler = null;
|
||||
}
|
||||
else
|
||||
} else
|
||||
aHandler = hubs.get(aName).getMyHarmony();
|
||||
return aHandler;
|
||||
}
|
||||
|
||||
|
||||
public List<HarmonyActivity> getActivities() {
|
||||
Iterator<String> keys = hubs.keySet().iterator();
|
||||
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
|
||||
if(!validHarmony)
|
||||
if (!validHarmony)
|
||||
return null;
|
||||
while(keys.hasNext()) {
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
Iterator<Activity> activities = hubs.get(key).getMyHarmony().getActivities().iterator();
|
||||
while(activities.hasNext()) {
|
||||
if (activities == null) {
|
||||
resetHub(hubs.get(key).getMyHarmony());
|
||||
activities = hubs.get(key).getMyHarmony().getActivities().iterator();
|
||||
if (activities == null) {
|
||||
if (resetHub(hubs.get(key).getMyHarmony())) {
|
||||
activities = hubs.get(key).getMyHarmony().getActivities().iterator();
|
||||
if (activities == null) {
|
||||
log.error("Could not get communication restored with hub: " + key
|
||||
+ ", please restart...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (activities != null) {
|
||||
while (activities.hasNext()) {
|
||||
HarmonyActivity anActivity = new HarmonyActivity();
|
||||
anActivity.setActivity(activities.next());
|
||||
anActivity.setHub(key);
|
||||
activityList.add(anActivity);
|
||||
}
|
||||
}
|
||||
}
|
||||
return activityList;
|
||||
}
|
||||
|
||||
public List<HarmonyActivity> getCurrentActivities() {
|
||||
Iterator<String> keys = hubs.keySet().iterator();
|
||||
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
|
||||
if (!validHarmony)
|
||||
return null;
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
Activity theActivity = hubs.get(key).getMyHarmony().getCurrentActivity();
|
||||
if (theActivity == null) {
|
||||
resetHub(hubs.get(key).getMyHarmony());
|
||||
theActivity = hubs.get(key).getMyHarmony().getCurrentActivity();
|
||||
if (theActivity == null) {
|
||||
if (resetHub(hubs.get(key).getMyHarmony())) {
|
||||
theActivity = hubs.get(key).getMyHarmony().getCurrentActivity();
|
||||
if (theActivity == null) {
|
||||
log.error("Could not get communication restored with hub: " + key
|
||||
+ ", please restart...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (theActivity != null) {
|
||||
HarmonyActivity anActivity = new HarmonyActivity();
|
||||
anActivity.setActivity(activities.next());
|
||||
anActivity.setActivity(theActivity);
|
||||
anActivity.setHub(key);
|
||||
activityList.add(anActivity);
|
||||
}
|
||||
}
|
||||
return activityList;
|
||||
}
|
||||
public List<HarmonyActivity> getCurrentActivities() {
|
||||
Iterator<String> keys = hubs.keySet().iterator();
|
||||
ArrayList<HarmonyActivity> activityList = new ArrayList<HarmonyActivity>();
|
||||
if(!validHarmony)
|
||||
return null;
|
||||
while(keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
Activity theActivity = hubs.get(key).getMyHarmony().getCurrentActivity();
|
||||
HarmonyActivity anActivity = new HarmonyActivity();
|
||||
anActivity.setActivity(theActivity);
|
||||
anActivity.setHub(key);
|
||||
activityList.add(anActivity);
|
||||
}
|
||||
return activityList;
|
||||
}
|
||||
|
||||
public List<HarmonyDevice> getDevices() {
|
||||
Iterator<String> keys = hubs.keySet().iterator();
|
||||
ArrayList<HarmonyDevice> deviceList = new ArrayList<HarmonyDevice>();
|
||||
if(!validHarmony)
|
||||
if (!validHarmony)
|
||||
return null;
|
||||
while(keys.hasNext()) {
|
||||
while (keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
Iterator<Device> devices = hubs.get(key).getMyHarmony().getDevices().iterator();
|
||||
while(devices.hasNext()) {
|
||||
HarmonyDevice aDevice = new HarmonyDevice();
|
||||
aDevice.setDevice(devices.next());
|
||||
aDevice.setHub(key);
|
||||
deviceList.add(aDevice);
|
||||
if (devices == null) {
|
||||
resetHub(hubs.get(key).getMyHarmony());
|
||||
devices = hubs.get(key).getMyHarmony().getDevices().iterator();
|
||||
if (devices == null) {
|
||||
if (resetHub(hubs.get(key).getMyHarmony())) {
|
||||
devices = hubs.get(key).getMyHarmony().getDevices().iterator();
|
||||
if (devices == null) {
|
||||
log.error("Could not get communication restored with hub: " + key
|
||||
+ ", please restart...");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (devices != null) {
|
||||
while (devices.hasNext()) {
|
||||
HarmonyDevice aDevice = new HarmonyDevice();
|
||||
aDevice.setDevice(devices.next());
|
||||
aDevice.setHub(key);
|
||||
deviceList.add(aDevice);
|
||||
}
|
||||
}
|
||||
}
|
||||
return deviceList;
|
||||
@@ -135,23 +180,22 @@ public class HarmonyHome implements Home {
|
||||
|
||||
@Override
|
||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||
Integer targetBri,Integer targetBriInc, ColorData colorData, DeviceDescriptor device, String body) {
|
||||
Integer targetBri, Integer targetBriInc, ColorData colorData, DeviceDescriptor device, String body) {
|
||||
String responseString = null;
|
||||
log.debug("executing HUE api request to change " + anItem.getType() + " to Harmony: " + device.getName());
|
||||
if(!validHarmony) {
|
||||
if (!validHarmony) {
|
||||
log.warn("Should not get here, no harmony configured");
|
||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
|
||||
+ "\",\"description\": \"Should not get here, no harmony configured\", \"parameter\": \"/lights/"
|
||||
+ lightId + "state\"}}]";
|
||||
+ lightId + "state\"}}]";
|
||||
} else {
|
||||
if(anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex]))
|
||||
{
|
||||
if (anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex])) {
|
||||
RunActivity anActivity = null;
|
||||
if(anItem.getItem().isJsonObject())
|
||||
if (anItem.getItem().isJsonObject())
|
||||
anActivity = aGsonHandler.fromJson(anItem.getItem(), RunActivity.class);
|
||||
else
|
||||
anActivity = aGsonHandler.fromJson(anItem.getItem().getAsString(), RunActivity.class);
|
||||
if(anActivity.getHub() == null || anActivity.getHub().isEmpty())
|
||||
if (anActivity.getHub() == null || anActivity.getHub().isEmpty())
|
||||
anActivity.setHub(device.getTargetDevice());
|
||||
HarmonyHandler myHarmony = getHarmonyHandler(anActivity.getHub());
|
||||
if (myHarmony == null) {
|
||||
@@ -160,11 +204,23 @@ public class HarmonyHome implements Home {
|
||||
+ "\",\"description\": \"Should not get here, no harmony hub available\", \"parameter\": \"/lights/"
|
||||
+ lightId + "state\"}}]";
|
||||
} else {
|
||||
myHarmony.startActivity(anActivity);
|
||||
if (!myHarmony.startActivity(anActivity)) {
|
||||
if (resetHub(myHarmony)) {
|
||||
myHarmony = getHarmonyHandler(anActivity.getHub());
|
||||
if (!myHarmony.startActivity(anActivity)) {
|
||||
log.error("Could not get communication restored with hub: " + anActivity.getHub()
|
||||
+ ", please restart...");
|
||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
|
||||
+ "\",\"description\": \"Could not communicate with harmony\", \"parameter\": \"/lights/"
|
||||
+ lightId + "state\"}}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if(anItem.getType().trim().equalsIgnoreCase(DeviceMapTypes.HARMONY_BUTTON[DeviceMapTypes.typeIndex])) {
|
||||
} else if (anItem.getType().trim()
|
||||
.equalsIgnoreCase(DeviceMapTypes.HARMONY_BUTTON[DeviceMapTypes.typeIndex])) {
|
||||
String url = null;
|
||||
if(anItem.getItem().isJsonObject() || anItem.getItem().isJsonArray()) {
|
||||
if (anItem.getItem().isJsonObject() || anItem.getItem().isJsonArray()) {
|
||||
url = aGsonHandler.toJson(anItem.getItem());
|
||||
} else
|
||||
url = anItem.getItem().getAsString();
|
||||
@@ -172,35 +228,50 @@ public class HarmonyHome implements Home {
|
||||
if (url.substring(0, 1).equalsIgnoreCase("{")) {
|
||||
url = "[" + url + "]";
|
||||
}
|
||||
|
||||
|
||||
url = BrightnessDecode.calculateReplaceIntensityValue(url, intensity, targetBri, targetBriInc, false);
|
||||
ButtonPress[] deviceButtons = aGsonHandler.fromJson(url, ButtonPress[].class);
|
||||
Integer theCount = 1;
|
||||
for(int z = 0; z < deviceButtons.length; z++) {
|
||||
if(deviceButtons[z].getCount() != null && deviceButtons[z].getCount() > 0)
|
||||
theCount = deviceButtons[z].getCount();
|
||||
for(int y = 0; y < theCount; y++) {
|
||||
if( y > 0 || z > 0) {
|
||||
try {
|
||||
Thread.sleep(aMultiUtil.getTheDelay());
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
Integer theCount = 1;
|
||||
for (int z = 0; z < deviceButtons.length; z++) {
|
||||
if (deviceButtons[z].getCount() != null && deviceButtons[z].getCount() > 0)
|
||||
theCount = deviceButtons[z].getCount();
|
||||
for (int y = 0; y < theCount; y++) {
|
||||
if (y > 0 || z > 0) {
|
||||
try {
|
||||
Thread.sleep(aMultiUtil.getTheDelay());
|
||||
} catch (InterruptedException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
if (anItem.getDelay() != null && anItem.getDelay() > 0)
|
||||
aMultiUtil.setTheDelay(anItem.getDelay());
|
||||
else
|
||||
aMultiUtil.setTheDelay(aMultiUtil.getDelayDefault());
|
||||
log.debug("pressing button: " + deviceButtons[z].getDevice() + " - "
|
||||
+ deviceButtons[z].getButton() + " with pressTime of: "
|
||||
+ deviceButtons[z].getPressTime() + " - iteration: " + String.valueOf(z) + " - count: "
|
||||
+ String.valueOf(y));
|
||||
if (deviceButtons[z].getHub() == null || deviceButtons[z].getHub().isEmpty())
|
||||
deviceButtons[z].setHub(device.getTargetDevice());
|
||||
HarmonyHandler myHarmony = getHarmonyHandler(deviceButtons[z].getHub());
|
||||
if (myHarmony == null)
|
||||
log.warn("Button Press - Should not get here, no harmony hub available");
|
||||
else{
|
||||
if (!myHarmony.pressButton(deviceButtons[z])) {
|
||||
if (resetHub(myHarmony)) {
|
||||
myHarmony = getHarmonyHandler(deviceButtons[z].getHub());
|
||||
if (!myHarmony.pressButton(deviceButtons[z])) {
|
||||
log.error("Could not get communication restored with hub: " + deviceButtons[z].getHub()
|
||||
+ ", please restart...");
|
||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId
|
||||
+ "\",\"description\": \"Could not communicate with harmony\", \"parameter\": \"/lights/"
|
||||
+ lightId + "state\"}}]";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (anItem.getDelay() != null && anItem.getDelay() > 0)
|
||||
aMultiUtil.setTheDelay(anItem.getDelay());
|
||||
else
|
||||
aMultiUtil.setTheDelay(aMultiUtil.getDelayDefault());
|
||||
log.debug("pressing button: " + deviceButtons[z].getDevice() + " - " + deviceButtons[z].getButton() + " with pressTime of: " + deviceButtons[z].getPressTime() + " - iteration: " + String.valueOf(z) + " - count: " + String.valueOf(y));
|
||||
if(deviceButtons[z].getHub() == null || deviceButtons[z].getHub().isEmpty())
|
||||
deviceButtons[z].setHub(device.getTargetDevice());
|
||||
HarmonyHandler myHarmony = getHarmonyHandler(deviceButtons[z].getHub());
|
||||
if (myHarmony == null)
|
||||
log.warn("Button Press - Should not get here, no harmony hub available");
|
||||
else
|
||||
myHarmony.pressButton(deviceButtons[z]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return responseString;
|
||||
@@ -208,15 +279,14 @@ public class HarmonyHome implements Home {
|
||||
|
||||
@Override
|
||||
public Home createHome(BridgeSettings bridgeSettings) {
|
||||
isDevMode = Boolean.parseBoolean(System.getProperty("dev.mode", "false"));
|
||||
validHarmony = bridgeSettings.getBridgeSettingsDescriptor().isValidHarmony();
|
||||
log.info("Harmony Home created." + (validHarmony ? "" : " No Harmony devices configured.") + (isDevMode ? " DevMode is set." : ""));
|
||||
if(validHarmony || isDevMode) {
|
||||
isDevMode = Boolean.parseBoolean(System.getProperty("dev.mode", "false"));
|
||||
validHarmony = bridgeSettings.getBridgeSettingsDescriptor().isValidHarmony();
|
||||
log.info("Harmony Home created." + (validHarmony ? "" : " No Harmony devices configured.")
|
||||
+ (isDevMode ? " DevMode is set." : ""));
|
||||
if (validHarmony || isDevMode) {
|
||||
hubs = new HashMap<String, HarmonyServer>();
|
||||
aGsonHandler =
|
||||
new GsonBuilder()
|
||||
.create();
|
||||
if(isDevMode) {
|
||||
aGsonHandler = new GsonBuilder().create();
|
||||
if (isDevMode) {
|
||||
NamedIP devModeIp = new NamedIP();
|
||||
devModeIp.setIp("10.10.10.10");
|
||||
devModeIp.setName("devMode");
|
||||
@@ -226,19 +296,21 @@ public class HarmonyHome implements Home {
|
||||
thedevList.setDevices(theList);
|
||||
bridgeSettings.getBridgeSettingsDescriptor().setHarmonyAddress(thedevList);
|
||||
}
|
||||
Iterator<NamedIP> theList = bridgeSettings.getBridgeSettingsDescriptor().getHarmonyAddress().getDevices().iterator();
|
||||
while(theList.hasNext() && validHarmony) {
|
||||
Iterator<NamedIP> theList = bridgeSettings.getBridgeSettingsDescriptor().getHarmonyAddress().getDevices()
|
||||
.iterator();
|
||||
while (theList.hasNext() && validHarmony) {
|
||||
NamedIP aHub = theList.next();
|
||||
boolean loopControl = true;
|
||||
int retryCount = 0;
|
||||
while(loopControl) {
|
||||
while (loopControl) {
|
||||
try {
|
||||
hubs.put(aHub.getName(), HarmonyServer.setup(bridgeSettings.getBridgeSettingsDescriptor(), isDevMode, aHub));
|
||||
loopControl = false;
|
||||
hubs.put(aHub.getName(), HarmonyServer.setup(isDevMode, aHub));
|
||||
loopControl = false;
|
||||
} catch (Exception e) {
|
||||
if(retryCount > 3) {
|
||||
log.error("Cannot get harmony client (" + aHub.getName() + ") setup, Exiting with message: " + e.getMessage(), e);
|
||||
loopControl = false;
|
||||
if (retryCount > 3) {
|
||||
log.error("Cannot get harmony client (" + aHub.getName() + ") setup, Exiting with message: "
|
||||
+ e.getMessage(), e);
|
||||
loopControl = false;
|
||||
} else {
|
||||
try {
|
||||
Thread.sleep(2000);
|
||||
@@ -246,25 +318,44 @@ public class HarmonyHome implements Home {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
retryCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(hubs.isEmpty())
|
||||
if (hubs.isEmpty())
|
||||
validHarmony = false;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean resetHub(HarmonyHandler aHarmony) {
|
||||
boolean resetSuccess = false;
|
||||
isDevMode = Boolean.parseBoolean(System.getProperty("dev.mode", "false"));
|
||||
NamedIP resetIp = aHarmony.getMyNameAndIP();
|
||||
log.info("Resetting harmony hub due to communication errror: " + resetIp.getName());
|
||||
if (!isDevMode) {
|
||||
try {
|
||||
hubs.remove(resetIp.getName());
|
||||
aHarmony.shutdown();
|
||||
hubs.put(resetIp.getName(), HarmonyServer.setup(isDevMode, resetIp));
|
||||
resetSuccess = true;
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot reset harmony client (" + resetIp.getName() + "), Exiting with message: "
|
||||
+ e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
return resetSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItems(String type) {
|
||||
if(validHarmony) {
|
||||
if(type.equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex]))
|
||||
if (validHarmony) {
|
||||
if (type.equalsIgnoreCase(DeviceMapTypes.HARMONY_ACTIVITY[DeviceMapTypes.typeIndex]))
|
||||
return getActivities();
|
||||
if(type.equalsIgnoreCase(DeviceMapTypes.HARMONY_BUTTON[DeviceMapTypes.typeIndex]))
|
||||
if (type.equalsIgnoreCase(DeviceMapTypes.HARMONY_BUTTON[DeviceMapTypes.typeIndex]))
|
||||
return getDevices();
|
||||
if(type.equalsIgnoreCase("current_activity"))
|
||||
if (type.equalsIgnoreCase("current_activity"))
|
||||
return getCurrentActivities();
|
||||
}
|
||||
return null;
|
||||
@@ -272,7 +363,7 @@ public class HarmonyHome implements Home {
|
||||
|
||||
@Override
|
||||
public void refresh() {
|
||||
// noop
|
||||
// noop
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.apache.http.client.methods.HttpGet;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.HABridge.BridgeSettingsDescriptor;
|
||||
import com.bwssystems.HABridge.NamedIP;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
@@ -50,11 +49,10 @@ public class HarmonyServer {
|
||||
}
|
||||
|
||||
public static HarmonyServer setup(
|
||||
BridgeSettingsDescriptor bridgeSettings,
|
||||
Boolean harmonyDevMode,
|
||||
NamedIP theHarmonyAddress
|
||||
) throws Exception {
|
||||
if (!bridgeSettings.isValidHarmony() && harmonyDevMode) {
|
||||
if (harmonyDevMode) {
|
||||
return new HarmonyServer(theHarmonyAddress);
|
||||
}
|
||||
Injector injector = null;
|
||||
@@ -65,11 +63,11 @@ public class HarmonyServer {
|
||||
if (!harmonyDevMode) {
|
||||
injector.injectMembers(mainObject);
|
||||
}
|
||||
mainObject.execute(bridgeSettings, harmonyDevMode);
|
||||
mainObject.execute(harmonyDevMode);
|
||||
return mainObject;
|
||||
}
|
||||
|
||||
private void execute(BridgeSettingsDescriptor mySettings, Boolean harmonyDevMode) throws Exception {
|
||||
private void execute(Boolean harmonyDevMode) throws Exception {
|
||||
Boolean noopCalls = Boolean.parseBoolean(System.getProperty("noop.calls", "false"));
|
||||
isDevMode = harmonyDevMode;
|
||||
String modeString = "";
|
||||
|
||||
@@ -9,7 +9,7 @@ import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -92,7 +92,7 @@ public class TCPHome implements Home {
|
||||
if (colorData != null) {
|
||||
theUrlBody = ColorDecode.replaceColorData(theUrlBody, colorData, BrightnessDecode.calculateIntensity(intensity, targetBri, targetBriInc), true);
|
||||
}
|
||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||
sendData = HexLibrary.decodeHexString(theUrlBody.substring(2));
|
||||
} else {
|
||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
||||
if (colorData != null) {
|
||||
|
||||
@@ -4,7 +4,7 @@ import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
import org.apache.commons.lang3.StringEscapeUtils;
|
||||
import org.slf4j.Logger;
|
||||
@@ -68,7 +68,7 @@ public class UDPHome implements Home {
|
||||
if (colorData != null) {
|
||||
theUrlBody = ColorDecode.replaceColorData(theUrlBody, colorData, BrightnessDecode.calculateIntensity(intensity, targetBri, targetBriInc), true);
|
||||
}
|
||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||
sendData = HexLibrary.decodeHexString(theUrlBody.substring(2));
|
||||
} else {
|
||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
||||
|
||||
|
||||
72
src/main/java/com/bwssystems/HABridge/util/HexLibrary.java
Normal file
72
src/main/java/com/bwssystems/HABridge/util/HexLibrary.java
Normal file
@@ -0,0 +1,72 @@
|
||||
package com.bwssystems.HABridge.util;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
public class HexLibrary {
|
||||
|
||||
public static String byteToHex(byte num) {
|
||||
char[] hexDigits = new char[2];
|
||||
hexDigits[0] = Character.forDigit((num >> 4) & 0xF, 16);
|
||||
hexDigits[1] = Character.forDigit((num & 0xF), 16);
|
||||
return new String(hexDigits);
|
||||
}
|
||||
|
||||
public static byte hexToByte(String hexString) {
|
||||
int firstDigit = toDigit(hexString.charAt(0));
|
||||
int secondDigit = toDigit(hexString.charAt(1));
|
||||
return (byte) ((firstDigit << 4) + secondDigit);
|
||||
}
|
||||
|
||||
private static int toDigit(char hexChar) {
|
||||
int digit = Character.digit(hexChar, 16);
|
||||
if (digit == -1) {
|
||||
throw new IllegalArgumentException("Invalid Hexadecimal Character: " + hexChar);
|
||||
}
|
||||
return digit;
|
||||
}
|
||||
|
||||
public static String encodeHexString(byte[] byteArray) {
|
||||
StringBuffer hexStringBuffer = new StringBuffer();
|
||||
for (int i = 0; i < byteArray.length; i++) {
|
||||
hexStringBuffer.append(byteToHex(byteArray[i]));
|
||||
}
|
||||
return hexStringBuffer.toString();
|
||||
}
|
||||
|
||||
public static byte[] decodeHexString(String hexString) {
|
||||
if (hexString.length() % 2 == 1) {
|
||||
throw new IllegalArgumentException("Invalid hexadecimal String supplied.");
|
||||
}
|
||||
|
||||
byte[] bytes = new byte[hexString.length() / 2];
|
||||
for (int i = 0; i < hexString.length(); i += 2) {
|
||||
bytes[i / 2] = hexToByte(hexString.substring(i, i + 2));
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
public static String encodeUsingBigIntegerStringFormat(byte[] bytes) {
|
||||
BigInteger bigInteger = new BigInteger(1, bytes);
|
||||
return String.format("%0" + (bytes.length << 1) + "x", bigInteger);
|
||||
}
|
||||
|
||||
public static String encodeUsingBigIntegerToString(String intValue) {
|
||||
BigInteger bigInteger = BigInteger.valueOf(Integer.decode(intValue));
|
||||
return bigInteger.toString(16);
|
||||
}
|
||||
|
||||
public static String encodeUsingBigIntegerToString(byte[] bytes) {
|
||||
BigInteger bigInteger = new BigInteger(1, bytes);
|
||||
return bigInteger.toString(16);
|
||||
}
|
||||
|
||||
public static byte[] decodeUsingBigInteger(String hexString) {
|
||||
byte[] byteArray = new BigInteger(hexString, 16).toByteArray();
|
||||
if (byteArray[0] == 0) {
|
||||
byte[] output = new byte[byteArray.length - 1];
|
||||
System.arraycopy(byteArray, 1, output, 0, output.length);
|
||||
return output;
|
||||
}
|
||||
return byteArray;
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ app.config (function ($locationProvider, $routeProvider) {
|
||||
templateUrl: 'views/configuration.html',
|
||||
controller: 'ViewingController',
|
||||
requiresAuthentication: true
|
||||
})
|
||||
});
|
||||
});
|
||||
|
||||
app.run(function ($rootScope, $location, Auth, bridgeService) {
|
||||
@@ -325,7 +325,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
return $http.post(this.state.systemsbase + "/changesecurityinfo", newSecurityInfo ).then(
|
||||
function (response) {
|
||||
self.state.securityInfo = response.data;
|
||||
self.displaySuccess("Updated security settings.")
|
||||
self.displaySuccess("Updated security settings.");
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
@@ -355,7 +355,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
var theEncodedPayload = $base64.encode(angular.toJson(newUserInfo));
|
||||
return $http.post(this.state.systemsbase + "/setpassword", theEncodedPayload ).then(
|
||||
function (response) {
|
||||
self.displaySuccess("Password updated")
|
||||
self.displaySuccess("Password updated");
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
@@ -376,7 +376,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
var theEncodedPayload = $base64.encode(angular.toJson(newUserInfo));
|
||||
return $http.put(this.state.systemsbase + "/adduser", theEncodedPayload ).then(
|
||||
function (response) {
|
||||
self.displaySuccess("User added")
|
||||
self.displaySuccess("User added");
|
||||
if(!self.isSecure()) {
|
||||
self.getHABridgeVersion();
|
||||
}
|
||||
@@ -398,7 +398,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
var theEncodedPayload = $base64.encode(angular.toJson(newUserInfo));
|
||||
return $http.put(this.state.systemsbase + "/deluser", theEncodedPayload ).then(
|
||||
function (response) {
|
||||
self.displaySuccess("User deleted")
|
||||
self.displaySuccess("User deleted");
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
@@ -438,7 +438,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
return $http.post(this.state.systemsbase + "/setwhitelist", whitelist ).then(
|
||||
function (response) {
|
||||
self.state.whitelist = response.data;
|
||||
self.displaySuccess("Updated whitelist.")
|
||||
self.displaySuccess("Updated whitelist.");
|
||||
},
|
||||
function (error) {
|
||||
self.displayWarn("Update whitelist Error: ", error);
|
||||
@@ -448,7 +448,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
|
||||
this.aContainsB = function (a, b) {
|
||||
return a.indexOf(b) >= 0;
|
||||
}
|
||||
};
|
||||
|
||||
this.deviceContainsType = function (device, aType) {
|
||||
if(device.mapType !== undefined && device.mapType !== null && device.mapType.indexOf(aType) >= 0)
|
||||
@@ -471,7 +471,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
this.compareHarmonyNumber = function(r1, r2) {
|
||||
if (r1.device !== undefined) {
|
||||
@@ -513,77 +513,77 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
this.updateShowVera = function () {
|
||||
this.state.showVera = self.state.settings.veraconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowFibaro = function () {
|
||||
this.state.showFibaro = self.state.settings.fibaroconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowNest = function () {
|
||||
this.state.showNest = self.state.settings.nestconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowHarmony = function () {
|
||||
this.state.showHarmony = self.state.settings.harmonyconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowHue = function () {
|
||||
this.state.showHue = self.state.settings.hueconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowHal = function () {
|
||||
this.state.showHal = self.state.settings.halconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowMqtt = function () {
|
||||
this.state.showMqtt = self.state.settings.mqttconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowHomeWizard = function () {
|
||||
this.state.showHomeWizard = self.state.settings.homewizardconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowHass = function () {
|
||||
this.state.showHass = self.state.settings.hassconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowDomoticz = function () {
|
||||
this.state.showDomoticz = self.state.settings.domoticzconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowSomfy = function () {
|
||||
this.state.showSomfy = self.state.settings.somfyconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowLifx = function () {
|
||||
this.state.showLifx = self.state.settings.lifxconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowOpenHAB = function () {
|
||||
this.state.showOpenHAB = self.state.settings.openhabconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowFhem = function () {
|
||||
this.state.showFHEM = self.state.settings.fhemconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateShowBroadlink = function () {
|
||||
this.state.showBroadlink = self.state.settings.broadlinkconfigured;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
this.loadBridgeSettings = function () {
|
||||
return $http.get(this.state.systemsbase + "/settings").then(
|
||||
@@ -988,28 +988,28 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
|
||||
deviceString = self.formatCallItem(deviceString);
|
||||
|
||||
var newDevices = angular.fromJson(deviceString)
|
||||
var i, s, len = newDevices.length
|
||||
var newDevices = angular.fromJson(deviceString);
|
||||
var i, s, len = newDevices.length;
|
||||
for (i=0; i<len; ++i) {
|
||||
if (i in newDevices) {
|
||||
s = newDevices[i];
|
||||
if (s.type !== undefined && s.type !== null)
|
||||
s.type = self.getMapType(s.type)
|
||||
s.type = self.getMapType(s.type);
|
||||
if (angular.isObject(s.item))
|
||||
s.item = angular.toJson(s.item)
|
||||
s.item = angular.toJson(s.item);
|
||||
}
|
||||
}
|
||||
return newDevices
|
||||
}
|
||||
return newDevices;
|
||||
};
|
||||
|
||||
this.updateCallObjectsType = function (theDevices) {
|
||||
var i, s, type, len = theDevices.length
|
||||
var i, s, type, len = theDevices.length;
|
||||
for (i=0; i<len; ++i) {
|
||||
if (i in theDevices) {
|
||||
s = theDevices[i];
|
||||
if (s.type !== undefined && s.type !== null) {
|
||||
type = self.getMapType(s.type[0])
|
||||
s.type = type[0]
|
||||
type = self.getMapType(s.type[0]);
|
||||
s.type = type[0];
|
||||
}
|
||||
if(s.delay === "" || s.delay === null)
|
||||
delete s.delay;
|
||||
@@ -1027,9 +1027,8 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
delete s.contentType;
|
||||
}
|
||||
}
|
||||
return theDevices
|
||||
|
||||
}
|
||||
return theDevices;
|
||||
};
|
||||
|
||||
this.viewMapTypes = function () {
|
||||
return $http.get(this.state.base + "/map/types").then(
|
||||
@@ -1055,12 +1054,13 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
this.updateLogLevels = function (logComponents) {
|
||||
return $http.put(this.state.systemsbase + "/logmgmt/update", logComponents ).then(
|
||||
function (response) {
|
||||
self.state.loggerInfo = response.data;
|
||||
self.displaySuccess("Updated " + logComponents.length + " loggers for log levels.")
|
||||
self.displaySuccess("Updated " + logComponents.length + " loggers for log levels.");
|
||||
},
|
||||
function (error) {
|
||||
if (error.status === 401)
|
||||
@@ -1371,17 +1371,17 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
var testBody = "{";
|
||||
if (type === "off") {
|
||||
testBody = testBody + "\"on\":false";
|
||||
addComma = true
|
||||
addComma = true;
|
||||
}
|
||||
if (type === "on") {
|
||||
testBody = testBody + "\"on\":true";
|
||||
addComma = true
|
||||
addComma = true;
|
||||
}
|
||||
if (valueType === "dim" && value) {
|
||||
if(addComma)
|
||||
testBody = testBody + ",";
|
||||
testBody = testBody + "\"bri\":" + value;
|
||||
addComma = true
|
||||
addComma = true;
|
||||
}
|
||||
if (valueType === "color" && value) {
|
||||
if(addComma)
|
||||
@@ -1439,7 +1439,7 @@ app.service ('bridgeService', function ($rootScope, $http, $base64, $location, n
|
||||
var currentOff = "";
|
||||
var currentColor = "";
|
||||
if (self.state.device !== undefined && self.state.device !== null) {
|
||||
if (self.state.device.onUrl !== undefined && self.state.device.onUrl !== null&& self.state.device.onUrl !== "")
|
||||
if (self.state.device.onUrl !== undefined && self.state.device.onUrl !== null && self.state.device.onUrl !== "")
|
||||
currentOn = self.state.device.onUrl;
|
||||
if (self.state.device.dimUrl !== undefined && self.state.device.dimUrl !== null && self.state.device.dimUrl !== "")
|
||||
currentDim = self.state.device.dimUrl;
|
||||
@@ -1549,7 +1549,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.veraaddress === undefined || $scope.bridge.settings.veraaddress === null) {
|
||||
$scope.bridge.settings.veraaddress = { devices: [] };
|
||||
}
|
||||
var newVera = {name: newveraname, ip: newveraip }
|
||||
var newVera = {name: newveraname, ip: newveraip };
|
||||
$scope.bridge.settings.veraaddress.devices.push(newVera);
|
||||
$scope.newveraname = null;
|
||||
$scope.newveraip = null;
|
||||
@@ -1566,7 +1566,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
$scope.bridge.settings.fibaroaddress = { devices: [] };
|
||||
}
|
||||
var stringFilter = angular.toJson(filters);
|
||||
var newFibaro = {name: newfibaroname, ip: newfibaroip, port: newfibaroport, username: newfibarousername, password: newfibaropassword, extensions: filters}
|
||||
var newFibaro = {name: newfibaroname, ip: newfibaroip, port: newfibaroport, username: newfibarousername, password: newfibaropassword, extensions: filters};
|
||||
$scope.bridge.settings.fibaroaddress.devices.push(newFibaro);
|
||||
$scope.newfibaroname = null;
|
||||
$scope.newfibaroip = null;
|
||||
@@ -1585,7 +1585,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.harmonyaddress === undefined || $scope.bridge.settings.harmonyaddress === null) {
|
||||
$scope.bridge.settings.harmonyaddress = { devices: [] };
|
||||
}
|
||||
var newharmony = {name: newharmonyname, ip: newharmonyip, webhook: newharmonywebhook}
|
||||
var newharmony = {name: newharmonyname, ip: newharmonyip, webhook: newharmonywebhook};
|
||||
$scope.bridge.settings.harmonyaddress.devices.push(newharmony);
|
||||
$scope.newharmonyname = null;
|
||||
$scope.newharmonyip = null;
|
||||
@@ -1601,7 +1601,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.hueaddress === undefined || $scope.bridge.settings.hueaddress === null) {
|
||||
$scope.bridge.settings.hueaddress = { devices: [] };
|
||||
}
|
||||
var newhue = {name: newhuename, ip: newhueip }
|
||||
var newhue = {name: newhuename, ip: newhueip };
|
||||
$scope.bridge.settings.hueaddress.devices.push(newhue);
|
||||
$scope.newhuename = null;
|
||||
$scope.newhueip = null;
|
||||
@@ -1617,7 +1617,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.haladdress === undefined || $scope.bridge.settings.haladdress === null) {
|
||||
$scope.bridge.settings.haladdress = { devices: [] };
|
||||
}
|
||||
var newhal = {name: newhalname, ip: newhalip, secure: newhalsecure, password: newhaltoken }
|
||||
var newhal = {name: newhalname, ip: newhalip, secure: newhalsecure, password: newhaltoken };
|
||||
$scope.bridge.settings.haladdress.devices.push(newhal);
|
||||
$scope.newhalname = null;
|
||||
$scope.newhalip = null;
|
||||
@@ -1633,7 +1633,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.mqttaddress === undefined || $scope.bridge.settings.mqttaddress === null) {
|
||||
$scope.bridge.settings.mqttaddress = { devices: [] };
|
||||
}
|
||||
var newmqtt = {name: newmqttname, ip: newmqttip, username: newmqttusername, password: newmqttpassword }
|
||||
var newmqtt = {name: newmqttname, ip: newmqttip, username: newmqttusername, password: newmqttpassword };
|
||||
$scope.bridge.settings.mqttaddress.devices.push(newmqtt);
|
||||
$scope.newmqttname = null;
|
||||
$scope.newmqttip = null;
|
||||
@@ -1651,7 +1651,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.hassaddress === undefined || $scope.bridge.settings.hassaddress === null) {
|
||||
$scope.bridge.settings.hassaddress = { devices: [] };
|
||||
}
|
||||
var newhass = {name: newhassname, ip: newhassip, port: newhassport, password: newhasspassword, secure: newhasssecure }
|
||||
var newhass = {name: newhassname, ip: newhassip, port: newhassport, password: newhasspassword, secure: newhasssecure };
|
||||
$scope.bridge.settings.hassaddress.devices.push(newhass);
|
||||
$scope.newhassname = null;
|
||||
$scope.newhassip = null;
|
||||
@@ -1670,7 +1670,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.homewizardaddress === undefined || $scope.bridge.settings.homewizardaddress === null) {
|
||||
$scope.bridge.settings.homewizardaddress = { devices: [] };
|
||||
}
|
||||
var newhomewizard = { name: newhomewizardname, ip: newhomewizardip, username: newhomewizardusername, password: newhomewizardpassword }
|
||||
var newhomewizard = { name: newhomewizardname, ip: newhomewizardip, username: newhomewizardusername, password: newhomewizardpassword };
|
||||
$scope.bridge.settings.homewizardaddress.devices.push(newhomewizard);
|
||||
$scope.newhomewizardname = null;
|
||||
$scope.newhomewizardip = null;
|
||||
@@ -1688,7 +1688,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.domoticzaddress === undefined || $scope.bridge.settings.domoticzaddress === null) {
|
||||
$scope.bridge.settings.domoticzaddress = { devices: [] };
|
||||
}
|
||||
var newdomoticz = {name: newdomoticzname, ip: newdomoticzip, port: newdomoticzport, username: newdomoticzusername, password: newdomoticzpassword, secure: newdomoticzsecure }
|
||||
var newdomoticz = {name: newdomoticzname, ip: newdomoticzip, port: newdomoticzport, username: newdomoticzusername, password: newdomoticzpassword, secure: newdomoticzsecure };
|
||||
$scope.bridge.settings.domoticzaddress.devices.push(newdomoticz);
|
||||
$scope.newdomoticzname = null;
|
||||
$scope.newdomoticzip = null;
|
||||
@@ -1706,7 +1706,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.somfyaddress == null) {
|
||||
$scope.bridge.settings.somfyaddress = { devices: [] };
|
||||
}
|
||||
var newSomfy = {name: newsomfyname, ip: newsomfyip, username: newsomfyusername, password: newsomfypassword }
|
||||
var newSomfy = {name: newsomfyname, ip: newsomfyip, username: newsomfyusername, password: newsomfypassword };
|
||||
$scope.bridge.settings.somfyaddress.devices.push(newSomfy);
|
||||
$scope.newsomfyname = null;
|
||||
$scope.newsomfyip = null;
|
||||
@@ -1724,7 +1724,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.openhabaddress === undefined || $scope.bridge.settings.openhabaddress === null) {
|
||||
$scope.bridge.settings.openhabaddress = { devices: [] };
|
||||
}
|
||||
var newopenhab = {name: newopenhabname, ip: newopenhabip, port: newopenhabport, username: newopenhabusername, password: newopenhabpassword, secure: newopenhabsecure }
|
||||
var newopenhab = {name: newopenhabname, ip: newopenhabip, port: newopenhabport, username: newopenhabusername, password: newopenhabpassword, secure: newopenhabsecure };
|
||||
$scope.bridge.settings.openhabaddress.devices.push(newopenhab);
|
||||
$scope.newopenhabname = null;
|
||||
$scope.newopenhabip = null;
|
||||
@@ -1744,7 +1744,7 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
if($scope.bridge.settings.fhemaddress === undefined || $scope.bridge.settings.fhemaddress === null) {
|
||||
$scope.bridge.settings.fhemaddress = { devices: [] };
|
||||
}
|
||||
var newfhem = {name: newfhemname, ip: newfhemip, port: newfhemport, username: newfhemusername, password: newfhempassword, secure: newfhemsecure, webhook: newfhemwebhook }
|
||||
var newfhem = {name: newfhemname, ip: newfhemip, port: newfhemport, username: newfhemusername, password: newfhempassword, secure: newfhemsecure, webhook: newfhemwebhook };
|
||||
$scope.bridge.settings.fhemaddress.devices.push(newfhem);
|
||||
$scope.newfhemname = null;
|
||||
$scope.newfhemip = null;
|
||||
@@ -1808,7 +1808,7 @@ app.directive('autofocus', ['$timeout', function($timeout) {
|
||||
$element[0].focus();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
app.directive('nuCheck', [function () {
|
||||
@@ -1833,7 +1833,7 @@ app.directive('nuCheck', [function () {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
app.directive('pwCheck', [function () {
|
||||
@@ -1851,7 +1851,7 @@ app.directive('pwCheck', [function () {
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
app.controller('SecurityDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
||||
@@ -1859,7 +1859,7 @@ app.controller('SecurityDialogCtrl', function ($scope, bridgeService, ngDialog)
|
||||
if(bridgeService.state.loggedInUser !== undefined)
|
||||
$scope.username = bridgeService.state.loggedInUser;
|
||||
else
|
||||
$scope.username = ""
|
||||
$scope.username = "";
|
||||
$scope.secureHueApi = bridgeService.state.securityInfo.secureHueApi;
|
||||
$scope.useLinkButton = bridgeService.state.securityInfo.useLinkButton;
|
||||
$scope.execGarden = bridgeService.state.securityInfo.execGarden;
|
||||
@@ -1883,7 +1883,7 @@ app.controller('SecurityDialogCtrl', function ($scope, bridgeService, ngDialog)
|
||||
if(bridgeService.staet.loggedInUser !== undefined)
|
||||
$scope.username = bridgeService.state.loggedInUser;
|
||||
else
|
||||
$scope.username = ""
|
||||
$scope.username = "";
|
||||
$scope.showPassword = $scope.isSecure;
|
||||
};
|
||||
|
||||
@@ -1934,7 +1934,7 @@ app.controller('ManageLinksDialogCtrl', function ($scope, bridgeService, ngDialo
|
||||
$scope.refresh = function () {
|
||||
bridgeService.getWhitelist();
|
||||
$scope.whitelist = bridgeService.state.whitelist;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.delAll = function () {
|
||||
$scope.whitelist = null;
|
||||
@@ -2099,7 +2099,7 @@ app.controller('ViewingController', function ($scope, $location, bridgeService,
|
||||
if (bridgeService.state.queueDevId !== null && bridgeService.state.queueDevId !== "") {
|
||||
bridgeService.state.viewDevId = bridgeService.state.queueDevId;
|
||||
$scope.$broadcast("rowSelected", bridgeService.state.viewDevId);
|
||||
console.log("Go to Row selected Id <<" + bridgeService.state.viewDevId + ">>")
|
||||
console.log("Go to Row selected Id <<" + bridgeService.state.viewDevId + ">>");
|
||||
bridgeService.state.queueDevId = null;
|
||||
}
|
||||
};
|
||||
@@ -2130,7 +2130,7 @@ app.controller('ValueDialogCtrl', function ($scope, bridgeService, ngDialog) {
|
||||
ngDialog.close('ngdialog1');
|
||||
var theValue = 1;
|
||||
if($scope.valueType === "percentage")
|
||||
theValue = Math.round(($scope.slider.value * .01) * 255);
|
||||
theValue = Math.round(($scope.slider.value * 0.01) * 255);
|
||||
else
|
||||
theValue = $scope.slider.value;
|
||||
bridgeService.testUrl($scope.bridge.device, $scope.bridge.type, theValue, "dim");
|
||||
@@ -2192,22 +2192,22 @@ app.controller('VeraController', function ($scope, $location, bridgeService, ngD
|
||||
|
||||
$scope.buildDeviceUrls = function (veradevice, dim_control, buildonly) {
|
||||
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) {
|
||||
dimpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&DeviceNum="
|
||||
+ veradevice.id
|
||||
+ "&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget="
|
||||
+ dim_control;
|
||||
dimpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port +
|
||||
"/data_request?id=action&output_format=json&DeviceNum=" +
|
||||
veradevice.id +
|
||||
"&serviceId=urn:upnp-org:serviceId:Dimming1&action=SetLoadLevelTarget&newLoadlevelTarget=" +
|
||||
dim_control;
|
||||
}
|
||||
else
|
||||
dimpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum="
|
||||
+ veradevice.id;
|
||||
onpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum="
|
||||
+ veradevice.id;
|
||||
offpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum="
|
||||
+ veradevice.id;
|
||||
dimpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port +
|
||||
"/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=" +
|
||||
veradevice.id;
|
||||
onpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port +
|
||||
"/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=1&DeviceNum=" +
|
||||
veradevice.id;
|
||||
offpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port +
|
||||
"/data_request?id=action&output_format=json&serviceId=urn:upnp-org:serviceId:SwitchPower1&action=SetTarget&newTargetValue=0&DeviceNum=" +
|
||||
veradevice.id;
|
||||
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, veradevice.id, veradevice.name, veradevice.veraname, "switch", "veraDevice", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
@@ -2218,12 +2218,12 @@ app.controller('VeraController', function ($scope, $location, bridgeService, ngD
|
||||
};
|
||||
|
||||
$scope.buildSceneUrls = function (verascene) {
|
||||
onpayload = "http://" + verascene.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="
|
||||
+ verascene.id;
|
||||
offpayload = "http://" + verascene.veraaddress + ":" + $scope.vera.port
|
||||
+ "/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum="
|
||||
+ verascene.id;
|
||||
onpayload = "http://" + verascene.veraaddress + ":" + $scope.vera.port +
|
||||
"/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=" +
|
||||
verascene.id;
|
||||
offpayload = "http://" + verascene.veraaddress + ":" + $scope.vera.port +
|
||||
"/data_request?id=action&output_format=json&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunScene&SceneNum=" +
|
||||
verascene.id;
|
||||
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, null, false, verascene.id, verascene.name, verascene.veraname, "scene", "veraScene", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
@@ -2267,7 +2267,7 @@ app.controller('VeraController', function ($scope, $location, bridgeService, ngD
|
||||
bridgeService.viewVeraScenes();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding Vera devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding Vera devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -2411,7 +2411,7 @@ app.controller('FibaroController', function ($scope, $location, bridgeService, n
|
||||
bridgeService.viewfibaroScenes();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding fibaro devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding fibaro devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -2702,7 +2702,7 @@ app.controller('HueController', function ($scope, $location, bridgeService, ngDi
|
||||
bridgeService.viewHueDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding Hue devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding Hue devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -2809,24 +2809,24 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
nameCmd = "!DeviceName=";
|
||||
}
|
||||
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preDimCmd
|
||||
+ dim_control
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
dimpayload = "http://" + haldevice.haladdress.ip +
|
||||
preDimCmd +
|
||||
dim_control +
|
||||
nameCmd +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
else
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOffCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
dimpayload = "http://" + haldevice.haladdress.ip +
|
||||
preOnCmd +
|
||||
nameCmd +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
onpayload = "http://" + haldevice.haladdress.ip +
|
||||
preOnCmd +
|
||||
nameCmd +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
offpayload = "http://" + haldevice.haladdress.ip +
|
||||
preOffCmd +
|
||||
nameCmd +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20");
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name, haldevice.haldevicename, haldevice.haladdress.name, aDeviceType, "halDevice", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -2861,18 +2861,18 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALHeatUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Heat";
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off";
|
||||
onpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Heat";
|
||||
dimpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Heat!HeatSpValue=${intensity.percent}";
|
||||
offpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -2882,18 +2882,18 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALCoolUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Cool";
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off";
|
||||
onpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Cool";
|
||||
dimpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Cool!CoolSpValue=${intensity.percent}";
|
||||
offpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetCool", haldevice.haldevicename + " Cool", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -2903,14 +2903,14 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALAutoUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Auto";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off";
|
||||
onpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Auto";
|
||||
offpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -2920,14 +2920,14 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALOffUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Auto";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off";
|
||||
onpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Auto";
|
||||
offpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!HVACMode=Off";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -2937,14 +2937,14 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALFanUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!FanMode=On";
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!FanMode=Auto";
|
||||
onpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!FanMode=On";
|
||||
offpayload = "http://" + haldevice.haladdress.ip +
|
||||
"/HVACService!HVACCmd=Set!HVACName=" +
|
||||
haldevice.haldevicename.replaceAll(" ", "%20") +
|
||||
"!FanMode=Auto";
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, null, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetFan", haldevice.haldevicename + " Fan", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -2993,7 +2993,7 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding HAL devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding HAL devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -3171,7 +3171,7 @@ app.controller('HassController', function ($scope, $location, bridgeService, ngD
|
||||
bridgeService.viewHassDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding Hass devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding Hass devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -3297,7 +3297,7 @@ app.controller('HomeWizardController', function ($scope, $location, bridgeServic
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding HomeWizard devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding HomeWizard devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -3381,35 +3381,35 @@ app.controller('DomoticzController', function ($scope, $location, bridgeService,
|
||||
var nameCmd = "";
|
||||
var aDeviceType;
|
||||
var postCmd = "";
|
||||
if(domoticzdevice.devicetype === "Scene") {
|
||||
if(domoticzdevice.devicetype === "Scene" || domoticzdevice.devicetype === "Group") {
|
||||
aDeviceType = "scene";
|
||||
preCmd = "/json.htm?type=command¶m=switchscene&idx="
|
||||
preCmd = "/json.htm?type=command¶m=switchscene&idx=";
|
||||
postOnCmd = "&switchcmd=On";
|
||||
postOffCmd = "&switchcmd=Off";
|
||||
}
|
||||
else {
|
||||
aDeviceType = "switch";
|
||||
preCmd = "/json.htm?type=command¶m=switchlight&idx="
|
||||
preCmd = "/json.htm?type=command¶m=switchlight&idx=";
|
||||
postOnCmd = "&switchcmd=On";
|
||||
postDimCmd = "&switchcmd=Set%20Level&level=";
|
||||
postOffCmd = "&switchcmd=Off";
|
||||
}
|
||||
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
|
||||
dimpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preCmd
|
||||
+ domoticzdevice.idx
|
||||
+ postDimCmd
|
||||
+ dim_control;
|
||||
dimpayload = "http://" + domoticzdevice.domoticzaddress +
|
||||
preCmd +
|
||||
domoticzdevice.idx +
|
||||
postDimCmd +
|
||||
dim_control;
|
||||
else
|
||||
dimpayload = null;
|
||||
onpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preCmd
|
||||
+ domoticzdevice.idx
|
||||
+ postOnCmd;
|
||||
offpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preCmd
|
||||
+ domoticzdevice.idx
|
||||
+ postOffCmd;
|
||||
onpayload = "http://" + domoticzdevice.domoticzaddress +
|
||||
preCmd +
|
||||
domoticzdevice.idx +
|
||||
postOnCmd;
|
||||
offpayload = "http://" + domoticzdevice.domoticzaddress +
|
||||
preCmd +
|
||||
domoticzdevice.idx +
|
||||
postOffCmd;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, null, false, domoticzdevice.devicename + "-" + domoticzdevice.domoticzname, domoticzdevice.devicename, domoticzdevice.domoticzname, aDeviceType, "domoticzDevice", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
@@ -3453,7 +3453,7 @@ app.controller('DomoticzController', function ($scope, $location, bridgeService,
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding Domoticz devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding Domoticz devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -3581,7 +3581,7 @@ app.controller('LifxController', function ($scope, $location, bridgeService, ngD
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding LIFX devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding LIFX devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -3710,7 +3710,7 @@ app.controller('SomfyController', function ($scope, $location, bridgeService, ng
|
||||
bridgeService.viewSomfyDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding Somfy devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding Somfy devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -3870,7 +3870,7 @@ app.controller('OpenHABController', function ($scope, $location, bridgeService,
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding openhab devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding openhab devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -4014,7 +4014,7 @@ app.controller('FhemController', function ($scope, $location, bridgeService, ngD
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding fhem devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding fhem devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -4169,7 +4169,7 @@ app.controller('BroadlinkController', function ($scope, $location, bridgeService
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding openhab devices in bulk.", error)
|
||||
bridgeService.displayWarn("Error adding openhab devices in bulk.", error);
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
@@ -4331,7 +4331,7 @@ app.controller('EditController', function ($scope, $location, bridgeService) {
|
||||
bridgeService.addDevice($scope.device).then(
|
||||
function () {
|
||||
bridgeService.state.queueDevId = $scope.device.id;
|
||||
console.log("Device updated for Q Id <<" + bridgeService.state.queueDevId + ">>")
|
||||
console.log("Device updated for Q Id <<" + bridgeService.state.queueDevId + ">>");
|
||||
$scope.clearDevice();
|
||||
$location.path('/');
|
||||
},
|
||||
@@ -4452,7 +4452,7 @@ app.filter('configuredVeraDevices', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredVeraScenes', function (bridgeService) {
|
||||
@@ -4466,7 +4466,7 @@ app.filter('configuredVeraScenes', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredFibaroDevices', function (bridgeService) {
|
||||
@@ -4480,7 +4480,7 @@ app.filter('configuredFibaroDevices', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredFibaroScenes', function (bridgeService) {
|
||||
@@ -4494,7 +4494,7 @@ app.filter('configuredFibaroScenes', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredNestItems', function (bridgeService) {
|
||||
@@ -4508,7 +4508,7 @@ app.filter('configuredNestItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredHueItems', function (bridgeService) {
|
||||
@@ -4522,7 +4522,7 @@ app.filter('configuredHueItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredHalItems', function (bridgeService) {
|
||||
@@ -4536,7 +4536,7 @@ app.filter('configuredHalItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredHarmonyActivities', function (bridgeService) {
|
||||
@@ -4550,7 +4550,7 @@ app.filter('configuredHarmonyActivities', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredHarmonyButtons', function (bridgeService) {
|
||||
@@ -4564,7 +4564,7 @@ app.filter('configuredHarmonyButtons', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredMqttMsgs', function (bridgeService) {
|
||||
@@ -4578,7 +4578,7 @@ app.filter('configuredMqttMsgs', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredHassItems', function (bridgeService) {
|
||||
@@ -4592,7 +4592,7 @@ app.filter('configuredHassItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredDomoticzItems', function (bridgeService) {
|
||||
@@ -4606,7 +4606,7 @@ app.filter('configuredDomoticzItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredLifxItems', function (bridgeService) {
|
||||
@@ -4620,7 +4620,7 @@ app.filter('configuredLifxItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredSomfyDevices', function (bridgeService) {
|
||||
@@ -4634,7 +4634,7 @@ app.filter('configuredSomfyDevices', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredHomeWizardDevices', function (bridgeService) {
|
||||
@@ -4648,7 +4648,7 @@ app.filter('configuredHomeWizardDevices', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredOpenHABItems', function (bridgeService) {
|
||||
@@ -4662,7 +4662,7 @@ app.filter('configuredOpenHABItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredFhemItems', function (bridgeService) {
|
||||
@@ -4676,7 +4676,7 @@ app.filter('configuredFhemItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('configuredBroadlinkItems', function (bridgeService) {
|
||||
@@ -4690,7 +4690,7 @@ app.filter('configuredBroadlinkItems', function (bridgeService) {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.filter('filterDevicesByRequester', function () {
|
||||
@@ -4731,7 +4731,7 @@ app.filter('filterDevicesByRequester', function () {
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('LoginController', function ($scope, $location, Auth, bridgeService) {
|
||||
@@ -4778,7 +4778,7 @@ app.directive('permission', ['Auth', function(Auth) {
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
}]);
|
||||
|
||||
app.factory('Auth', function($resource, $rootScope, $sessionStorage, $http, $base64, bridgeService){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.bwssystems.broadlink.test;
|
||||
|
||||
import javax.xml.bind.DatatypeConverter;
|
||||
import com.bwssystems.HABridge.util.HexLibrary;
|
||||
|
||||
public class BroadlinkDataConstructor {
|
||||
public final static byte[] testData1 = { 84, 104, 105, 115, 73, 115, 65, 84, 101, 115, 116, 83, 116, 114, 105, 110, 103, 49 };
|
||||
@@ -18,8 +18,8 @@ public class BroadlinkDataConstructor {
|
||||
System.out.println("----------------------------------");
|
||||
System.out.println("This is the test hex string: <<<" + theHexString + ">>>");
|
||||
try {
|
||||
theData = DatatypeConverter.parseHexBinary(theHexString);
|
||||
System.out.println("This is the test hex string from data bytes: <<<" + DatatypeConverter.printHexBinary(theData) + ">>>");
|
||||
theData = HexLibrary.decodeHexString(theHexString);
|
||||
System.out.println("This is the test hex string from data bytes: <<<" + HexLibrary.encodeHexString(theData) + ">>>");
|
||||
} catch(Exception e) {
|
||||
System.out.println("Error parsing he string: " + e.getMessage());
|
||||
return false;
|
||||
|
||||
@@ -14,7 +14,7 @@ public class ConvertCIEColorTestCase {
|
||||
|
||||
@Test
|
||||
public void testColorConversion() {
|
||||
ArrayList<Double> xy = new ArrayList<Double>(Arrays.asList(new Double(0.671254), new Double(0.303273)));
|
||||
ArrayList<Double> xy = new ArrayList<Double>(Arrays.asList(Double.parseDouble("0.671254"), Double.parseDouble("0.303273")));
|
||||
|
||||
List<Integer> colorDecode = ColorDecode.convertCIEtoRGB(xy, 254);
|
||||
List<Integer> assertDecode = new ArrayList<Integer>();
|
||||
|
||||
Reference in New Issue
Block a user