dirigera
Version:
A TypeScript client for IKEA's DIRIGERA smart home hub
68 lines (67 loc) • 1.81 kB
JavaScript
export default (got) => {
return {
async list() {
const home = await got.get(`home`).json();
return home.deviceSets;
},
async create({ name, icon }) {
return await got
.post(`device-set`, {
json: {
name,
icon,
},
})
.json();
},
async delete({ id }) {
await got.delete(`device-set/${id}`);
},
async update({ id, name, icon }) {
await got
.put(`device-set/${id}`, {
json: {
name,
icon,
},
})
.json();
},
async updateConfiguration({ id, deviceIds, roomId, remoteLinkIds, }) {
await got
.patch(`device-set/${id}/configuration`, {
json: {
deviceIds,
roomId,
remoteLinkIds,
},
})
.json();
},
async setIsOn({ id, isOn }) {
await got
.patch(`devices/set/${id}`, {
json: [
{
attributes: {
isOn,
},
},
],
})
.json();
},
async setAttributes({ id, attributes, transitionTime, }) {
await got
.patch(`devices/set/${id}`, {
json: [
{
attributes,
transitionTime,
},
],
})
.json();
},
};
};