UNPKG

@koush/ring-client-api

Version:

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

32 lines (31 loc) 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Outlet = void 0; const base_device_accessory_1 = require("./base-device-accessory"); const hap_1 = require("./hap"); class Outlet 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.Outlet, getValue: (data) => Boolean(data.on), setValue: (value) => this.setOnState(value), }); this.registerCharacteristic({ characteristicType: Characteristic.OutletInUse, serviceType: Service.Outlet, getValue: (data) => Boolean(data.on), }); } setOnState(on) { this.logger.info(`Turning ${this.device.name} ${on ? 'On' : 'Off'}`); return this.device.setInfo({ device: { v1: { on } } }); } } exports.Outlet = Outlet;