UNPKG

dirigera

Version:

A TypeScript client for IKEA's DIRIGERA smart home hub

42 lines (41 loc) 1.2 kB
export default (got) => { return { async list() { const devices = await got.get(`devices`).json(); return devices.filter((d) => d.type === 'blinds'); }, async get({ id }) { const device = await got.get(`devices/${id}`).json(); if (device.type !== 'blinds') { throw new Error('The requested device is not a blinds'); } return device; }, async setTargetLevel({ id, blindsTargetLevel, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { blindsTargetLevel, }, }, ], }) .json(); }, async setState({ id, blindsState, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { blindsState, }, }, ], }) .json(); }, }; };