diff --git a/src/vehicle-services/sentry.ts b/src/vehicle-services/sentry.ts index dc98175..94d140c 100644 --- a/src/vehicle-services/sentry.ts +++ b/src/vehicle-services/sentry.ts @@ -3,18 +3,25 @@ import { BaseService } from "./base.js"; export class SentryService extends BaseService { constructor(parent: VehicleAccessory) { - super(parent, parent.platform.Service.Switch, "Sentry", "sentry"); + super(parent, parent.platform.Service.SecuritySystem, "Sentry", "sentry"); - const on = this.service - .getCharacteristic(this.parent.platform.Characteristic.On) + const current = this.service + .getCharacteristic(this.parent.platform.Characteristic.SecuritySystemCurrentState); + + const target = this.service + .getCharacteristic(this.parent.platform.Characteristic.SecuritySystemTargetState) .onSet(async (value) => { + value = value === 3 ? 3 : 0; + target.updateValue(value); await this.parent.wakeUpAndWait() - .then(() => this.vehicle.set_sentry_mode(value as boolean)) - .then(() => on.updateValue(value)); + .then(() => this.vehicle.set_sentry_mode(value !== 3)) + .then(() => current.updateValue(value)); }); this.parent.emitter.on("vehicle_data", (data) => { - on.updateValue(data.vehicle_state.sentry_mode); + const value = data.vehicle_state.sentry_mode ? 0 : 3; + current.updateValue(value); + target.updateValue(value); }); } }