UNPKG

homebridge-tessie

Version:

Connect Homebridge to your Tessie account.

27 lines 1.26 kB
import { debounce } from "../utils/debounce.js"; import { BaseService } from "./base.js"; export class ChargeCurrentService extends BaseService { min = 2; max = 16; constructor(parent) { super(parent, parent.platform.Service.Lightbulb, "Charge Current", "charge_current"); const on = this.service .getCharacteristic(this.parent.platform.Characteristic.On); const level = this.service .getCharacteristic(this.parent.platform.Characteristic.Brightness) .onSet(debounce((value) => this.setLevel(value, level), 3000)); this.parent.emitter.on("vehicle_data", (data) => { on.updateValue(true); this.max = data.charge_state.charge_current_request_max; level.updateValue(data.charge_state.charge_current_request); }); } async setLevel(value, characteristic) { value = Math.max(this.min, Math.min(this.max, value)); await this.parent.wakeUpAndWait() .then(() => this.parent.vehicle.set_charging_amps(value)) .then(() => characteristic.updateValue(value)) .catch((e) => this.log.error(`${this.name} vehicle set_charging_amps failed: ${e}`)); } } //# sourceMappingURL=chargecurrent.js.map