@switchbot/homebridge-switchbot 3.7.1-beta.12 → 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 +141 -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 +1281 -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,12 +2,13 @@
2
2
  *
3
3
  * tv.ts: @switchbot/homebridge-switchbot.
4
4
  */
5
- import { irdeviceBase } from './irdevice.js';
5
+ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge'
6
6
 
7
- import type { SwitchBotPlatform } from '../platform.js';
8
- import type { irDevicesConfig } from '../settings.js';
9
- import type { irdevice } from '../types/irdevicelist.js';
10
- import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge';
7
+ import type { SwitchBotPlatform } from '../platform.js'
8
+ import type { irDevicesConfig } from '../settings.js'
9
+ import type { irdevice } from '../types/irdevicelist.js'
10
+
11
+ import { irdeviceBase } from './irdevice.js'
11
12
 
12
13
  /**
13
14
  * Platform Accessory
@@ -17,22 +18,22 @@ import type { CharacteristicValue, PlatformAccessory, Service } from 'homebridge
17
18
  export class TV extends irdeviceBase {
18
19
  // Services
19
20
  private Television: {
20
- Name: CharacteristicValue;
21
- ConfiguredName: CharacteristicValue;
22
- Service: Service;
23
- Active: CharacteristicValue;
24
- ActiveIdentifier: CharacteristicValue;
25
- SleepDiscoveryMode: CharacteristicValue;
26
- RemoteKey: CharacteristicValue;
27
- };
21
+ Name: CharacteristicValue
22
+ ConfiguredName: CharacteristicValue
23
+ Service: Service
24
+ Active: CharacteristicValue
25
+ ActiveIdentifier: CharacteristicValue
26
+ SleepDiscoveryMode: CharacteristicValue
27
+ RemoteKey: CharacteristicValue
28
+ }
28
29
 
29
30
  private TelevisionSpeaker: {
30
- Name: CharacteristicValue;
31
- Service: Service;
32
- Active: CharacteristicValue;
33
- VolumeControlType: CharacteristicValue;
34
- VolumeSelector: CharacteristicValue;
35
- };
31
+ Name: CharacteristicValue
32
+ Service: Service
33
+ Active: CharacteristicValue
34
+ VolumeControlType: CharacteristicValue
35
+ VolumeSelector: CharacteristicValue
36
+ }
36
37
 
37
38
  // Characteristic Values
38
39
 
@@ -41,10 +42,10 @@ export class TV extends irdeviceBase {
41
42
  accessory: PlatformAccessory,
42
43
  device: irdevice & irDevicesConfig,
43
44
  ) {
44
- super(platform, accessory, device);
45
+ super(platform, accessory, device)
45
46
 
46
47
  // Initialize Television Service
47
- accessory.context.Television = accessory.context.Television ?? {};
48
+ accessory.context.Television = accessory.context.Television ?? {}
48
49
  this.Television = {
49
50
  Name: accessory.displayName,
50
51
  ConfiguredName: accessory.displayName,
@@ -53,350 +54,327 @@ export class TV extends irdeviceBase {
53
54
  ActiveIdentifier: accessory.context.ActiveIdentifier ?? 1,
54
55
  SleepDiscoveryMode: accessory.context.SleepDiscoveryMode ?? this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE,
55
56
  RemoteKey: accessory.context.RemoteKey ?? this.hap.Characteristic.RemoteKey.EXIT,
56
- };
57
- accessory.context.Television = this.Television as object;
57
+ }
58
+ accessory.context.Television = this.Television as object
58
59
 
59
60
  switch (device.remoteType) {
60
61
  case 'Speaker':
61
62
  case 'DIY Speaker':
62
- accessory.category = this.hap.Categories.SPEAKER;
63
- break;
63
+ accessory.category = this.hap.Categories.SPEAKER
64
+ break
64
65
  case 'IPTV':
65
66
  case 'DIY IPTV':
66
- accessory.category = this.hap.Categories.TV_STREAMING_STICK;
67
- break;
67
+ accessory.category = this.hap.Categories.TV_STREAMING_STICK
68
+ break
68
69
  case 'DVD':
69
70
  case 'DIY DVD':
70
71
  case 'Set Top Box':
71
72
  case 'DIY Set Top Box':
72
- accessory.category = this.hap.Categories.TV_SET_TOP_BOX;
73
- break;
73
+ accessory.category = this.hap.Categories.TV_SET_TOP_BOX
74
+ break
74
75
  default:
75
- accessory.category = this.hap.Categories.TELEVISION;
76
+ accessory.category = this.hap.Categories.TELEVISION
76
77
  }
77
78
 
78
- this.Television.Service
79
- .setCharacteristic(this.hap.Characteristic.SleepDiscoveryMode, this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE)
80
- .setCharacteristic(this.hap.Characteristic.ConfiguredName, this.Television.ConfiguredName)
81
- .getCharacteristic(this.hap.Characteristic.ConfiguredName);
79
+ this.Television.Service.setCharacteristic(this.hap.Characteristic.SleepDiscoveryMode, this.hap.Characteristic.SleepDiscoveryMode.ALWAYS_DISCOVERABLE).setCharacteristic(this.hap.Characteristic.ConfiguredName, this.Television.ConfiguredName).getCharacteristic(this.hap.Characteristic.ConfiguredName)
82
80
 
83
- this.Television.Service
84
- .setCharacteristic(this.hap.Characteristic.ActiveIdentifier, 1)
85
- .getCharacteristic(this.hap.Characteristic.Active)
86
- .onGet(() => {
87
- return this.Television.Active;
88
- })
89
- .onSet(this.ActiveSet.bind(this));
81
+ this.Television.Service.setCharacteristic(this.hap.Characteristic.ActiveIdentifier, 1).getCharacteristic(this.hap.Characteristic.Active).onGet(() => {
82
+ return this.Television.Active
83
+ }).onSet(this.ActiveSet.bind(this))
90
84
 
91
- this.Television.Service
92
- .getCharacteristic(this.hap.Characteristic.ActiveIdentifier)
93
- .onGet(() => {
94
- return this.Television.ActiveIdentifier;
95
- })
96
- .onSet(this.ActiveIdentifierSet.bind(this));
85
+ this.Television.Service.getCharacteristic(this.hap.Characteristic.ActiveIdentifier).onGet(() => {
86
+ return this.Television.ActiveIdentifier
87
+ }).onSet(this.ActiveIdentifierSet.bind(this))
97
88
 
98
- this.Television.Service
99
- .getCharacteristic(this.hap.Characteristic.RemoteKey)
100
- .onGet(() => {
101
- return this.Television.RemoteKey;
102
- })
103
- .onSet(this.RemoteKeySet.bind(this));
89
+ this.Television.Service.getCharacteristic(this.hap.Characteristic.RemoteKey).onGet(() => {
90
+ return this.Television.RemoteKey
91
+ }).onSet(this.RemoteKeySet.bind(this))
104
92
 
105
93
  // Initialize TelevisionSpeaker Service
106
- accessory.context.TelevisionSpeaker = accessory.context.TelevisionSpeaker ?? {};
94
+ accessory.context.TelevisionSpeaker = accessory.context.TelevisionSpeaker ?? {}
107
95
  this.TelevisionSpeaker = {
108
96
  Name: `${accessory.displayName} Speaker`,
109
97
  Service: accessory.getService(this.hap.Service.TelevisionSpeaker) ?? accessory.addService(this.hap.Service.TelevisionSpeaker) as Service,
110
98
  Active: accessory.context.Active ?? false,
111
99
  VolumeControlType: accessory.context.VolumeControlType ?? this.hap.Characteristic.VolumeControlType.ABSOLUTE,
112
100
  VolumeSelector: accessory.context.VolumeSelector ?? this.hap.Characteristic.VolumeSelector.INCREMENT,
113
- };
114
- accessory.context.TelevisionSpeaker = this.TelevisionSpeaker as object;
115
-
116
- this.TelevisionSpeaker.Service
117
- .setCharacteristic(this.hap.Characteristic.Name, this.TelevisionSpeaker.Name)
118
- .setCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE)
119
- .setCharacteristic(this.hap.Characteristic.VolumeControlType, this.hap.Characteristic.VolumeControlType.ABSOLUTE)
120
- .getCharacteristic(this.hap.Characteristic.VolumeSelector)
121
- .onGet(() => {
122
- return this.TelevisionSpeaker.VolumeSelector;
123
- })
124
- .onSet(this.VolumeSelectorSet.bind(this));
101
+ }
102
+ accessory.context.TelevisionSpeaker = this.TelevisionSpeaker as object
103
+
104
+ this.TelevisionSpeaker.Service.setCharacteristic(this.hap.Characteristic.Name, this.TelevisionSpeaker.Name).setCharacteristic(this.hap.Characteristic.Active, this.hap.Characteristic.Active.ACTIVE).setCharacteristic(this.hap.Characteristic.VolumeControlType, this.hap.Characteristic.VolumeControlType.ABSOLUTE).getCharacteristic(this.hap.Characteristic.VolumeSelector).onGet(() => {
105
+ return this.TelevisionSpeaker.VolumeSelector
106
+ }).onSet(this.VolumeSelectorSet.bind(this))
125
107
  }
126
108
 
127
109
  async VolumeSelectorSet(value: CharacteristicValue): Promise<void> {
128
- await this.debugLog(`VolumeSelector: ${value}`);
110
+ await this.debugLog(`VolumeSelector: ${value}`)
129
111
  if (value === this.hap.Characteristic.VolumeSelector.INCREMENT) {
130
- this.pushVolumeUpChanges();
112
+ this.pushVolumeUpChanges()
131
113
  } else {
132
- this.pushVolumeDownChanges();
114
+ this.pushVolumeDownChanges()
133
115
  }
134
116
  }
135
117
 
136
118
  async RemoteKeySet(value: CharacteristicValue): Promise<void> {
137
119
  switch (value) {
138
120
  case this.hap.Characteristic.RemoteKey.REWIND: {
139
- await this.debugLog('Set Remote Key Pressed: REWIND');
140
- break;
121
+ await this.debugLog('Set Remote Key Pressed: REWIND')
122
+ break
141
123
  }
142
124
  case this.hap.Characteristic.RemoteKey.FAST_FORWARD: {
143
- await this.debugLog('Set Remote Key Pressed: FAST_FORWARD');
144
- break;
125
+ await this.debugLog('Set Remote Key Pressed: FAST_FORWARD')
126
+ break
145
127
  }
146
128
  case this.hap.Characteristic.RemoteKey.NEXT_TRACK: {
147
- await this.debugLog('Set Remote Key Pressed: NEXT_TRACK');
148
- break;
129
+ await this.debugLog('Set Remote Key Pressed: NEXT_TRACK')
130
+ break
149
131
  }
150
132
  case this.hap.Characteristic.RemoteKey.PREVIOUS_TRACK: {
151
- await this.debugLog('Set Remote Key Pressed: PREVIOUS_TRACK');
152
- break;
133
+ await this.debugLog('Set Remote Key Pressed: PREVIOUS_TRACK')
134
+ break
153
135
  }
154
136
  case this.hap.Characteristic.RemoteKey.ARROW_UP: {
155
- await this.debugLog('Set Remote Key Pressed: ARROW_UP');
156
- //this.pushUpChanges();
157
- break;
137
+ await this.debugLog('Set Remote Key Pressed: ARROW_UP')
138
+ // this.pushUpChanges();
139
+ break
158
140
  }
159
141
  case this.hap.Characteristic.RemoteKey.ARROW_DOWN: {
160
- await this.debugLog('Set Remote Key Pressed: ARROW_DOWN');
161
- //this.pushDownChanges();
162
- break;
142
+ await this.debugLog('Set Remote Key Pressed: ARROW_DOWN')
143
+ // this.pushDownChanges();
144
+ break
163
145
  }
164
146
  case this.hap.Characteristic.RemoteKey.ARROW_LEFT: {
165
- await this.debugLog('Set Remote Key Pressed: ARROW_LEFT');
166
- //this.pushLeftChanges();
167
- break;
147
+ await this.debugLog('Set Remote Key Pressed: ARROW_LEFT')
148
+ // this.pushLeftChanges();
149
+ break
168
150
  }
169
151
  case this.hap.Characteristic.RemoteKey.ARROW_RIGHT: {
170
- await this.debugLog('Set Remote Key Pressed: ARROW_RIGHT');
171
- //this.pushRightChanges();
172
- break;
152
+ await this.debugLog('Set Remote Key Pressed: ARROW_RIGHT')
153
+ // this.pushRightChanges();
154
+ break
173
155
  }
174
156
  case this.hap.Characteristic.RemoteKey.SELECT: {
175
- await this.debugLog('Set Remote Key Pressed: SELECT');
176
- //this.pushOkChanges();
177
- break;
157
+ await this.debugLog('Set Remote Key Pressed: SELECT')
158
+ // this.pushOkChanges();
159
+ break
178
160
  }
179
161
  case this.hap.Characteristic.RemoteKey.BACK: {
180
- await this.debugLog('Set Remote Key Pressed: BACK');
181
- //this.pushBackChanges();
182
- break;
162
+ await this.debugLog('Set Remote Key Pressed: BACK')
163
+ // this.pushBackChanges();
164
+ break
183
165
  }
184
166
  case this.hap.Characteristic.RemoteKey.EXIT: {
185
- await this.debugLog('Set Remote Key Pressed: EXIT');
186
- break;
167
+ await this.debugLog('Set Remote Key Pressed: EXIT')
168
+ break
187
169
  }
188
170
  case this.hap.Characteristic.RemoteKey.PLAY_PAUSE: {
189
- await this.debugLog('Set Remote Key Pressed: PLAY_PAUSE');
190
- break;
171
+ await this.debugLog('Set Remote Key Pressed: PLAY_PAUSE')
172
+ break
191
173
  }
192
174
  case this.hap.Characteristic.RemoteKey.INFORMATION: {
193
- await this.debugLog('Set Remote Key Pressed: INFORMATION');
194
- //this.pushMenuChanges();
195
- break;
175
+ await this.debugLog('Set Remote Key Pressed: INFORMATION')
176
+ // this.pushMenuChanges();
177
+ break
196
178
  }
197
179
  }
198
180
  }
199
181
 
200
182
  async ActiveIdentifierSet(value: CharacteristicValue): Promise<void> {
201
- await this.debugLog(`ActiveIdentifier: ${value}`);
202
- this.Television.ActiveIdentifier = value;
183
+ await this.debugLog(`ActiveIdentifier: ${value}`)
184
+ this.Television.ActiveIdentifier = value
203
185
  }
204
186
 
205
187
  async ActiveSet(value: CharacteristicValue): Promise<void> {
206
- await this.debugLog(`Active (value): ${value}`);
188
+ await this.debugLog(`Active (value): ${value}`)
207
189
 
208
- this.Television.Active = value;
190
+ this.Television.Active = value
209
191
  if (this.Television.Active === this.hap.Characteristic.Active.ACTIVE) {
210
- await this.pushTvOnChanges();
192
+ await this.pushTvOnChanges()
211
193
  } else {
212
- await this.pushTvOffChanges();
194
+ await this.pushTvOffChanges()
213
195
  }
214
196
  }
215
197
 
216
198
  /**
217
199
  * Pushes the requested changes to the SwitchBot API
218
- * deviceType commandType Command Parameter Description
219
- * TV "command" "turnOff" "default" set to OFF state
220
- * TV "command" "turnOn" "default" set to ON state
221
- * TV "command" "volumeAdd" "default" volume up
222
- * TV "command" "volumeSub" "default" volume down
223
- * TV "command" "channelAdd" "default" next channel
224
- * TV "command" "channelSub" "default" previous channel
200
+ * deviceType commandType Command Parameter Description
201
+ * TV "command" "turnOff" "default" set to OFF state
202
+ * TV "command" "turnOn" "default" set to ON state
203
+ * TV "command" "volumeAdd" "default" volume up
204
+ * TV "command" "volumeSub" "default" volume down
205
+ * TV "command" "channelAdd" "default" next channel
206
+ * TV "command" "channelSub" "default" previous channel
225
207
  */
