UNPKG

@koush/ring-client-api

Version:

Unofficial API for Ring doorbells, cameras, security alarm system and smart lighting

27 lines (26 loc) 971 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Switch = void 0; const base_device_accessory_1 = require("./base-device-accessory"); const hap_1 = require("./hap"); class Switch extends base_device_accessory_1.BaseDeviceAccessory { constructor(device, accessory, logger, config) { super(); this.device = device; this.accessory = accessory; this.logger = logger; this.config = config; const { Characteristic, Service } = hap_1.hap; this.registerCharacteristic({ characteristicType: Characteristic.On, serviceType: Service.Switch, getValue: (data) => Boolean(data.on), setValue: (value) => this.setOnState(value), }); } setOnState(on) { this.logger.info(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`); return this.device.setInfo({ device: { v1: { on } } }); } } exports.Switch = Switch;