homebridge-velux 0.0.2 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,6 +3,8 @@
3
3
  //
4
4
  // Homebridge plugin for Velux Integra KLF 200 gateway.
5
5
 
6
+ import { VeluxClient } from 'hb-velux-tools/VeluxClient'
7
+
6
8
  import { AccessoryDelegate } from 'homebridge-lib/AccessoryDelegate'
7
9
  import { VeluxService } from '../VeluxService/index.js'
8
10
 
@@ -12,11 +14,24 @@ class VeluxAccessory extends AccessoryDelegate {
12
14
  this.gateway = gateway
13
15
  this.client = gateway.client
14
16
  this.log(
15
- '%s [%d]: %s %s [%s] at %d%%', params.name, params.payload.nodeId,
17
+ 'node %d: %s %s [%s] at %d%%', params.payload.nodeId,
16
18
  params.manufacturer, params.model, params.payload.actuatorType,
17
19
  100 - params.payload.currentPosition
18
20
  )
19
21
  this.service = new VeluxService[params.ServiceName](this, params)
22
+
23
+ this.on('identify', async () => {
24
+ try {
25
+ this.log(
26
+ 'node %d: %s %s [%s] at %d%%', params.payload.nodeId,
27
+ params.manufacturer, params.model, params.payload.actuatorType,
28
+ 100 - params.payload.currentPosition
29
+ )
30
+ await this.client.request(VeluxClient.commands.GW_WINK_SEND_REQ, {
31
+ nodeIds: [params.payload.nodeId]
32
+ })
33
+ } catch (error) { this.warn(error) }
34
+ })
20
35
  }
21
36
 
22
37
  get logLevel () { return this.gateway?.logLevel ?? 2 }
@@ -3,7 +3,7 @@
3
3
  //
4
4
  // Homebridge plugin for Velux Integra KLF 200 gateway.
5
5
 
6
- import { timeout } from 'hb-lib-tools'
6
+ // import { timeout } from 'hb-lib-tools'
7
7
 
8
8
  import { VeluxClient } from 'hb-velux-tools/VeluxClient'
9
9
 
@@ -53,34 +53,41 @@ class WindowCovering extends VeluxService {
53
53
  nodeIds: [params.payload.nodeId]
54
54
  })
55
55
  } catch (error) { this.warn(error) }
56
- this.log('stop')
57
56
  })
58
57
 
59
- this.addCharacteristicDelegate({
60
- key: 'motorSpeed',
61
- Characteristic: this.Characteristics.my.MotorSpeed,
62
- unit: '',
63
- props: {
64
- unit: '',
65
- minValue: 0,
66
- maxValue: 2,
67
- minStep: 1
68
- }
69
- }).on('didSet', async (value, fromHomeKit) => {
70
- if (!fromHomeKit) {
71
- return
72
- }
73
- const speed = ['default', 'slow', 'fast'](value)
74
- this.log('set speed to %s', speed)
75
- })
58
+ // this.addCharacteristicDelegate({
59
+ // key: 'motorSpeed',
60
+ // Characteristic: this.Characteristics.my.MotorSpeed,
61
+ // unit: '',
62
+ // props: {
63
+ // unit: '',
64
+ // minValue: 0,
65
+ // maxValue: 2,
66
+ // minStep: 1
67
+ // }
68
+ // }).on('didSet', async (value, fromHomeKit) => {
69
+ // if (!fromHomeKit) {
70
+ // return
71
+ // }
72
+ // const speed = ['default', 'slow', 'fast'](value)
73
+ // this.log('set speed to %s', speed)
74
+ // })
76
75
 
77
76
  this.addCharacteristicDelegate({
78
77
  key: 'positionChange',
79
78
  Characteristic: this.Characteristics.my.PositionChange
80
- }).on('didSet', async (value) => {
81
- if (value !== 0) {
82
- this.log('change position by %s', value)
83
- await timeout(this.platform.config.waitTimeReset)
79
+ }).on('didSet', async (value, fromHomeKit) => {
80
+ if (!fromHomeKit || value === 0) {
81
+ return
82
+ }
83
+ try {
84
+ await this.client.request(VeluxClient.commands.GW_COMMAND_SEND_REQ, {
85
+ position: { delta: value * -1 },
86
+ nodeIds: [params.payload.nodeId]
87
+ })
88
+ } catch (error) {
89
+ this.warn(error)
90
+ } finally {
84
91
  this.values.positionChange = 0
85
92
  }
86
93
  })
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "ebaauw"
8
8
  ],
9
9
  "license": "Apache-2.0",
10
- "version": "0.0.2",
10
+ "version": "1.0.0",
11
11
  "keywords": [
12
12
  "homebridge-plugin",
13
13
  "homekit",
@@ -22,13 +22,13 @@
22
22
  "velux": "cli/velux.js"
23
23
  },
24
24
  "engines": {
25
- "homebridge": "^1.8.5||^2.0.0-beta",
25
+ "homebridge": "^1.9.0||^2.0.0-beta",
26
26
  "node": "^22||^20||^18",
27
27
  "klf200": "3.14"
28
28
  },
29
29
  "dependencies": {
30
- "hb-velux-tools": "~0.0.4",
31
- "homebridge-lib": "~7.1.3"
30
+ "hb-velux-tools": "~0.0.6",
31
+ "homebridge-lib": "~7.1.4"
32
32
  },
33
33
  "scripts": {
34
34
  "prepare": "standard",