226
208
  async pushTvOnChanges(): Promise<void> {
227
- await this.debugLog('pushTvOnChanges'
228
- + ` Active: ${this.Television.Active}, disablePushOn: ${this.disablePushOn}`);
209
+ await this.debugLog(`pushTvOnChanges Active: ${this.Television.Active}, disablePushOn: ${this.disablePushOn}`)
229
210
  if (this.Television.Active === this.hap.Characteristic.Active.ACTIVE && !this.disablePushOn) {
230
- const commandType: string = await this.commandType();
231
- const command: string = await this.commandOn();
211
+ const commandType: string = await this.commandType()
212
+ const command: string = await this.commandOn()
232
213
  const bodyChange = JSON.stringify({
233
- command: command,
214
+ command,
234
215
  parameter: 'default',
235
- commandType: commandType,
236
- });
237
- await this.pushTVChanges(bodyChange);
216
+ commandType,
217
+ })
218
+ await this.pushTVChanges(bodyChange)
238
219
  }
239
220
  }
240
221
 
241
222
  async pushTvOffChanges(): Promise<void> {
242
- await this.debugLog('pushTvOffChanges'
243
- + ` Active: ${this.Television.Active}, disablePushOff: ${this.disablePushOff}`);
223
+ await this.debugLog(`pushTvOffChanges Active: ${this.Television.Active}, disablePushOff: ${this.disablePushOff}`)
244
224
  if (this.Television.Active === this.hap.Characteristic.Active.INACTIVE && !this.disablePushOff) {
245
- const commandType: string = await this.commandType();
246
- const command: string = await this.commandOff();
225
+ const commandType: string = await this.commandType()
226
+ const command: string = await this.commandOff()
247
227
  const bodyChange = JSON.stringify({
248
- command: command,
228
+ command,
249
229
  parameter: 'default',
250
- commandType: commandType,
251
- });
252
- await this.pushTVChanges(bodyChange);
230
+ commandType,
231
+ })
232
+ await this.pushTVChanges(bodyChange)
253
233
  }
