mirror of
https://github.com/bwssytems/ha-bridge.git
synced 2025-12-18 16:17:30 +00:00
Updateing HAL handling
This commit is contained in:
@@ -1317,11 +1317,11 @@ app.controller ('SystemController', function ($scope, $location, bridgeService,
|
||||
}
|
||||
}
|
||||
};
|
||||
$scope.addHaltoSettings = function (newhalname, newhalip) {
|
||||
$scope.addHaltoSettings = function (newhalname, newhalip, newhalsecure, newhaltoken) {
|
||||
if($scope.bridge.settings.haladdress === undefined || $scope.bridge.settings.haladdress === null) {
|
||||
$scope.bridge.settings.haladdress = { devices: [] };
|
||||
}
|
||||
var newhal = {name: newhalname, ip: newhalip }
|
||||
var newhal = {name: newhalname, ip: newhalip, secure: newhalsecure, password: newhaltoken }
|
||||
$scope.bridge.settings.haladdress.devices.push(newhal);
|
||||
$scope.newhalname = null;
|
||||
$scope.newhalip = null;
|
||||
@@ -2202,7 +2202,11 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
var preOffCmd = "";
|
||||
var nameCmd = "";
|
||||
var aDeviceType;
|
||||
var postCmd = "?Token=" + $scope.bridge.settings.haltoken;
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
if(haldevice.haldevicetype === "Group") {
|
||||
aDeviceType = "group";
|
||||
preOnCmd = "/GroupService!GroupCmd=On";
|
||||
@@ -2227,29 +2231,29 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
nameCmd = "!DeviceName=";
|
||||
}
|
||||
if((dim_control.indexOf("byte") >= 0 || dim_control.indexOf("percent") >= 0 || dim_control.indexOf("math") >= 0) && aDeviceType === "switch")
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preDimCmd
|
||||
+ dim_control
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
else
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOnCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ preOffCmd
|
||||
+ nameCmd
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ postCmd;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname, haldevice.haldevicename, haldevice.halname, aDeviceType, "halDevice", null, null);
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name, haldevice.haldevicename, haldevice.haladdress.name, aDeviceType, "halDevice", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2260,10 +2264,15 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
$scope.buildButtonUrls = function (haldevice, onbutton, offbutton, buildonly) {
|
||||
var actionOn = angular.fromJson(onbutton);
|
||||
var actionOff = angular.fromJson(offbutton);
|
||||
onpayload = "http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20") + "?Token=" + $scope.bridge.settings.haltoken;
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOn.DeviceName.replaceAll(" ", "%20") + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip + "/IrService!IrCmd=Set!IrDevice=" + haldevice.haldevicename.replaceAll(" ", "%20") + "!IrButton=" + actionOff.DeviceName.replaceAll(" ", "%20") + postCmd;
|
||||
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.halname, "button", "halButton", null, null);
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-" + actionOn.DeviceName, haldevice.haldevicename, haldevice.haladdress.name, "button", "halButton", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2272,9 +2281,14 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALHomeUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Home?Token=" + $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress + "/ModeService!ModeCmd=Set!ModeName=Away?Token=" + $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-HomeAway", haldevice.haldevicename, haldevice.halname, "home", "halHome", null, null);
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip + "/ModeService!ModeCmd=Set!ModeName=Home" + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip + "/ModeService!ModeCmd=Set!ModeName=Away" + postCmd;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-HomeAway", haldevice.haldevicename, haldevice.haladdress.name, "home", "halHome", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2283,22 +2297,24 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALHeatUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Heat?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Heat" + postCmd;
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Heat!HeatSpValue=${intensity.percent}" + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off" + postCmd;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetHeat", haldevice.haldevicename + " Heat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2307,22 +2323,24 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALCoolUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Cool?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
dimpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Cool" + postCmd;
|
||||
dimpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Cool!CoolSpValue=${intensity.percent}" + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetCool", haldevice.haldevicename + " Cool", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off" + postCmd;
|
||||
bridgeService.buildUrls(onpayload, dimpayload, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetCool", haldevice.haldevicename + " Cool", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2331,16 +2349,20 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALAutoUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Auto?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Auto" + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!HVACMode=Off" + postCmd;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetAuto", haldevice.haldevicename + " Auto", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2349,17 +2371,20 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALOffUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Auto?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!HVACMode=Auto" + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!HVACMode=Off?Token="
|
||||
$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);
|
||||
+ "!HVACMode=Off" + postCmd;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-TurnOff", haldevice.haldevicename + " Thermostat", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
@@ -2368,17 +2393,20 @@ app.controller('HalController', function ($scope, $location, bridgeService, ngDi
|
||||
};
|
||||
|
||||
$scope.buildHALFanUrls = function (haldevice, buildonly) {
|
||||
onpayload = "http://" + haldevice.haladdress
|
||||
var postCmd = "?Token=";
|
||||
if(haldevice.haladdress.password === undefined || haldevice.haladdress.password === null || haldevice.haladdress.password.lenght === 0)
|
||||
postCmd = postCmd + $scope.bridge.settings.haltoken;
|
||||
else
|
||||
postCmd = postCmd + haldevice.haladdress.password;
|
||||
onpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!FanMode=On?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
offpayload = "http://" + haldevice.haladdress
|
||||
+ "!FanMode=On" + postCmd;
|
||||
offpayload = "http://" + haldevice.haladdress.ip
|
||||
+ "/HVACService!HVACCmd=Set!HVACName="
|
||||
+ haldevice.haldevicename.replaceAll(" ", "%20")
|
||||
+ "!FanMode=Auto?Token="
|
||||
+ $scope.bridge.settings.haltoken;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.halname + "-SetFan", haldevice.haldevicename + " Fan", haldevice.halname, "thermo", "halThermoSet", null, null);
|
||||
+ "!FanMode=Auto" + postCmd;
|
||||
bridgeService.buildUrls(onpayload, null, offpayload, false, haldevice.haldevicename + "-" + haldevice.haladdress.name + "-SetFan", haldevice.haldevicename + " Fan", haldevice.haladdress.name, "thermo", "halThermoSet", null, null);
|
||||
$scope.device = bridgeService.state.device;
|
||||
if (!buildonly) {
|
||||
bridgeService.editNewDevice($scope.device);
|
||||
|
||||
Reference in New Issue
Block a user