homebridge-hatch-baby-rest
Version:
Homebridge plugin for Hatch Rest/Restore WiFi sound machines
25 lines (24 loc) • 1.1 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RestoreAccessory = void 0;
const hap_1 = require("../shared/hap");
const base_accessory_1 = require("../shared/base-accessory");
const rest_iot_1 = require("./rest-iot");
const util_1 = require("../shared/util");
class RestoreAccessory extends base_accessory_1.BaseAccessory {
constructor(restore, accessory) {
super(restore, accessory);
const { Service, Characteristic } = hap_1.hap, onOffService = this.getService(Service.Switch), stepName = restore instanceof rest_iot_1.RestIot ? 'routine' : 'bedtime step';
this.registerCharacteristic(onOffService.getCharacteristic(Characteristic.On), restore.onSomeContentPlaying, (on) => {
(0, util_1.logInfo)(`Turning ${on ? `on first ${stepName} for` : 'off'} ${restore.name}`);
if (on) {
restore.turnOnRoutine();
}
else {
restore.turnOff();
}
});
onOffService.setPrimaryService(true);
}
}
exports.RestoreAccessory = RestoreAccessory;