254
234
  }
255
235
 
256
236
  async pushOkChanges(): Promise<void> {
257
- await this.debugLog(`pushOkChanges disablePushDetail: ${this.disablePushDetail}`);
237
+ await this.debugLog(`pushOkChanges disablePushDetail: ${this.disablePushDetail}`)
258
238
  if (!this.disablePushDetail) {
259
239
  const bodyChange = JSON.stringify({
260
240
  command: 'Ok',
261
241
  parameter: 'default',
262
242
  commandType: 'command',
263
- });
264
- await this.pushTVChanges(bodyChange);
243
+ })
244
+ await this.pushTVChanges(bodyChange)
265
245
  }
266
246
  }
267
247
 
268
248
  async pushBackChanges(): Promise<void> {
269
- await this.debugLog(`pushBackChanges disablePushDetail: ${this.disablePushDetail}`);
249
+ await this.debugLog(`pushBackChanges disablePushDetail: ${this.disablePushDetail}`)
270
250
  if (!this.disablePushDetail) {
271
251
  const bodyChange = JSON.stringify({
272
252
  command: 'Back',
273
253
  parameter: 'default',
274
254
  commandType: 'command',
275
- });
276
- await this.pushTVChanges(bodyChange);
255
+ })
256
+ await this.pushTVChanges(bodyChange)
277
257
  }
