mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Added Requester logic filtering. Added logic for count and delay in
items and buttons.
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
<groupId>com.bwssystems.HABridge</groupId>
|
<groupId>com.bwssystems.HABridge</groupId>
|
||||||
<artifactId>ha-bridge</artifactId>
|
<artifactId>ha-bridge</artifactId>
|
||||||
<version>3.2.2</version>
|
<version>3.2.2a</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<name>HA Bridge</name>
|
<name>HA Bridge</name>
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.bwssystems.HABridge.api;
|
|||||||
|
|
||||||
public class CallItem {
|
public class CallItem {
|
||||||
private String item;
|
private String item;
|
||||||
|
private Integer count;
|
||||||
|
private Integer delay;
|
||||||
|
|
||||||
public String getItem() {
|
public String getItem() {
|
||||||
return item;
|
return item;
|
||||||
@@ -10,4 +12,20 @@ public class CallItem {
|
|||||||
public void setItem(String anitem) {
|
public void setItem(String anitem) {
|
||||||
item = anitem;
|
item = anitem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCount(Integer count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDelay() {
|
||||||
|
return delay;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDelay(Integer delay) {
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package com.bwssystems.HABridge.api.hue;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
import com.bwssystems.HABridge.dao.DeviceDescriptor;
|
||||||
import com.bwssystems.HABridge.dao.DeviceRepository;
|
|
||||||
|
|
||||||
public class GroupResponse {
|
public class GroupResponse {
|
||||||
private DeviceState action;
|
private DeviceState action;
|
||||||
|
|||||||
@@ -56,6 +56,9 @@ public class DeviceDescriptor{
|
|||||||
@SerializedName("contentBodyDim")
|
@SerializedName("contentBodyDim")
|
||||||
@Expose
|
@Expose
|
||||||
private String contentBodyDim;
|
private String contentBodyDim;
|
||||||
|
@SerializedName("requesterAddress")
|
||||||
|
@Expose
|
||||||
|
private String requesterAddress;
|
||||||
|
|
||||||
private DeviceState deviceState;
|
private DeviceState deviceState;
|
||||||
|
|
||||||
@@ -187,6 +190,14 @@ public class DeviceDescriptor{
|
|||||||
this.contentBodyDim = contentBodyDim;
|
this.contentBodyDim = contentBodyDim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRequesterAddress() {
|
||||||
|
return requesterAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequesterAddress(String requesterAddress) {
|
||||||
|
this.requesterAddress = requesterAddress;
|
||||||
|
}
|
||||||
|
|
||||||
public DeviceState getDeviceState() {
|
public DeviceState getDeviceState() {
|
||||||
if(deviceState == null)
|
if(deviceState == null)
|
||||||
deviceState = DeviceState.createDeviceState();
|
deviceState = DeviceState.createDeviceState();
|
||||||
|
|||||||
@@ -73,12 +73,46 @@ public class DeviceRepository extends BackupHandler {
|
|||||||
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
public List<DeviceDescriptor> findByDeviceType(String aType) {
|
public List<DeviceDescriptor> findAllByRequester(String anAddress) {
|
||||||
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
||||||
return list;
|
List<DeviceDescriptor> theReturnList = new ArrayList<DeviceDescriptor>();
|
||||||
|
Iterator<DeviceDescriptor> anIterator = list.iterator();
|
||||||
|
DeviceDescriptor theDevice;
|
||||||
|
String theRequesterAddress;
|
||||||
|
while(anIterator.hasNext()) {
|
||||||
|
theDevice = anIterator.next();
|
||||||
|
theRequesterAddress = theDevice.getRequesterAddress();
|
||||||
|
if(theRequesterAddress == null || theRequesterAddress.length() == 0 || theRequesterAddress.contains(anAddress))
|
||||||
|
theReturnList.add(theDevice);
|
||||||
|
}
|
||||||
|
return theReturnList;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
public List<DeviceDescriptor> findAllByRequester(String anAddress) {
|
||||||
|
List<DeviceDescriptor> list = new ArrayList<DeviceDescriptor>(devices.values());
|
||||||
|
List<DeviceDescriptor> theReturnList = new ArrayList<DeviceDescriptor>();
|
||||||
|
Iterator<DeviceDescriptor> anIterator = list.iterator();
|
||||||
|
DeviceDescriptor theDevice;
|
||||||
|
String theRequesterAddress;
|
||||||
|
|
||||||
|
HashMap<String,String > addressMap;
|
||||||
|
while (anIterator.hasNext()) {
|
||||||
|
theDevice = anIterator.next();
|
||||||
|
theRequesterAddress = theDevice.getRequesterAddress();
|
||||||
|
addressMap = new HashMap<String, String>();
|
||||||
|
if (theRequesterAddress.contains(",")) {
|
||||||
|
String[] theArray = theRequesterAddress.split(",");
|
||||||
|
for (String v : theArray) {
|
||||||
|
addressMap.put(v, v);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
addressMap.put(theRequesterAddress, theRequesterAddress);
|
||||||
|
if (theRequesterAddress == null || theRequesterAddress.length() == 0 || addressMap.containsKey(anAddress))
|
||||||
|
theReturnList.add(theDevice);
|
||||||
|
}
|
||||||
|
return theReturnList;
|
||||||
|
}
|
||||||
public DeviceDescriptor findOne(String id) {
|
public DeviceDescriptor findOne(String id) {
|
||||||
return devices.get(id);
|
return devices.get(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import static spark.Spark.delete;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(groupId.equalsIgnoreCase("0")) {
|
if(groupId.equalsIgnoreCase("0")) {
|
||||||
GroupResponse theResponse = GroupResponse.createGroupResponse(repository.findAll());
|
GroupResponse theResponse = GroupResponse.createGroupResponse(repository.findAllByRequester(request.ip()));
|
||||||
return new Gson().toJson(theResponse, GroupResponse.class);
|
return new Gson().toJson(theResponse, GroupResponse.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -271,7 +271,7 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
return theErrorResp.getTheErrors();
|
return theErrorResp.getTheErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DeviceDescriptor> deviceList = repository.findAll();
|
List<DeviceDescriptor> deviceList = repository.findAllByRequester(request.ip());
|
||||||
Map<String, DeviceResponse> deviceResponseMap = new HashMap<>();
|
Map<String, DeviceResponse> deviceResponseMap = new HashMap<>();
|
||||||
for (DeviceDescriptor device : deviceList) {
|
for (DeviceDescriptor device : deviceList) {
|
||||||
DeviceResponse deviceResponse = null;
|
DeviceResponse deviceResponse = null;
|
||||||
@@ -437,7 +437,7 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
return theErrorResp.getTheErrors();
|
return theErrorResp.getTheErrors();
|
||||||
}
|
}
|
||||||
|
|
||||||
List<DeviceDescriptor> descriptorList = repository.findAll();
|
List<DeviceDescriptor> descriptorList = repository.findAllByRequester(request.ip());
|
||||||
HueApiResponse apiResponse = new HueApiResponse("Philips hue", bridgeSettings.getUpnpConfigAddress(), bridgeSettings.getWhitelist());
|
HueApiResponse apiResponse = new HueApiResponse("Philips hue", bridgeSettings.getUpnpConfigAddress(), bridgeSettings.getWhitelist());
|
||||||
Map<String, DeviceResponse> deviceList = new HashMap<>();
|
Map<String, DeviceResponse> deviceList = new HashMap<>();
|
||||||
if (descriptorList != null) {
|
if (descriptorList != null) {
|
||||||
@@ -623,6 +623,7 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
DeviceState state = null;
|
DeviceState state = null;
|
||||||
boolean stateHasBri = false;
|
boolean stateHasBri = false;
|
||||||
boolean stateHasBriInc = false;
|
boolean stateHasBriInc = false;
|
||||||
|
Integer theDelay = bridgeSettings.getButtonsleep();
|
||||||
log.debug("hue state change requested: " + userId + " from " + request.ip() + " body: " + request.body());
|
log.debug("hue state change requested: " + userId + " from " + request.ip() + " body: " + request.body());
|
||||||
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
|
response.header("Access-Control-Allow-Origin", request.headers("Origin"));
|
||||||
response.type("application/json");
|
response.type("application/json");
|
||||||
@@ -661,7 +662,6 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
state = device.getDeviceState();
|
state = device.getDeviceState();
|
||||||
if(state == null)
|
if(state == null)
|
||||||
state = DeviceState.createDeviceState();
|
state = DeviceState.createDeviceState();
|
||||||
state.fillIn();
|
|
||||||
|
|
||||||
theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class);
|
theHeaders = new Gson().fromJson(device.getHeaders(), NameValue[].class);
|
||||||
|
|
||||||
@@ -782,11 +782,21 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + "\",\"description\": \"Should not get here, no harmony hub available\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + "\",\"description\": \"Should not get here, no harmony hub available\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
Integer setCount = 1;
|
||||||
for(int i = 0; i < deviceButtons.length; i++) {
|
for(int i = 0; i < deviceButtons.length; i++) {
|
||||||
if( i > 0)
|
if(deviceButtons[i].getCount() != null && deviceButtons[i].getCount() > 0)
|
||||||
Thread.sleep(bridgeSettings.getButtonsleep());
|
setCount = deviceButtons[i].getCount();
|
||||||
log.debug("pressing button: " + deviceButtons[i].getDevice() + " - " + deviceButtons[i].getButton() + " - iteration: " + String.valueOf(i));
|
else
|
||||||
myHarmony.pressButton(deviceButtons[i]);
|
setCount = 1;
|
||||||
|
for(int x = 0; x < setCount; x++) {
|
||||||
|
if( x > 0) {
|
||||||
|
Thread.sleep(theDelay);
|
||||||
|
}
|
||||||
|
if(deviceButtons[i].getDelay() != null &&deviceButtons[i].getDelay() > 0)
|
||||||
|
theDelay = deviceButtons[i].getDelay();
|
||||||
|
log.debug("pressing button: " + deviceButtons[i].getDevice() + " - " + deviceButtons[i].getButton() + " - iteration: " + String.valueOf(i) + " - count: " + String.valueOf(x));
|
||||||
|
myHarmony.pressButton(deviceButtons[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -852,20 +862,29 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
url = "[{\"item\":\"" + url +"\"}]";
|
url = "[{\"item\":\"" + url +"\"}]";
|
||||||
}
|
}
|
||||||
CallItem[] callItems = new Gson().fromJson(url, CallItem[].class);
|
CallItem[] callItems = new Gson().fromJson(url, CallItem[].class);
|
||||||
|
Integer setCount = 1;
|
||||||
for(int i = 0; i < callItems.length; i++) {
|
for(int i = 0; i < callItems.length; i++) {
|
||||||
if( i > 0) {
|
if(callItems[i].getCount() != null && callItems[i].getCount() > 0)
|
||||||
Thread.sleep(bridgeSettings.getButtonsleep());
|
setCount = callItems[i].getCount();
|
||||||
}
|
else
|
||||||
String intermediate;
|
setCount = 1;
|
||||||
if(callItems[i].getItem().contains("exec://"))
|
for(int x = 0; x < setCount; x++) {
|
||||||
intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3);
|
if( x > 0) {
|
||||||
else
|
Thread.sleep(theDelay);
|
||||||
intermediate = callItems[i].getItem();
|
}
|
||||||
String anError = doExecRequest(intermediate, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), lightId);
|
if(callItems[i].getDelay() != null && callItems[i].getDelay() > 0)
|
||||||
if(anError != null) {
|
theDelay = callItems[i].getDelay();
|
||||||
responseString = anError;
|
String intermediate;
|
||||||
i = callItems.length+1;
|
if(callItems[i].getItem().contains("exec://"))
|
||||||
}
|
intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3);
|
||||||
|
else
|
||||||
|
intermediate = callItems[i].getItem();
|
||||||
|
String anError = doExecRequest(intermediate, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), lightId);
|
||||||
|
if(anError != null) {
|
||||||
|
responseString = anError;
|
||||||
|
i = callItems.length+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else // This section allows the usage of http/tcp/udp/exec calls in a given set of items
|
else // This section allows the usage of http/tcp/udp/exec calls in a given set of items
|
||||||
@@ -878,77 +897,86 @@ public class HueMulator implements HueErrorStringSet {
|
|||||||
url = "[{\"item\":\"" + url +"\"}]";
|
url = "[{\"item\":\"" + url +"\"}]";
|
||||||
}
|
}
|
||||||
CallItem[] callItems = new Gson().fromJson(url, CallItem[].class);
|
CallItem[] callItems = new Gson().fromJson(url, CallItem[].class);
|
||||||
|
Integer setCount = 1;
|
||||||
for(int i = 0; i < callItems.length; i++) {
|
for(int i = 0; i < callItems.length; i++) {
|
||||||
if( i > 0) {
|
if(callItems[i].getCount() != null && callItems[i].getCount() > 0)
|
||||||
Thread.sleep(bridgeSettings.getButtonsleep());
|
setCount = callItems[i].getCount();
|
||||||
}
|
else
|
||||||
try {
|
setCount = 1;
|
||||||
if(callItems[i].getItem().contains("udp://") || callItems[i].getItem().contains("tcp://")) {
|
for(int x = 0; x < setCount; x++) {
|
||||||
String intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3);
|
if( x > 0) {
|
||||||
String hostPortion = intermediate.substring(0, intermediate.indexOf('/'));
|
Thread.sleep(theDelay);
|
||||||
String theUrlBody = intermediate.substring(intermediate.indexOf('/')+1);
|
}
|
||||||
String hostAddr = null;
|
if(callItems[i].getDelay() != null && callItems[i].getDelay() > 0)
|
||||||
String port = null;
|
theDelay = callItems[i].getDelay();
|
||||||
if(hostPortion.contains(":")) {
|
try {
|
||||||
hostAddr = hostPortion.substring(0, intermediate.indexOf(':'));
|
if(callItems[i].getItem().contains("udp://") || callItems[i].getItem().contains("tcp://")) {
|
||||||
port = hostPortion.substring(intermediate.indexOf(':') + 1);
|
String intermediate = callItems[i].getItem().substring(callItems[i].getItem().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;
|
||||||
|
InetAddress IPAddress = InetAddress.getByName(hostAddr);;
|
||||||
|
if(theUrlBody.startsWith("0x")) {
|
||||||
|
theUrlBody = replaceIntensityValue(theUrlBody, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), true);
|
||||||
|
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
theUrlBody = replaceIntensityValue(theUrlBody, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
||||||
|
sendData = theUrlBody.getBytes();
|
||||||
|
}
|
||||||
|
if(callItems[i].getItem().contains("udp://")) {
|
||||||
|
log.debug("executing HUE api request to UDP: " + callItems[i].getItem());
|
||||||
|
theUDPDatagramSender.sendUDPResponse(new String(sendData), IPAddress, Integer.parseInt(port));
|
||||||
|
}
|
||||||
|
else if(callItems[i].getItem().contains("tcp://"))
|
||||||
|
{
|
||||||
|
log.debug("executing HUE api request to TCP: " + callItems[i].getItem());
|
||||||
|
Socket dataSendSocket = new Socket(IPAddress, Integer.parseInt(port));
|
||||||
|
DataOutputStream outToClient = new DataOutputStream(dataSendSocket.getOutputStream());
|
||||||
|
outToClient.write(sendData);
|
||||||
|
outToClient.flush();
|
||||||
|
dataSendSocket.close();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else if(callItems[i].getItem().contains("exec://")) {
|
||||||
hostAddr = hostPortion;
|
String intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3);
|
||||||
InetAddress IPAddress = InetAddress.getByName(hostAddr);;
|
String anError = doExecRequest(intermediate, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), lightId);
|
||||||
if(theUrlBody.startsWith("0x")) {
|
if(anError != null) {
|
||||||
theUrlBody = replaceIntensityValue(theUrlBody, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), true);
|
responseString = anError;
|
||||||
sendData = DatatypeConverter.parseHexBinary(theUrlBody.substring(2));
|
i = callItems.length+1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
theUrlBody = replaceIntensityValue(theUrlBody, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
log.debug("executing HUE api request to Http " + (device.getHttpVerb() == null?"GET":device.getHttpVerb()) + ": " + callItems[i].getItem());
|
||||||
sendData = theUrlBody.getBytes();
|
|
||||||
}
|
|
||||||
if(callItems[i].getItem().contains("udp://")) {
|
|
||||||
log.debug("executing HUE api request to UDP: " + callItems[i].getItem());
|
|
||||||
theUDPDatagramSender.sendUDPResponse(new String(sendData), IPAddress, Integer.parseInt(port));
|
|
||||||
}
|
|
||||||
else if(callItems[i].getItem().contains("tcp://"))
|
|
||||||
{
|
|
||||||
log.debug("executing HUE api request to TCP: " + callItems[i].getItem());
|
|
||||||
Socket dataSendSocket = new Socket(IPAddress, Integer.parseInt(port));
|
|
||||||
DataOutputStream outToClient = new DataOutputStream(dataSendSocket.getOutputStream());
|
|
||||||
outToClient.write(sendData);
|
|
||||||
outToClient.flush();
|
|
||||||
dataSendSocket.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if(callItems[i].getItem().contains("exec://")) {
|
|
||||||
String intermediate = callItems[i].getItem().substring(callItems[i].getItem().indexOf("://") + 3);
|
|
||||||
String anError = doExecRequest(intermediate, calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), lightId);
|
|
||||||
if(anError != null) {
|
|
||||||
responseString = anError;
|
|
||||||
i = callItems.length+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
log.debug("executing HUE api request to Http " + (device.getHttpVerb() == null?"GET":device.getHttpVerb()) + ": " + callItems[i].getItem());
|
|
||||||
|
|
||||||
String anUrl = replaceIntensityValue(callItems[i].getItem(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
String anUrl = replaceIntensityValue(callItems[i].getItem(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
||||||
String body;
|
String body;
|
||||||
if(stateHasBri || stateHasBriInc)
|
if(stateHasBri || stateHasBriInc)
|
||||||
body = replaceIntensityValue(device.getContentBodyDim(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
body = replaceIntensityValue(device.getContentBodyDim(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
||||||
else if (state.isOn())
|
else if (state.isOn())
|
||||||
body = replaceIntensityValue(device.getContentBody(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
body = replaceIntensityValue(device.getContentBody(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
||||||
else
|
else
|
||||||
body = replaceIntensityValue(device.getContentBodyOff(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
body = replaceIntensityValue(device.getContentBodyOff(), calculateIntensity(state, theStateChanges, stateHasBri, stateHasBriInc), false);
|
||||||
// make call
|
// make call
|
||||||
if (doHttpRequest(anUrl, device.getHttpVerb(), device.getContentType(), body, theHeaders) == null) {
|
if (doHttpRequest(anUrl, device.getHttpVerb(), device.getContentType(), body, theHeaders) == null) {
|
||||||
log.warn("Error on calling url to change device state: " + anUrl);
|
log.warn("Error on calling url to change device state: " + anUrl);
|
||||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + "\",\"description\": \"Error on calling url to change device state\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + "\",\"description\": \"Error on calling url to change device state\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
||||||
i = callItems.length+1;
|
i = callItems.length+1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warn("Change device state, Could not send data for network request: " + callItems[i].getItem() + " with Message: " + e.getMessage());
|
log.warn("Change device state, Could not send data for network request: " + callItems[i].getItem() + " with Message: " + e.getMessage());
|
||||||
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
responseString = "[{\"error\":{\"type\": 6, \"address\": \"/lights/" + lightId + "\",\"description\": \"Error on calling out to device\", \"parameter\": \"/lights/" + lightId + "state\"}}]";
|
||||||
i = callItems.length+1;
|
i = callItems.length+1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,8 @@ package com.bwssystems.harmony;
|
|||||||
public class ButtonPress {
|
public class ButtonPress {
|
||||||
private String device;
|
private String device;
|
||||||
private String button;
|
private String button;
|
||||||
|
private Integer delay;
|
||||||
|
private Integer count;
|
||||||
public String getDevice() {
|
public String getDevice() {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
@@ -15,6 +17,18 @@ public class ButtonPress {
|
|||||||
public void setButton(String button) {
|
public void setButton(String button) {
|
||||||
this.button = button;
|
this.button = button;
|
||||||
}
|
}
|
||||||
|
public Integer getDelay() {
|
||||||
|
return delay;
|
||||||
|
}
|
||||||
|
public void setDelay(Integer delay) {
|
||||||
|
this.delay = delay;
|
||||||
|
}
|
||||||
|
public Integer getCount() {
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
public void setCount(Integer count) {
|
||||||
|
this.count = count;
|
||||||
|
}
|
||||||
public Boolean isValid() {
|
public Boolean isValid() {
|
||||||
if (device != null && !device.isEmpty()){
|
if (device != null && !device.isEmpty()){
|
||||||
if (button != null && !button.isEmpty())
|
if (button != null && !button.isEmpty())
|
||||||
|
|||||||
@@ -145,6 +145,7 @@ app.service('bridgeService', function ($http, $window, ngToast) {
|
|||||||
self.state.device.contentBody = null;
|
self.state.device.contentBody = null;
|
||||||
self.state.device.contentBodyDim = null;
|
self.state.device.contentBodyDim = null;
|
||||||
self.state.device.contentBodyOff = null;
|
self.state.device.contentBodyOff = null;
|
||||||
|
self.state.device.requesterAddress = null;
|
||||||
self.state.olddevicename = "";
|
self.state.olddevicename = "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
<th sortable-header col="name">Name</th>
|
<th sortable-header col="name">Name</th>
|
||||||
<th sortable-header col="deviceType">Type</th>
|
<th sortable-header col="deviceType">Type</th>
|
||||||
<th sortable-header col="targetDevice">Target</th>
|
<th sortable-header col="targetDevice">Target</th>
|
||||||
|
<th sortable-header col="requesterAddress">Requester Address</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
@@ -48,6 +49,7 @@
|
|||||||
<td>{{device.name}}</td>
|
<td>{{device.name}}</td>
|
||||||
<td>{{device.deviceType}}</td>
|
<td>{{device.deviceType}}</td>
|
||||||
<td>{{device.targetDevice}}</td>
|
<td>{{device.targetDevice}}</td>
|
||||||
|
<td>{{device.requesterAddress}}</td>
|
||||||
<td>
|
<td>
|
||||||
<p>
|
<p>
|
||||||
<button class="btn btn-info" type="submit"
|
<button class="btn btn-info" type="submit"
|
||||||
|
|||||||
@@ -115,6 +115,14 @@
|
|||||||
ng-model="device.uniqueid" placeholder="AA:BB:CC:DD:EE:FF-XX" readonly>
|
ng-model="device.uniqueid" placeholder="AA:BB:CC:DD:EE:FF-XX" readonly>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<label class="col-xs-12 col-sm-2 control-label" for="device-requester-addr">Requester Address (comma separated list) </label>
|
||||||
|
|
||||||
|
<div class="col-xs-8 col-sm-7">
|
||||||
|
<input type="text" class="form-control" id="evice-requester-addr"
|
||||||
|
ng-model="device.requesterAddress" placeholder="Only use if you want to restrict this device to a specific caller(s)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div ng-if="device.mapType" class="form-group">
|
<div ng-if="device.mapType" class="form-group">
|
||||||
<label class="col-xs-12 col-sm-2 control-label" for="device-map-id">Map
|
<label class="col-xs-12 col-sm-2 control-label" for="device-map-id">Map
|
||||||
ID </label>
|
ID </label>
|
||||||
|
|||||||
@@ -129,6 +129,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="row">
|
||||||
|
<label class="col-xs-12 col-sm-2 control-label" for="device-requester-addr">Requester Address (comma separated list) </label>
|
||||||
|
|
||||||
|
<div class="col-xs-8 col-sm-7">
|
||||||
|
<input type="text" class="form-control" id="evice-requester-addr"
|
||||||
|
ng-model="device.requesterAddress" placeholder="Only use if you want to restrict this device to a specific caller(s)">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<label class="col-xs-12 col-sm-2 control-label" for="device-on-url">On
|
<label class="col-xs-12 col-sm-2 control-label" for="device-on-url">On
|
||||||
|
|||||||
Reference in New Issue
Block a user