@switchbot/homebridge-switchbot 3.7.1-beta.11 → 3.7.1-beta.13

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.
Files changed (190) hide show
  1. package/dist/device/blindtilt.d.ts +8 -8
  2. package/dist/device/blindtilt.d.ts.map +1 -1
  3. package/dist/device/blindtilt.js +34 -66
  4. package/dist/device/blindtilt.js.map +1 -1
  5. package/dist/device/bot.d.ts +9 -9
  6. package/dist/device/bot.d.ts.map +1 -1
  7. package/dist/device/bot.js +61 -97
  8. package/dist/device/bot.js.map +1 -1
  9. package/dist/device/ceilinglight.d.ts +13 -13
  10. package/dist/device/ceilinglight.d.ts.map +1 -1
  11. package/dist/device/ceilinglight.js +38 -73
  12. package/dist/device/ceilinglight.js.map +1 -1
  13. package/dist/device/colorbulb.d.ts +12 -12
  14. package/dist/device/colorbulb.d.ts.map +1 -1
  15. package/dist/device/colorbulb.js +41 -79
  16. package/dist/device/colorbulb.js.map +1 -1
  17. package/dist/device/contact.d.ts +5 -5
  18. package/dist/device/contact.d.ts.map +1 -1
  19. package/dist/device/contact.js +20 -42
  20. package/dist/device/contact.js.map +1 -1
  21. package/dist/device/curtain.d.ts +5 -5
  22. package/dist/device/curtain.d.ts.map +1 -1
  23. package/dist/device/curtain.js +36 -71
  24. package/dist/device/curtain.js.map +1 -1
  25. package/dist/device/device.d.ts +18 -18
  26. package/dist/device/device.d.ts.map +1 -1
  27. package/dist/device/device.js +33 -36
  28. package/dist/device/device.js.map +1 -1
  29. package/dist/device/fan.d.ts +8 -8
  30. package/dist/device/fan.d.ts.map +1 -1
  31. package/dist/device/fan.js +43 -75
  32. package/dist/device/fan.js.map +1 -1
  33. package/dist/device/hub.d.ts +5 -5
  34. package/dist/device/hub.d.ts.map +1 -1
  35. package/dist/device/hub.js +18 -39
  36. package/dist/device/hub.js.map +1 -1
  37. package/dist/device/humidifier.d.ts +5 -5
  38. package/dist/device/humidifier.d.ts.map +1 -1
  39. package/dist/device/humidifier.js +38 -78
  40. package/dist/device/humidifier.js.map +1 -1
  41. package/dist/device/iosensor.d.ts +5 -5
  42. package/dist/device/iosensor.d.ts.map +1 -1
  43. package/dist/device/iosensor.js +21 -40
  44. package/dist/device/iosensor.js.map +1 -1
  45. package/dist/device/lightstrip.d.ts +6 -6
  46. package/dist/device/lightstrip.d.ts.map +1 -1
  47. package/dist/device/lightstrip.js +34 -73
  48. package/dist/device/lightstrip.js.map +1 -1
  49. package/dist/device/lock.d.ts +9 -9
  50. package/dist/device/lock.d.ts.map +1 -1
  51. package/dist/device/lock.js +37 -52
  52. package/dist/device/lock.js.map +1 -1
  53. package/dist/device/meter.d.ts +5 -5
  54. package/dist/device/meter.d.ts.map +1 -1
  55. package/dist/device/meter.js +21 -39
  56. package/dist/device/meter.js.map +1 -1
  57. package/dist/device/meterplus.d.ts +5 -5
  58. package/dist/device/meterplus.d.ts.map +1 -1
  59. package/dist/device/meterplus.js +21 -38
  60. package/dist/device/meterplus.js.map +1 -1
  61. package/dist/device/motion.d.ts +5 -5
  62. package/dist/device/motion.d.ts.map +1 -1
  63. package/dist/device/motion.js +14 -32
  64. package/dist/device/motion.js.map +1 -1
  65. package/dist/device/plug.d.ts +12 -12
  66. package/dist/device/plug.d.ts.map +1 -1
  67. package/dist/device/plug.js +16 -25
  68. package/dist/device/plug.js.map +1 -1
  69. package/dist/device/robotvacuumcleaner.d.ts +11 -11
  70. package/dist/device/robotvacuumcleaner.d.ts.map +1 -1
  71. package/dist/device/robotvacuumcleaner.js +42 -56
  72. package/dist/device/robotvacuumcleaner.js.map +1 -1
  73. package/dist/device/waterdetector.d.ts +5 -5
  74. package/dist/device/waterdetector.d.ts.map +1 -1
  75. package/dist/device/waterdetector.js +22 -37
  76. package/dist/device/waterdetector.js.map +1 -1
  77. package/dist/homebridge-ui/server.js +2 -2
  78. package/dist/homebridge-ui/server.js.map +1 -1
  79. package/dist/index.d.ts.map +1 -1
  80. package/dist/index.js +0 -4
  81. package/dist/index.js.map +1 -1
  82. package/dist/irdevice/airconditioner.d.ts +8 -8
  83. package/dist/irdevice/airconditioner.d.ts.map +1 -1
  84. package/dist/irdevice/airconditioner.js +64 -105
  85. package/dist/irdevice/airconditioner.js.map +1 -1
  86. package/dist/irdevice/airpurifier.d.ts +10 -10
  87. package/dist/irdevice/airpurifier.d.ts.map +1 -1
  88. package/dist/irdevice/airpurifier.js +22 -42
  89. package/dist/irdevice/airpurifier.js.map +1 -1
  90. package/dist/irdevice/camera.d.ts +9 -9
  91. package/dist/irdevice/camera.d.ts.map +1 -1
  92. package/dist/irdevice/camera.js +15 -25
  93. package/dist/irdevice/camera.js.map +1 -1
  94. package/dist/irdevice/fan.d.ts +8 -8
  95. package/dist/irdevice/fan.d.ts.map +1 -1
  96. package/dist/irdevice/fan.js +21 -40
  97. package/dist/irdevice/fan.js.map +1 -1
  98. package/dist/irdevice/irdevice.d.ts +11 -11
  99. package/dist/irdevice/irdevice.d.ts.map +1 -1
  100. package/dist/irdevice/irdevice.js +14 -22
  101. package/dist/irdevice/irdevice.js.map +1 -1
  102. package/dist/irdevice/light.d.ts +9 -9
  103. package/dist/irdevice/light.d.ts.map +1 -1
  104. package/dist/irdevice/light.js +24 -47
  105. package/dist/irdevice/light.js.map +1 -1
  106. package/dist/irdevice/other.d.ts +9 -9
  107. package/dist/irdevice/other.d.ts.map +1 -1
  108. package/dist/irdevice/other.js +40 -83
  109. package/dist/irdevice/other.js.map +1 -1
  110. package/dist/irdevice/tv.d.ts +9 -9
  111. package/dist/irdevice/tv.d.ts.map +1 -1
  112. package/dist/irdevice/tv.js +29 -54
  113. package/dist/irdevice/tv.js.map +1 -1
  114. package/dist/irdevice/vacuumcleaner.d.ts +5 -5
  115. package/dist/irdevice/vacuumcleaner.d.ts.map +1 -1
  116. package/dist/irdevice/vacuumcleaner.js +11 -21
  117. package/dist/irdevice/vacuumcleaner.js.map +1 -1
  118. package/dist/irdevice/waterheater.d.ts +5 -5
  119. package/dist/irdevice/waterheater.d.ts.map +1 -1
  120. package/dist/irdevice/waterheater.js +11 -22
  121. package/dist/irdevice/waterheater.js.map +1 -1
  122. package/dist/platform.d.ts +5 -6
  123. package/dist/platform.d.ts.map +1 -1
  124. package/dist/platform.js +142 -146
  125. package/dist/platform.js.map +1 -1
  126. package/dist/settings.d.ts +2 -2
  127. package/dist/settings.d.ts.map +1 -1
  128. package/dist/settings.js.map +1 -1
  129. package/dist/types/bledevicestatus.d.ts +9 -9
  130. package/dist/types/bledevicestatus.d.ts.map +1 -1
  131. package/dist/types/devicelist.d.ts +6 -6
  132. package/dist/types/devicelist.d.ts.map +1 -1
  133. package/dist/types/deviceresponse.d.ts +4 -4
  134. package/dist/types/deviceresponse.d.ts.map +1 -1
  135. package/dist/types/devicestatus.d.ts +2 -2
  136. package/dist/types/devicestatus.d.ts.map +1 -1
  137. package/dist/types/devicewebhookstatus.d.ts +5 -5
  138. package/dist/types/devicewebhookstatus.d.ts.map +1 -1
  139. package/dist/types/irdevicelist.d.ts +4 -4
  140. package/dist/types/irdevicelist.d.ts.map +1 -1
  141. package/dist/types/pushbody.d.ts +2 -2
  142. package/dist/types/pushbody.d.ts.map +1 -1
  143. package/dist/utils.d.ts +4 -4
  144. package/dist/utils.d.ts.map +1 -1
  145. package/dist/utils.js +9 -13
  146. package/dist/utils.js.map +1 -1
  147. package/eslint.config.js +48 -93
  148. package/package.json +54 -47
  149. package/src/device/blindtilt.ts +419 -456
  150. package/src/device/bot.ts +656 -693
  151. package/src/device/ceilinglight.ts +331 -364
  152. package/src/device/colorbulb.ts +412 -448
  153. package/src/device/contact.ts +200 -221
  154. package/src/device/curtain.ts +400 -435
  155. package/src/device/device.ts +206 -208
  156. package/src/device/fan.ts +307 -340
  157. package/src/device/hub.ts +184 -209
  158. package/src/device/humidifier.ts +297 -342
  159. package/src/device/iosensor.ts +182 -204
  160. package/src/device/lightstrip.ts +362 -399
  161. package/src/device/lock.ts +262 -276
  162. package/src/device/meter.ts +183 -205
  163. package/src/device/meterplus.ts +183 -204
  164. package/src/device/motion.ts +169 -185
  165. package/src/device/plug.ts +174 -177
  166. package/src/device/robotvacuumcleaner.ts +256 -269
  167. package/src/device/waterdetector.ts +169 -184
  168. package/src/homebridge-ui/server.ts +16 -15
  169. package/src/index.ts +5 -6
  170. package/src/irdevice/airconditioner.ts +280 -326
  171. package/src/irdevice/airpurifier.ts +124 -143
  172. package/src/irdevice/camera.ts +58 -64
  173. package/src/irdevice/fan.ts +106 -123
  174. package/src/irdevice/irdevice.ts +116 -119
  175. package/src/irdevice/light.ts +119 -143
  176. package/src/irdevice/other.ts +417 -461
  177. package/src/irdevice/tv.ts +155 -177
  178. package/src/irdevice/vacuumcleaner.ts +54 -60
  179. package/src/irdevice/waterheater.ts +56 -63
  180. package/src/platform.ts +1282 -1281
  181. package/src/settings.ts +170 -170
  182. package/src/types/bledevicestatus.ts +255 -255
  183. package/src/types/devicelist.ts +79 -79
  184. package/src/types/deviceresponse.ts +12 -13
  185. package/src/types/devicestatus.ts +124 -124
  186. package/src/types/devicewebhookstatus.ts +126 -127
  187. package/src/types/irdevicelist.ts +10 -10
  188. package/src/types/pushbody.ts +5 -5
  189. package/src/utils.ts +64 -65
  190. package/tsconfig.json +10 -9
