Skip to content

Commit

Permalink
add startupOnOff endpoints to lights and outlets
Browse files Browse the repository at this point in the history
  • Loading branch information
lpgera committed Feb 4, 2024
1 parent a3dcf06 commit 1c891b7
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ await client.lights.setLightTemperature({
id: 'YOUR_DEVICE_ID',
colorTemperature: 2700, // between colorTemperatureMax and colorTemperatureMin
})

await client.lights.setStartupOnOff({
id: 'YOUR_DEVICE_ID',
startupOnOff: 'startOn', // 'startOn' | 'startPrevious'
})
```

#### [Motion sensors](./src/api/motionSensors.ts)
Expand Down Expand Up @@ -323,6 +328,11 @@ await client.outlets.setIsOn({
id: 'YOUR_DEVICE_ID',
isOn: true,
})

await client.outlets.setStartupOnOff({
id: 'YOUR_DEVICE_ID',
startupOnOff: 'startOn', // 'startOn' | 'startPrevious'
})
```

#### [Open/close sensors](./src/api/openCloseSensors.ts)
Expand Down
20 changes: 20 additions & 0 deletions src/api/lights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,25 @@ export default (got: Got) => {
})
.json()
},

async setStartupOnOff({
id,
startupOnOff,
}: {
id: string
startupOnOff: Light['attributes']['startupOnOff']
}) {
await got
.patch(`devices/${id}`, {
json: [
{
attributes: {
startupOnOff,
},
},
],
})
.json()
},
}
}
20 changes: 20 additions & 0 deletions src/api/outlets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,25 @@ export default (got: Got) => {
})
.json()
},

async setStartupOnOff({
id,
startupOnOff,
}: {
id: string
startupOnOff: Outlet['attributes']['startupOnOff']
}) {
await got
.patch(`devices/${id}`, {
json: [
{
attributes: {
startupOnOff,
},
},
],
})
.json()
},
}
}

0 comments on commit 1c891b7

Please sign in to comment.