278
258
  }
279
259
 
280
260
  async pushMenuChanges(): Promise<void> {
281
- await this.debugLog(`pushMenuChanges disablePushDetail: ${this.disablePushDetail}`);
261
+ await this.debugLog(`pushMenuChanges disablePushDetail: ${this.disablePushDetail}`)
282
262
  if (!this.disablePushDetail) {
283
263
  const bodyChange = JSON.stringify({
284
264
  command: 'Menu',
285
265
  parameter: 'default',
286
266
  commandType: 'command',
287
- });
288
- await this.pushTVChanges(bodyChange);
267
+ })
268
+ await this.pushTVChanges(bodyChange)
289
269
  }
290
270
  }
291
271
 
292
272
  async pushUpChanges(): Promise<void> {
293
- await this.debugLog(`pushUpChanges disablePushDetail: ${this.disablePushDetail}`);
273
+ await this.debugLog(`pushUpChanges disablePushDetail: ${this.disablePushDetail}`)
294
274
  if (!this.disablePushDetail) {
295
275
  const bodyChange = JSON.stringify({
296
276
  command: 'Up',
297
277
  parameter: 'default',
298
278
  commandType: 'command',
299
- });
300
- await this.pushTVChanges(bodyChange);
279
+ })
280
+ await this.pushTVChanges(bodyChange)
301
281
  }