@@ -2,90 +2,91 @@
2
2
  *
3
3
  * blindtilt.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
- import { deviceBase } from './device.js';
6
- import { BlindTiltMappingMode } from '../utils.js';
5
+ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
+
7
+ import type { SwitchBotPlatform } from '../platform.js'
8
+ import type { devicesConfig } from '../settings.js'
9
+ import type { blindTiltServiceData } from '../types/bledevicestatus.js'
10
+ import type { device } from '../types/devicelist.js'
11
+ import type { blindTiltStatus } from '../types/devicestatus.js'
12
+ import type { blindTiltWebhookContext } from '../types/devicewebhookstatus.js'
13
+
7
14
  /*
8
15
  * For Testing Locally:
9
16
  * import { SwitchBotBLEModel, SwitchBotBLEModelName } from '/Users/Shared/GitHub/OpenWonderLabs/node-switchbot/dist/index.js';
10
17
  */
11
- import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot';
12
- import { Subject, debounceTime, interval, skipWhile, take, tap } from 'rxjs';
13
-
14
- import type { devicesConfig } from '../settings.js';
15
- import type { device } from '../types/devicelist.js';
16
- import type { SwitchBotPlatform } from '../platform.js';
17
- import type { blindTiltServiceData } from '../types/bledevicestatus.js';
18
- import type { blindTiltStatus } from '../types/devicestatus.js';
19
- import type { blindTiltWebhookContext } from '../types/devicewebhookstatus.js';
20
- import type { Service, PlatformAccessory, CharacteristicValue } from 'homebridge';
18
+ import { SwitchBotBLEModel, SwitchBotBLEModelName } from 'node-switchbot'
19
+ import { debounceTime, interval, skipWhile, Subject, take, tap } from 'rxjs'
21
20
 
21
+ import { BlindTiltMappingMode } from '../utils.js'
22
+ import { deviceBase } from './device.js'
22
23
 
23
24
  export class BlindTilt extends deviceBase {
24
25
  // Services
25
26
  private WindowCovering: {
26
- Name: CharacteristicValue;
27
- Service: Service;
28
- PositionState: CharacteristicValue;
29
- TargetPosition: CharacteristicValue;
30
- CurrentPosition: CharacteristicValue;
31
- TargetHorizontalTiltAngle: CharacteristicValue;
32
- CurrentHorizontalTiltAngle: CharacteristicValue;
33
- };
27
+ Name: CharacteristicValue
28
+ Service: Service
29
+ PositionState: CharacteristicValue
30
+ TargetPosition: CharacteristicValue
31
+ CurrentPosition: CharacteristicValue
32
+ TargetHorizontalTiltAngle: CharacteristicValue
33
+ CurrentHorizontalTiltAngle: CharacteristicValue
34
+ }
34
35
 
35
36
  private Battery: {
36
- Name: CharacteristicValue;
37
- Service: Service;
38
- BatteryLevel: CharacteristicValue;
39
- StatusLowBattery: CharacteristicValue;
40
- ChargingState?: CharacteristicValue;
41
- };
37
+ Name: CharacteristicValue
38
+ Service: Service
39
+ BatteryLevel: CharacteristicValue
40
+ StatusLowBattery: CharacteristicValue
41
+ ChargingState?: CharacteristicValue
42
+ }
42
43
 
43
44
  private LightSensor?: {
44
- Name: CharacteristicValue;
45
- Service: Service;
46
- CurrentAmbientLightLevel?: CharacteristicValue;
47
- };
45
+ Name: CharacteristicValue
46
+ Service: Service
47
+ CurrentAmbientLightLevel?: CharacteristicValue
48
+ }
48
49
 
49
50
  // OpenAPI
50
- deviceStatus!: blindTiltStatus;
51
- mappingMode: BlindTiltMappingMode = BlindTiltMappingMode.OnlyUp;
51
+ deviceStatus!: blindTiltStatus
52
+ mappingMode: BlindTiltMappingMode = BlindTiltMappingMode.OnlyUp
52
53
 
53
- //Webhook
54
- webhookContext!: blindTiltWebhookContext;
54
+ // Webhook
55
+ webhookContext!: blindTiltWebhookContext
55
56
 
56
57
  // BLE
57
- serviceData!: blindTiltServiceData;
58
+ serviceData!: blindTiltServiceData
58
59
 
59
60
  // Target
60
- setNewTarget!: boolean;
61
- setNewTargetTimer!: NodeJS.Timeout;
61
+ setNewTarget!: boolean
62
+ setNewTargetTimer!: NodeJS.Timeout
62
63
 
63
64
  // Updates
64
- blindTiltMoving: boolean;
65
- blindTiltUpdateInProgress: boolean;
66
- doBlindTiltUpdate: Subject<void>;
65
+ blindTiltMoving: boolean
66
+ blindTiltUpdateInProgress: boolean
67
+ doBlindTiltUpdate: Subject<void>
67
68
 
68
69
  constructor(
69
70
  readonly platform: SwitchBotPlatform,
70
71
  accessory: PlatformAccessory,
71
72
  device: device & devicesConfig,
72
73
  ) {
73
- super(platform, accessory, device);
74
+ super(platform, accessory, device)
74
75
  // Set category
75
- accessory.category = this.hap.Categories.WINDOW_COVERING;
76
+ accessory.category = this.hap.Categories.WINDOW_COVERING
76
77
 
77
78
  // default placeholders
78
- this.mappingMode = (device.blindTilt?.mode as BlindTiltMappingMode) ?? BlindTiltMappingMode.OnlyUp;
79
- this.debugLog(`Mapping mode: ${this.mappingMode}`);
79
+ this.mappingMode = (device.blindTilt?.mode as BlindTiltMappingMode) ?? BlindTiltMappingMode.OnlyUp
80
+ this.debugLog(`Mapping mode: ${this.mappingMode}`)
80
81
 
81
82
  // this is subject we use to track when we need to POST changes to the SwitchBot API
82
- this.doBlindTiltUpdate = new Subject();
83
- this.blindTiltMoving = false;
84
- this.blindTiltUpdateInProgress = false;
85
- this.setNewTarget = false;
83
+ this.doBlindTiltUpdate = new Subject()
84
+ this.blindTiltMoving = false
85
+ this.blindTiltUpdateInProgress = false
86
+ this.setNewTarget = false
86
87
 
87
88
  // Initialize WindowCovering Service
88
- accessory.context.WindowCovering = accessory.context.WindowCovering ?? {};
89
+ accessory.context.WindowCovering = accessory.context.WindowCovering ?? {}
89
90
  this.WindowCovering = {
90
91
  Name: accessory.displayName,
91
92
  Service: accessory.getService(this.hap.Service.WindowCovering) ?? accessory.addService(this.hap.Service.WindowCovering) as Service,
@@ -94,310 +95,286 @@ export class BlindTilt extends deviceBase {
94
95
  CurrentPosition: accessory.context.CurrentPosition ?? 100,
95
96
  TargetHorizontalTiltAngle: accessory.context.TargetHorizontalTiltAngle ?? 90,
96
97
  CurrentHorizontalTiltAngle: accessory.context.CurrentHorizontalTiltAngle ?? 90,
97
- };
98
- accessory.context.WindowCovering = this.WindowCovering as object;
98
+ }
99
+ accessory.context.WindowCovering = this.WindowCovering as object
99
100
 
100
101
  // Initialize WindowCovering Characteristics
101
- this.WindowCovering.Service
102
- .setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name)
103
- .getCharacteristic(this.hap.Characteristic.TargetPosition)
104
- .setProps({
105
- minStep: device.blindTilt?.set_minStep ?? 1,
106
- minValue: 0,
107
- maxValue: 100,
108
- validValueRanges: [0, 100],
109
- })
110
- .onGet(() => {
111
- return this.WindowCovering.TargetPosition;
112
- })
113
- .onSet(this.TargetPositionSet.bind(this));
102
+ this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.Name, this.WindowCovering.Name).getCharacteristic(this.hap.Characteristic.TargetPosition).setProps({
103
+ minStep: device.blindTilt?.set_minStep ?? 1,
104
+ minValue: 0,
105
+ maxValue: 100,
106
+ validValueRanges: [0, 100],
107
+ }).onGet(() => {
108
+ return this.WindowCovering.TargetPosition
109
+ }).onSet(this.TargetPositionSet.bind(this))
114
110
 
115
111
  // Initialize WindowCovering CurrentPosition Characteristic
