UNPKG

dirigera

Version:

A TypeScript client for IKEA's DIRIGERA smart home hub

57 lines (56 loc) 1.66 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 === '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 setCurrentLevel({ id, blindsCurrentLevel, }) { await got .patch(`devices/${id}`, { json: [ { attributes: { blindsCurrentLevel, }, }, ], }) .json(); }, 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(); }, }; };