302
282
  }
303
283
 
304
284
  async pushDownChanges(): Promise<void> {
305
- await this.debugLog(`pushDownChanges disablePushDetail: ${this.disablePushDetail}`);
285
+ await this.debugLog(`pushDownChanges disablePushDetail: ${this.disablePushDetail}`)
306
286
  if (!this.disablePushDetail) {
307
287
  const bodyChange = JSON.stringify({
308
288
  command: 'Down',
309
289
  parameter: 'default',
310
290
  commandType: 'command',
311
- });
312
- await this.pushTVChanges(bodyChange);
291
+ })
292
+ await this.pushTVChanges(bodyChange)
313
293
  }
314
294
  }
315
295
 
316
296
  async pushRightChanges(): Promise<void> {
317
- await this.debugLog(`pushRightChanges disablePushDetail: ${this.disablePushDetail}`);
297
+ await this.debugLog(`pushRightChanges disablePushDetail: ${this.disablePushDetail}`)
318
298
  if (!this.disablePushDetail) {
319
299
  const bodyChange = JSON.stringify({
320
300
  command: 'Right',
321
301
  parameter: 'default',
322
302
  commandType: 'command',
323
- });
324
- await this.pushTVChanges(bodyChange);
303
+ })
304
+ await this.pushTVChanges(bodyChange)
325
305
  }