116
- this.WindowCovering.Service
117
- .getCharacteristic(this.hap.Characteristic.CurrentPosition)
118
- .setProps({
119
- minStep: device.blindTilt?.set_minStep ?? 1,
120
- minValue: 0,
121
- maxValue: 100,
122
- validValueRanges: [0, 100],
123
- }).onGet(() => {
124
- return this.WindowCovering.CurrentPosition ?? 0;
125
- });
112
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.CurrentPosition).setProps({
113
+ minStep: device.blindTilt?.set_minStep ?? 1,
114
+ minValue: 0,
115
+ maxValue: 100,
116
+ validValueRanges: [0, 100],
117
+ }).onGet(() => {
118
+ return this.WindowCovering.CurrentPosition ?? 0
119
+ })
126
120
 
127
121
  // Initialize WindowCovering TargetHorizontalTiltAngle Characteristic
128
- this.WindowCovering.Service
129
- .getCharacteristic(this.hap.Characteristic.TargetHorizontalTiltAngle)
130
- .setProps({
131
- minStep: 180,
132
- minValue: -90,
133
- maxValue: 90,
134
- validValues: [-90, 90],
135
- })
136
- .onGet(() => {
137
- return this.WindowCovering.TargetHorizontalTiltAngle;
138
- })
139
- .onSet(this.TargetHorizontalTiltAngleSet.bind(this));
122
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.TargetHorizontalTiltAngle).setProps({
123
+ minStep: 180,
124
+ minValue: -90,
125
+ maxValue: 90,
126
+ validValues: [-90, 90],
127
+ }).onGet(() => {
128
+ return this.WindowCovering.TargetHorizontalTiltAngle
129
+ }).onSet(this.TargetHorizontalTiltAngleSet.bind(this))
140
130
 
141
131
  // Initialize WindowCovering CurrentHorizontalTiltAngle Characteristic
142
- this.WindowCovering.Service
143
- .getCharacteristic(this.hap.Characteristic.CurrentHorizontalTiltAngle)
144
- .setProps({
145
- minStep: 180,
146
- minValue: -90,
147
- maxValue: 90,
148
- validValues: [-90, 90],
149
- }).onGet(() => {
150
- return this.WindowCovering.CurrentHorizontalTiltAngle ?? 0;
151
- });
132
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.CurrentHorizontalTiltAngle).setProps({
133
+ minStep: 180,
134
+ minValue: -90,
135
+ maxValue: 90,
136
+ validValues: [-90, 90],
137
+ }).onGet(() => {
138
+ return this.WindowCovering.CurrentHorizontalTiltAngle ?? 0
139
+ })
152
140
 
153
141
  // Initialize Battery Service
154
- accessory.context.Battery = accessory.context.Battery ?? {};
142
+ accessory.context.Battery = accessory.context.Battery ?? {}
155
143
  this.Battery = {
156
144
  Name: `${accessory.displayName} Battery`,
157
145
  Service: accessory.getService(this.hap.Service.Battery) ?? accessory.addService(this.hap.Service.Battery) as Service,
158
146
  BatteryLevel: accessory.context.BatteryLevel ?? 100,
159
147
  StatusLowBattery: this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL,
160
148
  ChargingState: accessory.context.ChargingState ?? this.hap.Characteristic.ChargingState.NOT_CHARGING,
161
- };
162
- accessory.context.Battery = this.Battery as object;
149
+ }
150
+ accessory.context.Battery = this.Battery as object
163
151
 
164
152
  // Initialize Battery Name Characteristic
165
- this.Battery.Service
166
- .setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name)
167
- .setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE);
153
+ this.Battery.Service.setCharacteristic(this.hap.Characteristic.Name, this.Battery.Name).setCharacteristic(this.hap.Characteristic.ChargingState, this.hap.Characteristic.ChargingState.NOT_CHARGEABLE)
168
154
 
169
155
  // Initialize LightSensor Service
170
156
  if (device.blindTilt?.hide_lightsensor) {
171
157
  if (this.LightSensor?.Service) {
172
- this.debugLog('Removing Light Sensor Service');
173
- this.LightSensor.Service = accessory.getService(this.hap.Service.LightSensor) as Service;
174
- accessory.removeService(this.LightSensor.Service);
175
- accessory.context.LightSensor = {};
158
+ this.debugLog('Removing Light Sensor Service')
159
+ this.LightSensor.Service = accessory.getService(this.hap.Service.LightSensor) as Service
160
+ accessory.removeService(this.LightSensor.Service)
161
+ accessory.context.LightSensor = {}
176
162
  } else {
177
- this.debugLog('Light Sensor Service is already removed');
163
+ this.debugLog('Light Sensor Service is already removed')
178
164
  }
179
165
  } else {
180
- accessory.context.LightSensor = accessory.context.LightSensor ?? {};
166
+ accessory.context.LightSensor = accessory.context.LightSensor ?? {}
181
167
  this.LightSensor = {
182
168
  Name: `${accessory.displayName} Light Sensor`,
183
169
  Service: accessory.getService(this.hap.Service.LightSensor) ?? accessory.addService(this.hap.Service.LightSensor) as Service,
184
170
  CurrentAmbientLightLevel: accessory.context.CurrentAmbientLightLevel ?? 0.0001,
185
- };
186
- accessory.context.LightSensor = this.LightSensor as object;
171
+ }
172
+ accessory.context.LightSensor = this.LightSensor as object
187
173
 
188
174
  // Initialize LightSensor Characteristics
189
- this.LightSensor.Service
190
- .setCharacteristic(this.hap.Characteristic.Name, this.LightSensor.Name)
191
- .setCharacteristic(this.hap.Characteristic.StatusActive, true)
192
- .getCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel)
193
- .onGet(() => {
194
- return this.LightSensor?.CurrentAmbientLightLevel ?? 0.0001;
195
- });
175
+ this.LightSensor.Service.setCharacteristic(this.hap.Characteristic.Name, this.LightSensor.Name).setCharacteristic(this.hap.Characteristic.StatusActive, true).getCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel).onGet(() => {
176
+ return this.LightSensor?.CurrentAmbientLightLevel ?? 0.0001
177
+ })
196
178
  }
197
179
 
198
180
  // Retrieve initial values and updateHomekit
199
181
  try {
200
- this.debugLog('Retrieve initial values and update Homekit');
201
- this.refreshStatus();
182
+ this.debugLog('Retrieve initial values and update Homekit')
183
+ this.refreshStatus()
202
184
  } catch (e: any) {
203
- this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`);
185
+ this.errorLog(`failed to retrieve initial values and update Homekit, Error: ${e}`)
204
186
  }
205
187
 
206
- //regisiter webhook event handler if enabled
188
+ // regisiter webhook event handler if enabled
207
189
  try {
208
- this.debugLog('Registering Webhook Event Handler');
209
- this.registerWebhook();
190
+ this.debugLog('Registering Webhook Event Handler')
191
+ this.registerWebhook()
210
192
  } catch (e: any) {
211
- this.errorLog(`failed to registerWebhook, Error: ${e}`);
193
+ this.errorLog(`failed to registerWebhook, Error: ${e}`)
212
194
  }
213
195
 
214
- //regisiter platform BLE event handler if enabled
196
+ // regisiter platform BLE event handler if enabled
215
197
  try {
216
- this.debugLog('Registering Platform BLE Event Handler');
217
- this.registerPlatformBLE();
198
+ this.debugLog('Registering Platform BLE Event Handler')
199
+ this.registerPlatformBLE()
218
200
  } catch (e: any) {
219
- this.errorLog(`failed to registerPlatformBLE, Error: ${e}`);
201
+ this.errorLog(`failed to registerPlatformBLE, Error: ${e}`)
220
202
  }
221
203
 
222
204
  // Start an update interval
223
205
  interval(this.deviceRefreshRate * 1000)
224
206
  .pipe(skipWhile(() => this.blindTiltUpdateInProgress))
225
207
  .subscribe(async () => {
226
- await this.refreshStatus();
227
- });
208
+ await this.refreshStatus()
209
+ })
228
210
 
229
211
  // update slide progress
230
212
  interval(this.deviceUpdateRate * 1000)
231
213
  .pipe(skipWhile(() => !this.blindTiltMoving))
232
214
  .subscribe(async () => {
233
215
  if (this.WindowCovering.PositionState === this.hap.Characteristic.PositionState.STOPPED) {
234
- return;
216
+ return
235
217
  }
236
- this.debugLog(`Refresh Status When Moving, PositionState: ${this.WindowCovering.PositionState}`);
237
- await this.refreshStatus();
238
- });
218
+ this.debugLog(`Refresh Status When Moving, PositionState: ${this.WindowCovering.PositionState}`)
219
+ await this.refreshStatus()
220
+ })
239
221
 
240
222
  // Watch for BlindTilt change events
241
223
  // We put in a debounce of 100ms so we don't make duplicate calls
242
224
  this.doBlindTiltUpdate
243
225
  .pipe(
244
226
  tap(() => {
245
- this.blindTiltUpdateInProgress = true;
227
+ this.blindTiltUpdateInProgress = true
246
228
  }),
247
229
  debounceTime(this.devicePushRate * 1000),
248
230
  )
249
231
  .subscribe(async () => {
250
232
  try {
251
- await this.pushChanges();
233
+ await this.pushChanges()
252
234
  } catch (e: any) {
253
- await this.apiError(e);
254
- await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
235
+ await this.apiError(e)
236
+ await this.errorLog(`failed pushChanges with ${device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
255
237
  }
256
- this.blindTiltUpdateInProgress = false;
257
- });
238
+ this.blindTiltUpdateInProgress = false
239
+ })
258
240
  }
259
241
 
260
242
  /**
261
243
  * Parse the device status from the SwitchBotBLE API
262
244
  */
