Skip to content

Commit f9937dc

Browse files
committed
fix custom characteristics for hb 2
1 parent 85b9e86 commit f9937dc

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ All notable changes to homebridge-ewelink will be documented in this file.
88

99
- fix custom plugin config modal styles in ui 5
1010
- fix eve characteristics for hb 2
11+
- fix custom characteristics for hb 2
1112

1213
### Other Changes
1314

lib/utils/custom-chars.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,34 @@
1-
import { inherits } from 'node:util'
2-
31
export default class {
42
constructor(api) {
5-
this.hapServ = api.hap.Service
6-
this.hapChar = api.hap.Characteristic
73
this.uuids = {
84
invertSwitch: 'E965F001-079E-48FF-8F27-9C2605A29F52',
95
festiveScene: 'E965F002-079E-48FF-8F27-9C2605A29F52',
106
}
11-
const self = this
12-
this.InvertSwitch = function InvertSwitch() {
13-
self.hapChar.call(this, 'Invert Switch', self.uuids.invertSwitch)
14-
this.setProps({
15-
format: api.hap.Formats.BOOL,
16-
perms: [api.hap.Perms.PAIRED_READ, api.hap.Perms.PAIRED_WRITE, api.hap.Perms.NOTIFY],
17-
})
18-
this.value = this.getDefaultValue()
7+
8+
const uuids = this.uuids
9+
10+
this.InvertSwitch = class extends api.hap.Characteristic {
11+
constructor() {
12+
super('Invert Switch', uuids.invertSwitch)
13+
this.setProps({
14+
format: api.hap.Formats.BOOL,
15+
perms: [api.hap.Perms.PAIRED_READ, api.hap.Perms.PAIRED_WRITE, api.hap.Perms.NOTIFY],
16+
})
17+
this.value = this.getDefaultValue()
18+
}
1919
}
20-
this.FestiveScene = function FestiveScene() {
21-
self.hapChar.call(this, 'Festive Scene', self.uuids.festiveScene)
22-
this.setProps({
23-
format: api.hap.Formats.BOOL,
24-
perms: [api.hap.Perms.PAIRED_READ, api.hap.Perms.PAIRED_WRITE, api.hap.Perms.NOTIFY],
25-
})
26-
this.value = this.getDefaultValue()
20+
21+
this.FestiveScene = class extends api.hap.Characteristic {
22+
constructor() {
23+
super('Festive Scene', uuids.festiveScene)
24+
this.setProps({
25+
format: api.hap.Formats.BOOL,
26+
perms: [api.hap.Perms.PAIRED_READ, api.hap.Perms.PAIRED_WRITE, api.hap.Perms.NOTIFY],
27+
})
28+
this.value = this.getDefaultValue()
29+
}
2730
}
28-
inherits(this.InvertSwitch, this.hapChar)
29-
inherits(this.FestiveScene, this.hapChar)
31+
3032
this.InvertSwitch.UUID = this.uuids.invertSwitch
3133
this.FestiveScene.UUID = this.uuids.festiveScene
3234
}

0 commit comments

Comments
 (0)