326
306
  }
327
307
 
328
308
  async pushLeftChanges(): Promise<void> {
329
- await this.debugLog(`pushLeftChanges disablePushDetail: ${this.disablePushDetail}`);
309
+ await this.debugLog(`pushLeftChanges disablePushDetail: ${this.disablePushDetail}`)
330
310
  if (!this.disablePushDetail) {
331
311
  const bodyChange = JSON.stringify({
332
312
  command: 'Left',
333
313
  parameter: 'default',
334
314
  commandType: 'command',
335
- });
336
- await this.pushTVChanges(bodyChange);
315
+ })
316
+ await this.pushTVChanges(bodyChange)
337
317
  }
338
318
  }
339
319
 
340
320
  async pushVolumeUpChanges(): Promise<void> {
341
- await this.debugLog(`pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`);
321
+ await this.debugLog(`pushVolumeUpChanges disablePushDetail: ${this.disablePushDetail}`)
342
322
  if (!this.disablePushDetail) {
343
323
  const bodyChange = JSON.stringify({
344
324
  command: 'volumeAdd',
345
325
  parameter: 'default',
346
326
  commandType: 'command',
347
- });
348
- await this.pushTVChanges(bodyChange);
327
+ })
328
+ await this.pushTVChanges(bodyChange)
349
329
  }