263
245
  async BLEparseStatus(): Promise<void> {
264
- await this.debugLog('BLEparseStatus');
265
- await this.debugLog(`(direction, slidePosition, battery, version) = BLE:(${this.serviceData.tilt}, ${this.serviceData.tilt},`
266
- + ` ${this.serviceData.battery}, ${this.accessory.context.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle},`
267
- + ` ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
246
+ await this.debugLog('BLEparseStatus')
247
+ await this.debugLog(`(direction, slidePosition, battery, version) = BLE:(${this.serviceData.tilt}, ${this.serviceData.tilt}, ${this.serviceData.battery}, ${this.accessory.context.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`)
268
248
 
269
249
  // CurrentPosition
270
- this.WindowCovering.CurrentPosition = 100 - Number(this.serviceData.tilt);
271
- await this.setMinMax();
272
- await this.debugLog(`CurrentPosition ${this.WindowCovering.CurrentPosition}`);
250
+ this.WindowCovering.CurrentPosition = 100 - Number(this.serviceData.tilt)
251
+ await this.setMinMax()
252
+ await this.debugLog(`CurrentPosition ${this.WindowCovering.CurrentPosition}`)
273
253
  if (this.setNewTarget) {
274
- await this.infoLog('Checking Status ...');
254
+ await this.infoLog('Checking Status ...')
275
255
  }
276
256
  if (this.setNewTarget && this.serviceData.inMotion) {
277
- this.blindTiltMoving = true;
278
- await this.setMinMax();
257
+ this.blindTiltMoving = true
258
+ await this.setMinMax()
279
259
  if (Number(this.WindowCovering.TargetPosition) > this.WindowCovering.CurrentPosition) {
280
- await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
281
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
282
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
283
- await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
260
+ await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
261
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING
262
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
263
+ await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`)
284
264
  } else if (Number(this.WindowCovering.TargetPosition) < this.WindowCovering.CurrentPosition) {
285
- await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
286
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
287
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
288
- await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
265
+ await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
266
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING
267
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
268
+ await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`)
289
269
  } else {
290
- await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
291
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
292
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
293
- await this.debugLog('Stopped, PositionState', this.WindowCovering.PositionState);
270
+ await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
271
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED
272
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
273
+ await this.debugLog('Stopped, PositionState', this.WindowCovering.PositionState)
294
274
  }
295
275
  } else {
296
- this.blindTiltMoving = false;
297
- await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
298
- this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition;
299
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
300
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
276
+ this.blindTiltMoving = false
277
+ await this.debugLog(`Standby, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
278
+ this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition
279
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED
280
+ await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`)
301
281
  }
302
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition},`
303
- + ` PositionState: ${this.WindowCovering.PositionState}`);
282
+ await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState}`)
304
283
 
305
284
  // CurrentAmbientLightLevel
306
285
  if (!this.device.blindTilt?.hide_lightsensor && this.LightSensor?.Service) {
307
- const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
308
- const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
309
- const spaceBetweenLevels = 9;
310
-
286
+ const set_minLux = this.device.blindTilt?.set_minLux ?? 1
287
+ const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001
288
+ const spaceBetweenLevels = 9
311
289
 
312
- await this.getLightLevel(this.serviceData.lightLevel, set_minLux, set_maxLux, spaceBetweenLevels);
313
- await this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`);
290
+ await this.getLightLevel(this.serviceData.lightLevel, set_minLux, set_maxLux, spaceBetweenLevels)
291
+ await this.debugLog(`LightLevel: ${this.serviceData.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor!.CurrentAmbientLightLevel}`)
314
292
  }
315
293
 
316
294
  // BatteryLevel
317
- this.Battery.BatteryLevel = this.serviceData.battery;
318
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
295
+ this.Battery.BatteryLevel = this.serviceData.battery
296
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
319
297
 
320
298
  // StatusLowBattery
321
299
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
322
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
323
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
300
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
301
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
302
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
324
303
  };
325
304
 
326
305
  /**
327
306
  * Parse the device status from the SwitchBot OpenAPI
328
307
  */
329
308
  async openAPIparseStatus(): Promise<void> {
330
- await this.debugLog('openAPIparseStatus');
331
- await this.debugLog(`(direction, slidePosition, battery, version) = OpenAPI:(${this.deviceStatus.direction}, ${this.deviceStatus.slidePosition},`
332
- + ` ${this.deviceStatus.battery}, ${this.deviceStatus.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle},`
333
- + ` ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
309
+ await this.debugLog('openAPIparseStatus')
310
+ await this.debugLog(`(direction, slidePosition, battery, version) = OpenAPI:(${this.deviceStatus.direction}, ${this.deviceStatus.slidePosition}, ${this.deviceStatus.battery}, ${this.deviceStatus.version}), current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`)
334
311
 
335
312
  // CurrentPosition
336
- await this.getCurrentPosttionDirection(this.deviceStatus.direction, this.deviceStatus.slidePosition);
313
+ await this.getCurrentPosttionDirection(this.deviceStatus.direction, this.deviceStatus.slidePosition)
337
314
 
338
315
  if (!this.device.blindTilt?.hide_lightsensor && this.LightSensor?.Service) {
339
- const set_minLux = this.device.blindTilt?.set_minLux ?? 1;
340
- const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001;
341
- const lightLevel = this.deviceStatus.lightLevel === 'bright' ? set_maxLux : set_minLux;
342
- this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2);
343
- await this.debugLog(`LightLevel: ${this.deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`);
316
+ const set_minLux = this.device.blindTilt?.set_minLux ?? 1
317
+ const set_maxLux = this.device.blindTilt?.set_maxLux ?? 6001
318
+ const lightLevel = this.deviceStatus.lightLevel === 'bright' ? set_maxLux : set_minLux
319
+ this.LightSensor.CurrentAmbientLightLevel = await this.getLightLevel(lightLevel, set_minLux, set_maxLux, 2)
320
+ await this.debugLog(`LightLevel: ${this.deviceStatus.lightLevel}, CurrentAmbientLightLevel: ${this.LightSensor.CurrentAmbientLightLevel}`)
344
321
  }
345
322
 
346
323
  // BatteryLevel
347
- this.Battery.BatteryLevel = this.deviceStatus.battery;
348
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
324
+ this.Battery.BatteryLevel = this.deviceStatus.battery
325
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
349
326
 
350
327
  // StatusLowBattery
351
328
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
352
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
353
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
329
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
330
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
331
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
354
332
 
355
333
  // Firmware Version
356
- const version = this.deviceStatus.version.toString();
357
- await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`);
358
- let deviceVersion: string;
334
+ const version = this.deviceStatus.version.toString()
335
+ await this.debugLog(`Firmware Version: ${version.replace(/^V|-.*$/g, '')}`)
336
+ let deviceVersion: string
359
337
  if (version?.includes('.') === false) {
360
- const replace = version?.replace(/^V|-.*$/g, '');
361
- const match = replace?.match(/.{1,1}/g);
362
- const blindTiltVersion = match?.join('.') ?? '0.0.0';
363
- deviceVersion = blindTiltVersion;
338
+ const replace = version?.replace(/^V|-.*$/g, '')
339
+ const match = replace?.match(/./g)
340
+ const blindTiltVersion = match?.join('.') ?? '0.0.0'
341
+ deviceVersion = blindTiltVersion
364
342
  } else {
365
- deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0';
343
+ deviceVersion = version.replace(/^V|-.*$/g, '') ?? '0.0.0'
366
344
  }
367
345
  this.accessory
368
346
  .getService(this.hap.Service.AccessoryInformation)!
369
347
  .setCharacteristic(this.hap.Characteristic.HardwareRevision, deviceVersion)
370
348
  .setCharacteristic(this.hap.Characteristic.FirmwareRevision, deviceVersion)
371
349
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
372
- .updateValue(deviceVersion);
373
- this.accessory.context.version = deviceVersion;
374
- await this.debugLog(`version: ${this.accessory.context.version}`);
350
+ .updateValue(deviceVersion)
351
+ this.accessory.context.version = deviceVersion
352
+ await this.debugLog(`version: ${this.accessory.context.version}`)
375
353
  }
376
354
 
377
355
  async parseStatusWebhook(): Promise<void> {
378
- await this.debugLog('parseStatusWebhook');
379
- await this.debugLog(`(slidePosition, battery, version) = Webhook:(${this.webhookContext.direction}, ${this.webhookContext.slidePosition},`
380
- + ` ${this.webhookContext.battery}, ${this.webhookContext.version}, current:(${this.WindowCovering.CurrentHorizontalTiltAngle},`
381
- + ` ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`);
356
+ await this.debugLog('parseStatusWebhook')
357
+ await this.debugLog(`(slidePosition, battery, version) = Webhook:(${this.webhookContext.direction}, ${this.webhookContext.slidePosition}, ${this.webhookContext.battery}, ${this.webhookContext.version}, current:(${this.WindowCovering.CurrentHorizontalTiltAngle}, ${this.WindowCovering.CurrentPosition}, ${this.Battery.BatteryLevel}, ${this.accessory.context.version})`)
382
358
  // CurrentPosition and CurrentHorizontalTiltAngle
383
- await this.getCurrentPosttionDirection(this.webhookContext.direction, this.webhookContext.slidePosition);
359
+ await this.getCurrentPosttionDirection(this.webhookContext.direction, this.webhookContext.slidePosition)
384
360
  // BatteryLevel
385
- this.Battery.BatteryLevel = this.webhookContext.battery;
386
- await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`);
361
+ this.Battery.BatteryLevel = this.webhookContext.battery
362
+ await this.debugLog(`BatteryLevel: ${this.Battery.BatteryLevel}`)
387
363
  // StatusLowBattery
388
364
  this.Battery.StatusLowBattery = this.Battery.BatteryLevel < 10
389
- ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL;
390
- await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`);
365
+ ? this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_LOW
366
+ : this.hap.Characteristic.StatusLowBattery.BATTERY_LEVEL_NORMAL
367
+ await this.debugLog(`StatusLowBattery: ${this.Battery.StatusLowBattery}`)
391
368
  // Firmware Version
392
- const deviceVersion = this.webhookContext.version.replace(/^V|-.*$/g, '') ?? '0.0.0';
369
+ const deviceVersion = this.webhookContext.version.replace(/^V|-.*$/g, '') ?? '0.0.0'
393
370
  this.accessory
394
371
  .getService(this.hap.Service.AccessoryInformation)!
395
372
  .setCharacteristic(this.hap.Characteristic.HardwareRevision, deviceVersion)
396
373
  .setCharacteristic(this.hap.Characteristic.FirmwareRevision, deviceVersion)
397
374
  .getCharacteristic(this.hap.Characteristic.FirmwareRevision)
398
- .updateValue(deviceVersion);
399
- this.accessory.context.version = deviceVersion;
400
- await this.debugSuccessLog(`version: ${this.accessory.context.version}`);
375
+ .updateValue(deviceVersion)
376
+ this.accessory.context.version = deviceVersion
377
+ await this.debugSuccessLog(`version: ${this.accessory.context.version}`)
401
378
  }
