dirigera
Version:
A TypeScript client for IKEA's DIRIGERA smart home hub
70 lines (69 loc) • 1.99 kB
JavaScript
;
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 === '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();
},
};
};