Skip to content

Commit

Permalink
google-device-access: use new state api
Browse files Browse the repository at this point in the history
  • Loading branch information
koush committed Feb 24, 2023
1 parent 9592b60 commit a9ab2d0
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion plugins/google-device-access/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,10 @@ class NestThermostat extends ScryptedDeviceBase implements HumiditySensor, Therm
this.console.log('executeCommandSetCelsius', command);
return this.provider.authPost(`/devices/${this.nativeId}:executeCommand`, command);
}
}, 12000)
}, 12000, {
leading: false,
trailing: true,
})

constructor(provider: GoogleSmartDeviceAccess, device: any) {
super(device.name.split('/').pop());
Expand All @@ -375,6 +378,7 @@ class NestThermostat extends ScryptedDeviceBase implements HumiditySensor, Therm

this.reload();
}

setTemperature(command: TemperatureCommand): Promise<void> {
throw new Error('Method not implemented.');
}
Expand Down Expand Up @@ -405,26 +409,37 @@ class NestThermostat extends ScryptedDeviceBase implements HumiditySensor, Therm
const heat = device.traits?.['sdm.devices.traits.ThermostatTemperatureSetpoint']?.heatCelsius;
const cool = device.traits?.['sdm.devices.traits.ThermostatTemperatureSetpoint']?.coolCelsius;

let setpoint: number|[number,number];
if (this.thermostatMode === ThermostatMode.Heat) {
this.thermostatSetpoint = heat;
this.thermostatSetpointHigh = undefined;
this.thermostatSetpointLow = undefined;
setpoint = heat;
}
else if (this.thermostatMode === ThermostatMode.Cool) {
this.thermostatSetpoint = cool;
this.thermostatSetpointHigh = undefined;
this.thermostatSetpointLow = undefined;
setpoint = cool;
}
else if (this.thermostatMode === ThermostatMode.HeatCool) {
this.thermostatSetpoint = undefined;
this.thermostatSetpointHigh = heat;
this.thermostatSetpointLow = cool;
setpoint = [cool, heat];
}
else {
this.thermostatSetpoint = undefined;
this.thermostatSetpointHigh = undefined;
this.thermostatSetpointLow = undefined;
}

this.temperatureSetting = {
activeMode: this.thermostatActiveMode,
mode: this.thermostatMode,
setpoint,
availableModes: modes,
}
}

async refresh(refreshInterface: string, userInitiated: boolean): Promise<void> {
Expand Down

0 comments on commit a9ab2d0

Please sign in to comment.