ecobee: cleanup request json

This commit is contained in:
Billy Zoellers
2021-11-14 16:26:06 -05:00
parent e3622dde5f
commit 6e2cd10619

View File

@@ -116,9 +116,16 @@ class EcobeeThermostat extends ScryptedDeviceBase implements HumiditySensor, The
*
*/
async _refresh(): Promise<void> {
const data = await this.provider.req('get', 'thermostatSummary', null, {
json: `\{"selection":\{"selectionType":"registered","selectionMatch":"${this.nativeId}","includeSettings": "true", "includeRuntime": "true", "includeEquipmentStatus": "true"\}\}`
});
const json = {
selection: {
selectionType: "registered",
selectionMatch: this.nativeId,
includeSettings: "true",
includeRuntime: "true",
includeEquipmentStatus: "true",
}
}
const data = await this.provider.req('get', 'thermostatSummary', null, { json });
// Update equipmentStatus, trigger reload if changes detected
this._updateEquipmentStatus(data.statusList[0].split(":")[1]);
@@ -188,9 +195,16 @@ class EcobeeThermostat extends ScryptedDeviceBase implements HumiditySensor, The
*
*/
async reload(): Promise<void> {
var data = (await this.provider.req('get', 'thermostat', {}, {
json: `\{"selection":\{"selectionType":"registered","selectionMatch":"${this.nativeId}","includeSettings": "true", "includeRuntime": "true", "includeEquipmentStatus": "true"\}\}`
})).thermostatList[0];
const json = {
selection: {
selectionType: "registered",
selectionMatch: this.nativeId,
includeSettings: "true",
includeRuntime: "true",
includeEquipmentStatus: "true"
}
}
var data = (await this.provider.req('get', 'thermostat', {}, { json })).thermostatList[0];
// Set runtime values
this.temperature = convertFtoC(Number(data.runtime.actualTemperature)/10)
@@ -509,10 +523,15 @@ class EcobeeController extends ScryptedDeviceBase implements DeviceProvider, Set
}
// Get a list of all accessible devices
const apiDevices = (await this.req('get', 'thermostat', null, {
json: `\{"selection":\{"selectionType":"registered","selectionMatch":"","includeSettings": "true"\}\}`
})).thermostatList
this.console.log(`Discovered ${apiDevices.length} devices.`)
const json = {
selection: {
selectionType: "registered",
selectionMatch: "",
includeSettings: "true",
}
}
const apiDevices = (await this.req('get', 'thermostat', null, { json })).thermostatList
this.console.log(`Discovered ${apiDevices.length} devices.`);
// Create a list of devices found from the API
const devices: Device[] = [];
@@ -562,4 +581,4 @@ class EcobeeController extends ScryptedDeviceBase implements DeviceProvider, Set
}
export default new EcobeeController();
export default new EcobeeController();