UNPKG

homebridge-appletv-enhanced

Version:

Plugin that exposes the Apple TV to HomeKit with much richer features than the vanilla Apple TV implementation of HomeKit.

50 lines 2.29 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.newPyatvCharacteristic = newPyatvCharacteristic; exports.newStringCharacteristic = newStringCharacteristic; const utils_1 = require("./utils"); const enums_1 = require("./enums"); const STRING_CHARACTERISTIC_PROPS = { format: "string" /* Formats.STRING */, perms: ["pr" /* Perms.PAIRED_READ */, "ev" /* Perms.NOTIFY */], maxLen: 256, }; const NUMBER_CHARACTERISTIC_PROPS = { format: "uint32" /* Formats.UINT32 */, perms: ["pr" /* Perms.PAIRED_READ */, "ev" /* Perms.NOTIFY */], minStep: 1, }; function newPyatvCharacteristic(hap, char) { let props = undefined; switch (char) { case enums_1.PyATVCustomCharacteristicID.ALBUM: case enums_1.PyATVCustomCharacteristicID.ARTIST: case enums_1.PyATVCustomCharacteristicID.CONTENT_IDENTIFIER: case enums_1.PyATVCustomCharacteristicID.GENRE: case enums_1.PyATVCustomCharacteristicID.OUTPUT_DEVICES: case enums_1.PyATVCustomCharacteristicID.SERIES_NAME: case enums_1.PyATVCustomCharacteristicID.TITLE: props = STRING_CHARACTERISTIC_PROPS; break; case enums_1.PyATVCustomCharacteristicID.REPEAT: props = { ...STRING_CHARACTERISTIC_PROPS, maxLen: 5 }; break; case enums_1.PyATVCustomCharacteristicID.SHUFFLE: props = { ...STRING_CHARACTERISTIC_PROPS, maxLen: 6 }; break; case enums_1.PyATVCustomCharacteristicID.EPISODE_NUMBER: case enums_1.PyATVCustomCharacteristicID.SEASON_NUMBER: case enums_1.PyATVCustomCharacteristicID.ITUNES_STORE_IDENTIFIER: props = NUMBER_CHARACTERISTIC_PROPS; break; case enums_1.PyATVCustomCharacteristicID.POSITION: case enums_1.PyATVCustomCharacteristicID.TOTAL_TIME: props = { ...NUMBER_CHARACTERISTIC_PROPS, unit: "seconds" /* Units.SECONDS */ }; break; } return new hap.Characteristic((0, utils_1.camelCaseToTitleCase)(char), hap.uuid.generate(`uuid-${char}`), props); } function newStringCharacteristic(hap, name) { return new hap.Characteristic(name, hap.uuid.generate(`uuid-${name}`), STRING_CHARACTERISTIC_PROPS); } //# sourceMappingURL=Characteristics.js.map