UNPKG

dirigera

Version:

A TypeScript client for IKEA's DIRIGERA smart home hub

29 lines (28 loc) 844 B
export default (got) => { return { async list() { const devices = await got.get(`devices`).json(); return devices.filter((d) => d.type === 'controller'); }, async get({ id }) { const device = await got.get(`devices/${id}`).json(); if (device.type !== 'controller') { throw new Error('The requested device is not a controller'); } return device; }, async setControlMode({ id, controlMode, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { controlMode, }, }, ], }) .json(); }, }; };