UNPKG

homebridge-tessie

Version:

Connect Homebridge to your Tessie account.

37 lines 1.7 kB
//https://developers.homebridge.io/#/service/Door import { BaseService } from "./base.js"; export class DoorService extends BaseService { trunk; key; open = false; constructor(parent, trunk) { super(parent, parent.platform.Service.Door, trunk === "front" ? "Frunk" : "Trunk", trunk); this.trunk = trunk; this.key = this.trunk === "front" ? "ft" : "rt"; const currentPosition = this.service .getCharacteristic(this.parent.platform.Characteristic.CurrentPosition); /*const positionState = this.service .getCharacteristic(this.parent.platform.Characteristic.PositionState) .onGet(() => this.getChargingState());*/ const targetPosition = this.service .getCharacteristic(this.parent.platform.Characteristic.TargetPosition) .onSet(async (value) => { targetPosition.updateValue(value); value = value; if ((!this.open && value > 50) || (this.open && value < 50 && this.trunk === "rear")) { await this.parent.wakeUpAndWait() .then(() => this.parent.vehicle.actuate_truck(this.trunk)) .then(() => currentPosition.updateValue(value)) .catch((e) => this.log.error(`${this.name} vehicle actuate_truck failed: ${e}`)); } }); this.parent.emitter.on("vehicle_data", (data) => { this.open = data.vehicle_state[this.key] === 1; const position = this.open ? 100 : 0; currentPosition.updateValue(position); targetPosition.updateValue(position); }); } } //# sourceMappingURL=door.js.map