Skip to content

Commit

Permalink
✨ Add released status to key status
Browse files Browse the repository at this point in the history
  • Loading branch information
bdsoha committed Oct 15, 2024
1 parent b0f21ef commit c30dd3b
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vitrea-client",
"version": "0.0.2",
"version": "0.0.3",
"description": "Vitrea Smart Home API Client",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/responses/KeyStatus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ describe('KeyStatus', () => {
expect(response).toHaveProperty('power', KeyPowerStatus.OFF)
expect(response).toHaveProperty('isOff', true)
expect(response).toHaveProperty('isOn', false)
expect(response).toHaveProperty('isRelease', false)
})

it('receives a buffer or an array', () => {
Expand Down
4 changes: 4 additions & 0 deletions src/responses/KeyStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ export class KeyStatus extends BaseResponse {
return this.power === KeyPowerStatus.OFF
}

get isReleased() {
return this.power === KeyPowerStatus.RELEASED
}

public get eventName(): string {
return Events.STATUS_UPDATE
}
Expand Down
1 change: 1 addition & 0 deletions src/utilities/Enums.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('Enums', () => {
expect(KeyPowerStatus.OFF).toBe(0x46)
expect(KeyPowerStatus.LONG).toBe(0x4C)
expect(KeyPowerStatus.SHORT).toBe(0x53)
expect(KeyPowerStatus.RELEASED).toBe(0x52)
})

it('LEDBackgroundBrightness', () => {
Expand Down
9 changes: 5 additions & 4 deletions src/utilities/Enums.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
export const KeyPowerStatus = {
ON: 0x4F,
OFF: 0x46,
LONG: 0x4C,
SHORT: 0x53
ON: 0x4F,
OFF: 0x46,
LONG: 0x4C,
SHORT: 0x53,
RELEASED: 0x52,
} as const

export const LEDBackgroundBrightness = {
Expand Down

0 comments on commit c30dd3b

Please sign in to comment.