mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 00:10:20 +00:00
Fixed hex conversions. Added checks for formats. Finished Bulk add
issues. Fixing Domoticz home and handler for user/pwd.
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>4.1.4b</version>
|
<version>4.1.4c</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public class HomeManager {
|
|||||||
homeList.put(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
homeList.put(DeviceMapTypes.CUSTOM_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||||
homeList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
homeList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||||
homeList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
|
homeList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
|
||||||
homeList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
|
||||||
//setup the tcp handler Home
|
//setup the tcp handler Home
|
||||||
aHome = new TCPHome(bridgeSettings);
|
aHome = new TCPHome(bridgeSettings);
|
||||||
homeList.put(DeviceMapTypes.TCP_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
homeList.put(DeviceMapTypes.TCP_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||||
@@ -87,6 +86,7 @@ public class HomeManager {
|
|||||||
resourceList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
|
resourceList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
|
||||||
//setup the Domoticz configuration if available
|
//setup the Domoticz configuration if available
|
||||||
aHome = new DomoticzHome(bridgeSettings);
|
aHome = new DomoticzHome(bridgeSettings);
|
||||||
|
homeList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||||
resourceList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
resourceList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||||
//setup the Lifx configuration if available
|
//setup the Lifx configuration if available
|
||||||
aHome = new LifxHome(bridgeSettings);
|
aHome = new LifxHome(bridgeSettings);
|
||||||
|
|||||||
@@ -1,15 +1,10 @@
|
|||||||
package com.bwssystems.HABridge.hue;
|
package com.bwssystems.HABridge.hue;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import javax.xml.bind.DatatypeConverter;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import net.java.dev.eval.Expression;
|
import net.java.dev.eval.Expression;
|
||||||
|
|
||||||
public class BrightnessDecode {
|
public class BrightnessDecode {
|
||||||
@@ -49,9 +44,7 @@ public class BrightnessDecode {
|
|||||||
}
|
}
|
||||||
if (request.contains(INTENSITY_BYTE)) {
|
if (request.contains(INTENSITY_BYTE)) {
|
||||||
if (isHex) {
|
if (isHex) {
|
||||||
BigInteger bigInt = BigInteger.valueOf(intensity);
|
String hexValue = Integer.toHexString(intensity);
|
||||||
byte[] theBytes = bigInt.toByteArray();
|
|
||||||
String hexValue = DatatypeConverter.printHexBinary(theBytes);
|
|
||||||
request = request.replace(INTENSITY_BYTE, hexValue);
|
request = request.replace(INTENSITY_BYTE, hexValue);
|
||||||
} else {
|
} else {
|
||||||
String intensityByte = String.valueOf(intensity);
|
String intensityByte = String.valueOf(intensity);
|
||||||
@@ -60,9 +53,7 @@ public class BrightnessDecode {
|
|||||||
} else if (request.contains(INTENSITY_PERCENT)) {
|
} else if (request.contains(INTENSITY_PERCENT)) {
|
||||||
int percentBrightness = (int) Math.round(intensity / 255.0 * 100);
|
int percentBrightness = (int) Math.round(intensity / 255.0 * 100);
|
||||||
if (isHex) {
|
if (isHex) {
|
||||||
BigInteger bigInt = BigInteger.valueOf(percentBrightness);
|
String hexValue = Integer.toHexString(percentBrightness);
|
||||||
byte[] theBytes = bigInt.toByteArray();
|
|
||||||
String hexValue = DatatypeConverter.printHexBinary(theBytes);
|
|
||||||
request = request.replace(INTENSITY_PERCENT, hexValue);
|
request = request.replace(INTENSITY_PERCENT, hexValue);
|
||||||
} else {
|
} else {
|
||||||
String intensityPercent = String.valueOf(percentBrightness);
|
String intensityPercent = String.valueOf(percentBrightness);
|
||||||
@@ -81,9 +72,7 @@ public class BrightnessDecode {
|
|||||||
BigDecimal result = exp.eval(variables);
|
BigDecimal result = exp.eval(variables);
|
||||||
Integer endResult = Math.round(result.floatValue());
|
Integer endResult = Math.round(result.floatValue());
|
||||||
if (isHex) {
|
if (isHex) {
|
||||||
BigInteger bigInt = BigInteger.valueOf(endResult);
|
String hexValue = Integer.toHexString(endResult);
|
||||||
byte[] theBytes = bigInt.toByteArray();
|
|
||||||
String hexValue = DatatypeConverter.printHexBinary(theBytes);
|
|
||||||
request = request.replace(INTENSITY_MATH + mathDescriptor + INTENSITY_MATH_CLOSE, hexValue);
|
request = request.replace(INTENSITY_MATH + mathDescriptor + INTENSITY_MATH_CLOSE, hexValue);
|
||||||
} else {
|
} else {
|
||||||
request = request.replace(INTENSITY_MATH + mathDescriptor + INTENSITY_MATH_CLOSE,
|
request = request.replace(INTENSITY_MATH + mathDescriptor + INTENSITY_MATH_CLOSE,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.bwssystems.HABridge.plugins.domoticz;
|
package com.bwssystems.HABridge.plugins.domoticz;
|
||||||
|
|
||||||
|
import java.net.InetAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@@ -13,8 +14,11 @@ import com.bwssystems.HABridge.BridgeSettingsDescriptor;
|
|||||||
import com.bwssystems.HABridge.Home;
|
import com.bwssystems.HABridge.Home;
|
||||||
import com.bwssystems.HABridge.NamedIP;
|
import com.bwssystems.HABridge.NamedIP;
|
||||||
import com.bwssystems.HABridge.api.CallItem;
|
import com.bwssystems.HABridge.api.CallItem;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueError;
|
||||||
|
import com.bwssystems.HABridge.api.hue.HueErrorResponse;
|
||||||
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||||
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
import com.bwssystems.HABridge.hue.MultiCommandUtil;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
|
||||||
public class DomoticzHome implements Home {
|
public class DomoticzHome implements Home {
|
||||||
private static final Logger log = LoggerFactory.getLogger(DomoticzHome.class);
|
private static final Logger log = LoggerFactory.getLogger(DomoticzHome.class);
|
||||||
@@ -66,8 +70,28 @@ public class DomoticzHome implements Home {
|
|||||||
@Override
|
@Override
|
||||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||||
// Not a device handler
|
String responseString = null;
|
||||||
return null;
|
|
||||||
|
String theUrl = anItem.getItem().getAsString();
|
||||||
|
if(theUrl != null && !theUrl.isEmpty () && (theUrl.startsWith("http://") || theUrl.startsWith("https://"))) {
|
||||||
|
String intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
|
||||||
|
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
||||||
|
String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
||||||
|
String hostAddr = null;
|
||||||
|
String port = null;
|
||||||
|
if (hostPortion.contains(":")) {
|
||||||
|
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
||||||
|
port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
||||||
|
} else
|
||||||
|
hostAddr = hostPortion;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
log.warn("Domoticz Call to be presented as http(s)://<ip_address>(:<port>)/payload, format of request unknown: " + theUrl);
|
||||||
|
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
|
||||||
|
"Error on calling url to change device state", "/lights/"
|
||||||
|
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
|
||||||
|
}
|
||||||
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -90,6 +114,11 @@ public class DomoticzHome implements Home {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private DomoticzHandler findHandlerByAddress(String hostAddress) {
|
||||||
|
DomoticzHandler aHandler = null;
|
||||||
|
|
||||||
|
return aHandler;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void closeHome() {
|
public void closeHome() {
|
||||||
// noop
|
// noop
|
||||||
|
|||||||
@@ -29,23 +29,25 @@ public class HTTPHome implements Home {
|
|||||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||||
String responseString = null;
|
String responseString = null;
|
||||||
|
|
||||||
//Backwards Compatibility Items
|
String theUrl = anItem.getItem().getAsString();
|
||||||
if(anItem.getHttpVerb() == null || anItem.getHttpVerb().isEmpty())
|
if(theUrl != null && !theUrl.isEmpty () && (theUrl.startsWith("http://") || theUrl.startsWith("https://"))) {
|
||||||
{
|
//Backwards Compatibility Items
|
||||||
if(device.getHttpVerb() != null && !device.getHttpVerb().isEmpty())
|
if(anItem.getHttpVerb() == null || anItem.getHttpVerb().isEmpty())
|
||||||
anItem.setHttpVerb(device.getHttpVerb());
|
{
|
||||||
}
|
if(device.getHttpVerb() != null && !device.getHttpVerb().isEmpty())
|
||||||
|
anItem.setHttpVerb(device.getHttpVerb());
|
||||||
|
}
|
||||||
|
|
||||||
if(anItem.getHttpHeaders() == null || anItem.getHttpHeaders().isEmpty()) {
|
if(anItem.getHttpHeaders() == null || anItem.getHttpHeaders().isEmpty()) {
|
||||||
if(device.getHeaders() != null && !device.getHeaders().isEmpty() )
|
if(device.getHeaders() != null && !device.getHeaders().isEmpty() )
|
||||||
anItem.setHttpHeaders(device.getHeaders());
|
anItem.setHttpHeaders(device.getHeaders());
|
||||||
}
|
}
|
||||||
|
|
||||||
log.debug("executing HUE api request to Http "
|
log.debug("executing HUE api request to Http "
|
||||||
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
|
+ (anItem.getHttpVerb() == null ? "GET" : anItem.getHttpVerb()) + ": "
|
||||||
+ anItem.getItem().getAsString());
|
+ anItem.getItem().getAsString());
|
||||||
|
|
||||||
String anUrl = BrightnessDecode.calculateReplaceIntensityValue(anItem.getItem().getAsString(),
|
String anUrl = BrightnessDecode.calculateReplaceIntensityValue(theUrl,
|
||||||
intensity, targetBri, targetBriInc, false);
|
intensity, targetBri, targetBriInc, false);
|
||||||
|
|
||||||
anUrl = TimeDecode.replaceTimeValue(anUrl);
|
anUrl = TimeDecode.replaceTimeValue(anUrl);
|
||||||
@@ -63,6 +65,13 @@ public class HTTPHome implements Home {
|
|||||||
"Error on calling url to change device state", "/lights/"
|
"Error on calling url to change device state", "/lights/"
|
||||||
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
|
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
log.warn("HTTP Call to be presented as http(s)://<ip_address>(:<port>)/payload, format of request unknown: " + theUrl);
|
||||||
|
responseString = new Gson().toJson(HueErrorResponse.createResponse("6", "/lights/" + lightId,
|
||||||
|
"Error on calling url to change device state", "/lights/"
|
||||||
|
+ lightId + "state", null, null).getTheErrors(), HueError[].class);
|
||||||
|
}
|
||||||
|
|
||||||
return responseString;
|
return responseString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -32,41 +32,45 @@ public class TCPHome implements Home {
|
|||||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||||
log.debug("executing HUE api request to TCP: " + anItem.getItem().getAsString());
|
log.debug("executing HUE api request to TCP: " + anItem.getItem().getAsString());
|
||||||
String intermediate = anItem.getItem().getAsString().substring(anItem.getItem().getAsString().indexOf("://") + 3);
|
String theUrl = anItem.getItem().getAsString();
|
||||||
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
if(theUrl != null && !theUrl.isEmpty () && theUrl.startsWith("tcp://")) {
|
||||||
String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
String intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
|
||||||
String hostAddr = null;
|
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
||||||
String port = null;
|
String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
||||||
InetAddress IPAddress = null;
|
String hostAddr = null;
|
||||||
if (hostPortion.contains(":")) {
|
String port = null;
|
||||||
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
InetAddress IPAddress = null;
|
||||||
port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
if (hostPortion.contains(":")) {
|
||||||
|
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
||||||
|
port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
||||||
|
} else
|
||||||
|
hostAddr = hostPortion;
|
||||||
|
try {
|
||||||
|
IPAddress = InetAddress.getByName(hostAddr);
|
||||||
|
} catch (UnknownHostException e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
|
|
||||||
|
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
||||||
|
if (theUrlBody.startsWith("0x")) {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
||||||
|
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||||
|
} else {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
||||||
|
sendData = theUrlBody.getBytes();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Socket dataSendSocket = new Socket(IPAddress, Integer.parseInt(port));
|
||||||
|
DataOutputStream outToClient = new DataOutputStream(dataSendSocket.getOutputStream());
|
||||||
|
outToClient.write(sendData);
|
||||||
|
outToClient.flush();
|
||||||
|
dataSendSocket.close();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// noop
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
hostAddr = hostPortion;
|
log.warn("Tcp Call to be presented as tcp://<ip_address>:<port>/payload, format of request unknown: " + theUrl);
|
||||||
try {
|
|
||||||
IPAddress = InetAddress.getByName(hostAddr);
|
|
||||||
} catch (UnknownHostException e) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
|
|
||||||
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
|
||||||
if (theUrlBody.startsWith("0x")) {
|
|
||||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
|
||||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
|
||||||
} else {
|
|
||||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
|
||||||
sendData = theUrlBody.getBytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
Socket dataSendSocket = new Socket(IPAddress, Integer.parseInt(port));
|
|
||||||
DataOutputStream outToClient = new DataOutputStream(dataSendSocket.getOutputStream());
|
|
||||||
outToClient.write(sendData);
|
|
||||||
outToClient.flush();
|
|
||||||
dataSendSocket.close();
|
|
||||||
} catch (Exception e) {
|
|
||||||
// noop
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,39 +33,44 @@ public class UDPHome implements Home {
|
|||||||
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
public String deviceHandler(CallItem anItem, MultiCommandUtil aMultiUtil, String lightId, int intensity,
|
||||||
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
Integer targetBri,Integer targetBriInc, DeviceDescriptor device, String body) {
|
||||||
log.debug("executing HUE api request to UDP: " + anItem.getItem().getAsString());
|
log.debug("executing HUE api request to UDP: " + anItem.getItem().getAsString());
|
||||||
String intermediate = anItem.getItem().getAsString().substring(anItem.getItem().getAsString().indexOf("://") + 3);
|
String theUrl = anItem.getItem().getAsString();
|
||||||
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
if(theUrl != null && !theUrl.isEmpty () && theUrl.startsWith("udp://")) {
|
||||||
String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
String intermediate = theUrl.substring(theUrl.indexOf("://") + 3);
|
||||||
String hostAddr = null;
|
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
||||||
String port = null;
|
String theUrlBody = intermediate.substring(intermediate.indexOf('/') + 1);
|
||||||
InetAddress IPAddress = null;
|
String hostAddr = null;
|
||||||
if (hostPortion.contains(":")) {
|
String port = null;
|
||||||
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
InetAddress IPAddress = null;
|
||||||
port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
if (hostPortion.contains(":")) {
|
||||||
} else
|
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
||||||
hostAddr = hostPortion;
|
port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
||||||
try {
|
} else
|
||||||
IPAddress = InetAddress.getByName(hostAddr);
|
hostAddr = hostPortion;
|
||||||
} catch (UnknownHostException e) {
|
try {
|
||||||
log.warn("Udp Call, unknown host, continuing...");
|
IPAddress = InetAddress.getByName(hostAddr);
|
||||||
return null;
|
} catch (UnknownHostException e) {
|
||||||
}
|
log.warn("Udp Call, unknown host, continuing...");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
||||||
|
if (theUrlBody.startsWith("0x")) {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
||||||
|
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||||
|
} else {
|
||||||
|
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
||||||
|
sendData = theUrlBody.getBytes();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
theUDPDatagramSender.sendUDPResponse(sendData, IPAddress, Integer.parseInt(port));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.warn("Udp Call, Number format exception on port, continuing...");
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.warn("IO exception on udp call, continuing...");
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
log.warn("Udp Call to be presented as udp://<ip_address>:<port>/payload, format of request unknown: " + theUrl);
|
||||||
|
|
||||||
theUrlBody = TimeDecode.replaceTimeValue(theUrlBody);
|
|
||||||
if (theUrlBody.startsWith("0x")) {
|
|
||||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, true);
|
|
||||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
|
||||||
} else {
|
|
||||||
theUrlBody = BrightnessDecode.calculateReplaceIntensityValue(theUrlBody, intensity, targetBri, targetBriInc, false);
|
|
||||||
sendData = theUrlBody.getBytes();
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
theUDPDatagramSender.sendUDPResponse(sendData, IPAddress, Integer.parseInt(port));
|
|
||||||
} catch (NumberFormatException e) {
|
|
||||||
log.warn("Udp Call, Number format exception on port, continuing...");
|
|
||||||
} catch (IOException e) {
|
|
||||||
log.warn("IO exception on udp call, continuing...");
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1227,7 +1227,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
|
|||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildDeviceUrls = function (veradevice, dim_control) {
|
$scope.buildDeviceUrls = function (veradevice, dim_control, buildonly) {
|
||||||
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) {
|
if(dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) {
|
||||||
dimpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
dimpayload = "http://" + veradevice.veraaddress + ":" + $scope.vera.port
|
||||||
+ "/data_request?id=action&output_format=json&DeviceNum="
|
+ "/data_request?id=action&output_format=json&DeviceNum="
|
||||||
@@ -1248,8 +1248,10 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
|
|||||||
|
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, veradevice.id, veradevice.name, veradevice.veraname, "switch", "veraDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, veradevice.id, veradevice.name, veradevice.veraname, "switch", "veraDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildSceneUrls = function (verascene) {
|
$scope.buildSceneUrls = function (verascene) {
|
||||||
@@ -1268,10 +1270,11 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
|
|||||||
|
|
||||||
$scope.bulkAddDevices = function(dim_control) {
|
$scope.bulkAddDevices = function(dim_control) {
|
||||||
var devicesList = [];
|
var devicesList = [];
|
||||||
|
$scope.clearDevice();
|
||||||
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
||||||
for(var x = 0; x < bridgeService.state.veradevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.veradevices.length; x++) {
|
||||||
if(bridgeService.state.veradevices[x].id === $scope.bulk.devices[i]) {
|
if(bridgeService.state.veradevices[x].id === $scope.bulk.devices[i]) {
|
||||||
$scope.buildDeviceUrls(bridgeService.state.veradevices[x],dim_control);
|
$scope.buildDeviceUrls(bridgeService.state.veradevices[x],dim_control,true);
|
||||||
devicesList[i] = {
|
devicesList[i] = {
|
||||||
name: $scope.device.name,
|
name: $scope.device.name,
|
||||||
mapId: $scope.device.mapId,
|
mapId: $scope.device.mapId,
|
||||||
@@ -1288,6 +1291,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
|
|||||||
contentBodyDim: $scope.device.contentBodyDim,
|
contentBodyDim: $scope.device.contentBodyDim,
|
||||||
contentBodyOff: $scope.device.contentBodyOff
|
contentBodyOff: $scope.device.contentBodyOff
|
||||||
};
|
};
|
||||||
|
$scope.clearDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1331,7 +1335,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
|
|||||||
else {
|
else {
|
||||||
$scope.selectAll = true;
|
$scope.selectAll = true;
|
||||||
for(var x = 0; x < bridgeService.state.veradevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.veradevices.length; x++) {
|
||||||
if($scope.bulk.devices.indexOf(bridgeService.state.veradevices[x]) < 0 && !bridgeService.findDeviceByMapId(bridgeService.state.veradevices[x].id, bridgeService.state.veradevices[x].veraname, "veraDevice"))
|
if($scope.bulk.devices.indexOf(bridgeService.state.veradevices[x]) < 0)
|
||||||
$scope.bulk.devices.push(bridgeService.state.veradevices[x].id);
|
$scope.bulk.devices.push(bridgeService.state.veradevices[x].id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1541,16 +1545,19 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
|
|||||||
offpayload = "{\"ipAddress\":\"" + huedevice.hueaddress + "\",\"deviceId\":\"" + huedevice.huedeviceid +"\",\"hueName\":\"" + huedevice.huename + "\"}";
|
offpayload = "{\"ipAddress\":\"" + huedevice.hueaddress + "\",\"deviceId\":\"" + huedevice.huedeviceid +"\",\"hueName\":\"" + huedevice.huename + "\"}";
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, true, huedevice.device.uniqueid, huedevice.device.name, huedevice.huename, "passthru", "hueDevice", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, true, huedevice.device.uniqueid, huedevice.device.name, huedevice.huename, "passthru", "hueDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.bulkAddDevices = function() {
|
$scope.bulkAddDevices = function() {
|
||||||
var devicesList = [];
|
var devicesList = [];
|
||||||
|
$scope.clearDevice();
|
||||||
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
||||||
for(var x = 0; x < bridgeService.state.huedevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.huedevices.length; x++) {
|
||||||
if(bridgeService.state.huedevices[x].device.uniqueid === $scope.bulk.devices[i]) {
|
if(bridgeService.state.huedevices[x].device.uniqueid === $scope.bulk.devices[i]) {
|
||||||
$scope.buildDeviceUrls(bridgeService.state.huedevices[x]);
|
$scope.buildDeviceUrls(bridgeService.state.huedevices[x],true);
|
||||||
devicesList[i] = {
|
devicesList[i] = {
|
||||||
name: $scope.device.name,
|
name: $scope.device.name,
|
||||||
mapId: $scope.device.mapId,
|
mapId: $scope.device.mapId,
|
||||||
@@ -1567,6 +1574,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
|
|||||||
contentBodyDim: $scope.device.contentBodyDim,
|
contentBodyDim: $scope.device.contentBodyDim,
|
||||||
contentBodyOff: $scope.device.contentBodyOff
|
contentBodyOff: $scope.device.contentBodyOff
|
||||||
};
|
};
|
||||||
|
$scope.clearDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1654,7 +1662,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildDeviceUrls = function (haldevice, dim_control) {
|
$scope.buildDeviceUrls = function (haldevice, dim_control, buildonly) {
|
||||||
var preOnCmd = "";
|
var preOnCmd = "";
|
||||||
var preDimCmd = "";
|
var preDimCmd = "";
|
||||||
var preOffCmd = "";
|
var preOffCmd = "";
|
||||||
@@ -1709,11 +1717,13 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
+ postCmd;
|
+ postCmd;
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname, haldevice.haldevicename, haldevice.halname, aDeviceType, "halDevice", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname, haldevice.haldevicename, haldevice.halname, aDeviceType, "halDevice", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildButtonUrls = function (haldevice, onbutton, offbutton) {
|
$scope.buildButtonUrls = function (haldevice, onbutton, offbutton, buildonly) {
|
||||||
var actionOn = angular.fromJson(onbutton);
|
var actionOn = angular.fromJson(onbutton);
|
||||||
var actionOff = angular.fromJson(offbutton);
|
var actionOff = angular.fromJson(offbutton);
|
||||||
onpayload = "http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken;
|
onpayload = "http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken;
|
||||||
@@ -1721,20 +1731,24 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
|
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.halname, "button", "halButton", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.halname, "button", "halButton", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALHomeUrls = function (haldevice) {
|
$scope.buildHALHomeUrls = function (haldevice, buildonly) {
|
||||||
onpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Home?Token=" + $scope.bridge.settings.haltoken;
|
onpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Home?Token=" + $scope.bridge.settings.haltoken;
|
||||||
offpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Away?Token=" + $scope.bridge.settings.haltoken;
|
offpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Away?Token=" + $scope.bridge.settings.haltoken;
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-HomeAway", haldevice.haldevicename, haldevice.halname, "home", "halHome", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-HomeAway", haldevice.haldevicename, haldevice.halname, "home", "halHome", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALHeatUrls = function (haldevice) {
|
$scope.buildHALHeatUrls = function (haldevice, buildonly) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
@@ -1752,11 +1766,13 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALCoolUrls = function (haldevice) {
|
$scope.buildHALCoolUrls = function (haldevice, buildonly) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
@@ -1774,11 +1790,13 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetCool", haldevice.haldevicename + " Cool", haldevice.halname, "thermo", "halThermoSet", null, null);
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetCool", haldevice.haldevicename + " Cool", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALAutoUrls = function (haldevice) {
|
$scope.buildHALAutoUrls = function (haldevice, buildonly) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
@@ -1790,11 +1808,13 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
+ "!HVACMode=Off?Token="
|
+ "!HVACMode=Off?Token="
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.halname, "thermo", "halThermoSet", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALOffUrls = function (haldevice) {
|
$scope.buildHALOffUrls = function (haldevice, buildonly) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
@@ -1807,11 +1827,13 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
$scope.device.offUrl = "http://" + haldevice.haladdress
|
$scope.device.offUrl = "http://" + haldevice.haladdress
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALFanUrls = function (haldevice) {
|
$scope.buildHALFanUrls = function (haldevice, buildonly) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
@@ -1824,21 +1846,24 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetFan", haldevice.haldevicename + " Fan", haldevice.halname, "thermo", "halThermoSet", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetFan", haldevice.haldevicename + " Fan", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
bridgeService.editNewDevice($scope.device);
|
if (!buildonly) {
|
||||||
$location.path('/editdevice');
|
bridgeService.editNewDevice($scope.device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.bulkAddDevices = function(dim_control) {
|
$scope.bulkAddDevices = function(dim_control) {
|
||||||
var devicesList = [];
|
var devicesList = [];
|
||||||
|
$scope.clearDevice();
|
||||||
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
||||||
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
||||||
if(bridgeService.state.haldevices[x].haldevicename === $scope.bulk.devices[i]) {
|
if(bridgeService.state.haldevices[x].haldevicename === $scope.bulk.devices[i]) {
|
||||||
if(bridgeService.state.haldevices[x].haldevicetype === "HVAC")
|
if(bridgeService.state.haldevices[x].haldevicetype === "HVAC")
|
||||||
$scope.buildHALAutoUrls(bridgeService.state.haldevices[x]);
|
$scope.buildHALAutoUrls(bridgeService.state.haldevices[x], true);
|
||||||
else if(bridgeService.state.haldevices[x].haldevicetype === "HOME")
|
else if(bridgeService.state.haldevices[x].haldevicetype === "HOME")
|
||||||
$scope.buildHALHomeUrls(bridgeService.state.haldevices[x]);
|
$scope.buildHALHomeUrls(bridgeService.state.haldevices[x], true);
|
||||||
else
|
else
|
||||||
$scope.buildDeviceUrls(bridgeService.state.haldevices[x],dim_control);
|
$scope.buildDeviceUrls(bridgeService.state.haldevices[x],dim_control, true);
|
||||||
devicesList[i] = {
|
devicesList[i] = {
|
||||||
name: $scope.device.name,
|
name: $scope.device.name,
|
||||||
mapId: $scope.device.mapId,
|
mapId: $scope.device.mapId,
|
||||||
@@ -1855,6 +1880,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
contentBodyDim: $scope.device.contentBodyDim,
|
contentBodyDim: $scope.device.contentBodyDim,
|
||||||
contentBodyOff: $scope.device.contentBodyOff
|
contentBodyOff: $scope.device.contentBodyOff
|
||||||
};
|
};
|
||||||
|
$scope.clearDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1897,7 +1923,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
else {
|
else {
|
||||||
$scope.selectAll = true;
|
$scope.selectAll = true;
|
||||||
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
||||||
if($scope.bulk.devices.indexOf(bridgeService.state.haldevices[x]) < 0 && !bridgeService.findDeviceByMapId(bridgeService.state.haldevices[x].haldevicename + "-" + bridgeService.state.haldevices[x].halname, bridgeService.state.haldevices[x].halname, "halDevice"))
|
if($scope.bulk.devices.indexOf(bridgeService.state.haldevices[x]) < 0)
|
||||||
$scope.bulk.devices.push(bridgeService.state.haldevices[x].haldevicename);
|
$scope.bulk.devices.push(bridgeService.state.haldevices[x].haldevicename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2191,7 +2217,7 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS
|
|||||||
bridgeService.viewHalDevices();
|
bridgeService.viewHalDevices();
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
bridgeService.displayWarn("Error adding HAL devices in bulk.", error)
|
bridgeService.displayWarn("Error adding Domoticz devices in bulk.", error)
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
$scope.bulk = { devices: [] };
|
$scope.bulk = { devices: [] };
|
||||||
@@ -2223,8 +2249,8 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS
|
|||||||
else {
|
else {
|
||||||
$scope.selectAll = true;
|
$scope.selectAll = true;
|
||||||
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
||||||
if($scope.bulk.devices.indexOf(bridgeService.state.haldevices[x]) < 0 && !bridgeService.findDeviceByMapId(bridgeService.state.haldevices[x].haldevicename + "-" + bridgeService.state.haldevices[x].halname, bridgeService.state.haldevices[x].halname, "halDevice"))
|
if($scope.bulk.devices.indexOf(bridgeService.state.domoticzdevices[x]) < 0)
|
||||||
$scope.bulk.devices.push(bridgeService.state.haldevices[x].haldevicename);
|
$scope.bulk.devices.push(bridgeService.state.domoticzdevices[x].devicename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -2281,6 +2307,7 @@ app.controller('LifxController', function ($scope, $location, $http, bridgeServi
|
|||||||
|
|
||||||
$scope.bulkAddDevices = function(dim_control) {
|
$scope.bulkAddDevices = function(dim_control) {
|
||||||
var devicesList = [];
|
var devicesList = [];
|
||||||
|
$scope.clearDevice();
|
||||||
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
||||||
for(var x = 0; x < bridgeService.state.lifxdevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.lifxdevices.length; x++) {
|
||||||
if(bridgeService.state.lifxdevices[x].devicename === $scope.bulk.devices[i]) {
|
if(bridgeService.state.lifxdevices[x].devicename === $scope.bulk.devices[i]) {
|
||||||
@@ -2301,6 +2328,7 @@ app.controller('LifxController', function ($scope, $location, $http, bridgeServi
|
|||||||
contentBodyDim: $scope.device.contentBodyDim,
|
contentBodyDim: $scope.device.contentBodyDim,
|
||||||
contentBodyOff: $scope.device.contentBodyOff
|
contentBodyOff: $scope.device.contentBodyOff
|
||||||
};
|
};
|
||||||
|
$scope.clearDevice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2343,8 +2371,8 @@ app.controller('LifxController', function ($scope, $location, $http, bridgeServi
|
|||||||
else {
|
else {
|
||||||
$scope.selectAll = true;
|
$scope.selectAll = true;
|
||||||
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
for(var x = 0; x < bridgeService.state.haldevices.length; x++) {
|
||||||
if($scope.bulk.devices.indexOf(bridgeService.state.haldevices[x]) < 0 && !bridgeService.findDeviceByMapId(bridgeService.state.haldevices[x].haldevicename + "-" + bridgeService.state.haldevices[x].halname, bridgeService.state.haldevices[x].halname, "halDevice"))
|
if($scope.bulk.devices.indexOf(bridgeService.state.lifxdevices[x]) < 0)
|
||||||
$scope.bulk.devices.push(bridgeService.state.haldevices[x].haldevicename);
|
$scope.bulk.devices.push(bridgeService.state.lifxdevices[x].devicename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -76,7 +76,7 @@
|
|||||||
<td>{{domoticzdevice.domoticzname}}</td>
|
<td>{{domoticzdevice.domoticzname}}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildDeviceUrls(domoticzdevice, device_dim_control)">Build Item</button>
|
ng-click="buildDeviceUrls(domoticzdevice, device_dim_control,false)">Build Item</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -89,27 +89,27 @@
|
|||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<button ng-if="haldevice.haldevicetype != 'Home' && haldevice.haldevicetype != 'HVAC' && haldevice.haldevicetype != 'IrData'" class="btn btn-success" type="submit"
|
<button ng-if="haldevice.haldevicetype != 'Home' && haldevice.haldevicetype != 'HVAC' && haldevice.haldevicetype != 'IrData'" class="btn btn-success" type="submit"
|
||||||
ng-click="buildDeviceUrls(haldevice, device_dim_control)">Build Item</button>
|
ng-click="buildDeviceUrls(haldevice, device_dim_control, false)">Build Item</button>
|
||||||
<button ng-if="haldevice.haldevicetype == 'Home'" class="btn btn-success" type="submit"
|
<button ng-if="haldevice.haldevicetype == 'Home'" class="btn btn-success" type="submit"
|
||||||
ng-click="buildHALHomeUrls(haldevice)">Build Home/Away</button>
|
ng-click="buildHALHomeUrls(haldevice, false)">Build Home/Away</button>
|
||||||
<button ng-if="haldevice.haldevicetype == 'IrData'" class="btn btn-success" type="submit"
|
<button ng-if="haldevice.haldevicetype == 'IrData'" class="btn btn-success" type="submit"
|
||||||
ng-click="buildButtonUrls(haldevice, button_on, button_off)">Build
|
ng-click="buildButtonUrls(haldevice, button_on, button_off, false)">Build
|
||||||
A Button</button>
|
A Button</button>
|
||||||
<ul ng-if="haldevice.haldevicetype == 'HVAC'" class="list-group">
|
<ul ng-if="haldevice.haldevicetype == 'HVAC'" class="list-group">
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<p>
|
<p>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildHALHeatUrls(haldevice)">Heat</button>
|
ng-click="buildHALHeatUrls(haldevice, false)">Heat</button>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildHALCoolUrls(haldevice)">Cool</button>
|
ng-click="buildHALCoolUrls(haldevice, false)">Cool</button>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildHALAutoUrls(haldevice)">Auto</button>
|
ng-click="buildHALAutoUrls(haldevice, false)">Auto</button>
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildHALOffUrls(haldevice)">Off</button>
|
ng-click="buildHALOffUrls(haldevice, false)">Off</button>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildHALFanUrls(haldevice)">Fan</button>
|
ng-click="buildHALFanUrls(haldevice, false)">Fan</button>
|
||||||
</p>
|
</p>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -65,7 +65,7 @@
|
|||||||
<td>{{huedevice.huename}}</td>
|
<td>{{huedevice.huename}}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildDeviceUrls(huedevice)">Build Item</button>
|
ng-click="buildDeviceUrls(huedevice, false)">Build Item</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
@@ -59,7 +59,7 @@
|
|||||||
<td>{{lifxdev.type}}</td>
|
<td>{{lifxdev.type}}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildDeviceUrls(lifxdev)">Build
|
ng-click="buildDeviceUrls(lifxdev, false)">Build
|
||||||
Item</button>
|
Item</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
@@ -80,7 +80,7 @@
|
|||||||
<td>{{veradevice.veraname}}</td>
|
<td>{{veradevice.veraname}}</td>
|
||||||
<td>
|
<td>
|
||||||
<button class="btn btn-success" type="submit"
|
<button class="btn btn-success" type="submit"
|
||||||
ng-click="buildDeviceUrls(veradevice, device_dim_control)">Build Item</button>
|
ng-click="buildDeviceUrls(veradevice, device_dim_control, false)">Build Item</button>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|||||||
Reference in New Issue
Block a user