350
330
  }
351
331
 
352
332
  async pushVolumeDownChanges(): Promise<void> {
353
- await this.debugLog(`pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`);
333
+ await this.debugLog(`pushVolumeDownChanges disablePushDetail: ${this.disablePushDetail}`)
354
334
  if (!this.disablePushDetail) {
355
335
  const bodyChange = JSON.stringify({
356
336
  command: 'volumeSub',
357
337
  parameter: 'default',
358
338
  commandType: 'command',
359
- });
360
- await this.pushTVChanges(bodyChange);
339
+ })
340
+ await this.pushTVChanges(bodyChange)
361
341
  }
362
342
  }
363
343
 
364
344
  async pushTVChanges(bodyChange: any): Promise<void> {
365
- await this.debugLog('pushTVChanges');
345
+ await this.debugLog('pushTVChanges')
366
346
  if (this.device.connectionType === 'OpenAPI') {
367
- await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`);
347
+ await this.infoLog(`Sending request to SwitchBot API, body: ${bodyChange},`)
368
348
  try {
369
- const { body, statusCode } = await this.pushChangeRequest(bodyChange);
370
- const deviceStatus: any = await body.json();
371
- await this.pushStatusCodes(statusCode, deviceStatus);
349
+ const { body, statusCode } = await this.pushChangeRequest(bodyChange)
350
+ const deviceStatus: any = await body.json()
351
+ await this.pushStatusCodes(statusCode, deviceStatus)
372
352
  if (await this.successfulStatusCodes(statusCode, deviceStatus)) {
373
- await this.successfulPushChange(statusCode, deviceStatus, bodyChange);
374
- await this.updateHomeKitCharacteristics();
353
+ await this.successfulPushChange(statusCode, deviceStatus, bodyChange)
354
+ await this.updateHomeKitCharacteristics()
375
355
  } else {
376
- await this.statusCode(statusCode);
377
- await this.statusCode(deviceStatus.statusCode);
356
+ await this.statusCode(statusCode)
357
+ await this.statusCode(deviceStatus.statusCode)
378
358
  }
379
359
  } catch (e: any) {
380
- await this.apiError(e);
381
- await this.pushChangeError(e);
360
+ await this.apiError(e)
361
+ await this.pushChangeError(e)
382
362
  }
383
363
  } else {
384
- await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`);
364
+ await this.warnLog(`Connection Type: ${this.device.connectionType}, commands will not be sent to OpenAPI`)
385
365
  }
386
366
  }
387
367
 
388
368
  async updateHomeKitCharacteristics(): Promise<void> {
389
- await this.debugLog('updateHomeKitCharacteristics');
369
+ await this.debugLog('updateHomeKitCharacteristics')
390
370
  // Active
391
- await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.Active,
392
- this.Television.Active, 'Active');
371
+ await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.Active, this.Television.Active, 'Active')
393
372
  // ActiveIdentifier
394
- await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.ActiveIdentifier,
395
- this.Television.ActiveIdentifier, 'ActiveIdentifier');
373
+ await this.updateCharacteristic(this.Television.Service, this.hap.Characteristic.ActiveIdentifier, this.Television.ActiveIdentifier, 'ActiveIdentifier')
396
374
  }
397
375
 
398
376
  async apiError(e: any): Promise<void> {
399
- this.Television.Service.updateCharacteristic(this.hap.Characteristic.Active, e);
400
- this.Television.Service.updateCharacteristic(this.hap.Characteristic.ActiveIdentifier, e);
377
+ this.Television.Service.updateCharacteristic(this.hap.Characteristic.Active, e)
378
+ this.Television.Service.updateCharacteristic(this.hap.Characteristic.ActiveIdentifier, e)
401
379
  }
402
380
  }