402
379
 
403
380
  /**
@@ -405,128 +382,128 @@ export class BlindTilt extends deviceBase {
405
382
  */
406
383
  async refreshStatus(): Promise<void> {
407
384
  if (!this.device.enableCloudService && this.OpenAPI) {
408
- await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`);
385
+ await this.errorLog(`refreshStatus enableCloudService: ${this.device.enableCloudService}`)
409
386
  } else if (this.BLE) {
410
- await this.BLERefreshStatus();
387
+ await this.BLERefreshStatus()
411
388
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
412
- await this.openAPIRefreshStatus();
389
+ await this.openAPIRefreshStatus()
413
390
  } else {
414
- await this.offlineOff();
415
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`);
391
+ await this.offlineOff()
392
+ await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, refreshStatus will not happen.`)
416
393
  }
417
394
  }
418
395
 
419
396
  async BLERefreshStatus(): Promise<void> {
420
- await this.debugLog('BLERefreshStatus');
421
- const switchbot = await this.switchbotBLE();
397
+ await this.debugLog('BLERefreshStatus')
398
+ const switchbot = await this.switchbotBLE()
422
399
  if (switchbot === undefined) {
423
- await this.BLERefreshConnection(switchbot);
400
+ await this.BLERefreshConnection(switchbot)
424
401
  } else {
425
402
  // Start to monitor advertisement packets
426
403
  (async () => {
427
404
  // Start to monitor advertisement packets
428
- const serviceData = await this.monitorAdvertisementPackets(switchbot) as blindTiltServiceData;
405
+ const serviceData = await this.monitorAdvertisementPackets(switchbot) as blindTiltServiceData
429
406
  // Update HomeKit
430
407
  if (serviceData.model === SwitchBotBLEModel.BlindTilt && serviceData.modelName === SwitchBotBLEModelName.BlindTilt) {
431
- this.serviceData = serviceData;
432
- await this.BLEparseStatus();
433
- await this.updateHomeKitCharacteristics();
408
+ this.serviceData = serviceData
409
+ await this.BLEparseStatus()
410
+ await this.updateHomeKitCharacteristics()
434
411
  } else {
435
- await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`);
436
- await this.BLERefreshConnection(switchbot);
412
+ await this.errorLog(`failed to get serviceData, serviceData: ${serviceData}`)
413
+ await this.BLERefreshConnection(switchbot)
437
414
  }
438
- })();
415
+ })()
439
416
  }
440
417
  }
441
418
 
442
419
  async registerPlatformBLE(): Promise<void> {
443
- await this.debugLog('registerPlatformBLE');
420
+ await this.debugLog('registerPlatformBLE')
444
421
  if (this.config.options?.BLE) {
445
- await this.debugLog('is listening to Platform BLE.');
446
- this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase();
447
- await this.debugLog(`bleMac: ${this.device.bleMac}`);
422
+ await this.debugLog('is listening to Platform BLE.')
423
+ this.device.bleMac = this.device.deviceId!.match(/.{1,2}/g)!.join(':').toLowerCase()
424
+ await this.debugLog(`bleMac: ${this.device.bleMac}`)
448
425
  this.platform.bleEventHandler[this.device.bleMac] = async (context: blindTiltServiceData) => {
449
426
  try {
450
- await this.debugLog(`received BLE: ${JSON.stringify(context)}`);
451
- this.serviceData = context;
452
- await this.BLEparseStatus();
453
- await this.updateHomeKitCharacteristics();
427
+ await this.debugLog(`received BLE: ${JSON.stringify(context)}`)
428
+ this.serviceData = context
429
+ await this.BLEparseStatus()
430
+ await this.updateHomeKitCharacteristics()
454
431
  } catch (e: any) {
455
- await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`);
432
+ await this.errorLog(`failed to handle BLE. Received: ${JSON.stringify(context)} Error: ${e}`)
456
433
  }
457
- };
434
+ }
458
435
  } else {
459
- await this.debugLog('is not listening to Platform BLE');
436
+ await this.debugLog('is not listening to Platform BLE')
460
437
  }
461
438
  }
462
439
 
463
440
  async openAPIRefreshStatus(): Promise<void> {
464
- await this.debugLog('openAPIRefreshStatus');
441
+ await this.debugLog('openAPIRefreshStatus')
465
442
  try {
466
- const { body, statusCode } = await this.deviceRefreshStatus();
467
- const deviceStatus: any = await body.json();
468
- await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);;
443
+ const { body, statusCode } = await this.deviceRefreshStatus()
444
+ const deviceStatus: any = await body.json()
445
+ await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
469
446
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
470
- await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
471
- this.deviceStatus = deviceStatus.body;
472
- await this.openAPIparseStatus();
473
- await this.updateHomeKitCharacteristics();
447
+ await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
448
+ this.deviceStatus = deviceStatus.body
449
+ await this.openAPIparseStatus()
450
+ await this.updateHomeKitCharacteristics()
474
451
  } else {
475
- await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
476
- await this.debugWarnLog(statusCode, deviceStatus);
452
+ await this.debugWarnLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
453
+ await this.debugWarnLog(statusCode, deviceStatus)
477
454
  }
478
455
  } catch (e: any) {
479
- await this.apiError(e);
480
- await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
456
+ await this.apiError(e)
457
+ await this.errorLog(`failed openAPIRefreshStatus with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
481
458
  }
482
459
  }
483
460
 
484
461
  async registerWebhook(): Promise<void> {
485
462
  if (this.device.webhook) {
486
- await this.debugLog('is listening webhook.');
463
+ await this.debugLog('is listening webhook.')
487
464
  this.platform.webhookEventHandler[this.device.deviceId] = async (context: blindTiltWebhookContext) => {
488
465
  try {
489
- await this.debugLog(`received Webhook: ${JSON.stringify(context)}`);
490
- this.webhookContext = context;
491
- await this.parseStatusWebhook();
492
- await this.updateHomeKitCharacteristics();
466
+ await this.debugLog(`received Webhook: ${JSON.stringify(context)}`)
467
+ this.webhookContext = context
468
+ await this.parseStatusWebhook()
469
+ await this.updateHomeKitCharacteristics()
493
470
  } catch (e: any) {
494
- await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`);
471
+ await this.errorLog(`failed to handle webhook. Received: ${JSON.stringify(context)} Error: ${e}`)
495
472
  }
496
- };
473
+ }
497
474
  } else {
498
- await this.debugLog('is not listening webhook.');
475
+ await this.debugLog('is not listening webhook.')
499
476
  }
500
477
  }
501
478
 
502
479
  async pushChanges(): Promise<void> {
503
480
  if (!this.device.enableCloudService && this.OpenAPI) {
504
- await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`);
481
+ await this.errorLog(`pushChanges enableCloudService: ${this.device.enableCloudService}`)
505
482
  } else if (this.BLE) {
506
- await this.BLEpushChanges();
483
+ await this.BLEpushChanges()
507
484
  } else if (this.OpenAPI && this.platform.config.credentials?.token) {
508
- await this.openAPIpushChanges();
485
+ await this.openAPIpushChanges()
509
486
  } else {
510
- await this.offlineOff();
511
- await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`);
487
+ await this.offlineOff()
488
+ await this.debugWarnLog(`Connection Type: ${this.device.connectionType}, pushChanges will not happen.`)
512
489
  }
513
490
  // Refresh the status from the API
514
491
  interval(15000)
515
492
  .pipe(skipWhile(() => this.blindTiltUpdateInProgress))
516
493
  .pipe(take(1))
517
494
  .subscribe(async () => {
518
- await this.refreshStatus();
519
- });
495
+ await this.refreshStatus()
496
+ })
520
497
  }
521
498
 
522
499
  async BLEpushChanges(): Promise<void> {
523
- await this.debugLog('BLEpushChanges');
500
+ await this.debugLog('BLEpushChanges')
524
501
  if (this.WindowCovering.TargetPosition !== this.WindowCovering.CurrentPosition) {
525
- await this.debugLog(`BLEpushChanges On: ${this.WindowCovering.TargetPosition} OnCached: ${this.WindowCovering.CurrentPosition}`);
526
- const switchbot = await this.platform.connectBLE(this.accessory, this.device);
527
- await this.convertBLEAddress();
528
- const { setPositionMode, Mode }: { setPositionMode: number; Mode: string; } = await this.setPerformance();
529
- await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
502
+ await this.debugLog(`BLEpushChanges On: ${this.WindowCovering.TargetPosition} OnCached: ${this.WindowCovering.CurrentPosition}`)
503
+ const switchbot = await this.platform.connectBLE(this.accessory, this.device)
504
+ await this.convertBLEAddress()
505
+ const { setPositionMode, Mode }: { setPositionMode: number, Mode: string } = await this.setPerformance()
506
+ await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`)
530
507
  if (switchbot !== false) {
531
508
  switchbot
532
509
  .discover({ model: this.device.bleModel, quick: true, id: this.device.bleMac })
@@ -534,82 +511,78 @@ export class BlindTilt extends deviceBase {
534
511
  return await this.retryBLE({
535
512
  max: await this.maxRetryBLE(),
536
513
  fn: async () => {
537
- return await device_list[0].runToPos(100 - Number(this.WindowCovering.TargetPosition), setPositionMode);
514
+ return await device_list[0].runToPos(100 - Number(this.WindowCovering.TargetPosition), setPositionMode)
538
515
  },
539
- });
516
+ })
540
517
  })
541
518
  .then(async () => {
542
- await this.successLog(`TargetPostion: ${this.WindowCovering.TargetPosition} sent over SwitchBot BLE, sent successfully`);
543
- await this.updateHomeKitCharacteristics();
519
+ await this.successLog(`TargetPostion: ${this.WindowCovering.TargetPosition} sent over SwitchBot BLE, sent successfully`)
520
+ await this.updateHomeKitCharacteristics()
544
521
  })
545
522
  .catch(async (e: any) => {
546
- await this.apiError(e);
547
- await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
548
- await this.BLEPushConnection();
549
- });
523
+ await this.apiError(e)
524
+ await this.errorLog(`failed BLEpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
525
+ await this.BLEPushConnection()
526
+ })
550
527
  } else {
551
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
552
- await this.BLEPushConnection();
528
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
529
+ await this.BLEPushConnection()
553
530
  }
554
531
  } else {
555
- await this.debugLog(`No changes (BLEpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition},`
556
- + ` CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
532
+ await this.debugLog(`No changes (BLEpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
557
533
  }
558
534
  }
559
535
 
560
536
  async openAPIpushChanges(): Promise<void> {
561
- await this.debugLog('openAPIpushChanges');
562
- const hasDifferentAndRelevantHorizontalTiltAngle =
563
- this.mappingMode === BlindTiltMappingMode.UseTiltForDirection
564
- && this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle;
537
+ await this.debugLog('openAPIpushChanges')
538
+ const hasDifferentAndRelevantHorizontalTiltAngle
539
+ = this.mappingMode === BlindTiltMappingMode.UseTiltForDirection
540
+ && this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle
565
541
  if (this.WindowCovering.TargetPosition !== this.WindowCovering.CurrentPosition
566
542
  || hasDifferentAndRelevantHorizontalTiltAngle || this.device.disableCaching) {
567
- const [direction, position] = this.mapHomekitValuesToDeviceValues(Number(this.WindowCovering.TargetPosition),
568
- Number(this.WindowCovering.TargetHorizontalTiltAngle));
569
- const { Mode, setPositionMode }: { setPositionMode: number; Mode: string; } = await this.setPerformance();
570
- await this.debugLog(`Pushing ${this.WindowCovering.TargetPosition} (device = ${direction};${position})`);
571
- await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`);
572
- let bodyChange: string;
543
+ const [direction, position] = this.mapHomekitValuesToDeviceValues(Number(this.WindowCovering.TargetPosition), Number(this.WindowCovering.TargetHorizontalTiltAngle))
544
+ const { Mode, setPositionMode }: { setPositionMode: number, Mode: string } = await this.setPerformance()
545
+ await this.debugLog(`Pushing ${this.WindowCovering.TargetPosition} (device = ${direction};${position})`)
546
+ await this.debugLog(`Mode: ${Mode}, setPositionMode: ${setPositionMode}`)
547
+ let bodyChange: string
573
548
  if (position === 100) {
574
549
  bodyChange = JSON.stringify({
575
550
  command: 'fullyOpen',
576
551
  parameter: 'default',
577
552
  commandType: 'command',
578
- });
553
+ })
579
554
  } else if (position === 0) {
580
555
  bodyChange = JSON.stringify({
581
556
  command: direction === 'up' ? 'closeUp' : 'closeDown',
582
557
  parameter: 'default',
583
558
  commandType: 'command',
584
- });
559
+ })
585
560
  } else {
586
561
  bodyChange = JSON.stringify({
587
562
  command: 'setPosition',
588
563
  parameter: `${direction};${position}`,
589
564
  commandType: 'command',
590
- });
565
+ })
591
566
  }
