mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-16 18:24:36 +00:00
Continue Domoitcz impl
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -5,7 +5,7 @@
|
||||
|
||||
<groupId>com.bwssystems.HABridge</groupId>
|
||||
<artifactId>ha-bridge</artifactId>
|
||||
<version>4.1.0beta2</version>
|
||||
<version>4.1.0beta3</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>HA Bridge</name>
|
||||
|
||||
@@ -134,16 +134,10 @@ public class BridgeSettings extends BackupHandler {
|
||||
if(theBridgeSettings.getUpnpDeviceDb() == null)
|
||||
theBridgeSettings.setUpnpDeviceDb(Configuration.DEVICE_DB_DIRECTORY);
|
||||
|
||||
if(theBridgeSettings.getNumberoflogmessages() == null)
|
||||
if(theBridgeSettings.getNumberoflogmessages() == null || theBridgeSettings.getNumberoflogmessages() <= 0)
|
||||
theBridgeSettings.setNumberoflogmessages(new Integer(Configuration.NUMBER_OF_LOG_MESSAGES));
|
||||
|
||||
if(theBridgeSettings.getNumberoflogmessages() <= 0)
|
||||
theBridgeSettings.setNumberoflogmessages(new Integer(Configuration.NUMBER_OF_LOG_MESSAGES));
|
||||
|
||||
if(theBridgeSettings.getButtonsleep() == null)
|
||||
theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP));
|
||||
|
||||
if(theBridgeSettings.getButtonsleep() < 0)
|
||||
if(theBridgeSettings.getButtonsleep() == null || theBridgeSettings.getButtonsleep() < 0)
|
||||
theBridgeSettings.setButtonsleep(Integer.parseInt(Configuration.DEFAULT_BUTTON_SLEEP));
|
||||
|
||||
theBridgeSettings.setVeraconfigured(theBridgeSettings.isValidVera());
|
||||
@@ -153,7 +147,8 @@ public class BridgeSettings extends BackupHandler {
|
||||
theBridgeSettings.setHalconfigured(theBridgeSettings.isValidHal());
|
||||
theBridgeSettings.setMqttconfigured(theBridgeSettings.isValidMQTT());
|
||||
theBridgeSettings.setHassconfigured(theBridgeSettings.isValidHass());
|
||||
if(serverPortOverride != null)
|
||||
theBridgeSettings.setDomoticzconfigured(theBridgeSettings.isValidDomoticz());
|
||||
if(serverPortOverride != null)
|
||||
theBridgeSettings.setServerPort(serverPortOverride);
|
||||
if(serverIpOverride != null)
|
||||
theBridgeSettings.setWebaddress(serverIpOverride);
|
||||
|
||||
@@ -25,6 +25,7 @@ public class DeviceMapTypes {
|
||||
public final static String[] UDP_DEVICE = { "udpDevice", "UDP Device"};
|
||||
public final static String[] UDP_DEVICE_COMPAT = { "UDP", "UDP Device"};
|
||||
public final static String[] HTTP_DEVICE = { "httpDevice", "HTTP Device"};
|
||||
public final static String[] DOMOTICZ_DEVICE = { "domoticzDevice", "Domoticz Device"};
|
||||
|
||||
public final static int typeIndex = 0;
|
||||
public final static int displayIndex = 1;
|
||||
@@ -35,10 +36,13 @@ public class DeviceMapTypes {
|
||||
super();
|
||||
deviceMapTypes = new ArrayList<String[]>();
|
||||
deviceMapTypes.add(CMD_DEVICE);
|
||||
deviceMapTypes.add(DOMOTICZ_DEVICE);
|
||||
deviceMapTypes.add(HAL_DEVICE);
|
||||
deviceMapTypes.add(HAL_HOME);
|
||||
deviceMapTypes.add(HAL_THERMO_SET);
|
||||
deviceMapTypes.add(HAL_BUTTON);
|
||||
deviceMapTypes.add(HARMONY_ACTIVITY);
|
||||
deviceMapTypes.add(HARMONY_BUTTON);
|
||||
deviceMapTypes.add(HASS_DEVICE);
|
||||
deviceMapTypes.add(HTTP_DEVICE);
|
||||
deviceMapTypes.add(HUE_DEVICE);
|
||||
@@ -49,8 +53,6 @@ public class DeviceMapTypes {
|
||||
deviceMapTypes.add(UDP_DEVICE);
|
||||
deviceMapTypes.add(VERA_DEVICE);
|
||||
deviceMapTypes.add(VERA_SCENE);
|
||||
deviceMapTypes.add(HARMONY_ACTIVITY);
|
||||
deviceMapTypes.add(HARMONY_BUTTON);
|
||||
}
|
||||
public static int getTypeIndex() {
|
||||
return typeIndex;
|
||||
|
||||
@@ -5,6 +5,7 @@ import java.util.Map;
|
||||
|
||||
import com.bwssystems.HABridge.devicemanagmeent.ResourceHandler;
|
||||
import com.bwssystems.HABridge.plugins.NestBridge.NestHome;
|
||||
import com.bwssystems.HABridge.plugins.domoticz.DomoticzHome;
|
||||
import com.bwssystems.HABridge.plugins.exec.CommandHome;
|
||||
import com.bwssystems.HABridge.plugins.hal.HalHome;
|
||||
import com.bwssystems.HABridge.plugins.harmony.HarmonyHome;
|
||||
@@ -81,6 +82,10 @@ public class HomeManager {
|
||||
aHome = new VeraHome(bridgeSettings);
|
||||
resourceList.put(DeviceMapTypes.VERA_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||
resourceList.put(DeviceMapTypes.VERA_SCENE[DeviceMapTypes.typeIndex], aHome);
|
||||
//setup the HomeAssistant configuration if available
|
||||
aHome = new DomoticzHome(bridgeSettings);
|
||||
resourceList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||
homeList.put(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex], aHome);
|
||||
}
|
||||
|
||||
public Home findHome(String type) {
|
||||
|
||||
@@ -213,6 +213,12 @@ public class DeviceResource {
|
||||
return homeManager.findResource(DeviceMapTypes.HASS_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.HASS_DEVICE[DeviceMapTypes.typeIndex]);
|
||||
}, new JsonTransformer());
|
||||
|
||||
get (API_CONTEXT + "/domoticz/devices", "application/json", (request, response) -> {
|
||||
log.debug("Get Domoticz Clients");
|
||||
response.status(HttpStatus.SC_OK);
|
||||
return homeManager.findResource(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]);
|
||||
}, new JsonTransformer());
|
||||
|
||||
get (API_CONTEXT + "/map/types", "application/json", (request, response) -> {
|
||||
log.debug("Get map types");
|
||||
return new DeviceMapTypes().getDeviceMapTypes();
|
||||
|
||||
@@ -82,6 +82,12 @@ public class DeviceResult {
|
||||
@SerializedName("Notifications")
|
||||
@Expose
|
||||
private String notifications;
|
||||
@SerializedName("OffAction")
|
||||
@Expose
|
||||
private String offAction;
|
||||
@SerializedName("OnAction")
|
||||
@Expose
|
||||
private String onAction;
|
||||
@SerializedName("PlanID")
|
||||
@Expose
|
||||
private String planID;
|
||||
@@ -343,6 +349,23 @@ public class DeviceResult {
|
||||
this.notifications = notifications;
|
||||
}
|
||||
|
||||
|
||||
public String getOffAction() {
|
||||
return offAction;
|
||||
}
|
||||
|
||||
public void setOffAction(String offAction) {
|
||||
this.offAction = offAction;
|
||||
}
|
||||
|
||||
public String getOnAction() {
|
||||
return onAction;
|
||||
}
|
||||
|
||||
public void setOnAction(String onAction) {
|
||||
this.onAction = onAction;
|
||||
}
|
||||
|
||||
public String getPlanID() {
|
||||
return planID;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,9 @@ public class Devices {
|
||||
@SerializedName("ActTime")
|
||||
@Expose
|
||||
private Integer actTime;
|
||||
@SerializedName("AllowWidgetOrdering")
|
||||
@Expose
|
||||
private Boolean allowWidgetOrdering;
|
||||
@SerializedName("ServerTime")
|
||||
@Expose
|
||||
private String serverTime;
|
||||
@@ -37,6 +40,14 @@ public class Devices {
|
||||
this.actTime = actTime;
|
||||
}
|
||||
|
||||
public Boolean getAllowWidgetOrdering() {
|
||||
return allowWidgetOrdering;
|
||||
}
|
||||
|
||||
public void setAllowWidgetOrdering(Boolean allowWidgetOrdering) {
|
||||
this.allowWidgetOrdering = allowWidgetOrdering;
|
||||
}
|
||||
|
||||
public String getServerTime() {
|
||||
return serverTime;
|
||||
}
|
||||
|
||||
@@ -1,32 +1,32 @@
|
||||
package com.bwssystems.HABridge.plugins.domoticz;
|
||||
|
||||
public class DomoticzDevice {
|
||||
private String Domoticzdevicetype;
|
||||
private String Domoticzdevicename;
|
||||
private String Domoticzaddress;
|
||||
private String Domoticzname;
|
||||
public String getDomoticzdevicetype() {
|
||||
return Domoticzdevicetype;
|
||||
private String devicetype;
|
||||
private String devicename;
|
||||
private String domoticzaddress;
|
||||
private String domoticzname;
|
||||
public String getDevicetype() {
|
||||
return devicetype;
|
||||
}
|
||||
public void setDomoticzdevicetype(String Domoticzdevicetype) {
|
||||
this.Domoticzdevicetype = Domoticzdevicetype;
|
||||
public void setDevicetype(String devicetype) {
|
||||
this.devicetype = devicetype;
|
||||
}
|
||||
public String getDomoticzdevicename() {
|
||||
return Domoticzdevicename;
|
||||
public String getDevicename() {
|
||||
return devicename;
|
||||
}
|
||||
public void setDomoticzdevicename(String Domoticzdevicename) {
|
||||
this.Domoticzdevicename = Domoticzdevicename;
|
||||
public void setDevicename(String devicename) {
|
||||
this.devicename = devicename;
|
||||
}
|
||||
public String getDomoticzaddress() {
|
||||
return Domoticzaddress;
|
||||
return domoticzaddress;
|
||||
}
|
||||
public void setDomoticzaddress(String Domoticzaddress) {
|
||||
this.Domoticzaddress = Domoticzaddress;
|
||||
public void setDomoticzaddress(String domoticzaddress) {
|
||||
this.domoticzaddress = domoticzaddress;
|
||||
}
|
||||
public String getDomoticzname() {
|
||||
return Domoticzname;
|
||||
return domoticzname;
|
||||
}
|
||||
public void setDomoticzname(String Domoticzname) {
|
||||
this.Domoticzname = Domoticzname;
|
||||
public void setDomoticzname(String domoticzname) {
|
||||
this.domoticzname = domoticzname;
|
||||
}
|
||||
}
|
||||
@@ -9,102 +9,44 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.bwssystems.HABridge.NamedIP;
|
||||
import com.bwssystems.HABridge.plugins.http.HTTPHandler;
|
||||
import com.bwssystems.HABridge.util.TextStringFormatter;
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class DomoticzHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(DomoticzHandler.class);
|
||||
private static final String DEVICE_REQUEST = "/DeviceData!DeviceCmd=GetNames!DeviceType=";
|
||||
private static final String HVAC_REQUEST = "/HVACData!HVACCmd=GetNames";
|
||||
private static final String GROUP_REQUEST = "/GroupData!GroupCmd=GetNames";
|
||||
private static final String MACRO_REQUEST = "/MacroData!MacroCmd=GetNames";
|
||||
private static final String SCENE_REQUEST = "/SceneData!SceneCmd=GetNames";
|
||||
private static final String IRDATA_REQUEST = "/IrData!IRCmd=GetNames";
|
||||
private static final String IRBUTTON_REQUEST = "/IrData!IRCmd=GetButtons!IrDevice=";
|
||||
private static final String TOKEN_REQUEST = "?Token=";
|
||||
private static final String LIGHT_REQUEST = "Light";
|
||||
private static final String APPL_REQUEST = "Appl";
|
||||
// private static final String VIDEO_REQUEST = "Video";
|
||||
private static final String THEATRE_REQUEST = "Theatre";
|
||||
private static final String CUSTOM_REQUEST = "Custom";
|
||||
private static final String HVAC_TYPE = "HVAC";
|
||||
private static final String HOME_TYPE = "Home";
|
||||
private static final String GROUP_TYPE = "Group";
|
||||
private static final String MACRO_TYPE = "Macro";
|
||||
private static final String SCENE_TYPE = "Scene";
|
||||
private static final String IRDATA_TYPE = "IrData";
|
||||
private static final String GET_REQUEST = "/json.htm?type=";
|
||||
private static final String DEVICES_TYPE = "devices";
|
||||
private static final String SCENES_TYPE = "scenes";
|
||||
private static final String FILTER_USED = "&used=";
|
||||
private HTTPHandler httpClient;
|
||||
private NamedIP domoticzAddress;
|
||||
private String theToken;
|
||||
|
||||
public DomoticzHandler(NamedIP addressName, String aGivenToken) {
|
||||
public DomoticzHandler(NamedIP addressName) {
|
||||
super();
|
||||
httpClient = new HTTPHandler();
|
||||
domoticzAddress = addressName;
|
||||
theToken = aGivenToken;
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getLights() {
|
||||
return getDomoticzDevices(DEVICE_REQUEST + LIGHT_REQUEST + TOKEN_REQUEST, LIGHT_REQUEST);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getAppliances() {
|
||||
return getDomoticzDevices(DEVICE_REQUEST + APPL_REQUEST + TOKEN_REQUEST, APPL_REQUEST);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getTheatre() {
|
||||
return getDomoticzDevices(DEVICE_REQUEST + THEATRE_REQUEST + TOKEN_REQUEST, THEATRE_REQUEST);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getCustom() {
|
||||
return getDomoticzDevices(DEVICE_REQUEST + CUSTOM_REQUEST + TOKEN_REQUEST, CUSTOM_REQUEST);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getHVAC() {
|
||||
return getDomoticzDevices(HVAC_REQUEST + TOKEN_REQUEST, HVAC_TYPE);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getGroups() {
|
||||
return getDomoticzDevices(GROUP_REQUEST + TOKEN_REQUEST, GROUP_TYPE);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getMacros() {
|
||||
return getDomoticzDevices(MACRO_REQUEST + TOKEN_REQUEST, MACRO_TYPE);
|
||||
public List<DomoticzDevice> getDevices() {
|
||||
return getDomoticzDevices(GET_REQUEST, DEVICES_TYPE, FILTER_USED);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getScenes() {
|
||||
return getDomoticzDevices(SCENE_REQUEST + TOKEN_REQUEST, SCENE_TYPE);
|
||||
return getDomoticzDevices(GET_REQUEST, SCENES_TYPE, null);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getButtons() {
|
||||
List<DomoticzDevice> irDataDevices = getDomoticzDevices(IRDATA_REQUEST + TOKEN_REQUEST, IRDATA_TYPE);
|
||||
|
||||
return getDeviceButtons(irDataDevices);
|
||||
}
|
||||
|
||||
public List<DomoticzDevice> getHome(String theDeviceName) {
|
||||
List<DomoticzDevice> deviceList = null;
|
||||
deviceList = new ArrayList<DomoticzDevice>();
|
||||
DomoticzDevice aNewDomoticzDevice = new DomoticzDevice();
|
||||
aNewDomoticzDevice.setDomoticzdevicetype(HOME_TYPE);
|
||||
aNewDomoticzDevice.setDomoticzdevicename(theDeviceName);
|
||||
deviceList.add(aNewDomoticzDevice);
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
private List<DomoticzDevice> getDomoticzDevices(String apiType, String deviceType) {
|
||||
private List<DomoticzDevice> getDomoticzDevices(String rootRequest, String type, String postpend) {
|
||||
Devices theDomoticzApiResponse = null;
|
||||
List<DomoticzDevice> deviceList = null;
|
||||
|
||||
String theUrl = null;
|
||||
String theData;
|
||||
theUrl = "http://" + domoticzAddress.getIp() + apiType + theToken;
|
||||
theUrl = "http://" + domoticzAddress.getIp() + rootRequest + type;
|
||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||
if(theData != null) {
|
||||
log.debug("GET " + deviceType + " DomoticzApiResponse - data: " + theData);
|
||||
log.debug("GET " + type + " DomoticzApiResponse - data: " + theData);
|
||||
theDomoticzApiResponse = new Gson().fromJson(theData, Devices.class);
|
||||
if(theDomoticzApiResponse.getResult() == null) {
|
||||
log.warn("Cannot get an devices for type " + deviceType + " for Domoticz " + domoticzAddress.getName() + " as response is not parsable.");
|
||||
log.warn("Cannot get any devices for type " + type + " for Domoticz " + domoticzAddress.getName() + " as response is not parsable.");
|
||||
return deviceList;
|
||||
}
|
||||
deviceList = new ArrayList<DomoticzDevice>();
|
||||
@@ -113,51 +55,20 @@ public class DomoticzHandler {
|
||||
while(theDeviceNames.hasNext()) {
|
||||
DeviceResult theDevice = theDeviceNames.next();
|
||||
DomoticzDevice aNewDomoticzDevice = new DomoticzDevice();
|
||||
aNewDomoticzDevice.setDomoticzdevicetype(deviceType);
|
||||
// aNewDomoticzDevice.setDomoticzdevicename(theDevice.getDeviceName());
|
||||
aNewDomoticzDevice.setDevicetype(theDevice.getType());
|
||||
aNewDomoticzDevice.setDevicename(theDevice.getName());
|
||||
aNewDomoticzDevice.setDomoticzaddress(domoticzAddress.getIp());
|
||||
aNewDomoticzDevice.setDomoticzname(domoticzAddress.getName());
|
||||
deviceList.add(aNewDomoticzDevice);
|
||||
|
||||
}
|
||||
}
|
||||
else {
|
||||
log.warn("Get Domoticz device types " + deviceType + " for " + domoticzAddress.getName() + " - returned null, no data.");
|
||||
log.warn("Get Domoticz device types " + type + " for " + domoticzAddress.getName() + " - returned null, no data.");
|
||||
}
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
private List<DomoticzDevice> getDeviceButtons(List<DomoticzDevice> theIrDevices) {
|
||||
Devices theDomoticzApiResponse = null;
|
||||
List<DomoticzDevice> deviceList = null;
|
||||
|
||||
String theUrl = null;
|
||||
String theData;
|
||||
if(theIrDevices == null)
|
||||
return null;
|
||||
Iterator<DomoticzDevice> theDomoticzDevices = theIrDevices.iterator();
|
||||
deviceList = new ArrayList<DomoticzDevice>();
|
||||
while (theDomoticzDevices.hasNext()) {
|
||||
DomoticzDevice theDomoticzDevice = theDomoticzDevices.next();
|
||||
theUrl = "http://" + domoticzAddress.getIp() + IRBUTTON_REQUEST + TextStringFormatter.forQuerySpaceUrl(theDomoticzDevice.getDomoticzdevicename()) + TOKEN_REQUEST + theToken;
|
||||
theData = httpClient.doHttpRequest(theUrl, null, null, null, null);
|
||||
if (theData != null) {
|
||||
log.debug("GET IrData for IR Device " + theDomoticzDevice.getDomoticzdevicename() + " DomoticzApiResponse - data: " + theData);
|
||||
theDomoticzApiResponse = new Gson().fromJson(theData, Devices.class);
|
||||
if (theDomoticzApiResponse.getResult() == null) {
|
||||
log.warn("Cannot get buttons for IR Device " + theDomoticzDevice.getDomoticzdevicename() + " for Domoticz "
|
||||
+ domoticzAddress.getName() + " as response is not parsable.");
|
||||
return deviceList;
|
||||
}
|
||||
// theDomoticzDevice.setButtons(theDomoticzApiResponse);
|
||||
deviceList.add(theDomoticzDevice);
|
||||
|
||||
} else {
|
||||
log.warn("Get Domoticz buttons for IR Device " + theDomoticzDevice.getDomoticzdevicename() + " for "
|
||||
+ domoticzAddress.getName() + " - returned null, no data.");
|
||||
}
|
||||
}
|
||||
return deviceList;
|
||||
}
|
||||
|
||||
public NamedIP getDomoticzAddress() {
|
||||
return domoticzAddress;
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.google.gson.Gson;
|
||||
|
||||
public class DomoticzHome implements Home {
|
||||
private static final Logger log = LoggerFactory.getLogger(DomoticzHome.class);
|
||||
private Map<String, DomoticzHandler> Domoticzs;
|
||||
private Map<String, DomoticzHandler> domoticzs;
|
||||
private Boolean validDomoticz;
|
||||
private HTTPHandler anHttpHandler;
|
||||
|
||||
@@ -39,62 +39,22 @@ public class DomoticzHome implements Home {
|
||||
return null;
|
||||
log.debug("consolidating devices for hues");
|
||||
List<DomoticzDevice> theResponse = null;
|
||||
Iterator<String> keys = Domoticzs.keySet().iterator();
|
||||
Iterator<String> keys = domoticzs.keySet().iterator();
|
||||
List<DomoticzDevice> deviceList = new ArrayList<DomoticzDevice>();
|
||||
while(keys.hasNext()) {
|
||||
String key = keys.next();
|
||||
theResponse = Domoticzs.get(key).getLights();
|
||||
theResponse = domoticzs.get(key).getDevices();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else {
|
||||
log.warn("Cannot get lights for Domoticz with name: " + key + ", skipping this Domoticz.");
|
||||
continue;
|
||||
}
|
||||
theResponse = Domoticzs.get(key).getAppliances();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get appliances for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getTheatre();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get theatre for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getCustom();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get custom for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getHVAC();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get HVAC for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getHome(key);
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get Homes for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getGroups();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get Groups for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getMacros();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get Macros for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getScenes();
|
||||
theResponse = domoticzs.get(key).getScenes();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get Scenes for Domoticz with name: " + key);
|
||||
theResponse = Domoticzs.get(key).getButtons();
|
||||
if(theResponse != null)
|
||||
addDomoticzDevices(deviceList, theResponse, key);
|
||||
else
|
||||
log.warn("Cannot get Buttons for Domoticz with name: " + key);
|
||||
}
|
||||
return deviceList;
|
||||
}
|
||||
@@ -106,10 +66,9 @@ public class DomoticzHome implements Home {
|
||||
while(devices.hasNext()) {
|
||||
DomoticzDevice theDevice = devices.next();
|
||||
DomoticzDevice aNewDomoticzDevice = new DomoticzDevice();
|
||||
aNewDomoticzDevice.setDomoticzdevicetype(theDevice.getDomoticzdevicetype());
|
||||
aNewDomoticzDevice.setDomoticzdevicename(theDevice.getDomoticzdevicename());
|
||||
// aNewDomoticzDevice.setButtons(theDevice.getButtons());
|
||||
aNewDomoticzDevice.setDomoticzaddress(Domoticzs.get(theKey).getDomoticzAddress().getIp());
|
||||
aNewDomoticzDevice.setDevicetype(theDevice.getDevicetype());
|
||||
aNewDomoticzDevice.setDevicename(theDevice.getDevicename());
|
||||
aNewDomoticzDevice.setDomoticzaddress(domoticzs.get(theKey).getDomoticzAddress().getIp());
|
||||
aNewDomoticzDevice.setDomoticzname(theKey);
|
||||
theDeviceList.add(aNewDomoticzDevice);
|
||||
}
|
||||
@@ -141,16 +100,16 @@ public class DomoticzHome implements Home {
|
||||
|
||||
@Override
|
||||
public Home createHome(BridgeSettingsDescriptor bridgeSettings) {
|
||||
// validDomoticz = bridgeSettings.isValidDomoticz();
|
||||
validDomoticz = bridgeSettings.isValidDomoticz();
|
||||
log.info("Domoticz Home created." + (validDomoticz ? "" : " No Domoticz devices configured."));
|
||||
if(!validDomoticz)
|
||||
return null;
|
||||
Domoticzs = new HashMap<String, DomoticzHandler>();
|
||||
domoticzs = new HashMap<String, DomoticzHandler>();
|
||||
Iterator<NamedIP> theList = bridgeSettings.getDomoticzaddress().getDevices().iterator();
|
||||
while(theList.hasNext()) {
|
||||
NamedIP aDomoticz = theList.next();
|
||||
try {
|
||||
Domoticzs.put(aDomoticz.getName(), new DomoticzHandler(aDomoticz, "stuff"));
|
||||
domoticzs.put(aDomoticz.getName(), new DomoticzHandler(aDomoticz));
|
||||
} catch (Exception e) {
|
||||
log.error("Cannot get Domoticz client (" + aDomoticz.getName() + ") setup, Exiting with message: " + e.getMessage(), e);
|
||||
return null;
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
|
||||
package com.bwssystems.HABridge.plugins.domoticz;
|
||||
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class SceneResult {
|
||||
|
||||
@SerializedName("Description")
|
||||
@Expose
|
||||
private String description;
|
||||
@SerializedName("Favorite")
|
||||
@Expose
|
||||
private Integer favorite;
|
||||
@SerializedName("LastUpdate")
|
||||
@Expose
|
||||
private String lastUpdate;
|
||||
@SerializedName("Name")
|
||||
@Expose
|
||||
private String name;
|
||||
@SerializedName("OffAction")
|
||||
@Expose
|
||||
private String offAction;
|
||||
@SerializedName("OnAction")
|
||||
@Expose
|
||||
private String onAction;
|
||||
@SerializedName("Protected")
|
||||
@Expose
|
||||
private Boolean _protected;
|
||||
@SerializedName("Status")
|
||||
@Expose
|
||||
private String status;
|
||||
@SerializedName("Timers")
|
||||
@Expose
|
||||
private String timers;
|
||||
@SerializedName("Type")
|
||||
@Expose
|
||||
private String type;
|
||||
@SerializedName("UsedByCamera")
|
||||
@Expose
|
||||
private Boolean usedByCamera;
|
||||
@SerializedName("idx")
|
||||
@Expose
|
||||
private String idx;
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Integer getFavorite() {
|
||||
return favorite;
|
||||
}
|
||||
|
||||
public void setFavorite(Integer favorite) {
|
||||
this.favorite = favorite;
|
||||
}
|
||||
|
||||
public String getLastUpdate() {
|
||||
return lastUpdate;
|
||||
}
|
||||
|
||||
public void setLastUpdate(String lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getOffAction() {
|
||||
return offAction;
|
||||
}
|
||||
|
||||
public void setOffAction(String offAction) {
|
||||
this.offAction = offAction;
|
||||
}
|
||||
|
||||
public String getOnAction() {
|
||||
return onAction;
|
||||
}
|
||||
|
||||
public void setOnAction(String onAction) {
|
||||
this.onAction = onAction;
|
||||
}
|
||||
|
||||
public Boolean getProtected() {
|
||||
return _protected;
|
||||
}
|
||||
|
||||
public void setProtected(Boolean _protected) {
|
||||
this._protected = _protected;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTimers() {
|
||||
return timers;
|
||||
}
|
||||
|
||||
public void setTimers(String timers) {
|
||||
this.timers = timers;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public Boolean getUsedByCamera() {
|
||||
return usedByCamera;
|
||||
}
|
||||
|
||||
public void setUsedByCamera(Boolean usedByCamera) {
|
||||
this.usedByCamera = usedByCamera;
|
||||
}
|
||||
|
||||
public String getIdx() {
|
||||
return idx;
|
||||
}
|
||||
|
||||
public void setIdx(String idx) {
|
||||
this.idx = idx;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,99 +0,0 @@
|
||||
|
||||
package com.bwssystems.HABridge.plugins.domoticz;
|
||||
|
||||
import java.util.List;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
public class Scenes {
|
||||
|
||||
@SerializedName("ActTime")
|
||||
@Expose
|
||||
private Integer actTime;
|
||||
@SerializedName("AllowWidgetOrdering")
|
||||
@Expose
|
||||
private Boolean allowWidgetOrdering;
|
||||
@SerializedName("ServerTime")
|
||||
@Expose
|
||||
private String serverTime;
|
||||
@SerializedName("Sunrise")
|
||||
@Expose
|
||||
private String sunrise;
|
||||
@SerializedName("Sunset")
|
||||
@Expose
|
||||
private String sunset;
|
||||
@SerializedName("result")
|
||||
@Expose
|
||||
private List<SceneResult> result = null;
|
||||
@SerializedName("status")
|
||||
@Expose
|
||||
private String status;
|
||||
@SerializedName("title")
|
||||
@Expose
|
||||
private String title;
|
||||
|
||||
public Integer getActTime() {
|
||||
return actTime;
|
||||
}
|
||||
|
||||
public void setActTime(Integer actTime) {
|
||||
this.actTime = actTime;
|
||||
}
|
||||
|
||||
public Boolean getAllowWidgetOrdering() {
|
||||
return allowWidgetOrdering;
|
||||
}
|
||||
|
||||
public void setAllowWidgetOrdering(Boolean allowWidgetOrdering) {
|
||||
this.allowWidgetOrdering = allowWidgetOrdering;
|
||||
}
|
||||
|
||||
public String getServerTime() {
|
||||
return serverTime;
|
||||
}
|
||||
|
||||
public void setServerTime(String serverTime) {
|
||||
this.serverTime = serverTime;
|
||||
}
|
||||
|
||||
public String getSunrise() {
|
||||
return sunrise;
|
||||
}
|
||||
|
||||
public void setSunrise(String sunrise) {
|
||||
this.sunrise = sunrise;
|
||||
}
|
||||
|
||||
public String getSunset() {
|
||||
return sunset;
|
||||
}
|
||||
|
||||
public void setSunset(String sunset) {
|
||||
this.sunset = sunset;
|
||||
}
|
||||
|
||||
public List<SceneResult> getResult() {
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setResult(List<SceneResult> result) {
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -42,6 +42,9 @@ app.config (function ($locationProvider, $routeProvider) {
|
||||
}).when ('/hassdevices', {
|
||||
templateUrl: 'views/hassdevice.html',
|
||||
controller: 'HassController'
|
||||
}).when ('/domoticzdevices', {
|
||||
templateUrl: 'views/domoticzdevice.html',
|
||||
controller: 'DomoticzController'
|
||||
}).otherwise ({
|
||||
templateUrl: 'views/configuration.html',
|
||||
controller: 'ViewingController'
|
||||
@@ -68,7 +71,7 @@ String.prototype.replaceAll = function (search, replace)
|
||||
|
||||
app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||
var self = this;
|
||||
this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, habridgeversion: ""};
|
||||
this.state = {base: window.location.origin + "/api/devices", bridgelocation: window.location.origin, systemsbase: window.location.origin + "/system", huebase: window.location.origin + "/api", configs: [], backups: [], devices: [], device: {}, mapandid: [], type: "", settings: [], myToastMsg: [], logMsgs: [], loggerInfo: [], mapTypes: [], olddevicename: "", logShowAll: false, isInControl: false, showVera: false, showHarmony: false, showNest: false, showHue: false, showHal: false, showMqtt: false, showHass: false, showDomoticz: false, habridgeversion: ""};
|
||||
|
||||
this.displayWarn = function(errorTitle, error) {
|
||||
var toastContent = errorTitle;
|
||||
@@ -230,6 +233,11 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.updateShowDomoticz = function () {
|
||||
this.state.showDomoticz = self.state.settings.domoticzconfigured;
|
||||
return;
|
||||
}
|
||||
|
||||
this.loadBridgeSettings = function () {
|
||||
return $http.get(this.state.systemsbase + "/settings").then(
|
||||
function (response) {
|
||||
@@ -241,6 +249,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||
self.updateShowHal();
|
||||
self.updateShowMqtt();
|
||||
self.updateShowHass();
|
||||
self.updateShowDomoticz();
|
||||
},
|
||||
function (error) {
|
||||
self.displayWarn("Load Bridge Settings Error: ", error);
|
||||
@@ -409,6 +418,19 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||
);
|
||||
};
|
||||
|
||||
this.viewDomoticzDevices = function () {
|
||||
if (!this.state.showDomoticz)
|
||||
return;
|
||||
return $http.get(this.state.base + "/domoticz/devices").then(
|
||||
function (response) {
|
||||
self.state.domoticzdevices = response.data;
|
||||
},
|
||||
function (error) {
|
||||
self.displayWarn("Get Domoticz Devices Error: ", error);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
this.formatCallItem = function (currentItem) {
|
||||
if(!currentItem.startsWith("{\"item") && !currentItem.startsWith("[{\"item")) {
|
||||
if (currentItem.startsWith("[") || currentItem.startsWith("{"))
|
||||
@@ -943,6 +965,24 @@ app.controller ('SystemController', function ($scope, $location, $http, $window,
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.addDomoticztoSettings = function (newdomoticzname, newdomoticzip, newdomoticzport, newdomoticzusername, newdomoticzpassword) {
|
||||
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 }
|
||||
$scope.bridge.settings.domoticzaddress.devices.push(newdomoticz);
|
||||
$scope.newdomoticzname = null;
|
||||
$scope.newdomoticzip = null;
|
||||
$scope.newdomoticzport = null;
|
||||
$scope.newdomoticzpassword = null;
|
||||
};
|
||||
$scope.removeDomoticztoSettings = function (domoticzname, domoticzip) {
|
||||
for(var i = $scope.bridge.settings.domoticzaddress.devices.length - 1; i >= 0; i--) {
|
||||
if($scope.bridge.settings.domoticzaddress.devices[i].name === domoticzname && $scope.bridge.settings.domoticzaddress.devices[i].ip === domoticzip) {
|
||||
$scope.bridge.settings.domoticzaddress.devices.splice(i, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.bridgeReinit = function () {
|
||||
bridgeService.reinit();
|
||||
};
|
||||
@@ -2085,6 +2125,162 @@ app.controller('HassController', function ($scope, $location, $http, bridgeServi
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('DomoticzController', function ($scope, $location, $http, bridgeService, ngDialog) {
|
||||
$scope.bridge = bridgeService.state;
|
||||
$scope.device = bridgeService.state.device;
|
||||
$scope.device_dim_control = "";
|
||||
$scope.bulk = { devices: [] };
|
||||
$scope.selectAll = false;
|
||||
bridgeService.viewDomoticzDevices();
|
||||
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
|
||||
$scope.buttonsVisible = false;
|
||||
|
||||
$scope.clearDevice = function () {
|
||||
bridgeService.clearDevice();
|
||||
$scope.device = bridgeService.state.device;
|
||||
};
|
||||
|
||||
$scope.buildDeviceUrls = function (domoticzdevice, dim_control) {
|
||||
var preOnCmd = "";
|
||||
var preDimCmd = "";
|
||||
var preOffCmd = "";
|
||||
var nameCmd = "";
|
||||
var aDeviceType;
|
||||
var postCmd = "";
|
||||
if(domoticzdevice.devicetype === "Scene") {
|
||||
aDeviceType = "scene";
|
||||
preOnCmd = "/SceneService!SceneCmd=Set!SceneName=";
|
||||
preOffCmd = preOnCmd;
|
||||
}
|
||||
else {
|
||||
aDeviceType = "switch";
|
||||
preOnCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=On";
|
||||
preDimCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Dim!DevicePercent=";
|
||||
preOffCmd = "/DeviceService!DeviceCmd=SetDevice!DeviceValue=Off";
|
||||
nameCmd = "!DeviceName=";
|
||||
}
|
||||
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
|
||||
dimpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preDimCmd
|
||||
+ dim_control
|
||||
+ nameCmd
|
||||
+ domoticzdevice.devicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
else
|
||||
dimpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ domoticzdevice.devicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
onpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ domoticzdevice.devicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
offpayload = "http://" + domoticzdevice.domoticzaddress
|
||||
+ preOffCmd
|
||||
+ nameCmd
|
||||
+ domoticzdevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, domoticzdevice.devicename + "-" + domoticzdevice.domoticzname, domoticzdevice.devicename, domoticzdevice.domoticzname, aDeviceType, "domoticzDevice", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
$location.path('/editdevice');
|
||||
};
|
||||
|
||||
$scope.bulkAddDevices = function(dim_control) {
|
||||
var devicesList = [];
|
||||
for(var i = 0; i < $scope.bulk.devices.length; i++) {
|
||||
for(var x = 0; x < bridgeService.state.domoticzdevices.length; x++) {
|
||||
if(bridgeService.state.domoticzdevices[x].devicename === $scope.bulk.devices[i]) {
|
||||
$scope.buildDeviceUrls(bridgeService.state.domoticzdevices[x],dim_control);
|
||||
devicesList[i] = {
|
||||
name: $scope.device.name,
|
||||
mapId: $scope.device.mapId,
|
||||
mapType: $scope.device.mapType,
|
||||
deviceType: $scope.device.deviceType,
|
||||
targetDevice: $scope.device.targetDevice,
|
||||
onUrl: $scope.device.onUrl,
|
||||
dimUrl: $scope.device.dimUrl,
|
||||
offUrl: $scope.device.offUrl,
|
||||
headers: $scope.device.headers,
|
||||
httpVerb: $scope.device.httpVerb,
|
||||
contentType: $scope.device.contentType,
|
||||
contentBody: $scope.device.contentBody,
|
||||
contentBodyDim: $scope.device.contentBodyDim,
|
||||
contentBodyOff: $scope.device.contentBodyOff
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
bridgeService.bulkAddDevice(devicesList).then(
|
||||
function () {
|
||||
$scope.clearDevice();
|
||||
bridgeService.viewDevices();
|
||||
bridgeService.viewHalDevices();
|
||||
},
|
||||
function (error) {
|
||||
bridgeService.displayWarn("Error adding HAL devices in bulk.", error)
|
||||
}
|
||||
);
|
||||
$scope.bulk = { devices: [] };
|
||||
$scope.selectAll = false;
|
||||
};
|
||||
|
||||
$scope.toggleSelection = function toggleSelection(deviceId) {
|
||||
var idx = $scope.bulk.devices.indexOf(deviceId);
|
||||
|
||||
// is currently selected
|
||||
if (idx > -1) {
|
||||
$scope.bulk.devices.splice(idx, 1);
|
||||
if($scope.bulk.devices.length === 0 && $scope.selectAll)
|
||||
$scope.selectAll = false;
|
||||
}
|
||||
|
||||
// is newly selected
|
||||
else {
|
||||
$scope.bulk.devices.push(deviceId);
|
||||
$scope.selectAll = true;
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleSelectAll = function toggleSelectAll() {
|
||||
if($scope.selectAll) {
|
||||
$scope.selectAll = false;
|
||||
$scope.bulk = { devices: [] };
|
||||
}
|
||||
else {
|
||||
$scope.selectAll = true;
|
||||
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"))
|
||||
$scope.bulk.devices.push(bridgeService.state.haldevices[x].haldevicename);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$scope.toggleButtons = function () {
|
||||
$scope.buttonsVisible = !$scope.buttonsVisible;
|
||||
if($scope.buttonsVisible)
|
||||
$scope.imgButtonsUrl = "glyphicon glyphicon-minus";
|
||||
else
|
||||
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
|
||||
};
|
||||
|
||||
$scope.deleteDevice = function (device) {
|
||||
$scope.bridge.device = device;
|
||||
ngDialog.open({
|
||||
template: 'deleteDialog',
|
||||
controller: 'DeleteDialogCtrl',
|
||||
className: 'ngdialog-theme-default'
|
||||
});
|
||||
};
|
||||
|
||||
$scope.editDevice = function (device) {
|
||||
bridgeService.editDevice(device);
|
||||
$location.path('/editdevice');
|
||||
};
|
||||
});
|
||||
|
||||
app.controller('EditController', function ($scope, $location, $http, bridgeService) {
|
||||
bridgeService.viewMapTypes();
|
||||
$scope.bridge = bridgeService.state;
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
href="#!/haldevices">HAL Devices</a></li>
|
||||
<li ng-if="bridge.showMqtt" role="presentation"><a href="#!/mqttmessages">MQTT Messages</a></li>
|
||||
<li ng-if="bridge.showHass" role="presentation"><a href="#!/hassdevices">HomeAssistant Devices</a></li>
|
||||
<li ng-if="bridge.showDomoticz" role="presentation"><a href="#!/domoticzdevices">Domoticz Devices</a></li>
|
||||
<li role="presentation"><a href="#!/editdevice">Add/Edit</a></li>
|
||||
</ul>
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
href="#!/haldevices">HAL Devices</a></li>
|
||||
<li ng-if="bridge.showMqtt" role="presentation"><a href="#!/mqttmessages">MQTT Messages</a></li>
|
||||
<li ng-if="bridge.showHass" role="presentation"><a href="#!/hassdevices">HomeAssistant Devices</a></li>
|
||||
<li ng-if="bridge.showDomoticz" role="presentation"><a href="#!/domoticzdevices">Domoticz Devices</a></li>
|
||||
<li role="presentation"><a href="#!/editdevice">Add/Edit</a></li>
|
||||
</ul>
|
||||
|
||||
@@ -306,6 +307,51 @@
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Domoticz Names and IP Addresses</td>
|
||||
<td><table
|
||||
class="table table-bordered table-striped table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>IP</th>
|
||||
<th>Port</th>
|
||||
<th>Username (opt)</th>
|
||||
<th>Password (opt)</th>
|
||||
<th>Manage</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tr ng-repeat="domoticz in bridge.settings.domoticzaddress.devices">
|
||||
<td>{{domoticz.name}}</td>
|
||||
<td>{{domoticz.ip}}</td>
|
||||
<td>{{domoticz.port}}</td>
|
||||
<td>{{domoticz.username}}</td>
|
||||
<td ng-if="domoticz.password">*******</td>
|
||||
<td ng-if="!domoticz.password"> </td>
|
||||
<td><button class="btn btn-danger" type="submit"
|
||||
ng-click="removeDomoticztoSettings(domoticz.name, domoticz.ip)">Del</button></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><input id="bridge-settings-next-domoticz-name"
|
||||
class="form-control" type="text" ng-model="newdomoticzname"
|
||||
placeholder="A HomeAssistant"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-ip"
|
||||
class="form-control" type="text" ng-model="newdomoticzip"
|
||||
placeholder="192.168.1.3"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-port"
|
||||
class="form-control" type="text" ng-model="newdomoticzport"
|
||||
placeholder="8123"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-username"
|
||||
class="form-control" type="text" ng-model="newdomoticzusername"
|
||||
placeholder="username"></td>
|
||||
<td><input id="bridge-settings-next-domoticz-password"
|
||||
class="form-control" type="password" ng-model="newdomoticzpassword"
|
||||
placeholder="Home Assistant password (opt)"></td>
|
||||
<td><button class="btn btn-success" type="submit"
|
||||
ng-click="addDomoticztoSettings(newdomoticzname, newdomoticzip, newdomoticzport, newdomoticzusername, newdomoticzpassword)">Add</button></td>
|
||||
</tr>
|
||||
</table></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Nest Username</td>
|
||||
<td><input id="bridge-settings-nestuser" class="form-control"
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.bwssystems.hass.test;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import com.bwssystems.HABridge.plugins.domoticz.DeviceResult;
|
||||
import com.bwssystems.HABridge.plugins.domoticz.Devices;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
|
||||
public class DomoticzDeviceConstructor {
|
||||
public final static String DevicesTestData = "{ \"ActTime\" : 1485295582, \"ServerTime\" : \"2017-01-24 16:06:22\", \"Sunrise\" : \"07:11\", \"Sunset\" : \"16:53\", \"result\" : [ { \"AddjMulti\" : 1.0, \"AddjMulti2\" : 1.0, \"AddjValue\" : 0.0, \"AddjValue2\" : 0.0, \"BatteryLevel\" : 255, \"CustomImage\" : 2, \"Data\" : \"On\", \"Description\" : \"\", \"Favorite\" : 1, \"HardwareID\" : 3, \"HardwareName\" : \"MyHue\", \"HardwareType\" : \"Philips Hue Bridge\", \"HardwareTypeVal\" : 38, \"HaveDimmer\" : true, \"HaveGroupCmd\" : false, \"HaveTimeout\" : false, \"ID\" : \"1\", \"Image\" : \"TV\", \"IsSubDevice\" : false, \"LastUpdate\" : \"2017-01-23 17:15:22\", \"Level\" : 0, \"LevelInt\" : 0, \"MaxDimLevel\" : 100, \"Name\" : \"TV\", \"Notifications\" : \"false\", \"PlanID\" : \"0\", \"PlanIDs\" : [ 0 ], \"Protected\" : false, \"ShowNotifications\" : true, \"SignalLevel\" : \"-\", \"Status\" : \"On\", \"StrParam1\" : \"\", \"StrParam2\" : \"\", \"SubType\" : \"RGBW\", \"SwitchType\" : \"On/Off\", \"SwitchTypeVal\" : 0, \"Timers\" : \"false\", \"Type\" : \"Lighting Limitless/Applamp\", \"TypeImg\" : \"lightbulb\", \"Unit\" : 1, \"Used\" : 1, \"UsedByCamera\" : false, \"XOffset\" : \"0\", \"YOffset\" : \"0\", \"idx\" : \"23\" }, { \"AddjMulti\" : 1.0, \"AddjMulti2\" : 1.0, \"AddjValue\" : 0.0, \"AddjValue2\" : 0.0, \"BatteryLevel\" : 255, \"CustomImage\" : 0, \"Data\" : \"On\", \"Description\" : \"\", \"Favorite\" : 1, \"HardwareID\" : 3, \"HardwareName\" : \"MyHue\", \"HardwareType\" : \"Philips Hue Bridge\", \"HardwareTypeVal\" : 38, \"HaveDimmer\" : true, \"HaveGroupCmd\" : false, \"HaveTimeout\" : false, \"ID\" : \"0000000B\", \"Image\" : \"Light\", \"IsSubDevice\" : false, \"LastUpdate\" : \"2017-01-23 16:15:31\", \"Level\" : 0, \"LevelInt\" : 0, \"MaxDimLevel\" : 100, \"Name\" : \"lights\", \"Notifications\" : \"false\", \"PlanID\" : \"0\", \"PlanIDs\" : [ 0 ], \"Protected\" : false, \"ShowNotifications\" : true, \"SignalLevel\" : \"-\", \"Status\" : \"On\", \"StrParam1\" : \"\", \"StrParam2\" : \"\", \"SubType\" : \"RGBW\", \"SwitchType\" : \"On/Off\", \"SwitchTypeVal\" : 0, \"Timers\" : \"false\", \"Type\" : \"Lighting Limitless/Applamp\", \"TypeImg\" : \"lightbulb\", \"Unit\" : 1, \"Used\" : 1, \"UsedByCamera\" : false, \"XOffset\" : \"0\", \"YOffset\" : \"0\", \"idx\" : \"25\" }, { \"AddjMulti\" : 1.0, \"AddjMulti2\" : 1.0, \"AddjValue\" : 0.0, \"AddjValue2\" : 0.0, \"BatteryLevel\" : 255, \"CustomImage\" : 0, \"Data\" : \"Off\", \"Description\" : \"\", \"Favorite\" : 1, \"HardwareID\" : 3, \"HardwareName\" : \"MyHue\", \"HardwareType\" : \"Philips Hue Bridge\", \"HardwareTypeVal\" : 38, \"HaveDimmer\" : true, \"HaveGroupCmd\" : false, \"HaveTimeout\" : false, \"ID\" : \"00000014\", \"Image\" : \"Light\", \"IsSubDevice\" : false, \"LastUpdate\" : \"2017-01-23 11:25:59\", \"Level\" : 0, \"LevelInt\" : 0, \"MaxDimLevel\" : 100, \"Name\" : \"testUDP\", \"Notifications\" : \"false\", \"PlanID\" : \"0\", \"PlanIDs\" : [ 0 ], \"Protected\" : false, \"ShowNotifications\" : true, \"SignalLevel\" : \"-\", \"Status\" : \"Off\", \"StrParam1\" : \"\", \"StrParam2\" : \"\", \"SubType\" : \"RGBW\", \"SwitchType\" : \"Dimmer\", \"SwitchTypeVal\" : 7, \"Timers\" : \"false\", \"Type\" : \"Lighting Limitless/Applamp\", \"TypeImg\" : \"dimmer\", \"Unit\" : 1, \"Used\" : 1, \"UsedByCamera\" : false, \"XOffset\" : \"0\", \"YOffset\" : \"0\", \"idx\" : \"35\" }, { \"AddjMulti\" : 1.0, \"AddjMulti2\" : 1.0, \"AddjValue\" : 0.0, \"AddjValue2\" : 0.0, \"BatteryLevel\" : 255, \"CustomImage\" : 0, \"Data\" : \"Off\", \"Description\" : \"\", \"Favorite\" : 1, \"HardwareID\" : 3, \"HardwareName\" : \"MyHue\", \"HardwareType\" : \"Philips Hue Bridge\", \"HardwareTypeVal\" : 38, \"HaveDimmer\" : true, \"HaveGroupCmd\" : false, \"HaveTimeout\" : false, \"ID\" : \"00000009\", \"Image\" : \"Light\", \"IsSubDevice\" : false, \"LastUpdate\" : \"2017-01-24 09:18:22\", \"Level\" : 94, \"LevelInt\" : 94, \"MaxDimLevel\" : 100, \"Name\" : \"Test Light on CM15 (PL) N1\", \"Notifications\" : \"false\", \"PlanID\" : \"0\", \"PlanIDs\" : [ 0 ], \"Protected\" : false, \"ShowNotifications\" : true, \"SignalLevel\" : \"-\", \"Status\" : \"Off\", \"StrParam1\" : \"\", \"StrParam2\" : \"\", \"SubType\" : \"RGBW\", \"SwitchType\" : \"Dimmer\", \"SwitchTypeVal\" : 7, \"Timers\" : \"false\", \"Type\" : \"Lighting Limitless/Applamp\", \"TypeImg\" : \"dimmer\", \"Unit\" : 1, \"Used\" : 1, \"UsedByCamera\" : false, \"XOffset\" : \"0\", \"YOffset\" : \"0\", \"idx\" : \"44\" } ], \"status\" : \"OK\", \"title\" : \"Devices\" }";
|
||||
public final static String ScenesTestData = "{ \"ActTime\" : 1485295431, \"AllowWidgetOrdering\" : true, \"ServerTime\" : \"2017-01-24 16:03:51\", \"Sunrise\" : \"07:11\", \"Sunset\" : \"16:53\", \"result\" : [ { \"Description\" : \"\", \"Favorite\" : 0, \"LastUpdate\" : \"2017-01-23 11:06:31\", \"Name\" : \"Watch TV\", \"OffAction\" : \"\", \"OnAction\" : \"\", \"Protected\" : false, \"Status\" : \"On\", \"Timers\" : \"false\", \"Type\" : \"Scene\", \"UsedByCamera\" : false, \"idx\" : \"1\" }, { \"Description\" : \"\", \"Favorite\" : 0, \"LastUpdate\" : \"2017-01-23 11:25:58\", \"Name\" : \"TestScene\", \"OffAction\" : \"\", \"OnAction\" : \"\", \"Protected\" : false, \"Status\" : \"Off\", \"Timers\" : \"false\", \"Type\" : \"Scene\", \"UsedByCamera\" : false, \"idx\" : \"2\" } ], \"status\" : \"OK\", \"title\" : \"Scenes\" }";
|
||||
public static void main(String[] args){
|
||||
DomoticzDeviceConstructor aTestService = new DomoticzDeviceConstructor();
|
||||
if(aTestService.validateStructure())
|
||||
System.out.println("Test Successful");
|
||||
}
|
||||
|
||||
public Boolean validateStructure() {
|
||||
Gson aGson;
|
||||
try {
|
||||
aGson = new GsonBuilder()
|
||||
// .registerTypeAdapter(Service.class, new ServiceDeserializer())
|
||||
// .registerTypeHierarchyAdapter(Field.class, new FieldDeserializer())
|
||||
.create();
|
||||
System.out.println("Decode Domoticz Devices Data");
|
||||
Devices aDeviceContainer = aGson.fromJson(DevicesTestData, Devices.class);
|
||||
Iterator<DeviceResult> aList = aDeviceContainer.getResult().iterator();
|
||||
while(aList.hasNext()) {
|
||||
DeviceResult theResult = aList.next();
|
||||
System.out.println(" " + theResult.getName() + " - " + theResult.getDescription() + " - " + theResult.getType());
|
||||
}
|
||||
System.out.println("Decode Domoticz Sceness Data");
|
||||
aDeviceContainer = aGson.fromJson(ScenesTestData, Devices.class);
|
||||
aList = aDeviceContainer.getResult().iterator();
|
||||
while(aList.hasNext()) {
|
||||
DeviceResult theResult = aList.next();
|
||||
System.out.println(" " + theResult.getName() + " - " + theResult.getDescription() + " - " + theResult.getType());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.bwssystems.hass.test;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
public class DomoticzStructureTestCase {
|
||||
|
||||
@Test
|
||||
public void testValidateStructure() {
|
||||
DomoticzDeviceConstructor aTestService = new DomoticzDeviceConstructor();
|
||||
Assert.assertEquals(aTestService.validateStructure(), true);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user