mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-19 00:20:26 +00:00
Add Somfy devices
This commit is contained in:
@@ -40,13 +40,16 @@ public class BridgeSettingsDescriptor {
|
|||||||
private String hubversion;
|
private String hubversion;
|
||||||
private IpList domoticzaddress;
|
private IpList domoticzaddress;
|
||||||
private boolean domoticzconfigured;
|
private boolean domoticzconfigured;
|
||||||
|
private IpList somfyaddress;
|
||||||
|
private boolean somfyconfigured;
|
||||||
|
|
||||||
public BridgeSettingsDescriptor() {
|
public BridgeSettingsDescriptor() {
|
||||||
super();
|
super();
|
||||||
this.upnpstrict = true;
|
this.upnpstrict = true;
|
||||||
this.traceupnp = false;
|
this.traceupnp = false;
|
||||||
this.nestconfigured = false;
|
this.nestconfigured = false;
|
||||||
this.veraconfigured = false;
|
this.veraconfigured = false;
|
||||||
|
this.somfyconfigured = false;
|
||||||
this.harmonyconfigured = false;
|
this.harmonyconfigured = false;
|
||||||
this.hueconfigured = false;
|
this.hueconfigured = false;
|
||||||
this.halconfigured = false;
|
this.halconfigured = false;
|
||||||
@@ -92,9 +95,15 @@ public class BridgeSettingsDescriptor {
|
|||||||
public IpList getVeraAddress() {
|
public IpList getVeraAddress() {
|
||||||
return veraaddress;
|
return veraaddress;
|
||||||
}
|
}
|
||||||
|
public IpList getSomfyAddress() {
|
||||||
|
return somfyaddress;
|
||||||
|
}
|
||||||
public void setVeraAddress(IpList veraAddress) {
|
public void setVeraAddress(IpList veraAddress) {
|
||||||
this.veraaddress = veraAddress;
|
this.veraaddress = veraAddress;
|
||||||
}
|
}
|
||||||
|
public void setSomfyAddress(IpList somfyAddress) {
|
||||||
|
this.somfyaddress = somfyAddress;
|
||||||
|
}
|
||||||
public IpList getHarmonyAddress() {
|
public IpList getHarmonyAddress() {
|
||||||
return harmonyaddress;
|
return harmonyaddress;
|
||||||
}
|
}
|
||||||
@@ -128,9 +137,15 @@ public class BridgeSettingsDescriptor {
|
|||||||
public boolean isVeraconfigured() {
|
public boolean isVeraconfigured() {
|
||||||
return veraconfigured;
|
return veraconfigured;
|
||||||
}
|
}
|
||||||
|
public boolean isSomfyconfigured() {
|
||||||
|
return somfyconfigured;
|
||||||
|
}
|
||||||
public void setVeraconfigured(boolean veraconfigured) {
|
public void setVeraconfigured(boolean veraconfigured) {
|
||||||
this.veraconfigured = veraconfigured;
|
this.veraconfigured = veraconfigured;
|
||||||
}
|
}
|
||||||
|
public void setSomfyconfigured(boolean somfyconfigured) {
|
||||||
|
this.somfyconfigured = somfyconfigured;
|
||||||
|
}
|
||||||
public boolean isHarmonyconfigured() {
|
public boolean isHarmonyconfigured() {
|
||||||
return harmonyconfigured;
|
return harmonyconfigured;
|
||||||
}
|
}
|
||||||
@@ -314,7 +329,7 @@ public class BridgeSettingsDescriptor {
|
|||||||
}
|
}
|
||||||
public Boolean isValidHass() {
|
public Boolean isValidHass() {
|
||||||
if(this.getHassaddress() == null || this.getHassaddress().getDevices().size() <= 0)
|
if(this.getHassaddress() == null || this.getHassaddress().getDevices().size() <= 0)
|
||||||
return false;
|
return false;
|
||||||
List<NamedIP> devicesList = this.getHassaddress().getDevices();
|
List<NamedIP> devicesList = this.getHassaddress().getDevices();
|
||||||
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
||||||
return false;
|
return false;
|
||||||
@@ -322,10 +337,18 @@ public class BridgeSettingsDescriptor {
|
|||||||
}
|
}
|
||||||
public Boolean isValidDomoticz() {
|
public Boolean isValidDomoticz() {
|
||||||
if(this.getDomoticzaddress() == null || this.getDomoticzaddress().getDevices().size() <= 0)
|
if(this.getDomoticzaddress() == null || this.getDomoticzaddress().getDevices().size() <= 0)
|
||||||
return false;
|
return false;
|
||||||
List<NamedIP> devicesList = this.getDomoticzaddress().getDevices();
|
List<NamedIP> devicesList = this.getDomoticzaddress().getDevices();
|
||||||
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
public Boolean isValidSomfy() {
|
||||||
|
if(this.getSomfyAddress() == null || this.getSomfyAddress().getDevices().size() <= 0)
|
||||||
|
return false;
|
||||||
|
List<NamedIP> devicesList = this.getSomfyAddress().getDevices();
|
||||||
|
if(devicesList.get(0).getIp().contains(Configuration.DEFAULT_ADDRESS))
|
||||||
|
return false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,82 +1,84 @@
|
|||||||
package com.bwssystems.HABridge;
|
package com.bwssystems.HABridge;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class DeviceMapTypes {
|
public class DeviceMapTypes {
|
||||||
|
|
||||||
public final static String[] CUSTOM_DEVICE = { "custom", "Custom"};
|
public final static String[] CUSTOM_DEVICE = { "custom", "Custom"};
|
||||||
public final static String[] VERA_DEVICE = { "veraDevice", "Vera Device"};
|
public final static String[] VERA_DEVICE = { "veraDevice", "Vera Device"};
|
||||||
public final static String[] VERA_SCENE = { "veraScene", "Vera Scene"};
|
public final static String[] VERA_SCENE = { "veraScene", "Vera Scene"};
|
||||||
public final static String[] HARMONY_ACTIVITY = { "harmonyActivity", "Harmony Activity"};
|
public final static String[] HARMONY_ACTIVITY = { "harmonyActivity", "Harmony Activity"};
|
||||||
public final static String[] HARMONY_BUTTON = { "harmonyButton", "Harmony Button"};
|
public final static String[] HARMONY_BUTTON = { "harmonyButton", "Harmony Button"};
|
||||||
public final static String[] NEST_HOMEAWAY = { "nestHomeAway", "Nest Home Status"};
|
public final static String[] NEST_HOMEAWAY = { "nestHomeAway", "Nest Home Status"};
|
||||||
public final static String[] NEST_THERMO_SET = { "nestThermoSet", "Nest Thermostat"};
|
public final static String[] NEST_THERMO_SET = { "nestThermoSet", "Nest Thermostat"};
|
||||||
public final static String[] HUE_DEVICE = { "hueDevice", "Hue Device"};
|
public final static String[] HUE_DEVICE = { "hueDevice", "Hue Device"};
|
||||||
public final static String[] HAL_DEVICE = { "halDevice", "HAL Device"};
|
public final static String[] HAL_DEVICE = { "halDevice", "HAL Device"};
|
||||||
public final static String[] HAL_BUTTON = { "halButton", "HAL Button"};
|
public final static String[] HAL_BUTTON = { "halButton", "HAL Button"};
|
||||||
public final static String[] HAL_HOME = { "halHome", "HAL Home Status"};
|
public final static String[] HAL_HOME = { "halHome", "HAL Home Status"};
|
||||||
public final static String[] HAL_THERMO_SET = { "halThermoSet", "HAL Thermostat"};
|
public final static String[] HAL_THERMO_SET = { "halThermoSet", "HAL Thermostat"};
|
||||||
public final static String[] MQTT_MESSAGE = { "mqttMessage", "MQTT Message"};
|
public final static String[] MQTT_MESSAGE = { "mqttMessage", "MQTT Message"};
|
||||||
public final static String[] EXEC_DEVICE_COMPAT = { "exec", "Execute Script/Program"};
|
public final static String[] EXEC_DEVICE_COMPAT = { "exec", "Execute Script/Program"};
|
||||||
public final static String[] CMD_DEVICE = { "cmdDevice", "Execute Command/Script/Program"};
|
public final static String[] CMD_DEVICE = { "cmdDevice", "Execute Command/Script/Program"};
|
||||||
public final static String[] HASS_DEVICE = { "hassDevice", "HomeAssistant Device"};
|
public final static String[] HASS_DEVICE = { "hassDevice", "HomeAssistant Device"};
|
||||||
public final static String[] TCP_DEVICE = { "tcpDevice", "TCP Device"};
|
public final static String[] TCP_DEVICE = { "tcpDevice", "TCP Device"};
|
||||||
public final static String[] TCP_DEVICE_COMPAT = { "TCP", "TCP Device"};
|
public final static String[] TCP_DEVICE_COMPAT = { "TCP", "TCP Device"};
|
||||||
public final static String[] UDP_DEVICE = { "udpDevice", "UDP Device"};
|
public final static String[] UDP_DEVICE = { "udpDevice", "UDP Device"};
|
||||||
public final static String[] UDP_DEVICE_COMPAT = { "UDP", "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[] HTTP_DEVICE = { "httpDevice", "HTTP Device"};
|
||||||
public final static String[] DOMOTICZ_DEVICE = { "domoticzDevice", "Domoticz Device"};
|
public final static String[] DOMOTICZ_DEVICE = { "domoticzDevice", "Domoticz Device"};
|
||||||
|
public final static String[] SOMFY_DEVICE = { "somfyDevice", "Somfy Device"};
|
||||||
public final static int typeIndex = 0;
|
|
||||||
public final static int displayIndex = 1;
|
public final static int typeIndex = 0;
|
||||||
|
public final static int displayIndex = 1;
|
||||||
ArrayList<String[]> deviceMapTypes;
|
|
||||||
|
ArrayList<String[]> deviceMapTypes;
|
||||||
public DeviceMapTypes() {
|
|
||||||
super();
|
public DeviceMapTypes() {
|
||||||
deviceMapTypes = new ArrayList<String[]>();
|
super();
|
||||||
deviceMapTypes.add(CMD_DEVICE);
|
deviceMapTypes = new ArrayList<String[]>();
|
||||||
deviceMapTypes.add(DOMOTICZ_DEVICE);
|
deviceMapTypes.add(CMD_DEVICE);
|
||||||
deviceMapTypes.add(HAL_DEVICE);
|
deviceMapTypes.add(DOMOTICZ_DEVICE);
|
||||||
deviceMapTypes.add(HAL_HOME);
|
deviceMapTypes.add(HAL_DEVICE);
|
||||||
deviceMapTypes.add(HAL_THERMO_SET);
|
deviceMapTypes.add(HAL_HOME);
|
||||||
deviceMapTypes.add(HAL_BUTTON);
|
deviceMapTypes.add(HAL_THERMO_SET);
|
||||||
deviceMapTypes.add(HARMONY_ACTIVITY);
|
deviceMapTypes.add(HAL_BUTTON);
|
||||||
deviceMapTypes.add(HARMONY_BUTTON);
|
deviceMapTypes.add(HARMONY_ACTIVITY);
|
||||||
deviceMapTypes.add(HASS_DEVICE);
|
deviceMapTypes.add(HARMONY_BUTTON);
|
||||||
deviceMapTypes.add(HTTP_DEVICE);
|
deviceMapTypes.add(HASS_DEVICE);
|
||||||
deviceMapTypes.add(HUE_DEVICE);
|
deviceMapTypes.add(HTTP_DEVICE);
|
||||||
deviceMapTypes.add(MQTT_MESSAGE);
|
deviceMapTypes.add(HUE_DEVICE);
|
||||||
deviceMapTypes.add(NEST_HOMEAWAY);
|
deviceMapTypes.add(MQTT_MESSAGE);
|
||||||
deviceMapTypes.add(NEST_THERMO_SET);
|
deviceMapTypes.add(NEST_HOMEAWAY);
|
||||||
deviceMapTypes.add(TCP_DEVICE);
|
deviceMapTypes.add(NEST_THERMO_SET);
|
||||||
deviceMapTypes.add(UDP_DEVICE);
|
deviceMapTypes.add(TCP_DEVICE);
|
||||||
deviceMapTypes.add(VERA_DEVICE);
|
deviceMapTypes.add(UDP_DEVICE);
|
||||||
deviceMapTypes.add(VERA_SCENE);
|
deviceMapTypes.add(VERA_DEVICE);
|
||||||
}
|
deviceMapTypes.add(VERA_SCENE);
|
||||||
public static int getTypeIndex() {
|
deviceMapTypes.add(SOMFY_DEVICE);
|
||||||
return typeIndex;
|
}
|
||||||
}
|
public static int getTypeIndex() {
|
||||||
public static int getDisplayIndex() {
|
return typeIndex;
|
||||||
return displayIndex;
|
}
|
||||||
}
|
public static int getDisplayIndex() {
|
||||||
public ArrayList<String[]> getDeviceMapTypes() {
|
return displayIndex;
|
||||||
return deviceMapTypes;
|
}
|
||||||
}
|
public ArrayList<String[]> getDeviceMapTypes() {
|
||||||
|
return deviceMapTypes;
|
||||||
public Boolean validateType(String type) {
|
}
|
||||||
if(type == null || type.trim().isEmpty())
|
|
||||||
return false;
|
public Boolean validateType(String type) {
|
||||||
for(String[] mapType : deviceMapTypes) {
|
if(type == null || type.trim().isEmpty())
|
||||||
if(type.trim().contentEquals(mapType[typeIndex]))
|
return false;
|
||||||
return true;
|
for(String[] mapType : deviceMapTypes) {
|
||||||
}
|
if(type.trim().contentEquals(mapType[typeIndex]))
|
||||||
if(type.trim().contentEquals(EXEC_DEVICE_COMPAT[typeIndex]))
|
return true;
|
||||||
return true;
|
}
|
||||||
if(type.trim().contentEquals(TCP_DEVICE_COMPAT[typeIndex]))
|
if(type.trim().contentEquals(EXEC_DEVICE_COMPAT[typeIndex]))
|
||||||
return true;
|
return true;
|
||||||
if(type.trim().contentEquals(UDP_DEVICE_COMPAT[typeIndex]))
|
if(type.trim().contentEquals(TCP_DEVICE_COMPAT[typeIndex]))
|
||||||
return true;
|
return true;
|
||||||
return false;
|
if(type.trim().contentEquals(UDP_DEVICE_COMPAT[typeIndex]))
|
||||||
}
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -219,7 +219,13 @@ public class DeviceResource {
|
|||||||
return homeManager.findResource(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]);
|
return homeManager.findResource(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.DOMOTICZ_DEVICE[DeviceMapTypes.typeIndex]);
|
||||||
}, new JsonTransformer());
|
}, new JsonTransformer());
|
||||||
|
|
||||||
get (API_CONTEXT + "/map/types", "application/json", (request, response) -> {
|
get (API_CONTEXT + "/somfy/devices", "application/json", (request, response) -> {
|
||||||
|
log.debug("Get somfy devices");
|
||||||
|
response.status(HttpStatus.SC_OK);
|
||||||
|
return homeManager.findResource(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex]).getItems(DeviceMapTypes.SOMFY_DEVICE[DeviceMapTypes.typeIndex]);
|
||||||
|
}, new JsonTransformer());
|
||||||
|
|
||||||
|
get (API_CONTEXT + "/map/types", "application/json", (request, response) -> {
|
||||||
log.debug("Get map types");
|
log.debug("Get map types");
|
||||||
return new DeviceMapTypes().getDeviceMapTypes();
|
return new DeviceMapTypes().getDeviceMapTypes();
|
||||||
}, new JsonTransformer());
|
}, new JsonTransformer());
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ app.config (function ($locationProvider, $routeProvider) {
|
|||||||
controller: 'VeraController'
|
controller: 'VeraController'
|
||||||
}).when ('/verascenes', {
|
}).when ('/verascenes', {
|
||||||
templateUrl: 'views/verascene.html',
|
templateUrl: 'views/verascene.html',
|
||||||
controller: 'VeraController'
|
controller: 'VeraController'
|
||||||
}).when ('/harmonydevices', {
|
}).when ('/harmonydevices', {
|
||||||
templateUrl: 'views/harmonydevice.html',
|
templateUrl: 'views/harmonydevice.html',
|
||||||
controller: 'HarmonyController'
|
controller: 'HarmonyController'
|
||||||
@@ -41,11 +41,14 @@ app.config (function ($locationProvider, $routeProvider) {
|
|||||||
controller: 'MQTTController'
|
controller: 'MQTTController'
|
||||||
}).when ('/hassdevices', {
|
}).when ('/hassdevices', {
|
||||||
templateUrl: 'views/hassdevice.html',
|
templateUrl: 'views/hassdevice.html',
|
||||||
controller: 'HassController'
|
controller: 'HassController'
|
||||||
}).when ('/domoticzdevices', {
|
}).when ('/domoticzdevices', {
|
||||||
templateUrl: 'views/domoticzdevice.html',
|
templateUrl: 'views/domoticzdevice.html',
|
||||||
controller: 'DomoticzController'
|
controller: 'DomoticzController'
|
||||||
}).otherwise ({
|
}).when('/somfydevices', {
|
||||||
|
templateUrl: 'views/somfydevice.html',
|
||||||
|
controller: 'SomfyController'
|
||||||
|
}).otherwise ({
|
||||||
templateUrl: 'views/configuration.html',
|
templateUrl: 'views/configuration.html',
|
||||||
controller: 'ViewingController'
|
controller: 'ViewingController'
|
||||||
})
|
})
|
||||||
@@ -71,7 +74,7 @@ String.prototype.replaceAll = function (search, replace)
|
|||||||
|
|
||||||
app.service ('bridgeService', function ($http, $window, ngToast) {
|
app.service ('bridgeService', function ($http, $window, ngToast) {
|
||||||
var self = this;
|
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, showDomoticz: 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, showSomfy: false, habridgeversion: ""};
|
||||||
|
|
||||||
this.displayWarn = function(errorTitle, error) {
|
this.displayWarn = function(errorTitle, error) {
|
||||||
var toastContent = errorTitle;
|
var toastContent = errorTitle;
|
||||||
@@ -164,20 +167,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
this.deviceContainsType = function (device, aType) {
|
this.deviceContainsType = function (device, aType) {
|
||||||
if(device.mapType !== undefined && device.mapType !== null && device.mapType.indexOf(aType) >= 0)
|
if(device.mapType !== undefined && device.mapType !== null && device.mapType.indexOf(aType) >= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(device.deviceType !== undefined && device.deviceType !== null && device.deviceType.indexOf(aType) >= 0)
|
if(device.deviceType !== undefined && device.deviceType !== null && device.deviceType.indexOf(aType) >= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(device.onUrl !== undefined && device.onUrl !== null && device.onUrl.indexOf(aType) >= 0)
|
if(device.onUrl !== undefined && device.onUrl !== null && device.onUrl.indexOf(aType) >= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(device.dimUrl !== undefined && device.dimUrl !== null && device.dimUrl.indexOf(aType) >= 0)
|
if(device.dimUrl !== undefined && device.dimUrl !== null && device.dimUrl.indexOf(aType) >= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if(device.offUrl !== undefined && device.offUrl !== null && device.offUrl.indexOf(aType) >= 0)
|
if(device.offUrl !== undefined && device.offUrl !== null && device.offUrl.indexOf(aType) >= 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
this.compareHarmonyNumber = function(r1, r2) {
|
this.compareHarmonyNumber = function(r1, r2) {
|
||||||
@@ -257,6 +260,11 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.updateShowSomfy = function () {
|
||||||
|
this.state.showSomfy = self.state.settings.somfyconfigured;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.loadBridgeSettings = function () {
|
this.loadBridgeSettings = function () {
|
||||||
return $http.get(this.state.systemsbase + "/settings").then(
|
return $http.get(this.state.systemsbase + "/settings").then(
|
||||||
function (response) {
|
function (response) {
|
||||||
@@ -269,6 +277,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
self.updateShowMqtt();
|
self.updateShowMqtt();
|
||||||
self.updateShowHass();
|
self.updateShowHass();
|
||||||
self.updateShowDomoticz();
|
self.updateShowDomoticz();
|
||||||
|
self.updateShowSomfy();
|
||||||
},
|
},
|
||||||
function (error) {
|
function (error) {
|
||||||
self.displayWarn("Load Bridge Settings Error: ", error);
|
self.displayWarn("Load Bridge Settings Error: ", error);
|
||||||
@@ -450,6 +459,20 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.viewSomfyDevices = function () {
|
||||||
|
if(!this.state.showSomfy)
|
||||||
|
return;
|
||||||
|
return $http.get(this.state.base + "/somfy/devices").then(
|
||||||
|
function (response) {
|
||||||
|
self.state.somfydevices = response.data;
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
self.displayWarn("Get Somfy Devices Error: ", error);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.formatCallItem = function (currentItem) {
|
this.formatCallItem = function (currentItem) {
|
||||||
if(!currentItem.startsWith("{\"item") && !currentItem.startsWith("[{\"item")) {
|
if(!currentItem.startsWith("{\"item") && !currentItem.startsWith("[{\"item")) {
|
||||||
if (currentItem.startsWith("[") || currentItem.startsWith("{"))
|
if (currentItem.startsWith("[") || currentItem.startsWith("{"))
|
||||||
@@ -461,7 +484,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
|
|
||||||
return currentItem;
|
return currentItem;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getCallObjects = function (deviceString) {
|
this.getCallObjects = function (deviceString) {
|
||||||
if (deviceString === undefined || deviceString === "")
|
if (deviceString === undefined || deviceString === "")
|
||||||
return null;
|
return null;
|
||||||
@@ -481,7 +504,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
}
|
}
|
||||||
return newDevices
|
return newDevices
|
||||||
}
|
}
|
||||||
|
|
||||||
this.updateCallObjectsType = function (theDevices) {
|
this.updateCallObjectsType = function (theDevices) {
|
||||||
var i, s, type, len = theDevices.length
|
var i, s, type, len = theDevices.length
|
||||||
for (i=0; i<len; ++i) {
|
for (i=0; i<len; ++i) {
|
||||||
@@ -494,9 +517,9 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return theDevices
|
return theDevices
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.viewMapTypes = function () {
|
this.viewMapTypes = function () {
|
||||||
return $http.get(this.state.base + "/map/types").then(
|
return $http.get(this.state.base + "/map/types").then(
|
||||||
function (response) {
|
function (response) {
|
||||||
@@ -782,7 +805,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.formatUrlItem = function (currentItem) {
|
this.formatUrlItem = function (currentItem) {
|
||||||
var formattedItem = "";
|
var formattedItem = "";
|
||||||
if (currentItem !== "") {
|
if (currentItem !== "") {
|
||||||
@@ -809,7 +832,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
if (self.state.device !== undefined && self.state.device !== null && self.state.device.mapType !== undefined && self.state.device.mapType !== null && self.state.device.mapType !== "") {
|
if (self.state.device !== undefined && self.state.device !== null && self.state.device.mapType !== undefined && self.state.device.mapType !== null && self.state.device.mapType !== "") {
|
||||||
self.state.device.mapId = self.state.device.mapId + "-" + anId;
|
self.state.device.mapId = self.state.device.mapId + "-" + anId;
|
||||||
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "") {
|
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "") {
|
||||||
self.state.device.dimUrl = self.formatUrlItem(currentDim);
|
self.state.device.dimUrl = self.formatUrlItem(currentDim);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (onpayload !== undefined && onpayload !== null && onpayload !== "") {
|
if (onpayload !== undefined && onpayload !== null && onpayload !== "") {
|
||||||
@@ -833,7 +856,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
if (offpayload !== undefined && offpayload !== null && offpayload !== "")
|
if (offpayload !== undefined && offpayload !== null && offpayload !== "")
|
||||||
self.state.device.offUrl = "[{\"item\":";
|
self.state.device.offUrl = "[{\"item\":";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isObject) {
|
if (isObject) {
|
||||||
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "")
|
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "")
|
||||||
self.state.device.dimUrl = self.state.device.dimUrl + dimpayload;
|
self.state.device.dimUrl = self.state.device.dimUrl + dimpayload;
|
||||||
@@ -841,7 +864,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
self.state.device.onUrl = self.state.device.onUrl + onpayload;
|
self.state.device.onUrl = self.state.device.onUrl + onpayload;
|
||||||
if (offpayload !== undefined && offpayload !== null && offpayload !== "")
|
if (offpayload !== undefined && offpayload !== null && offpayload !== "")
|
||||||
self.state.device.offUrl = self.state.device.offUrl + offpayload;
|
self.state.device.offUrl = self.state.device.offUrl + offpayload;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "")
|
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "")
|
||||||
self.state.device.dimUrl = self.state.device.dimUrl + "\"" + dimpayload + "\"";
|
self.state.device.dimUrl = self.state.device.dimUrl + "\"" + dimpayload + "\"";
|
||||||
@@ -850,7 +873,7 @@ app.service ('bridgeService', function ($http, $window, ngToast) {
|
|||||||
if (offpayload !== undefined && offpayload !== null && offpayload !== "")
|
if (offpayload !== undefined && offpayload !== null && offpayload !== "")
|
||||||
self.state.device.offUrl = self.state.device.offUrl + "\"" + offpayload + "\"";
|
self.state.device.offUrl = self.state.device.offUrl + "\"" + offpayload + "\"";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count !== undefined && count !== null && count !== "") {
|
if (count !== undefined && count !== null && count !== "") {
|
||||||
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "")
|
if (dimpayload !== undefined && dimpayload !== null && dimpayload !== "")
|
||||||
self.state.device.dimUrl = self.state.device.dimUrl + ",\"count\":\"" + count;
|
self.state.device.dimUrl = self.state.device.dimUrl + ",\"count\":\"" + count;
|
||||||
@@ -982,7 +1005,7 @@ app.controller ('SystemController', function ($scope, $location, $http, $window,
|
|||||||
if($scope.bridge.settings.hassaddress.devices[i].name === hassname && $scope.bridge.settings.hassaddress.devices[i].ip === hassip) {
|
if($scope.bridge.settings.hassaddress.devices[i].name === hassname && $scope.bridge.settings.hassaddress.devices[i].ip === hassip) {
|
||||||
$scope.bridge.settings.hassaddress.devices.splice(i, 1);
|
$scope.bridge.settings.hassaddress.devices.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.addDomoticztoSettings = function (newdomoticzname, newdomoticzip, newdomoticzport, newdomoticzusername, newdomoticzpassword) {
|
$scope.addDomoticztoSettings = function (newdomoticzname, newdomoticzip, newdomoticzport, newdomoticzusername, newdomoticzpassword) {
|
||||||
if($scope.bridge.settings.domoticzaddress === undefined || $scope.bridge.settings.domoticzaddress === null) {
|
if($scope.bridge.settings.domoticzaddress === undefined || $scope.bridge.settings.domoticzaddress === null) {
|
||||||
@@ -1000,8 +1023,27 @@ app.controller ('SystemController', function ($scope, $location, $http, $window,
|
|||||||
if($scope.bridge.settings.domoticzaddress.devices[i].name === domoticzname && $scope.bridge.settings.domoticzaddress.devices[i].ip === domoticzip) {
|
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.bridge.settings.domoticzaddress.devices.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
$scope.addSomfytoSettings = function (newsomfyname, newsomfyip, newsomfyusername, newsomfypassword) {
|
||||||
|
if($scope.bridge.settings.somfyaddress == null) {
|
||||||
|
$scope.bridge.settings.somfyaddress = { devices: [] };
|
||||||
|
}
|
||||||
|
var newSomfy = {name: newsomfyname, ip: newsomfyip, username: newsomfyusername, password: newsomfypassword }
|
||||||
|
$scope.bridge.settings.somfyaddress.devices.push(newSomfy);
|
||||||
|
$scope.newsomfyname = null;
|
||||||
|
$scope.newsomfyip = null;
|
||||||
|
$scope.newsomfyusername = null;
|
||||||
|
$scope.newsomfypassword = null;
|
||||||
|
};
|
||||||
|
$scope.removeSomfytoSettings = function (somfyname, somfyip) {
|
||||||
|
for(var i = $scope.bridge.settings.somfyaddress.devices.length - 1; i >= 0; i--) {
|
||||||
|
if($scope.bridge.settings.somfyaddress.devices[i].name === somfyname && $scope.bridge.settings.somfyaddress.devices[i].ip === somfyip) {
|
||||||
|
$scope.bridge.settings.somfyaddress.devices.splice(i, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$scope.bridgeReinit = function () {
|
$scope.bridgeReinit = function () {
|
||||||
bridgeService.reinit();
|
bridgeService.reinit();
|
||||||
};
|
};
|
||||||
@@ -1331,7 +1373,7 @@ app.controller('VeraController', function ($scope, $location, $http, bridgeServi
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -1356,7 +1398,7 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe
|
|||||||
|
|
||||||
$scope.buildActivityUrls = function (harmonyactivity) {
|
$scope.buildActivityUrls = function (harmonyactivity) {
|
||||||
onpayload = "{\"name\":\"" + harmonyactivity.activity.id + "\",\"hub\":\"" + harmonyactivity.hub + "\"}";
|
onpayload = "{\"name\":\"" + harmonyactivity.activity.id + "\",\"hub\":\"" + harmonyactivity.hub + "\"}";
|
||||||
offpayload = "{\"name\":\"-1\",\"hub\":\"" + harmonyactivity.hub + "\"}";
|
offpayload = "{\"name\":\"-1\",\"hub\":\"" + harmonyactivity.hub + "\"}";
|
||||||
|
|
||||||
bridgeService.buildUrls(onpayload, null, offpayload, true, harmonyactivity.activity.id, harmonyactivity.activity.label, harmonyactivity.hub, "activity", "harmonyActivity", null, null);
|
bridgeService.buildUrls(onpayload, null, offpayload, true, harmonyactivity.activity.id, harmonyactivity.activity.label, harmonyactivity.hub, "activity", "harmonyActivity", null, null);
|
||||||
$scope.device = bridgeService.state.device;
|
$scope.device = bridgeService.state.device;
|
||||||
@@ -1392,7 +1434,7 @@ app.controller('HarmonyController', function ($scope, $location, $http, bridgeSe
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -1493,7 +1535,7 @@ app.controller('NestController', function ($scope, $location, $http, bridgeServi
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -1610,7 +1652,7 @@ app.controller('HueController', function ($scope, $location, $http, bridgeServic
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -1680,7 +1722,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
+ nameCmd
|
+ nameCmd
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ postCmd;
|
+ postCmd;
|
||||||
offpayload = "http://" + haldevice.haladdress
|
offpayload = "http://" + haldevice.haladdress
|
||||||
+ preOffCmd
|
+ preOffCmd
|
||||||
+ nameCmd
|
+ nameCmd
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
@@ -1713,17 +1755,17 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALHeatUrls = function (haldevice) {
|
$scope.buildHALHeatUrls = function (haldevice) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Heat?Token="
|
+ "!HVACMode=Heat?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
dimpayload = "http://" + haldevice.haladdress
|
dimpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}?Token="
|
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
offpayload = "http://" + haldevice.haladdress
|
offpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Off?Token="
|
+ "!HVACMode=Off?Token="
|
||||||
@@ -1735,17 +1777,17 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALCoolUrls = function (haldevice) {
|
$scope.buildHALCoolUrls = function (haldevice) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Cool?Token="
|
+ "!HVACMode=Cool?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
dimpayload = "http://" + haldevice.haladdress
|
dimpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}?Token="
|
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
offpayload = "http://" + haldevice.haladdress
|
offpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Off?Token="
|
+ "!HVACMode=Off?Token="
|
||||||
@@ -1757,12 +1799,12 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALAutoUrls = function (haldevice) {
|
$scope.buildHALAutoUrls = function (haldevice) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Auto?Token="
|
+ "!HVACMode=Auto?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
offpayload = "http://" + haldevice.haladdress
|
offpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Off?Token="
|
+ "!HVACMode=Off?Token="
|
||||||
@@ -1773,16 +1815,16 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALOffUrls = function (haldevice) {
|
$scope.buildHALOffUrls = function (haldevice) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Auto?Token="
|
+ "!HVACMode=Auto?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
offpayload = "http://" + haldevice.haladdress
|
offpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!HVACMode=Off?Token="
|
+ "!HVACMode=Off?Token="
|
||||||
$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);
|
bridgeService.editNewDevice($scope.device);
|
||||||
@@ -1790,12 +1832,12 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
};
|
};
|
||||||
|
|
||||||
$scope.buildHALFanUrls = function (haldevice) {
|
$scope.buildHALFanUrls = function (haldevice) {
|
||||||
onpayload = "http://" + haldevice.haladdress
|
onpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!FanMode=On?Token="
|
+ "!FanMode=On?Token="
|
||||||
+ $scope.bridge.settings.haltoken;
|
+ $scope.bridge.settings.haltoken;
|
||||||
offpayload = "http://" + haldevice.haladdress
|
offpayload = "http://" + haldevice.haladdress
|
||||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||||
+ "!FanMode=Auto?Token="
|
+ "!FanMode=Auto?Token="
|
||||||
@@ -1897,7 +1939,7 @@ app.controller('HalController', function ($scope, $location, $http, bridgeServic
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -1942,7 +1984,7 @@ app.controller('MQTTController', function ($scope, $location, $http, bridgeServi
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -2137,7 +2179,7 @@ app.controller('HassController', function ($scope, $location, $http, bridgeServi
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.editDevice = function (device) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -2192,7 +2234,7 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS
|
|||||||
+ preCmd
|
+ preCmd
|
||||||
+ domoticzdevice.idx
|
+ domoticzdevice.idx
|
||||||
+ postOnCmd;
|
+ postOnCmd;
|
||||||
offpayload = "http://" + domoticzdevice.domoticzaddress
|
offpayload = "http://" + domoticzdevice.domoticzaddress
|
||||||
+ preCmd
|
+ preCmd
|
||||||
+ domoticzdevice.idx
|
+ domoticzdevice.idx
|
||||||
+ postOffCmd;
|
+ postOffCmd;
|
||||||
@@ -2288,7 +2330,131 @@ app.controller('DomoticzController', function ($scope, $location, $http, bridgeS
|
|||||||
className: 'ngdialog-theme-default'
|
className: 'ngdialog-theme-default'
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
$scope.editDevice = function (device) {
|
||||||
|
bridgeService.editDevice(device);
|
||||||
|
$location.path('/editdevice');
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
app.controller('SomfyController', 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;
|
||||||
|
$scope.somfy = {base: "http://", port: "3480", id: ""};
|
||||||
|
bridgeService.viewSomfyDevices();
|
||||||
|
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
|
||||||
|
$scope.buttonsVisible = false;
|
||||||
|
$scope.comparatorUniqueId = bridgeService.compareUniqueId;
|
||||||
|
|
||||||
|
$scope.clearDevice = function () {
|
||||||
|
bridgeService.clearDevice();
|
||||||
|
$scope.device = bridgeService.state.device;
|
||||||
|
};
|
||||||
|
|
||||||
|
$scope.buildDeviceUrls = function (somfydevice, dim_control) {
|
||||||
|
//TODO - support partial window opening
|
||||||
|
dimpayload = "";
|
||||||
|
onpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"open\",\"parameters\":[]}]}]}";
|
||||||
|
offpayload = "{\"label\":\"Label that is ignored probably\",\"actions\":[{\"deviceURL\":\""+ somfydevice.deviceUrl+"\",\"commands\":[{\"name\":\"close\",\"parameters\":[]}]}]}";
|
||||||
|
|
||||||
|
bridgeService.buildUrls(onpayload, dimpayload, offpayload, true, somfydevice.id, somfydevice.name, somfydevice.somfyname, "switch", "somfyDevice", 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.somfydevices.length; x++) {
|
||||||
|
if(bridgeService.state.somfydevices[x].id === $scope.bulk.devices[i]) {
|
||||||
|
$scope.buildDeviceUrls(bridgeService.state.somfydevices[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.viewSomfyDevices();
|
||||||
|
},
|
||||||
|
function (error) {
|
||||||
|
bridgeService.displayWarn("Error adding Somfy 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.somfydevices.length; x++) {
|
||||||
|
if($scope.bulk.devices.indexOf(bridgeService.state.somfydevices[x]) < 0 && !bridgeService.findDeviceByMapId(bridgeService.state.somfydevices[x].id, bridgeService.state.somfydevices[x].somfyname, "somfyDevice"))
|
||||||
|
$scope.bulk.devices.push(bridgeService.state.somfydevices[x].id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
$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) {
|
$scope.editDevice = function (device) {
|
||||||
bridgeService.editDevice(device);
|
bridgeService.editDevice(device);
|
||||||
$location.path('/editdevice');
|
$location.path('/editdevice');
|
||||||
@@ -2310,11 +2476,11 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
|
|||||||
if($scope.bridge.device.offUrl !== undefined)
|
if($scope.bridge.device.offUrl !== undefined)
|
||||||
$scope.offDevices = bridgeService.getCallObjects($scope.bridge.device.offUrl);
|
$scope.offDevices = bridgeService.getCallObjects($scope.bridge.device.offUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
$scope.newOnItem = {};
|
$scope.newOnItem = {};
|
||||||
$scope.newDimItem = {};
|
$scope.newDimItem = {};
|
||||||
$scope.newOffItem = {};
|
$scope.newOffItem = {};
|
||||||
$scope.mapTypeSelected = bridgeService.getMapType($scope.device.mapType);
|
$scope.mapTypeSelected = bridgeService.getMapType($scope.device.mapType);
|
||||||
$scope.device_dim_control = "";
|
$scope.device_dim_control = "";
|
||||||
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
|
$scope.imgButtonsUrl = "glyphicon glyphicon-plus";
|
||||||
$scope.buttonsVisible = false;
|
$scope.buttonsVisible = false;
|
||||||
@@ -2380,7 +2546,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
|
|||||||
if($scope.onDevices[i].item === anItem.item && $scope.onDevices[i].type === anItem.type) {
|
if($scope.onDevices[i].item === anItem.item && $scope.onDevices[i].type === anItem.type) {
|
||||||
$scope.onDevices.splice(i, 1);
|
$scope.onDevices.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.addItemDim = function (anItem) {
|
$scope.addItemDim = function (anItem) {
|
||||||
@@ -2397,7 +2563,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
|
|||||||
if($scope.dimDevices[i].item === anItem.item && $scope.dimDevices[i].type === anItem.type) {
|
if($scope.dimDevices[i].item === anItem.item && $scope.dimDevices[i].type === anItem.type) {
|
||||||
$scope.dimDevices.splice(i, 1);
|
$scope.dimDevices.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.addItemOff = function (anItem) {
|
$scope.addItemOff = function (anItem) {
|
||||||
@@ -2414,7 +2580,7 @@ app.controller('EditController', function ($scope, $location, $http, bridgeServi
|
|||||||
if($scope.offDevices[i].item === anItem.item && $scope.offDevices[i].type === anItem.type) {
|
if($scope.offDevices[i].item === anItem.item && $scope.offDevices[i].type === anItem.type) {
|
||||||
$scope.offDevices.splice(i, 1);
|
$scope.offDevices.splice(i, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
$scope.toggleButtons = function () {
|
$scope.toggleButtons = function () {
|
||||||
$scope.buttonsVisible = !$scope.buttonsVisible;
|
$scope.buttonsVisible = !$scope.buttonsVisible;
|
||||||
@@ -2566,6 +2732,36 @@ app.filter('configuredDomoticzItems', function (bridgeService) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
app.filter('availableSomfyDeviceId', function(bridgeService) {
|
||||||
|
return function(input) {
|
||||||
|
var out = [];
|
||||||
|
if(input == null)
|
||||||
|
return out;
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
if(!bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){
|
||||||
|
out.push(input[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.filter('unavailableSomfyDeviceId', function(bridgeService) {
|
||||||
|
return function(input) {
|
||||||
|
var out = [];
|
||||||
|
if(input == null)
|
||||||
|
return out;
|
||||||
|
for (var i = 0; i < input.length; i++) {
|
||||||
|
if(bridgeService.findDeviceByMapId(input[i].id, input[i].somfyname, "somfyDevice")){
|
||||||
|
out.push(input[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
app.controller('VersionController', function ($scope, bridgeService) {
|
app.controller('VersionController', function ($scope, bridgeService) {
|
||||||
$scope.bridge = bridgeService.state;
|
$scope.bridge = bridgeService.state;
|
||||||
});
|
});
|
||||||
Reference in New Issue
Block a user