592
- await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`);
567
+ await this.debugLog(`SwitchBot OpenAPI bodyChange: ${JSON.stringify(bodyChange)}`)
593
568
  try {
594
- const { body, statusCode } = await this.pushChangeRequest(bodyChange);
595
- const deviceStatus: any = await body.json();
596
- await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
569
+ const { body, statusCode } = await this.pushChangeRequest(bodyChange)
570
+ const deviceStatus: any = await body.json()
571
+ await this.debugLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
597
572
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
598
- await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`);
599
- await this.updateHomeKitCharacteristics();
573
+ await this.debugSuccessLog(`statusCode: ${statusCode}, deviceStatus: ${JSON.stringify(deviceStatus)}`)
574
+ await this.updateHomeKitCharacteristics()
600
575
  } else {
601
- await this.statusCode(statusCode);
602
- await this.statusCode(deviceStatus.statusCode);
576
+ await this.statusCode(statusCode)
577
+ await this.statusCode(deviceStatus.statusCode)
603
578
  }
604
579
  } catch (e: any) {
605
- await this.apiError(e);
606
- await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`);
580
+ await this.apiError(e)
581
+ await this.errorLog(`failed openAPIpushChanges with ${this.device.connectionType} Connection, Error Message: ${JSON.stringify(e.message)}`)
607
582
  }
608
583
  } else {
609
- await this.debugLog(`No changes (openAPIpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition},`
610
- + ` CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
611
- await this.debugLog(`No changes (openAPIpushChanges), TargetHorizontalTiltAngle: ${this.WindowCovering.TargetHorizontalTiltAngle},`
612
- + ` CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
584
+ await this.debugLog(`No changes (openAPIpushChanges), TargetPosition: ${this.WindowCovering.TargetPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
585
+ await this.debugLog(`No changes (openAPIpushChanges), TargetHorizontalTiltAngle: ${this.WindowCovering.TargetHorizontalTiltAngle}, CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`)
613
586
  }
614
587
  }
615
588
 
@@ -618,15 +591,15 @@ export class BlindTilt extends deviceBase {
618
591
  */
619
592
  async TargetHorizontalTiltAngleSet(value: CharacteristicValue): Promise<void> {
620
593
  if (this.WindowCovering.TargetHorizontalTiltAngle !== this.accessory.context.TargetHorizontalTiltAngle) {
621
- await this.debugLog(`Set TargetHorizontalTiltAngle: ${value}`);
594
+ await this.debugLog(`Set TargetHorizontalTiltAngle: ${value}`)
622
595
  } else {
623
- await this.debugLog(`No changes, TargetHorizontalTiltAngle: ${value}`);
596
+ await this.debugLog(`No changes, TargetHorizontalTiltAngle: ${value}`)
624
597
  }
625
598
 
626
- //value = value < 0 ? -90 : 90;
627
- this.WindowCovering.TargetHorizontalTiltAngle = value;
628
- await this.mqtt('TargetHorizontalTiltAngle', this.WindowCovering.TargetHorizontalTiltAngle);
629
- await this.startUpdatingBlindTiltIfNeeded();
599
+ // value = value < 0 ? -90 : 90;
600
+ this.WindowCovering.TargetHorizontalTiltAngle = value
601
+ await this.mqtt('TargetHorizontalTiltAngle', this.WindowCovering.TargetHorizontalTiltAngle)
602
+ await this.startUpdatingBlindTiltIfNeeded()
630
603
  }
631
604
 
632
605
  /**
@@ -634,172 +607,164 @@ export class BlindTilt extends deviceBase {
634
607
  */
635
608
  async TargetPositionSet(value: CharacteristicValue): Promise<void> {
636
609
  if (this.WindowCovering.TargetPosition !== this.accessory.context.TargetPosition) {
637
- await this.debugLog(`Set TargetPosition: ${value}`);
610
+ await this.debugLog(`Set TargetPosition: ${value}`)
638
611
  } else {
639
- await this.debugLog(`No changes, TargetPosition: ${value}`);
612
+ await this.debugLog(`No changes, TargetPosition: ${value}`)
640
613
  }
641
614
 
642
- this.WindowCovering.TargetPosition = value;
643
- await this.mqtt('TargetPosition', this.WindowCovering.TargetPosition);
644
- await this.startUpdatingBlindTiltIfNeeded();
615
+ this.WindowCovering.TargetPosition = value
616
+ await this.mqtt('TargetPosition', this.WindowCovering.TargetPosition)
617
+ await this.startUpdatingBlindTiltIfNeeded()
645
618
  }
646
619
 
647
620
  async startUpdatingBlindTiltIfNeeded(): Promise<void> {
648
- await this.setMinMax();
649
- await this.debugLog('setMinMax');
621
+ await this.setMinMax()
622
+ await this.debugLog('setMinMax')
650
623
  if (this.WindowCovering.TargetPosition > this.WindowCovering.CurrentPosition
651
624
  || this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle) {
652
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
653
- this.setNewTarget = true;
654
- await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
625
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING
626
+ this.setNewTarget = true
627
+ await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
655
628
  } else if (this.WindowCovering.TargetPosition < this.WindowCovering.CurrentPosition) {
656
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
657
- this.setNewTarget = true;
658
- await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
629
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING
630
+ this.setNewTarget = true
631
+ await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
659
632
  } else {
660
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
661
- this.setNewTarget = false;
662
- await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
633
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED
634
+ this.setNewTarget = false
635
+ await this.debugLog(`value: ${this.WindowCovering.CurrentPosition}, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
663
636
  }
664
- this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.WindowCovering.PositionState);
665
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
637
+ this.WindowCovering.Service.setCharacteristic(this.hap.Characteristic.PositionState, this.WindowCovering.PositionState)
638
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
666
639
 
667
640
  /**
668
641
  * If Blind Tilt movement time is short, the moving flag from backend is always false.
669
642
  * The minimum time depends on the network control latency.
670
643
  */
671
- clearTimeout(this.setNewTargetTimer);
672
- await this.debugLog(`deviceUpdateRate: ${this.deviceUpdateRate}`);
644
+ clearTimeout(this.setNewTargetTimer)
645
+ await this.debugLog(`deviceUpdateRate: ${this.deviceUpdateRate}`)
673
646
  if (this.setNewTarget) {
674
647
  this.setNewTargetTimer = setTimeout(async () => {
675
- await this.debugLog(`setNewTarget ${this.setNewTarget} timeout`);
676
- this.setNewTarget = false;
677
- }, this.deviceUpdateRate * 1000);
648
+ await this.debugLog(`setNewTarget ${this.setNewTarget} timeout`)
649
+ this.setNewTarget = false
650
+ }, this.deviceUpdateRate * 1000)
678
651
  }
679
- this.doBlindTiltUpdate.next();
652
+ this.doBlindTiltUpdate.next()
680
653
  }
681
654
 
682
655
  async updateHomeKitCharacteristics(): Promise<void> {
683
- await this.setMinMax();
656
+ await this.setMinMax()
684
657
  // CurrentHorizontalTiltAngle
685
658
  if (this.mappingMode === BlindTiltMappingMode.UseTiltForDirection) {
686
- await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.CurrentHorizontalTiltAngle,
687
- this.WindowCovering.CurrentHorizontalTiltAngle, 'CurrentHorizontalTiltAngle');
659
+ await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.CurrentHorizontalTiltAngle, this.WindowCovering.CurrentHorizontalTiltAngle, 'CurrentHorizontalTiltAngle')
688
660
  }
689
661
  // CurrentPosition
690
- await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.CurrentPosition,
691
- this.WindowCovering.CurrentPosition, 'CurrentPosition');
662
+ await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.CurrentPosition, this.WindowCovering.CurrentPosition, 'CurrentPosition')
692
663
  // PositionState
693
- await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.PositionState,
694
- this.WindowCovering.PositionState, 'PositionState');
664
+ await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.PositionState, this.WindowCovering.PositionState, 'PositionState')
695
665
  // TargetPosition
696
- await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.TargetPosition,
697
- this.WindowCovering.TargetPosition, 'TargetPosition');
666
+ await this.updateCharacteristic(this.WindowCovering.Service, this.hap.Characteristic.TargetPosition, this.WindowCovering.TargetPosition, 'TargetPosition')
698
667
  // CurrentAmbientLightLevel
699
668
  if (!this.device.blindTilt?.hide_lightsensor && this.LightSensor?.Service) {
700
- const history = { time: Math.round(new Date().valueOf() / 1000), lux: this.LightSensor.CurrentAmbientLightLevel };
701
- await this.updateCharacteristic(this.LightSensor?.Service, this.hap.Characteristic.CurrentAmbientLightLevel,
702
- this.LightSensor?.CurrentAmbientLightLevel, 'CurrentAmbientLightLevel', history);
669
+ const history = { time: Math.round(new Date().valueOf() / 1000), lux: this.LightSensor.CurrentAmbientLightLevel }
670
+ await this.updateCharacteristic(this.LightSensor?.Service, this.hap.Characteristic.CurrentAmbientLightLevel, this.LightSensor?.CurrentAmbientLightLevel, 'CurrentAmbientLightLevel', history)
703
671
  }
704
672
  // BatteryLevel
705
- await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel,
706
- this.Battery.BatteryLevel, 'BatteryLevel');
673
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.BatteryLevel, this.Battery.BatteryLevel, 'BatteryLevel')
707
674
  // StatusLowBattery
708
- await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery,
709
- this.Battery.StatusLowBattery, 'StatusLowBattery');
675
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.StatusLowBattery, this.Battery.StatusLowBattery, 'StatusLowBattery')
710
676
  // ChargingState
711
- await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.ChargingState,
712
- this.Battery.ChargingState, 'ChargingState');
677
+ await this.updateCharacteristic(this.Battery.Service, this.hap.Characteristic.ChargingState, this.Battery.ChargingState, 'ChargingState')
713
678
  }
714
679
 
715
680
  async BLEPushConnection() {
716
681
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
717
- await this.warnLog('Using OpenAPI Connection to Push Changes');
718
- await this.openAPIpushChanges();
682
+ await this.warnLog('Using OpenAPI Connection to Push Changes')
683
+ await this.openAPIpushChanges()
719
684
  }
720
685
  }
721
686
 
722
687
  async BLERefreshConnection(switchbot: any): Promise<void> {
723
- await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`);
688
+ await this.errorLog(`wasn't able to establish BLE Connection, node-switchbot: ${switchbot}`)
724
689
  if (this.platform.config.credentials?.token && this.device.connectionType === 'BLE/OpenAPI') {
725
- await this.warnLog('Using OpenAPI Connection to Refresh Status');
726
- await this.openAPIRefreshStatus();
690
+ await this.warnLog('Using OpenAPI Connection to Refresh Status')
691
+ await this.openAPIRefreshStatus()
727
692
  }
728
693
  }
729
694
 
730
695
  async setPerformance() {
731
- let setPositionMode: number;
732
- let Mode: string;
696
+ let setPositionMode: number
697
+ let Mode: string
733
698
  if (Number(this.WindowCovering.TargetPosition) > 50) {
734
699
  if (this.device.blindTilt?.setOpenMode === '1') {
735
- setPositionMode = 1;
736
- Mode = 'Silent Mode';
700
+ setPositionMode = 1
701
+ Mode = 'Silent Mode'
737
702
  } else if (this.device.blindTilt?.setOpenMode === '0') {
738
- setPositionMode = 0;
739
- Mode = 'Performance Mode';
703
+ setPositionMode = 0
704
+ Mode = 'Performance Mode'
740
705
  } else {
741
- setPositionMode = 0;
742
- Mode = 'Default Mode';
706
+ setPositionMode = 0
707
+ Mode = 'Default Mode'
743
708
  }
744
709
  } else {
745
710
  if (this.device.blindTilt?.setCloseMode === '1') {
746
- setPositionMode = 1;
747
- Mode = 'Silent Mode';
711
+ setPositionMode = 1
712
+ Mode = 'Silent Mode'
748
713
  } else if (this.device.blindTilt?.setOpenMode === '0') {
749
- setPositionMode = 0;
750
- Mode = 'Performance Mode';
714
+ setPositionMode = 0
715
+ Mode = 'Performance Mode'
751
716
  } else {
752
- setPositionMode = 0;
753
- Mode = 'Default Mode';
717
+ setPositionMode = 0
718
+ Mode = 'Default Mode'
754
719
  }
755
720
  }
756
- return { setPositionMode, Mode };
721
+ return { setPositionMode, Mode }
757
722
  }
758
723
 
759
724
  async setMinMax(): Promise<void> {
760
725
  if (this.device.blindTilt?.set_min) {
761
726
  if (Number(this.WindowCovering.CurrentPosition) <= this.device.blindTilt?.set_min) {
762
- this.WindowCovering.CurrentPosition = 0;
727
+ this.WindowCovering.CurrentPosition = 0
763
728
  }
764
729
  }
765
730
  if (this.device.blindTilt?.set_max) {
766
731
  if (Number(this.WindowCovering.CurrentPosition) >= this.device.blindTilt?.set_max) {
767
- this.WindowCovering.CurrentPosition = 100;
732
+ this.WindowCovering.CurrentPosition = 100
768
733
  }
769
734
  }
770
735
  if (this.device.history) {
771
- const motion = this.accessory.getService(this.hap.Service.MotionSensor);
772
- const state = Number(this.WindowCovering.CurrentPosition) > 0 ? 1 : 0;
773
- motion?.updateCharacteristic(this.hap.Characteristic.MotionDetected, state);
736
+ const motion = this.accessory.getService(this.hap.Service.MotionSensor)
737
+ const state = Number(this.WindowCovering.CurrentPosition) > 0 ? 1 : 0
738
+ motion?.updateCharacteristic(this.hap.Characteristic.MotionDetected, state)
774
739
  }
775
740
 
776
741
  if (this.mappingMode === BlindTiltMappingMode.UseTiltForDirection) {
777
- this.WindowCovering.CurrentHorizontalTiltAngle = Number(this.WindowCovering.CurrentHorizontalTiltAngle) < 0 ? -90 : 90;
742
+ this.WindowCovering.CurrentHorizontalTiltAngle = Number(this.WindowCovering.CurrentHorizontalTiltAngle) < 0 ? -90 : 90
778
743
  }
779
744
  }
780
745
 
781
746
  async offlineOff(): Promise<void> {
782
747
  if (this.device.offline) {
783
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100);
784
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED);
785
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100);
786
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentHorizontalTiltAngle, 90);
787
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetHorizontalTiltAngle, 90);
748
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, 100)
749
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, this.hap.Characteristic.PositionState.STOPPED)
750
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, 100)
751
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentHorizontalTiltAngle, 90)
752
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetHorizontalTiltAngle, 90)
788
753
  }
