UNPKG

dirigera

Version:

A TypeScript client for IKEA's DIRIGERA smart home hub

44 lines (43 loc) 1.25 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = (got) => { return { async list() { const devices = await got.get(`devices`).json(); return devices.filter((d) => d.type === 'speaker'); }, async get({ id }) { const device = await got.get(`devices/${id}`).json(); if (device.type !== 'speaker') { throw new Error('The requested device is not a speaker'); } return device; }, async setVolume({ id, volume }) { await got .patch(`devices/${id}`, { json: [ { attributes: { volume, }, }, ], }) .json(); }, async setPlayback({ id, playback, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { playback, }, }, ], }) .json(); }, }; };