UNPKG

dirigera

Version:

A TypeScript client for IKEA's DIRIGERA smart home hub

68 lines (67 loc) 1.91 kB
export default (got) => { return { async list() { const devices = await got.get(`devices`).json(); return devices.filter((d) => d.type === 'airPurifier'); }, async get({ id }) { const device = await got.get(`devices/${id}`).json(); if (device.type !== 'airPurifier') { throw new Error('The requested device is not an airPurifier'); } return device; }, async setFanMode({ id, fanMode, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { fanMode, }, }, ], }) .json(); }, async setMotorState({ id, motorState, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { motorState, }, }, ], }) .json(); }, async setChildLock({ id, childLock, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { childLock, }, }, ], }) .json(); }, async setStatusLight({ id, statusLight, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { statusLight, }, }, ], }) .json(); }, }; };