789
754
  }
790
755
 
791
756
  async apiError(e: any): Promise<void> {
792
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e);
793
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e);
794
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e);
795
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentHorizontalTiltAngle, e);
796
- this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetHorizontalTiltAngle, e);
797
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e);
798
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e);
799
- this.Battery.Service.updateCharacteristic(this.hap.Characteristic.ChargingState, e);
757
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentPosition, e)
758
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.PositionState, e)
759
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetPosition, e)
760
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.CurrentHorizontalTiltAngle, e)
761
+ this.WindowCovering.Service.updateCharacteristic(this.hap.Characteristic.TargetHorizontalTiltAngle, e)
762
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.BatteryLevel, e)
763
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.StatusLowBattery, e)
764
+ this.Battery.Service.updateCharacteristic(this.hap.Characteristic.ChargingState, e)
800
765
  if (!this.device.blindTilt?.hide_lightsensor && this.LightSensor?.Service) {
801
- this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, e);
802
- this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.StatusActive, e);
766
+ this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.CurrentAmbientLightLevel, e)
767
+ this.LightSensor.Service.updateCharacteristic(this.hap.Characteristic.StatusActive, e)
803
768
  }
804
769
  }
805
770
 
@@ -807,60 +772,58 @@ export class BlindTilt extends deviceBase {
807
772
  direction: blindTiltStatus['direction'] | blindTiltWebhookContext['direction'],
808
773
  slidePosition: blindTiltStatus['slidePosition'] | blindTiltWebhookContext['slidePosition'],
809
774
  ) {
810
- const [homekitPosition, homekitTiltAngle] = this.mapDeviceValuesToHomekitValues(Number(slidePosition),
811
- String(direction));
812
- await this.debugLog(`Slide Position: ${slidePosition}`);
813
- await this.debugLog(`Homekit Position: ${homekitPosition}`);
775
+ const [homekitPosition, homekitTiltAngle] = this.mapDeviceValuesToHomekitValues(Number(slidePosition), String(direction))
776
+ await this.debugLog(`Slide Position: ${slidePosition}`)
777
+ await this.debugLog(`Homekit Position: ${homekitPosition}`)
814
778
 
815
- this.WindowCovering.CurrentPosition = homekitPosition;
816
- await this.setMinMax();
817
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
779
+ this.WindowCovering.CurrentPosition = homekitPosition
780
+ await this.setMinMax()
781
+ await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
818
782
 
819
783
  if (homekitTiltAngle) {
820
- this.WindowCovering.CurrentHorizontalTiltAngle = homekitTiltAngle!;
821
- await this.debugLog(`CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`);
784
+ this.WindowCovering.CurrentHorizontalTiltAngle = homekitTiltAngle!
785
+ await this.debugLog(`CurrentHorizontalTiltAngle: ${this.WindowCovering.CurrentHorizontalTiltAngle}`)
822
786
  }
823
787
 
824
788
  if (this.setNewTarget) {
825
- this.blindTiltMoving = true;
826
- await this.infoLog('Checking Status ...');
827
- await this.setMinMax();
789
+ this.blindTiltMoving = true
790
+ await this.infoLog('Checking Status ...')
791
+ await this.setMinMax()
828
792
  if (this.WindowCovering.TargetPosition > this.WindowCovering.CurrentPosition
829
793
  || (homekitTiltAngle && this.WindowCovering.TargetHorizontalTiltAngle !== this.WindowCovering.CurrentHorizontalTiltAngle)) {
830
- await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
831
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING;
832
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
833
- await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`);
794
+ await this.debugLog(`Closing, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
795
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.INCREASING
796
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
797
+ await this.debugLog(`Increasing, PositionState: ${this.WindowCovering.PositionState}`)
834
798
  } else if (this.WindowCovering.TargetPosition < this.WindowCovering.CurrentPosition) {
835
- await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
836
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING;
837
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
838
- await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`);
799
+ await this.debugLog(`Opening, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
800
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.DECREASING
801
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
802
+ await this.debugLog(`Decreasing, PositionState: ${this.WindowCovering.PositionState}`)
839
803
  } else {
840
- await this.debugLog(`Standby because reached position, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
841
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
842
- this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState);
843
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
804
+ await this.debugLog(`Standby because reached position, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
805
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED
806
+ this.WindowCovering.Service.getCharacteristic(this.hap.Characteristic.PositionState).updateValue(this.WindowCovering.PositionState)
807
+ await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`)
844
808
  }
845
809
  } else {
846
- this.blindTiltMoving = false;
847
- await this.debugLog(`Standby because device not moving, CurrentPosition: ${this.WindowCovering.CurrentPosition}`);
848
- this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition;
810
+ this.blindTiltMoving = false
811
+ await this.debugLog(`Standby because device not moving, CurrentPosition: ${this.WindowCovering.CurrentPosition}`)
812
+ this.WindowCovering.TargetPosition = this.WindowCovering.CurrentPosition
849
813
  if (homekitTiltAngle) {
850
- this.WindowCovering.TargetHorizontalTiltAngle = this.WindowCovering.CurrentHorizontalTiltAngle;
814
+ this.WindowCovering.TargetHorizontalTiltAngle = this.WindowCovering.CurrentHorizontalTiltAngle
851
815
  }
852
- this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED;
853
- await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`);
816
+ this.WindowCovering.PositionState = this.hap.Characteristic.PositionState.STOPPED
817
+ await this.debugLog(`Stopped, PositionState: ${this.WindowCovering.PositionState}`)
854
818
  }
855
- await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition},`
856
- + ` PositionState: ${this.WindowCovering.PositionState}`);
819
+ await this.debugLog(`CurrentPosition: ${this.WindowCovering.CurrentPosition}, TargetPosition: ${this.WindowCovering.TargetPosition}, PositionState: ${this.WindowCovering.PositionState}`)
857
820
  }
858
821
 
859
822
  /**
860
823
  * Maps device values to homekit values
861
824
  *
862
825
  * @param devicePosition the position as reported by the devide
863
- * @param direction the direction as reported by the device
826
+ * @param deviceDirection the direction as reported by the device
864
827
  * @returns [homekit position, homekit tiltAngle]
865
828
  */
866
829
  mapDeviceValuesToHomekitValues(devicePosition: number, deviceDirection: string): [CharacteristicValue, CharacteristicValue?] {
@@ -870,44 +833,44 @@ export class BlindTilt extends deviceBase {
870
833
 
871
834
  // homekit position 0 => closed
872
835
  // homekit position 100 => open
873
- const direction = deviceDirection === 'up' ? 'up' : 'down';
874
- this.debugLog(`Mapping device values to homekit values, devicePostion: ${devicePosition}, deviceDirection: ${direction}`);
836
+ const direction = deviceDirection === 'up' ? 'up' : 'down'
837
+ this.debugLog(`Mapping device values to homekit values, devicePostion: ${devicePosition}, deviceDirection: ${direction}`)
875
838
  switch (this.mappingMode) {
876
839
  case BlindTiltMappingMode.OnlyUp:
877
840
  // we only close upwards, so we see anything that is tilted downwards(<50) as open
878
841
  if (devicePosition < 50) {
879
- return [100, undefined]; // fully open in homekit
842
+ return [100, undefined] // fully open in homekit
880
843
  } else {
881
844
  // we range from 50->100, with 100 being closed, so map to homekit by scaling to 0..100 and then reversing
882
- return [100 - (devicePosition - 50) * 2, undefined];
845
+ return [100 - (devicePosition - 50) * 2, undefined]
883
846
  }
884
847
 
885
848
  case BlindTiltMappingMode.OnlyDown:
886
849
  // we only close downwards, so we see anything that is tilted upwards(>50) as upwards
887
850
  if (devicePosition > 50) {
888
- return [100, undefined]; // fully open in homekit
851
+ return [100, undefined] // fully open in homekit
889
852
  } else {
890
853
  // we range from 0..50 so scale to homekit and then reverse
891
- return [devicePosition * 2, undefined];
854
+ return [devicePosition * 2, undefined]
892
855
  }
893
856
 
894
857
  case BlindTiltMappingMode.DownAndUp:
895
858
  // we close both ways with closed downwards being 0 in homekit and closed upwards in homekit being 100. Open is 50 in homekit
896
- return [devicePosition, undefined];
859
+ return [devicePosition, undefined]
897
860
 
898
861
  case BlindTiltMappingMode.UpAndDown:
899
862
  // we close both ways with closed downwards being 1000 in homekit and closed upwards in homekit being 0. Open is 50 in homekit.,
900
863
  // so we reverse the value
901
- return [100 - devicePosition, undefined];
864
+ return [100 - devicePosition, undefined]
902
865
 
903
866
  case BlindTiltMappingMode.UseTiltForDirection:
904
867
  // we use tilt for direction, so being closed downwards is 0 in homekit with -90 tilt, while being closed upwards is 0 with 90 tilt.
905
868
  if (devicePosition <= 50) {
906
869
  // downwards tilted, so we range from 0..50, with 0 being closed and 50 being open, so scale.
907
- return [devicePosition * 2, -90];
870
+ return [devicePosition * 2, -90]
908
871
  } else {
909
872
  // upwards tilted, so we range from 50..100, with 50 being open and 100 being closed, so scale and rever
910
- return [100 - (devicePosition - 50) * 2, 90];
873
+ return [100 - (devicePosition - 50) * 2, 90]
911
874
  }
912
875
  }
913
876
  }
@@ -916,7 +879,7 @@ export class BlindTilt extends deviceBase {
916
879
  * Maps homekit values to device values
917
880
  *
918
881
  * @param homekitPosition the position as reported by homekit
919
- * @param homekitTiltAngle? the tilt angle as reported by homekit
882
+ * @param homekitTiltAngle the tilt angle as reported by homekit
920
883
  * @returns [device position, device direction]
921
884
  */
922
885
  mapHomekitValuesToDeviceValues(homekitPosition: number, homekitTiltAngle: number): [string, number] {
@@ -931,10 +894,10 @@ export class BlindTilt extends deviceBase {
931
894
  switch (this.mappingMode) {
932
895
  case BlindTiltMappingMode.OnlyUp:
933
896
  // invert
934
- return ['up', homekitPosition];
897
+ return ['up', homekitPosition]
935
898
  case BlindTiltMappingMode.OnlyDown:
936
899
  // invert
937
- return ['down', homekitPosition];
900
+ return ['down', homekitPosition]
938
901
 
939
902
  case BlindTiltMappingMode.DownAndUp:
940
903
  // homekit 0 = downwards closed,
@@ -942,10 +905,10 @@ export class BlindTilt extends deviceBase {
942
905
  // homekit 100 = upwards closed
943
906
  if (homekitPosition <= 50) {
944
907
  // homekit 0..50 -> device 100..0 so scale and invert
945
- return ['down', 100 - homekitPosition * 2];
908
+ return ['down', 100 - homekitPosition * 2]
946
909
  } else {
947
910
  // homekit 50..100 -> device 0..100, so rebase, scale and invert
948
- return ['up', (homekitPosition - 50) * 2];
911
+ return ['up', (homekitPosition - 50) * 2]
949
912
  }
950
913
 
951
914
  case BlindTiltMappingMode.UpAndDown:
@@ -954,10 +917,10 @@ export class BlindTilt extends deviceBase {
954
917
  // homekit 100 = upwards closed
955
918
  if (homekitPosition <= 50) {
956
919
  // homekit 0..50 -> device 0..100 so scale and invert
957
- return ['up', homekitPosition * 2];
920
+ return ['up', homekitPosition * 2]
958
921
  } else {
959
922
  // homekit 50..100 -> device 100...0 so scale
960
- return ['down', 100 - homekitPosition * 2];
923
+ return ['down', 100 - homekitPosition * 2]
961
924
  }
962
925
 
963
926
  case BlindTiltMappingMode.UseTiltForDirection:
@@ -968,11 +931,11 @@ export class BlindTilt extends deviceBase {
968
931
  if (homekitTiltAngle! <= 0) {
969
932
  // downwards
970
933
  // homekit 0..100 -> device 0..100, so invert
971
- return ['down', homekitPosition];
934
+ return ['down', homekitPosition]
972
935
  } else {
973
936
  // upwards
974
937
  // homekit 0..100 -> device 0..100, so invert
975
- return ['up', homekitPosition];
938
+ return ['up', homekitPosition]
976
939
  }
977
940
  }
978
941
  }