dirigera
Version:
A TypeScript client for IKEA's DIRIGERA smart home hub
54 lines (53 loc) • 1.41 kB
JavaScript
export default (got) => {
return {
async list() {
return await got.get(`devices`).json();
},
async get({ id }) {
return await got.get(`devices/${id}`).json();
},
async setCustomName({ id, customName, }) {
await got
.patch(`devices/${id}`, {
json: [
{
attributes: {
customName,
},
},
],
})
.json();
},
async setAttributes({ id, attributes, transitionTime, }) {
await got
.patch(`devices/${id}`, {
json: [
{
attributes,
transitionTime,
},
],
})
.json();
},
async startIdentifying({ id }) {
await got
.put(`devices/${id}/identify`, {
json: {
period: 30,
},
})
.json();
},
async stopIdentifying({ id }) {
await got
.put(`devices/${id}/identify`, {
json: {
period: 0,
},
})
.json();
},
};
};