homebridge-tcc
Advanced tools
Comparing version 0.2.25 to 0.2.26
@@ -58,3 +58,3 @@ const soapRequest = require('easy-soap-request'); | ||
} | ||
var current = await this._GetLocationListData(); | ||
var current = await this._GetLocationListData(true); | ||
if (this.thermostats.LocationInfo && current.LocationInfo) { | ||
@@ -82,5 +82,5 @@ debug("pollThermostat - delta", JSON.stringify(tccMessage.diff(this.thermostats, current), null, 2)); | ||
debug("TCC - Login Succeeded"); | ||
this.thermostats = await this._GetLocationListData(); | ||
this.thermostats = await this._GetLocationListData(true); | ||
} | ||
var CommTaskID = await this._UpdateThermostat(desiredState); | ||
var CommTaskID = await this._UpdateThermostat(desiredState, true); | ||
await this._GetCommTaskState(CommTaskID); | ||
@@ -99,3 +99,3 @@ var thermostat = await this._GetThermostat(desiredState.ThermostatID); | ||
tcc.prototype._UpdateThermostat = function(desiredState) { | ||
tcc.prototype._UpdateThermostat = function(desiredState, withRetry) { | ||
debug("_UpdateThermostat()", desiredState); | ||
@@ -137,7 +137,17 @@ return new Promise((resolve, reject) => { | ||
debug("ERROR: _UpdateThermostat %s", ChangeThermostat.Result, message); | ||
reject(new Error("ERROR: _UpdateThermostat %s", ChangeThermostat.Result)); | ||
if (withRetry) { | ||
try { | ||
const CommTaskID = await this._UpdateThermostat(desiredState, false); | ||
resolve(CommTaskID); | ||
} catch (err) { | ||
debug("ERROR: _UpdateThermostat retry"); | ||
reject(err); | ||
} | ||
} else { | ||
reject(new Error("ERROR: _UpdateThermostat (200)", ChangeThermostat.Result)); | ||
} | ||
} | ||
} else { | ||
debug("ERROR: _UpdateThermostat %s", response, message); | ||
reject(new Error("ERROR: _UpdateThermostat %s", ChangeThermostat.Result)); | ||
reject(new Error("ERROR: _UpdateThermostat (!200)", ChangeThermostat.Result)); | ||
} | ||
@@ -161,3 +171,5 @@ } catch (err) { | ||
HEADER.soapAction = 'http://services.alarmnet.com/Services/MobileV2/AuthenticateUserLogin'; | ||
var message = '<?xml version="1.0" encoding="utf-8"?>' + parser.toXml(tccMessage.soapMessage(tccMessage.AuthenticateUserLoginMessage(this._username, this._password)), { sanitize: true }); | ||
var message = '<?xml version="1.0" encoding="utf-8"?>' + parser.toXml(tccMessage.soapMessage(tccMessage.AuthenticateUserLoginMessage(this._username, this._password)), { | ||
sanitize: true | ||
}); | ||
var { | ||
@@ -303,6 +315,9 @@ response | ||
tcc.prototype._GetLocationListData = function() { | ||
tcc.prototype._GetLocationListData = function(withRetry) { | ||
return new Promise((resolve, reject) => { | ||
(async () => { | ||
try { | ||
if (!this.sessionID) { | ||
this.sessionID = await this._login(); | ||
} | ||
HEADER.soapAction = 'http://services.alarmnet.com/Services/MobileV2/GetLocations'; | ||
@@ -338,10 +353,21 @@ var message = '<?xml version="1.0" encoding="utf-8"?>' + parser.toXml(tccMessage.soapMessage(tccMessage.GetLocationsMessage(this.sessionID))); | ||
this.sessionID = null; | ||
// debug("Info: %s", GetLocationsResult.Result, message); | ||
reject(new Error("GetLocations " + GetLocationsResult.Result)); | ||
if (withRetry) { | ||
try { | ||
const locListData = await this._GetLocationListData(false); | ||
resolve(locListData); | ||
} catch (err) { | ||
debug("error get locations retry", err); | ||
reject(err); | ||
} | ||
} else { | ||
debug("GetLocations error, Info: %s", GetLocationsResult.Result); | ||
reject(new Error("GetLocations " + GetLocationsResult.Result)); | ||
} | ||
} | ||
} else { | ||
debug("GetLocations error, statusCode: %s", response.statusCode); | ||
reject(new Error("ERROR: GetLocations Response Status Code", response.statusCode)); | ||
} | ||
} catch (err) { | ||
// console.error("GetLocations Error:", err.message); | ||
console.error("GetLocations Error:", err); | ||
this.sessionID = null; | ||
@@ -348,0 +374,0 @@ reject(err); |
{ | ||
"name": "homebridge-tcc", | ||
"version": "0.2.25", | ||
"version": "0.2.26", | ||
"description": "Honeywell Total Connect Comfort support for Homebridge: https://github.com/nfarina/homebridge", | ||
@@ -5,0 +5,0 @@ "license": "ISC", |
59151
1407