matter-all-in-one-addon 2.3.1 → 2.3.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 (457) hide show
  1. package/README.md +16 -8
  2. package/dist/camera/ai/camera-ai-detector.d.ts +0 -2
  3. package/dist/camera/ai/camera-ai-detector.js +52 -57
  4. package/dist/camera/ai/camera-ai-detector.js.map +1 -1
  5. package/dist/camera/browser-preview.d.ts +9 -0
  6. package/dist/camera/browser-preview.js +135 -0
  7. package/dist/camera/browser-preview.js.map +1 -0
  8. package/dist/camera/camera-source-resolver.js +5 -3
  9. package/dist/camera/camera-source-resolver.js.map +1 -1
  10. package/dist/camera/camera-types.d.ts +0 -2
  11. package/dist/camera/cameraui/cameraui-client.js +91 -30
  12. package/dist/camera/cameraui/cameraui-client.js.map +1 -1
  13. package/dist/camera/cameraui/cameraui-homekit-bridge.js +13 -4
  14. package/dist/camera/cameraui/cameraui-homekit-bridge.js.map +1 -1
  15. package/dist/camera/cameraui/cameraui-storage.js.map +1 -1
  16. package/dist/camera/cameraui/cameraui-types.d.ts +6 -2
  17. package/dist/camera/cameraui/ha-camera-entity.js +5 -2
  18. package/dist/camera/cameraui/ha-camera-entity.js.map +1 -1
  19. package/dist/camera/homekit/ffmpeg-helper.js +17 -35
  20. package/dist/camera/homekit/ffmpeg-helper.js.map +1 -1
  21. package/dist/camera/homekit/hevc/fmp4-hevc.js +3 -1
  22. package/dist/camera/homekit/hevc/fmp4-hevc.js.map +1 -1
  23. package/dist/camera/homekit/hevc/hevc-recording.d.ts +0 -2
  24. package/dist/camera/homekit/hevc/hevc-recording.js +28 -63
  25. package/dist/camera/homekit/hevc/hevc-recording.js.map +1 -1
  26. package/dist/camera/homekit/hevc/multi-tier-rtp.d.ts +1 -15
  27. package/dist/camera/homekit/hevc/multi-tier-rtp.js +70 -228
  28. package/dist/camera/homekit/hevc/multi-tier-rtp.js.map +1 -1
  29. package/dist/camera/homekit/hevc/sframe-rtp.d.ts +0 -2
  30. package/dist/camera/homekit/hevc/sframe-rtp.js +0 -25
  31. package/dist/camera/homekit/hevc/sframe-rtp.js.map +1 -1
  32. package/dist/camera/homekit/hevc/sframe.d.ts +1 -11
  33. package/dist/camera/homekit/hevc/sframe.js +18 -133
  34. package/dist/camera/homekit/hevc/sframe.js.map +1 -1
  35. package/dist/camera/homekit/hevc/types.js +81 -9
  36. package/dist/camera/homekit/hevc/types.js.map +1 -1
  37. package/dist/camera/homekit/hevc/webrtc-session.d.ts +3 -17
  38. package/dist/camera/homekit/hevc/webrtc-session.js +55 -229
  39. package/dist/camera/homekit/hevc/webrtc-session.js.map +1 -1
  40. package/dist/camera/homekit/homekit-camera-recording.delegate.d.ts +0 -1
  41. package/dist/camera/homekit/homekit-camera-recording.delegate.js +115 -43
  42. package/dist/camera/homekit/homekit-camera-recording.delegate.js.map +1 -1
  43. package/dist/camera/homekit/homekit-camera-stream.delegate.d.ts +4 -7
  44. package/dist/camera/homekit/homekit-camera-stream.delegate.js +388 -201
  45. package/dist/camera/homekit/homekit-camera-stream.delegate.js.map +1 -1
  46. package/dist/camera/homekit/homekit-camera.accessory.d.ts +7 -34
  47. package/dist/camera/homekit/homekit-camera.accessory.js +207 -169
  48. package/dist/camera/homekit/homekit-camera.accessory.js.map +1 -1
  49. package/dist/camera/homekit/live-view-telemetry.d.ts +0 -4
  50. package/dist/camera/homekit/live-view-telemetry.js.map +1 -1
  51. package/dist/camera/homekit/tuya-hap-talkback.d.ts +41 -0
  52. package/dist/camera/homekit/tuya-hap-talkback.js +326 -0
  53. package/dist/camera/homekit/tuya-hap-talkback.js.map +1 -0
  54. package/dist/camera/matter/camera-endpoint.builder.js +9 -7
  55. package/dist/camera/matter/camera-endpoint.builder.js.map +1 -1
  56. package/dist/camera/matter/camera-session-manager.d.ts +1 -0
  57. package/dist/camera/matter/camera-session-manager.js +2 -0
  58. package/dist/camera/matter/camera-session-manager.js.map +1 -1
  59. package/dist/camera/matter/camera-webrtc-adapter.js +32 -15
  60. package/dist/camera/matter/camera-webrtc-adapter.js.map +1 -1
  61. package/dist/camera/motion/ffmpeg-motion-detector.js +28 -14
  62. package/dist/camera/motion/ffmpeg-motion-detector.js.map +1 -1
  63. package/dist/camera/nest/nest-camera-adapter.js +9 -5
  64. package/dist/camera/nest/nest-camera-adapter.js.map +1 -1
  65. package/dist/camera/ptz/ptz-capabilities.js +3 -1
  66. package/dist/camera/ptz/ptz-capabilities.js.map +1 -1
  67. package/dist/camera/ptz/ptz-legacy-discovery.js.map +1 -1
  68. package/dist/camera/ptz/ptz-mqtt-publisher.js +50 -12
  69. package/dist/camera/ptz/ptz-mqtt-publisher.js.map +1 -1
  70. package/dist/camera/ptz/ptz-zones-manager.js +6 -1
  71. package/dist/camera/ptz/ptz-zones-manager.js.map +1 -1
  72. package/dist/camera/scrypted/scrypted-camera-card.js +3 -1
  73. package/dist/camera/scrypted/scrypted-camera-card.js.map +1 -1
  74. package/dist/camera/scrypted/scrypted-camera-discovery-adapter.js +7 -5
  75. package/dist/camera/scrypted/scrypted-camera-discovery-adapter.js.map +1 -1
  76. package/dist/camera/scrypted/scrypted-client-discovery-adapter.js.map +1 -1
  77. package/dist/camera/scrypted/scrypted-client.js +6 -5
  78. package/dist/camera/scrypted/scrypted-client.js.map +1 -1
  79. package/dist/camera/scrypted/scrypted-discovery-provider.js.map +1 -1
  80. package/dist/camera/scrypted/scrypted-homekit-bridge.js +6 -4
  81. package/dist/camera/scrypted/scrypted-homekit-bridge.js.map +1 -1
  82. package/dist/camera/scrypted/scrypted-reconnect-manager.js.map +1 -1
  83. package/dist/camera/scrypted/scrypted-runtime-facade.js +2 -2
  84. package/dist/camera/scrypted/scrypted-runtime-facade.js.map +1 -1
  85. package/dist/camera/scrypted/scrypted-runtime-ingest.js +3 -1
  86. package/dist/camera/scrypted/scrypted-runtime-ingest.js.map +1 -1
  87. package/dist/camera/scrypted/scrypted-storage.js +12 -6
  88. package/dist/camera/scrypted/scrypted-storage.js.map +1 -1
  89. package/dist/camera/scrypted/scrypted-stream-validator.js +25 -7
  90. package/dist/camera/scrypted/scrypted-stream-validator.js.map +1 -1
  91. package/dist/camera/tuya-webrtc-session.d.ts +53 -0
  92. package/dist/camera/tuya-webrtc-session.js +261 -0
  93. package/dist/camera/tuya-webrtc-session.js.map +1 -0
  94. package/dist/converters/sensor.converter.js +4 -1
  95. package/dist/converters/sensor.converter.js.map +1 -1
  96. package/dist/device-profiles.js +3 -1
  97. package/dist/device-profiles.js.map +1 -1
  98. package/dist/entities/air_quality.entity.js +3 -1
  99. package/dist/entities/air_quality.entity.js.map +1 -1
  100. package/dist/entities/base.entity.js +45 -17
  101. package/dist/entities/base.entity.js.map +1 -1
  102. package/dist/entities/camera.entity.d.ts +1 -0
  103. package/dist/entities/camera.entity.js +24 -2
  104. package/dist/entities/camera.entity.js.map +1 -1
  105. package/dist/entities/composite-device.entity.js +37 -13
  106. package/dist/entities/composite-device.entity.js.map +1 -1
  107. package/dist/entities/energy_tariff.entity.js.map +1 -1
  108. package/dist/entities/pet_feeder.entity.d.ts +1 -0
  109. package/dist/entities/pet_feeder.entity.js +12 -0
  110. package/dist/entities/pet_feeder.entity.js.map +1 -1
  111. package/dist/entities/vacuum.entity.js +16 -5
  112. package/dist/entities/vacuum.entity.js.map +1 -1
  113. package/dist/frontend/assets/index-1k-iTL-m.js +26 -0
  114. package/dist/frontend/assets/{index-NrzHqycm.css → index-CJdlkpIy.css} +1 -1
  115. package/dist/frontend/index.html +2 -2
  116. package/dist/hap/hap-generic-accessory.d.ts +4 -0
  117. package/dist/hap/hap-generic-accessory.js +512 -122
  118. package/dist/hap/hap-generic-accessory.js.map +1 -1
  119. package/dist/homeAssistant.d.ts +1 -0
  120. package/dist/homeAssistant.js +23 -5
  121. package/dist/homeAssistant.js.map +1 -1
  122. package/dist/index.js +3 -1
  123. package/dist/index.js.map +1 -1
  124. package/dist/mqtt/mqtt-client.js.map +1 -1
  125. package/dist/mqtt/mqtt.entity.js +41 -17
  126. package/dist/mqtt/mqtt.entity.js.map +1 -1
  127. package/dist/platform.d.ts +1 -0
  128. package/dist/platform.js +83 -13
  129. package/dist/platform.js.map +1 -1
  130. package/dist/utils/atomic-json-store.js +5 -1
  131. package/dist/utils/atomic-json-store.js.map +1 -1
  132. package/dist/utils/ha-state.js +3 -1
  133. package/dist/utils/ha-state.js.map +1 -1
  134. package/dist/utils/light-color.js +3 -5
  135. package/dist/utils/light-color.js.map +1 -1
  136. package/dist/utils/matter-command-response.js.map +1 -1
  137. package/dist/utils/matter-firmware.js +1 -2
  138. package/dist/utils/matter-firmware.js.map +1 -1
  139. package/dist/utils/matter-protocol.d.ts +1 -0
  140. package/dist/utils/matter-protocol.js +30 -0
  141. package/dist/utils/matter-protocol.js.map +1 -0
  142. package/package.json +27 -19
  143. package/dist/camera/camera-entity-control.d.ts +0 -12
  144. package/dist/camera/camera-entity-control.js +0 -24
  145. package/dist/camera/camera-entity-control.js.map +0 -1
  146. package/dist/camera/homekit/hevc/bootstrap.d.ts +0 -9
  147. package/dist/camera/homekit/hevc/bootstrap.js +0 -47
  148. package/dist/camera/homekit/hevc/bootstrap.js.map +0 -1
  149. package/dist/camera/homekit/hevc/recording-output.d.ts +0 -2
  150. package/dist/camera/homekit/hevc/recording-output.js +0 -33
  151. package/dist/camera/homekit/hevc/recording-output.js.map +0 -1
  152. package/dist/camera/homekit/media-policy.d.ts +0 -25
  153. package/dist/camera/homekit/media-policy.js +0 -102
  154. package/dist/camera/homekit/media-policy.js.map +0 -1
  155. package/dist/camera/homekit/route-address.d.ts +0 -2
  156. package/dist/camera/homekit/route-address.js +0 -27
  157. package/dist/camera/homekit/route-address.js.map +0 -1
  158. package/dist/camera/homekit/rtp-relay.d.ts +0 -21
  159. package/dist/camera/homekit/rtp-relay.js +0 -112
  160. package/dist/camera/homekit/rtp-relay.js.map +0 -1
  161. package/dist/camera/homekit/startup-timing.d.ts +0 -8
  162. package/dist/camera/homekit/startup-timing.js +0 -14
  163. package/dist/camera/homekit/startup-timing.js.map +0 -1
  164. package/dist/camera/source-adapter.d.ts +0 -132
  165. package/dist/camera/source-adapter.js +0 -282
  166. package/dist/camera/source-adapter.js.map +0 -1
  167. package/dist/frontend/assets/index-Bka3TVAQ.js +0 -21
  168. package/vendor/hap-nodejs/LICENSE +0 -176
  169. package/vendor/hap-nodejs/MIAO.md +0 -5
  170. package/vendor/hap-nodejs/PATCH.md +0 -37
  171. package/vendor/hap-nodejs/README.md +0 -86
  172. package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.d.ts +0 -2
  173. package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.d.ts.map +0 -1
  174. package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.js +0 -128
  175. package/vendor/hap-nodejs/dist/accessories/AirConditioner_accessory.js.map +0 -1
  176. package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.d.ts +0 -2
  177. package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.d.ts.map +0 -1
  178. package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.js +0 -159
  179. package/vendor/hap-nodejs/dist/accessories/AppleTVRemote_accessory.js.map +0 -1
  180. package/vendor/hap-nodejs/dist/accessories/Camera_accessory.d.ts +0 -2
  181. package/vendor/hap-nodejs/dist/accessories/Camera_accessory.d.ts.map +0 -1
  182. package/vendor/hap-nodejs/dist/accessories/Camera_accessory.js +0 -545
  183. package/vendor/hap-nodejs/dist/accessories/Camera_accessory.js.map +0 -1
  184. package/vendor/hap-nodejs/dist/accessories/Fan_accessory.d.ts +0 -2
  185. package/vendor/hap-nodejs/dist/accessories/Fan_accessory.d.ts.map +0 -1
  186. package/vendor/hap-nodejs/dist/accessories/Fan_accessory.js +0 -74
  187. package/vendor/hap-nodejs/dist/accessories/Fan_accessory.js.map +0 -1
  188. package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.d.ts +0 -2
  189. package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.d.ts.map +0 -1
  190. package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.js +0 -78
  191. package/vendor/hap-nodejs/dist/accessories/GarageDoorOpener_accessory.js.map +0 -1
  192. package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +0 -2
  193. package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +0 -1
  194. package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.js +0 -106
  195. package/vendor/hap-nodejs/dist/accessories/Light-AdaptiveLighting_accessory.js.map +0 -1
  196. package/vendor/hap-nodejs/dist/accessories/Light_accessory.d.ts +0 -2
  197. package/vendor/hap-nodejs/dist/accessories/Light_accessory.d.ts.map +0 -1
  198. package/vendor/hap-nodejs/dist/accessories/Light_accessory.js +0 -145
  199. package/vendor/hap-nodejs/dist/accessories/Light_accessory.js.map +0 -1
  200. package/vendor/hap-nodejs/dist/accessories/Lock_accessory.d.ts +0 -2
  201. package/vendor/hap-nodejs/dist/accessories/Lock_accessory.d.ts.map +0 -1
  202. package/vendor/hap-nodejs/dist/accessories/Lock_accessory.js +0 -76
  203. package/vendor/hap-nodejs/dist/accessories/Lock_accessory.js.map +0 -1
  204. package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.d.ts +0 -2
  205. package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.d.ts.map +0 -1
  206. package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.js +0 -45
  207. package/vendor/hap-nodejs/dist/accessories/MotionSensor_accessory.js.map +0 -1
  208. package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.d.ts +0 -2
  209. package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.d.ts.map +0 -1
  210. package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.js +0 -79
  211. package/vendor/hap-nodejs/dist/accessories/Outlet_accessory.js.map +0 -1
  212. package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.d.ts +0 -2
  213. package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.d.ts.map +0 -1
  214. package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.js +0 -44
  215. package/vendor/hap-nodejs/dist/accessories/SmartSpeaker_accessory.js.map +0 -1
  216. package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.d.ts +0 -2
  217. package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.d.ts.map +0 -1
  218. package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.js +0 -128
  219. package/vendor/hap-nodejs/dist/accessories/Sprinkler_accessory.js.map +0 -1
  220. package/vendor/hap-nodejs/dist/accessories/TV_accessory.d.ts +0 -2
  221. package/vendor/hap-nodejs/dist/accessories/TV_accessory.d.ts.map +0 -1
  222. package/vendor/hap-nodejs/dist/accessories/TV_accessory.js +0 -101
  223. package/vendor/hap-nodejs/dist/accessories/TV_accessory.js.map +0 -1
  224. package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.d.ts +0 -2
  225. package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.d.ts.map +0 -1
  226. package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.js +0 -44
  227. package/vendor/hap-nodejs/dist/accessories/TemperatureSensor_accessory.js.map +0 -1
  228. package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.d.ts +0 -3
  229. package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.d.ts.map +0 -1
  230. package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.js +0 -17
  231. package/vendor/hap-nodejs/dist/accessories/Wi-FiRouter_accessory.js.map +0 -1
  232. package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.d.ts +0 -3
  233. package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +0 -1
  234. package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.js +0 -19
  235. package/vendor/hap-nodejs/dist/accessories/Wi-FiSatellite_accessory.js.map +0 -1
  236. package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.d.ts +0 -25
  237. package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.d.ts.map +0 -1
  238. package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.js +0 -145
  239. package/vendor/hap-nodejs/dist/accessories/gstreamer-audioProducer.js.map +0 -1
  240. package/vendor/hap-nodejs/dist/accessories/types.d.ts +0 -78
  241. package/vendor/hap-nodejs/dist/accessories/types.d.ts.map +0 -1
  242. package/vendor/hap-nodejs/dist/accessories/types.js +0 -88
  243. package/vendor/hap-nodejs/dist/accessories/types.js.map +0 -1
  244. package/vendor/hap-nodejs/dist/index.d.ts +0 -50
  245. package/vendor/hap-nodejs/dist/index.d.ts.map +0 -1
  246. package/vendor/hap-nodejs/dist/index.js +0 -54
  247. package/vendor/hap-nodejs/dist/index.js.map +0 -1
  248. package/vendor/hap-nodejs/dist/internal-types.d.ts +0 -76
  249. package/vendor/hap-nodejs/dist/internal-types.d.ts.map +0 -1
  250. package/vendor/hap-nodejs/dist/internal-types.js +0 -80
  251. package/vendor/hap-nodejs/dist/internal-types.js.map +0 -1
  252. package/vendor/hap-nodejs/dist/lib/Accessory.d.ts +0 -521
  253. package/vendor/hap-nodejs/dist/lib/Accessory.d.ts.map +0 -1
  254. package/vendor/hap-nodejs/dist/lib/Accessory.js +0 -1762
  255. package/vendor/hap-nodejs/dist/lib/Accessory.js.map +0 -1
  256. package/vendor/hap-nodejs/dist/lib/Advertiser.d.ts +0 -190
  257. package/vendor/hap-nodejs/dist/lib/Advertiser.d.ts.map +0 -1
  258. package/vendor/hap-nodejs/dist/lib/Advertiser.js +0 -592
  259. package/vendor/hap-nodejs/dist/lib/Advertiser.js.map +0 -1
  260. package/vendor/hap-nodejs/dist/lib/Bridge.d.ts +0 -12
  261. package/vendor/hap-nodejs/dist/lib/Bridge.d.ts.map +0 -1
  262. package/vendor/hap-nodejs/dist/lib/Bridge.js +0 -19
  263. package/vendor/hap-nodejs/dist/lib/Bridge.js.map +0 -1
  264. package/vendor/hap-nodejs/dist/lib/Characteristic.d.ts +0 -1768
  265. package/vendor/hap-nodejs/dist/lib/Characteristic.d.ts.map +0 -1
  266. package/vendor/hap-nodejs/dist/lib/Characteristic.js +0 -2532
  267. package/vendor/hap-nodejs/dist/lib/Characteristic.js.map +0 -1
  268. package/vendor/hap-nodejs/dist/lib/HAPServer.d.ts +0 -299
  269. package/vendor/hap-nodejs/dist/lib/HAPServer.d.ts.map +0 -1
  270. package/vendor/hap-nodejs/dist/lib/HAPServer.js +0 -968
  271. package/vendor/hap-nodejs/dist/lib/HAPServer.js.map +0 -1
  272. package/vendor/hap-nodejs/dist/lib/Service.d.ts +0 -598
  273. package/vendor/hap-nodejs/dist/lib/Service.d.ts.map +0 -1
  274. package/vendor/hap-nodejs/dist/lib/Service.js +0 -797
  275. package/vendor/hap-nodejs/dist/lib/Service.js.map +0 -1
  276. package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.d.ts +0 -102
  277. package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.d.ts.map +0 -1
  278. package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.js +0 -317
  279. package/vendor/hap-nodejs/dist/lib/camera/CMAFIngest.js.map +0 -1
  280. package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.d.ts +0 -38
  281. package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.d.ts.map +0 -1
  282. package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.js +0 -174
  283. package/vendor/hap-nodejs/dist/lib/camera/HDSSnapshotTransport.js.map +0 -1
  284. package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.d.ts +0 -59
  285. package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.d.ts.map +0 -1
  286. package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.js +0 -267
  287. package/vendor/hap-nodejs/dist/lib/camera/RTPProxy.js.map +0 -1
  288. package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.d.ts +0 -379
  289. package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.d.ts.map +0 -1
  290. package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.js +0 -1021
  291. package/vendor/hap-nodejs/dist/lib/camera/RTPStreamManagement.js.map +0 -1
  292. package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.d.ts +0 -325
  293. package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.d.ts.map +0 -1
  294. package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.js +0 -800
  295. package/vendor/hap-nodejs/dist/lib/camera/RecordingManagement.js.map +0 -1
  296. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.d.ts +0 -20
  297. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.d.ts.map +0 -1
  298. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.js +0 -48
  299. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoCredentials.js.map +0 -1
  300. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.d.ts +0 -618
  301. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.d.ts.map +0 -1
  302. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.js +0 -911
  303. package/vendor/hap-nodejs/dist/lib/camera/SecureVideoTypes.js.map +0 -1
  304. package/vendor/hap-nodejs/dist/lib/camera/index.d.ts +0 -8
  305. package/vendor/hap-nodejs/dist/lib/camera/index.d.ts.map +0 -1
  306. package/vendor/hap-nodejs/dist/lib/camera/index.js +0 -11
  307. package/vendor/hap-nodejs/dist/lib/camera/index.js.map +0 -1
  308. package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.d.ts +0 -452
  309. package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.d.ts.map +0 -1
  310. package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.js +0 -868
  311. package/vendor/hap-nodejs/dist/lib/controller/AdaptiveLightingController.js.map +0 -1
  312. package/vendor/hap-nodejs/dist/lib/controller/CameraController.d.ts +0 -410
  313. package/vendor/hap-nodejs/dist/lib/controller/CameraController.d.ts.map +0 -1
  314. package/vendor/hap-nodejs/dist/lib/controller/CameraController.js +0 -658
  315. package/vendor/hap-nodejs/dist/lib/controller/CameraController.js.map +0 -1
  316. package/vendor/hap-nodejs/dist/lib/controller/Controller.d.ts +0 -197
  317. package/vendor/hap-nodejs/dist/lib/controller/Controller.d.ts.map +0 -1
  318. package/vendor/hap-nodejs/dist/lib/controller/Controller.js +0 -32
  319. package/vendor/hap-nodejs/dist/lib/controller/Controller.js.map +0 -1
  320. package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.d.ts +0 -59
  321. package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.d.ts.map +0 -1
  322. package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.js +0 -102
  323. package/vendor/hap-nodejs/dist/lib/controller/DoorbellController.js.map +0 -1
  324. package/vendor/hap-nodejs/dist/lib/controller/RemoteController.d.ts +0 -434
  325. package/vendor/hap-nodejs/dist/lib/controller/RemoteController.d.ts.map +0 -1
  326. package/vendor/hap-nodejs/dist/lib/controller/RemoteController.js +0 -1178
  327. package/vendor/hap-nodejs/dist/lib/controller/RemoteController.js.map +0 -1
  328. package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.d.ts +0 -380
  329. package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.d.ts.map +0 -1
  330. package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.js +0 -947
  331. package/vendor/hap-nodejs/dist/lib/controller/SecureVideoController.js.map +0 -1
  332. package/vendor/hap-nodejs/dist/lib/controller/index.d.ts +0 -7
  333. package/vendor/hap-nodejs/dist/lib/controller/index.d.ts.map +0 -1
  334. package/vendor/hap-nodejs/dist/lib/controller/index.js +0 -10
  335. package/vendor/hap-nodejs/dist/lib/controller/index.js.map +0 -1
  336. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.d.ts +0 -73
  337. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.d.ts.map +0 -1
  338. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.js +0 -205
  339. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamManagement.js.map +0 -1
  340. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.d.ts +0 -186
  341. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.d.ts.map +0 -1
  342. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.js +0 -880
  343. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamParser.js.map +0 -1
  344. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.d.ts +0 -351
  345. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.d.ts.map +0 -1
  346. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.js +0 -878
  347. package/vendor/hap-nodejs/dist/lib/datastream/DataStreamServer.js.map +0 -1
  348. package/vendor/hap-nodejs/dist/lib/datastream/index.d.ts +0 -4
  349. package/vendor/hap-nodejs/dist/lib/datastream/index.d.ts.map +0 -1
  350. package/vendor/hap-nodejs/dist/lib/datastream/index.js +0 -7
  351. package/vendor/hap-nodejs/dist/lib/datastream/index.js.map +0 -1
  352. package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.d.ts +0 -2245
  353. package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +0 -1
  354. package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.js +0 -4957
  355. package/vendor/hap-nodejs/dist/lib/definitions/CharacteristicDefinitions.js.map +0 -1
  356. package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.d.ts +0 -584
  357. package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.d.ts.map +0 -1
  358. package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.js +0 -1518
  359. package/vendor/hap-nodejs/dist/lib/definitions/ServiceDefinitions.js.map +0 -1
  360. package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.d.ts +0 -34
  361. package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.d.ts.map +0 -1
  362. package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.js +0 -624
  363. package/vendor/hap-nodejs/dist/lib/definitions/generate-definitions.js.map +0 -1
  364. package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.d.ts +0 -22
  365. package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.d.ts.map +0 -1
  366. package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.js +0 -734
  367. package/vendor/hap-nodejs/dist/lib/definitions/generator-configuration.js.map +0 -1
  368. package/vendor/hap-nodejs/dist/lib/definitions/index.d.ts +0 -3
  369. package/vendor/hap-nodejs/dist/lib/definitions/index.d.ts.map +0 -1
  370. package/vendor/hap-nodejs/dist/lib/definitions/index.js +0 -6
  371. package/vendor/hap-nodejs/dist/lib/definitions/index.js.map +0 -1
  372. package/vendor/hap-nodejs/dist/lib/gen/HomeKit.d.ts +0 -8
  373. package/vendor/hap-nodejs/dist/lib/gen/HomeKit.d.ts.map +0 -1
  374. package/vendor/hap-nodejs/dist/lib/gen/HomeKit.js +0 -9
  375. package/vendor/hap-nodejs/dist/lib/gen/HomeKit.js.map +0 -1
  376. package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.d.ts +0 -91
  377. package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.d.ts.map +0 -1
  378. package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.js +0 -311
  379. package/vendor/hap-nodejs/dist/lib/model/AccessoryInfo.js.map +0 -1
  380. package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.d.ts +0 -46
  381. package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.d.ts.map +0 -1
  382. package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.js +0 -277
  383. package/vendor/hap-nodejs/dist/lib/model/ControllerStorage.js.map +0 -1
  384. package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.d.ts +0 -75
  385. package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.d.ts.map +0 -1
  386. package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.js +0 -190
  387. package/vendor/hap-nodejs/dist/lib/model/HAPFileStorage.js.map +0 -1
  388. package/vendor/hap-nodejs/dist/lib/model/HAPStorage.d.ts +0 -26
  389. package/vendor/hap-nodejs/dist/lib/model/HAPStorage.d.ts.map +0 -1
  390. package/vendor/hap-nodejs/dist/lib/model/HAPStorage.js +0 -79
  391. package/vendor/hap-nodejs/dist/lib/model/HAPStorage.js.map +0 -1
  392. package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.d.ts +0 -33
  393. package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.d.ts.map +0 -1
  394. package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.js +0 -114
  395. package/vendor/hap-nodejs/dist/lib/model/IdentifierCache.js.map +0 -1
  396. package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.d.ts +0 -83
  397. package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.d.ts.map +0 -1
  398. package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.js +0 -127
  399. package/vendor/hap-nodejs/dist/lib/tv/AccessControlManagement.js.map +0 -1
  400. package/vendor/hap-nodejs/dist/lib/util/checkName.d.ts +0 -8
  401. package/vendor/hap-nodejs/dist/lib/util/checkName.d.ts.map +0 -1
  402. package/vendor/hap-nodejs/dist/lib/util/checkName.js +0 -28
  403. package/vendor/hap-nodejs/dist/lib/util/checkName.js.map +0 -1
  404. package/vendor/hap-nodejs/dist/lib/util/clone.d.ts +0 -7
  405. package/vendor/hap-nodejs/dist/lib/util/clone.d.ts.map +0 -1
  406. package/vendor/hap-nodejs/dist/lib/util/clone.js +0 -22
  407. package/vendor/hap-nodejs/dist/lib/util/clone.js.map +0 -1
  408. package/vendor/hap-nodejs/dist/lib/util/color-utils.d.ts +0 -18
  409. package/vendor/hap-nodejs/dist/lib/util/color-utils.d.ts.map +0 -1
  410. package/vendor/hap-nodejs/dist/lib/util/color-utils.js +0 -442
  411. package/vendor/hap-nodejs/dist/lib/util/color-utils.js.map +0 -1
  412. package/vendor/hap-nodejs/dist/lib/util/eventedhttp.d.ts +0 -251
  413. package/vendor/hap-nodejs/dist/lib/util/eventedhttp.d.ts.map +0 -1
  414. package/vendor/hap-nodejs/dist/lib/util/eventedhttp.js +0 -714
  415. package/vendor/hap-nodejs/dist/lib/util/eventedhttp.js.map +0 -1
  416. package/vendor/hap-nodejs/dist/lib/util/hapCrypto.d.ts +0 -50
  417. package/vendor/hap-nodejs/dist/lib/util/hapCrypto.d.ts.map +0 -1
  418. package/vendor/hap-nodejs/dist/lib/util/hapCrypto.js +0 -185
  419. package/vendor/hap-nodejs/dist/lib/util/hapCrypto.js.map +0 -1
  420. package/vendor/hap-nodejs/dist/lib/util/hapStatusError.d.ts +0 -16
  421. package/vendor/hap-nodejs/dist/lib/util/hapStatusError.d.ts.map +0 -1
  422. package/vendor/hap-nodejs/dist/lib/util/hapStatusError.js +0 -29
  423. package/vendor/hap-nodejs/dist/lib/util/hapStatusError.js.map +0 -1
  424. package/vendor/hap-nodejs/dist/lib/util/net-utils.d.ts +0 -21
  425. package/vendor/hap-nodejs/dist/lib/util/net-utils.d.ts.map +0 -1
  426. package/vendor/hap-nodejs/dist/lib/util/net-utils.js +0 -79
  427. package/vendor/hap-nodejs/dist/lib/util/net-utils.js.map +0 -1
  428. package/vendor/hap-nodejs/dist/lib/util/once.d.ts +0 -7
  429. package/vendor/hap-nodejs/dist/lib/util/once.d.ts.map +0 -1
  430. package/vendor/hap-nodejs/dist/lib/util/once.js +0 -22
  431. package/vendor/hap-nodejs/dist/lib/util/once.js.map +0 -1
  432. package/vendor/hap-nodejs/dist/lib/util/promise-utils.d.ts +0 -14
  433. package/vendor/hap-nodejs/dist/lib/util/promise-utils.d.ts.map +0 -1
  434. package/vendor/hap-nodejs/dist/lib/util/promise-utils.js +0 -29
  435. package/vendor/hap-nodejs/dist/lib/util/promise-utils.js.map +0 -1
  436. package/vendor/hap-nodejs/dist/lib/util/request-util.d.ts +0 -36
  437. package/vendor/hap-nodejs/dist/lib/util/request-util.d.ts.map +0 -1
  438. package/vendor/hap-nodejs/dist/lib/util/request-util.js +0 -108
  439. package/vendor/hap-nodejs/dist/lib/util/request-util.js.map +0 -1
  440. package/vendor/hap-nodejs/dist/lib/util/time.d.ts +0 -9
  441. package/vendor/hap-nodejs/dist/lib/util/time.d.ts.map +0 -1
  442. package/vendor/hap-nodejs/dist/lib/util/time.js +0 -23
  443. package/vendor/hap-nodejs/dist/lib/util/time.js.map +0 -1
  444. package/vendor/hap-nodejs/dist/lib/util/tlv.d.ts +0 -90
  445. package/vendor/hap-nodejs/dist/lib/util/tlv.d.ts.map +0 -1
  446. package/vendor/hap-nodejs/dist/lib/util/tlv.js +0 -318
  447. package/vendor/hap-nodejs/dist/lib/util/tlv.js.map +0 -1
  448. package/vendor/hap-nodejs/dist/lib/util/uuid.d.ts +0 -23
  449. package/vendor/hap-nodejs/dist/lib/util/uuid.d.ts.map +0 -1
  450. package/vendor/hap-nodejs/dist/lib/util/uuid.js +0 -78
  451. package/vendor/hap-nodejs/dist/lib/util/uuid.js.map +0 -1
  452. package/vendor/hap-nodejs/dist/types.d.ts +0 -276
  453. package/vendor/hap-nodejs/dist/types.d.ts.map +0 -1
  454. package/vendor/hap-nodejs/dist/types.js +0 -11
  455. package/vendor/hap-nodejs/dist/types.js.map +0 -1
  456. package/vendor/hap-nodejs/package.json +0 -53
  457. package/vendor/hap-nodejs/src/lib/util/hapCrypto.ts +0 -208
@@ -1,2532 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Characteristic = exports.CharacteristicEventTypes = exports.ChangeReason = exports.Access = exports.Perms = exports.Units = exports.Formats = void 0;
4
- exports.isValidPerms = isValidPerms;
5
- exports.describePerms = describePerms;
6
- const tslib_1 = require("tslib");
7
- const assert_1 = tslib_1.__importDefault(require("assert"));
8
- const debug_1 = tslib_1.__importDefault(require("debug"));
9
- const events_1 = require("events");
10
- const util_1 = require("util");
11
- const HAPServer_1 = require("./HAPServer");
12
- const clone_1 = require("./util/clone");
13
- const hapStatusError_1 = require("./util/hapStatusError");
14
- const once_1 = require("./util/once");
15
- const request_util_1 = require("./util/request-util");
16
- const uuid_1 = require("./util/uuid");
17
- const debug = (0, debug_1.default)("HAP-NodeJS:Characteristic");
18
- /**
19
- * @group Characteristic
20
- */
21
- var Formats;
22
- (function (Formats) {
23
- Formats["BOOL"] = "bool";
24
- /**
25
- * Signed 32-bit integer
26
- */
27
- Formats["INT"] = "int";
28
- /**
29
- * Signed 64-bit floating point
30
- */
31
- Formats["FLOAT"] = "float";
32
- /**
33
- * String encoded in utf8
34
- */
35
- Formats["STRING"] = "string";
36
- /**
37
- * Unsigned 8-bit integer.
38
- */
39
- Formats["UINT8"] = "uint8";
40
- /**
41
- * Unsigned 16-bit integer.
42
- */
43
- Formats["UINT16"] = "uint16";
44
- /**
45
- * Unsigned 32-bit integer.
46
- */
47
- Formats["UINT32"] = "uint32";
48
- /**
49
- * Unsigned 64-bit integer.
50
- */
51
- Formats["UINT64"] = "uint64";
52
- /**
53
- * Data is base64 encoded string.
54
- */
55
- Formats["DATA"] = "data";
56
- /**
57
- * Base64 encoded tlv8 string.
58
- */
59
- Formats["TLV8"] = "tlv8";
60
- })(Formats || (exports.Formats = Formats = {}));
61
- /**
62
- * @group Characteristic
63
- */
64
- var Units;
65
- (function (Units) {
66
- /**
67
- * Celsius is the only temperature unit in the HomeKit Accessory Protocol.
68
- * Unit conversion is always done on the client side e.g. on the iPhone in the Home App depending on
69
- * the configured unit on the device itself.
70
- */
71
- Units["CELSIUS"] = "celsius";
72
- Units["PERCENTAGE"] = "percentage";
73
- Units["ARC_DEGREE"] = "arcdegrees";
74
- Units["LUX"] = "lux";
75
- Units["SECONDS"] = "seconds";
76
- })(Units || (exports.Units = Units = {}));
77
- /**
78
- * @group Characteristic
79
- */
80
- var Perms;
81
- (function (Perms) {
82
- Perms["PAIRED_READ"] = "pr";
83
- Perms["PAIRED_WRITE"] = "pw";
84
- Perms["NOTIFY"] = "ev";
85
- // eslint-disable-next-line @typescript-eslint/no-duplicate-enum-values
86
- Perms["EVENTS"] = "ev";
87
- Perms["ADDITIONAL_AUTHORIZATION"] = "aa";
88
- Perms["TIMED_WRITE"] = "tw";
89
- Perms["HIDDEN"] = "hd";
90
- Perms["WRITE_RESPONSE"] = "wr";
91
- })(Perms || (exports.Perms = Perms = {}));
92
- /**
93
- * The wire values of {@link Perms}, as a runtime lookup. A const enum is erased during compilation and cannot be enumerated, so this set is the enum's
94
- * runtime mirror and lives beside it: a permission added to the enum above must be added here as well. The members are referenced rather than retyped,
95
- * so the compiler inlines the same string literals the enum declares. `EVENTS` is an alias of `NOTIFY` and shares its value, hence is not listed.
96
- */
97
- const VALID_PERMS = new Set([
98
- "pr" /* Perms.PAIRED_READ */,
99
- "pw" /* Perms.PAIRED_WRITE */,
100
- "ev" /* Perms.NOTIFY */,
101
- "aa" /* Perms.ADDITIONAL_AUTHORIZATION */,
102
- "tw" /* Perms.TIMED_WRITE */,
103
- "hd" /* Perms.HIDDEN */,
104
- "wr" /* Perms.WRITE_RESPONSE */,
105
- ]);
106
- /**
107
- * Checks that a value is a well-formed permissions array: a non-empty array in which every entry is one of the {@link Perms} wire values.
108
- *
109
- * HomeKit rejects an accessory whose characteristics carry anything else, so {@link Characteristic.setProps} reports a failing array through the
110
- * characteristic warning channel and the accessory database excludes bridged accessories that fail it.
111
- *
112
- * @param perms - the value to check.
113
- * @returns true if the value is a permissions array HomeKit accepts.
114
- *
115
- * @private
116
- */
117
- function isValidPerms(perms) {
118
- if (!Array.isArray(perms) || perms.length === 0) {
119
- return false;
120
- }
121
- // for...of iteration surfaces the holes of a sparse array as undefined, which Array.prototype.every would silently skip. A hole survives JSON
122
- // serialization as null, the exact malformed entry this check exists to reject.
123
- for (const permission of perms) {
124
- if (typeof permission !== "string" || !VALID_PERMS.has(permission)) {
125
- return false;
126
- }
127
- }
128
- return true;
129
- }
130
- /**
131
- * Formats a permissions value for a diagnostic message without ever throwing. `JSON.stringify` is not total over unknown input (a bigint or a cyclic
132
- * entry raises a `TypeError`), and a diagnostic must never become the failure it reports, so anything the JSON form cannot render falls back to
133
- * `util.inspect`, which renders any value.
134
- *
135
- * @param perms - the value to format.
136
- * @returns a human-readable rendering of the value.
137
- *
138
- * @private
139
- */
140
- function describePerms(perms) {
141
- try {
142
- return JSON.stringify(perms) ?? String(perms);
143
- }
144
- catch {
145
- return (0, util_1.inspect)(perms);
146
- }
147
- }
148
- /**
149
- * Describes the abstract access to a {@link Characteristic}.
150
- * It abstracts the more granular access described by {@link Perms}.
151
- *
152
- * It is used in {@link CharacteristicProps.adminOnlyAccess}.
153
- *
154
- * @group Characteristic
155
- */
156
- var Access;
157
- (function (Access) {
158
- Access[Access["READ"] = 0] = "READ";
159
- Access[Access["WRITE"] = 1] = "WRITE";
160
- Access[Access["NOTIFY"] = 2] = "NOTIFY";
161
- })(Access || (exports.Access = Access = {}));
162
- /**
163
- * @group Characteristic
164
- */
165
- var ChangeReason;
166
- (function (ChangeReason) {
167
- /**
168
- * Reason used when HomeKit writes a value or the API user calls {@link Characteristic.setValue}.
169
- */
170
- ChangeReason["WRITE"] = "write";
171
- /**
172
- * Reason used when the API user calls the method {@link Characteristic.updateValue}.
173
- */
174
- ChangeReason["UPDATE"] = "update";
175
- /**
176
- * Used when HomeKit reads a value or the API user calls the deprecated method `Characteristic.getValue`.
177
- */
178
- ChangeReason["READ"] = "read";
179
- /**
180
- * Used when call to {@link Characteristic.sendEventNotification} was made.
181
- */
182
- ChangeReason["EVENT"] = "event";
183
- })(ChangeReason || (exports.ChangeReason = ChangeReason = {}));
184
- /**
185
- * @group Characteristic
186
- */
187
- var CharacteristicEventTypes;
188
- (function (CharacteristicEventTypes) {
189
- /**
190
- * This event is thrown when a HomeKit controller wants to read the current value of the characteristic.
191
- * The event handler should call the supplied callback as fast as possible.
192
- *
193
- * HAP-NodeJS will complain about slow running get handlers after 3 seconds and terminate the request after 10 seconds.
194
- */
195
- CharacteristicEventTypes["GET"] = "get";
196
- /**
197
- * This event is thrown when a HomeKit controller wants to write a new value to the characteristic.
198
- * The event handler should call the supplied callback as fast as possible.
199
- *
200
- * HAP-NodeJS will complain about slow running set handlers after 3 seconds and terminate the request after 10 seconds.
201
- */
202
- CharacteristicEventTypes["SET"] = "set";
203
- /**
204
- * Emitted after a new value is set for the characteristic.
205
- * The new value can be set via a request by a HomeKit controller or via an API call.
206
- */
207
- CharacteristicEventTypes["CHANGE"] = "change";
208
- /**
209
- * @private
210
- */
211
- CharacteristicEventTypes["SUBSCRIBE"] = "subscribe";
212
- /**
213
- * @private
214
- */
215
- CharacteristicEventTypes["UNSUBSCRIBE"] = "unsubscribe";
216
- /**
217
- * @private
218
- */
219
- CharacteristicEventTypes["CHARACTERISTIC_WARNING"] = "characteristic-warning";
220
- })(CharacteristicEventTypes || (exports.CharacteristicEventTypes = CharacteristicEventTypes = {}));
221
- /**
222
- * @group Characteristic
223
- */
224
- class ValidValuesIterable {
225
- props;
226
- constructor(props) {
227
- (0, assert_1.default)((0, request_util_1.isNumericFormat)(props.format), "Cannot instantiate valid values iterable when format is not numeric. Found " + props.format);
228
- this.props = props;
229
- }
230
- *[Symbol.iterator]() {
231
- if (this.props.validValues) {
232
- for (const value of this.props.validValues) {
233
- yield value;
234
- }
235
- }
236
- else {
237
- let min = 0; // default is zero for all the uint types
238
- let max;
239
- let stepValue = 1;
240
- if (this.props.validValueRanges) {
241
- min = this.props.validValueRanges[0];
242
- max = this.props.validValueRanges[1];
243
- }
244
- else if (this.props.minValue != null && this.props.maxValue != null) {
245
- min = this.props.minValue;
246
- max = this.props.maxValue;
247
- if (this.props.minStep != null) {
248
- stepValue = this.props.minStep;
249
- }
250
- }
251
- else if ((0, request_util_1.isUnsignedNumericFormat)(this.props.format)) {
252
- max = (0, request_util_1.numericUpperBound)(this.props.format);
253
- }
254
- else {
255
- throw new Error("Could not find valid iterator strategy for props: " + JSON.stringify(this.props));
256
- }
257
- for (let i = min; i <= max; i += stepValue) {
258
- yield i;
259
- }
260
- }
261
- }
262
- }
263
- const numberPattern = /^-?\d+$/;
264
- function extractHAPStatusFromError(error) {
265
- let errorValue = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
266
- if (numberPattern.test(error.message)) {
267
- const value = parseInt(error.message, 10);
268
- if ((0, HAPServer_1.IsKnownHAPStatusError)(value)) {
269
- errorValue = value;
270
- }
271
- }
272
- return errorValue;
273
- }
274
- function maxWithUndefined(a, b) {
275
- if (a == null) {
276
- return b;
277
- }
278
- else if (b == null) {
279
- return a;
280
- }
281
- else {
282
- return Math.max(a, b);
283
- }
284
- }
285
- function minWithUndefined(a, b) {
286
- if (a == null) {
287
- return b;
288
- }
289
- else if (b == null) {
290
- return a;
291
- }
292
- else {
293
- return Math.min(a, b);
294
- }
295
- }
296
- /**
297
- * Characteristic represents a particular typed variable that can be assigned to a Service. For instance, a
298
- * "Hue" Characteristic might store a 'float' value of type 'arcdegrees'. You could add the Hue Characteristic
299
- * to a {@link Service} in order to store that value. A particular Characteristic is distinguished from others by its
300
- * UUID. HomeKit provides a set of known Characteristic UUIDs defined in HomeKit.ts along with a
301
- * corresponding concrete subclass.
302
- *
303
- * You can also define custom Characteristics by providing your own UUID. Custom Characteristics can be added
304
- * to any native or custom Services, but Siri will likely not be able to work with these.
305
- *
306
- * @group Characteristic
307
- */
308
- // eslint-disable-next-line @typescript-eslint/no-unsafe-declaration-merging
309
- class Characteristic extends events_1.EventEmitter {
310
- // Pattern below is for automatic detection of the section of defined characteristics. Used by the generator
311
- // -=-=-=-=-=-=-=-=-=-=-=-=-=-=-
312
- /**
313
- * @group Characteristic Definitions
314
- */
315
- static AccessCodeControlPoint;
316
- /**
317
- * @group Characteristic Definitions
318
- */
319
- static AccessCodeSupportedConfiguration;
320
- /**
321
- * @group Characteristic Definitions
322
- */
323
- static AccessControlLevel;
324
- /**
325
- * @group Characteristic Definitions
326
- */
327
- static AccessoryFlags;
328
- /**
329
- * @group Characteristic Definitions
330
- */
331
- static AccessoryIdentifier;
332
- /**
333
- * @group Characteristic Definitions
334
- */
335
- static Active;
336
- /**
337
- * @group Characteristic Definitions
338
- */
339
- static ActiveIdentifier;
340
- /**
341
- * @group Characteristic Definitions
342
- */
343
- static ActivityInterval;
344
- /**
345
- * @group Characteristic Definitions
346
- */
347
- static AdministratorOnlyAccess;
348
- /**
349
- * @group Characteristic Definitions
350
- */
351
- static AirParticulateDensity;
352
- /**
353
- * @group Characteristic Definitions
354
- */
355
- static AirParticulateSize;
356
- /**
357
- * @group Characteristic Definitions
358
- */
359
- static AirPlayEnable;
360
- /**
361
- * @group Characteristic Definitions
362
- */
363
- static AirQuality;
364
- /**
365
- * @group Characteristic Definitions
366
- */
367
- static AppMatchingIdentifier;
368
- /**
369
- * @group Characteristic Definitions
370
- */
371
- static AssetUpdateReadiness;
372
- /**
373
- * @group Characteristic Definitions
374
- */
375
- static AudioFeedback;
376
- /**
377
- * @group Characteristic Definitions
378
- */
379
- static BatteryLevel;
380
- /**
381
- * @group Characteristic Definitions
382
- */
383
- static Brightness;
384
- /**
385
- * @group Characteristic Definitions
386
- */
387
- static BufferActivityCommand;
388
- /**
389
- * @group Characteristic Definitions
390
- */
391
- static BufferEventCommand;
392
- /**
393
- * @group Characteristic Definitions
394
- */
395
- static BufferEventSequenceNumber;
396
- /**
397
- * @group Characteristic Definitions
398
- */
399
- static BufferUploadCommand;
400
- /**
401
- * @group Characteristic Definitions
402
- */
403
- static ButtonEvent;
404
- /**
405
- * @group Characteristic Definitions
406
- */
407
- static CameraCapabilitiesConfiguration;
408
- /**
409
- * @group Characteristic Definitions
410
- */
411
- static CameraClientCertificate;
412
- /**
413
- * @group Characteristic Definitions
414
- */
415
- static CameraClientCertificateStatus;
416
- /**
417
- * @group Characteristic Definitions
418
- */
419
- static CameraClientCSR;
420
- /**
421
- * @group Characteristic Definitions
422
- */
423
- static CameraKey;
424
- /**
425
- * @group Characteristic Definitions
426
- */
427
- static CameraKeyID;
428
- /**
429
- * @group Characteristic Definitions
430
- */
431
- static CameraOperatingModeIndicator;
432
- /**
433
- * @group Characteristic Definitions
434
- */
435
- static CameraRecordingPublishingPoint;
436
- /**
437
- * @group Characteristic Definitions
438
- */
439
- static CameraZones;
440
- /**
441
- * @group Characteristic Definitions
442
- */
443
- static CarbonDioxideDetected;
444
- /**
445
- * @group Characteristic Definitions
446
- */
447
- static CarbonDioxideLevel;
448
- /**
449
- * @group Characteristic Definitions
450
- */
451
- static CarbonDioxidePeakLevel;
452
- /**
453
- * @group Characteristic Definitions
454
- */
455
- static CarbonMonoxideDetected;
456
- /**
457
- * @group Characteristic Definitions
458
- */
459
- static CarbonMonoxideLevel;
460
- /**
461
- * @group Characteristic Definitions
462
- */
463
- static CarbonMonoxidePeakLevel;
464
- /**
465
- * @group Characteristic Definitions
466
- */
467
- static CCAEnergyDetectThreshold;
468
- /**
469
- * @group Characteristic Definitions
470
- */
471
- static CCASignalDetectThreshold;
472
- /**
473
- * @group Characteristic Definitions
474
- */
475
- static CharacteristicValueActiveTransitionCount;
476
- /**
477
- * @group Characteristic Definitions
478
- */
479
- static CharacteristicValueTransitionControl;
480
- /**
481
- * @group Characteristic Definitions
482
- */
483
- static ChargingState;
484
- /**
485
- * @group Characteristic Definitions
486
- */
487
- static ClosedCaptions;
488
- /**
489
- * @group Characteristic Definitions
490
- */
491
- static ColorTemperature;
492
- /**
493
- * @group Characteristic Definitions
494
- */
495
- static ConfigurationState;
496
- /**
497
- * @group Characteristic Definitions
498
- */
499
- static ConfiguredName;
500
- /**
501
- * @group Characteristic Definitions
502
- */
503
- static ConnectionHealthMonitor;
504
- /**
505
- * @group Characteristic Definitions
506
- */
507
- static ContactSensorState;
508
- /**
509
- * @group Characteristic Definitions
510
- */
511
- static ContributingSensors;
512
- /**
513
- * @group Characteristic Definitions
514
- */
515
- static CoolingThresholdTemperature;
516
- /**
517
- * @group Characteristic Definitions
518
- */
519
- static CryptoHash;
520
- /**
521
- * @group Characteristic Definitions
522
- */
523
- static CurrentAirPurifierState;
524
- /**
525
- * @group Characteristic Definitions
526
- */
527
- static CurrentAmbientLightLevel;
528
- /**
529
- * @group Characteristic Definitions
530
- */
531
- static CurrentDoorState;
532
- /**
533
- * @group Characteristic Definitions
534
- */
535
- static CurrentFanState;
536
- /**
537
- * @group Characteristic Definitions
538
- */
539
- static CurrentHeaterCoolerState;
540
- /**
541
- * @group Characteristic Definitions
542
- */
543
- static CurrentHeatingCoolingState;
544
- /**
545
- * @group Characteristic Definitions
546
- */
547
- static CurrentHorizontalTiltAngle;
548
- /**
549
- * @group Characteristic Definitions
550
- */
551
- static CurrentHumidifierDehumidifierState;
552
- /**
553
- * @group Characteristic Definitions
554
- */
555
- static CurrentMediaState;
556
- /**
557
- * @group Characteristic Definitions
558
- */
559
- static CurrentPosition;
560
- /**
561
- * @group Characteristic Definitions
562
- */
563
- static CurrentRelativeHumidity;
564
- /**
565
- * @group Characteristic Definitions
566
- */
567
- static CurrentSlatState;
568
- /**
569
- * @group Characteristic Definitions
570
- */
571
- static CurrentTemperature;
572
- /**
573
- * @group Characteristic Definitions
574
- */
575
- static CurrentTiltAngle;
576
- /**
577
- * @group Characteristic Definitions
578
- */
579
- static CurrentTransport;
580
- /**
581
- * @group Characteristic Definitions
582
- */
583
- static CurrentVerticalTiltAngle;
584
- /**
585
- * @group Characteristic Definitions
586
- */
587
- static CurrentVisibilityState;
588
- /**
589
- * @group Characteristic Definitions
590
- */
591
- static DataStreamHAPTransport;
592
- /**
593
- * @group Characteristic Definitions
594
- */
595
- static DataStreamHAPTransportInterrupt;
596
- /**
597
- * @group Characteristic Definitions
598
- */
599
- static DiagonalFieldOfView;
600
- /**
601
- * @group Characteristic Definitions
602
- */
603
- static DigitalZoom;
604
- /**
605
- * @group Characteristic Definitions
606
- */
607
- static DisplayOrder;
608
- /**
609
- * @group Characteristic Definitions
610
- */
611
- static EventRetransmissionMaximum;
612
- /**
613
- * @group Characteristic Definitions
614
- */
615
- static EventSnapshotsActive;
616
- /**
617
- * @group Characteristic Definitions
618
- */
619
- static EventTransmissionCounters;
620
- /**
621
- * @group Characteristic Definitions
622
- */
623
- static FilterChangeIndication;
624
- /**
625
- * @group Characteristic Definitions
626
- */
627
- static FilterLifeLevel;
628
- /**
629
- * @group Characteristic Definitions
630
- */
631
- static FirmwareRevision;
632
- /**
633
- * @group Characteristic Definitions
634
- */
635
- static FirmwareUpdateProtocolList;
636
- /**
637
- * @group Characteristic Definitions
638
- */
639
- static FirmwareUpdateReadiness;
640
- /**
641
- * @group Characteristic Definitions
642
- */
643
- static FirmwareUpdateStatus;
644
- /**
645
- * @group Characteristic Definitions
646
- */
647
- static HardwareFinish;
648
- /**
649
- * @group Characteristic Definitions
650
- */
651
- static HardwareRevision;
652
- /**
653
- * @group Characteristic Definitions
654
- */
655
- static HeartBeat;
656
- /**
657
- * @group Characteristic Definitions
658
- */
659
- static HeatingThresholdTemperature;
660
- /**
661
- * @group Characteristic Definitions
662
- */
663
- static HoldPosition;
664
- /**
665
- * @group Characteristic Definitions
666
- */
667
- static HomeKitCameraActive;
668
- /**
669
- * @group Characteristic Definitions
670
- */
671
- static Hue;
672
- /**
673
- * @group Characteristic Definitions
674
- */
675
- static Identifier;
676
- /**
677
- * @group Characteristic Definitions
678
- */
679
- static Identify;
680
- /**
681
- * @group Characteristic Definitions
682
- */
683
- static ImageMirroring;
684
- /**
685
- * @group Characteristic Definitions
686
- */
687
- static ImageRotation;
688
- /**
689
- * @group Characteristic Definitions
690
- */
691
- static InputDeviceType;
692
- /**
693
- * @group Characteristic Definitions
694
- */
695
- static InputSourceType;
696
- /**
697
- * @group Characteristic Definitions
698
- */
699
- static InUse;
700
- /**
701
- * @group Characteristic Definitions
702
- */
703
- static IsConfigured;
704
- /**
705
- * @group Characteristic Definitions
706
- */
707
- static LeakDetected;
708
- /**
709
- * @group Characteristic Definitions
710
- */
711
- static ListPairings;
712
- /**
713
- * @group Characteristic Definitions
714
- */
715
- static LockControlPoint;
716
- /**
717
- * @group Characteristic Definitions
718
- */
719
- static LockCurrentState;
720
- /**
721
- * @group Characteristic Definitions
722
- */
723
- static LockLastKnownAction;
724
- /**
725
- * @group Characteristic Definitions
726
- */
727
- static LockManagementAutoSecurityTimeout;
728
- /**
729
- * @group Characteristic Definitions
730
- */
731
- static LockPhysicalControls;
732
- /**
733
- * @group Characteristic Definitions
734
- */
735
- static LockTargetState;
736
- /**
737
- * @group Characteristic Definitions
738
- */
739
- static Logs;
740
- /**
741
- * @group Characteristic Definitions
742
- */
743
- static MACRetransmissionMaximum;
744
- /**
745
- * @group Characteristic Definitions
746
- */
747
- static MACTransmissionCounters;
748
- /**
749
- * @group Characteristic Definitions
750
- */
751
- static ManagedNetworkEnable;
752
- /**
753
- * @group Characteristic Definitions
754
- */
755
- static ManuallyDisabled;
756
- /**
757
- * @group Characteristic Definitions
758
- */
759
- static Manufacturer;
760
- /**
761
- * @group Characteristic Definitions
762
- */
763
- static MatterFirmwareRevisionNumber;
764
- /**
765
- * @group Characteristic Definitions
766
- */
767
- static MatterFirmwareUpdateStatus;
768
- /**
769
- * @group Characteristic Definitions
770
- */
771
- static MaximumTransmitPower;
772
- /**
773
- * @group Characteristic Definitions
774
- */
775
- static MediaAccessControlLevel;
776
- /**
777
- * @group Characteristic Definitions
778
- */
779
- static MetricsBufferFullState;
780
- /**
781
- * @group Characteristic Definitions
782
- */
783
- static Model;
784
- /**
785
- * @group Characteristic Definitions
786
- */
787
- static MotionDetected;
788
- /**
789
- * @group Characteristic Definitions
790
- */
791
- static MotionEnabled;
792
- /**
793
- * @group Characteristic Definitions
794
- */
795
- static MultifunctionButton;
796
- /**
797
- * @group Characteristic Definitions
798
- */
799
- static Mute;
800
- /**
801
- * @group Characteristic Definitions
802
- */
803
- static Name;
804
- /**
805
- * @group Characteristic Definitions
806
- */
807
- static NetworkAccessViolationControl;
808
- /**
809
- * @group Characteristic Definitions
810
- */
811
- static NetworkClientProfileControl;
812
- /**
813
- * @group Characteristic Definitions
814
- */
815
- static NetworkClientStatusControl;
816
- /**
817
- * @group Characteristic Definitions
818
- */
819
- static NFCAccessControlPoint;
820
- /**
821
- * @group Characteristic Definitions
822
- */
823
- static NFCAccessSupportedConfiguration;
824
- /**
825
- * @group Characteristic Definitions
826
- */
827
- static NightVision;
828
- /**
829
- * @group Characteristic Definitions
830
- */
831
- static NitrogenDioxideDensity;
832
- /**
833
- * @group Characteristic Definitions
834
- */
835
- static ObstructionDetected;
836
- /**
837
- * @group Characteristic Definitions
838
- */
839
- static OccupancyDetected;
840
- /**
841
- * @group Characteristic Definitions
842
- */
843
- static On;
844
- /**
845
- * @group Characteristic Definitions
846
- */
847
- static OperatingStateResponse;
848
- /**
849
- * @group Characteristic Definitions
850
- */
851
- static OpticalZoom;
852
- /**
853
- * @group Characteristic Definitions
854
- */
855
- static OutletInUse;
856
- /**
857
- * @group Characteristic Definitions
858
- */
859
- static OzoneDensity;
860
- /**
861
- * @group Characteristic Definitions
862
- */
863
- static PairingFeatures;
864
- /**
865
- * @group Characteristic Definitions
866
- */
867
- static PairSetup;
868
- /**
869
- * @group Characteristic Definitions
870
- */
871
- static PairVerify;
872
- /**
873
- * @group Characteristic Definitions
874
- */
875
- static PasswordSetting;
876
- /**
877
- * @group Characteristic Definitions
878
- */
879
- static PeriodicSnapshotsActive;
880
- /**
881
- * @group Characteristic Definitions
882
- */
883
- static PictureMode;
884
- /**
885
- * @group Characteristic Definitions
886
- */
887
- static Ping;
888
- /**
889
- * @group Characteristic Definitions
890
- */
891
- static PM10Density;
892
- /**
893
- * @group Characteristic Definitions
894
- */
895
- static PM2_5Density;
896
- /**
897
- * @group Characteristic Definitions
898
- */
899
- static PositionState;
900
- /**
901
- * @group Characteristic Definitions
902
- */
903
- static PowerModeSelection;
904
- /**
905
- * @group Characteristic Definitions
906
- */
907
- static PreferredWiFiList;
908
- /**
909
- * @group Characteristic Definitions
910
- */
911
- static ProductData;
912
- /**
913
- * @group Characteristic Definitions
914
- */
915
- static ProgrammableSwitchEvent;
916
- /**
917
- * @group Characteristic Definitions
918
- */
919
- static ProgrammableSwitchOutputState;
920
- /**
921
- * @group Characteristic Definitions
922
- */
923
- static ProgramMode;
924
- /**
925
- * @group Characteristic Definitions
926
- */
927
- static ReceivedSignalStrengthIndication;
928
- /**
929
- * @group Characteristic Definitions
930
- */
931
- static ReceiverSensitivity;
932
- /**
933
- * @group Characteristic Definitions
934
- */
935
- static RecordingAudioActive;
936
- /**
937
- * @group Characteristic Definitions
938
- */
939
- static RelativeHumidityDehumidifierThreshold;
940
- /**
941
- * @group Characteristic Definitions
942
- */
943
- static RelativeHumidityHumidifierThreshold;
944
- /**
945
- * @group Characteristic Definitions
946
- * @deprecated Removed
947
- */
948
- static RelayControlPoint;
949
- /**
950
- * @group Characteristic Definitions
951
- * @deprecated Removed
952
- */
953
- static RelayEnabled;
954
- /**
955
- * @group Characteristic Definitions
956
- * @deprecated Removed
957
- */
958
- static RelayState;
959
- /**
960
- * @group Characteristic Definitions
961
- */
962
- static RemainingDuration;
963
- /**
964
- * @group Characteristic Definitions
965
- */
966
- static RemoteKey;
967
- /**
968
- * @group Characteristic Definitions
969
- */
970
- static ResetFilterIndication;
971
- /**
972
- * @group Characteristic Definitions
973
- */
974
- static RotationDirection;
975
- /**
976
- * @group Characteristic Definitions
977
- */
978
- static RotationSpeed;
979
- /**
980
- * @group Characteristic Definitions
981
- */
982
- static RouterStatus;
983
- /**
984
- * @group Characteristic Definitions
985
- */
986
- static RTPStreamingControl;
987
- /**
988
- * @group Characteristic Definitions
989
- */
990
- static Saturation;
991
- /**
992
- * @group Characteristic Definitions
993
- */
994
- static SecuritySystemAlarmType;
995
- /**
996
- * @group Characteristic Definitions
997
- */
998
- static SecuritySystemCurrentState;
999
- /**
1000
- * @group Characteristic Definitions
1001
- */
1002
- static SecuritySystemTargetState;
1003
- /**
1004
- * @group Characteristic Definitions
1005
- */
1006
- static SelectedAudioStreamConfiguration;
1007
- /**
1008
- * @group Characteristic Definitions
1009
- */
1010
- static SelectedCameraRecordingConfiguration;
1011
- /**
1012
- * @group Characteristic Definitions
1013
- */
1014
- static SelectedDiagnosticsModes;
1015
- /**
1016
- * @group Characteristic Definitions
1017
- */
1018
- static SelectedRTPStreamConfiguration;
1019
- /**
1020
- * @group Characteristic Definitions
1021
- */
1022
- static SelectedSessionKeepaliveConfigurationList;
1023
- /**
1024
- * @group Characteristic Definitions
1025
- */
1026
- static SelectedSleepConfiguration;
1027
- /**
1028
- * @group Characteristic Definitions
1029
- */
1030
- static SensorUUID;
1031
- /**
1032
- * @group Characteristic Definitions
1033
- */
1034
- static SerialNumber;
1035
- /**
1036
- * @group Characteristic Definitions
1037
- */
1038
- static ServiceLabelIndex;
1039
- /**
1040
- * @group Characteristic Definitions
1041
- */
1042
- static ServiceLabelNamespace;
1043
- /**
1044
- * @group Characteristic Definitions
1045
- */
1046
- static SetDuration;
1047
- /**
1048
- * @group Characteristic Definitions
1049
- */
1050
- static SetupDataStreamTransport;
1051
- /**
1052
- * @group Characteristic Definitions
1053
- */
1054
- static SetupEndpoints;
1055
- /**
1056
- * @group Characteristic Definitions
1057
- */
1058
- static SetupTransferTransport;
1059
- /**
1060
- * @group Characteristic Definitions
1061
- */
1062
- static SignalToNoiseRatio;
1063
- /**
1064
- * @group Characteristic Definitions
1065
- */
1066
- static SiriEnable;
1067
- /**
1068
- * @group Characteristic Definitions
1069
- */
1070
- static SiriEndpointSessionStatus;
1071
- /**
1072
- * @group Characteristic Definitions
1073
- */
1074
- static SiriEngineVersion;
1075
- /**
1076
- * @group Characteristic Definitions
1077
- */
1078
- static SiriInputType;
1079
- /**
1080
- * @group Characteristic Definitions
1081
- */
1082
- static SiriLightOnUse;
1083
- /**
1084
- * @group Characteristic Definitions
1085
- */
1086
- static SiriListening;
1087
- /**
1088
- * @group Characteristic Definitions
1089
- */
1090
- static SiriTouchToUse;
1091
- /**
1092
- * @group Characteristic Definitions
1093
- */
1094
- static SlatType;
1095
- /**
1096
- * @group Characteristic Definitions
1097
- */
1098
- static SleepDiscoveryMode;
1099
- /**
1100
- * @group Characteristic Definitions
1101
- */
1102
- static SleepInterval;
1103
- /**
1104
- * @group Characteristic Definitions
1105
- */
1106
- static SmokeDetected;
1107
- /**
1108
- * @group Characteristic Definitions
1109
- */
1110
- static SoftwareRevision;
1111
- /**
1112
- * @group Characteristic Definitions
1113
- */
1114
- static StagedFirmwareVersion;
1115
- /**
1116
- * @group Characteristic Definitions
1117
- */
1118
- static StatusActive;
1119
- /**
1120
- * @group Characteristic Definitions
1121
- */
1122
- static StatusFault;
1123
- /**
1124
- * @group Characteristic Definitions
1125
- */
1126
- static StatusJammed;
1127
- /**
1128
- * @group Characteristic Definitions
1129
- */
1130
- static StatusLowBattery;
1131
- /**
1132
- * @group Characteristic Definitions
1133
- */
1134
- static StatusTampered;
1135
- /**
1136
- * @group Characteristic Definitions
1137
- */
1138
- static StreamingEnabled;
1139
- /**
1140
- * @group Characteristic Definitions
1141
- */
1142
- static StreamingStatus;
1143
- /**
1144
- * @group Characteristic Definitions
1145
- */
1146
- static SulphurDioxideDensity;
1147
- /**
1148
- * @group Characteristic Definitions
1149
- */
1150
- static SupportedAssetTypes;
1151
- /**
1152
- * @group Characteristic Definitions
1153
- */
1154
- static SupportedAudioRecordingConfiguration;
1155
- /**
1156
- * @group Characteristic Definitions
1157
- */
1158
- static SupportedAudioStreamConfiguration;
1159
- /**
1160
- * @group Characteristic Definitions
1161
- */
1162
- static SupportedAudioStreamTiers;
1163
- /**
1164
- * @group Characteristic Definitions
1165
- */
1166
- static SupportedCameraRecordingConfiguration;
1167
- /**
1168
- * @group Characteristic Definitions
1169
- */
1170
- static SupportedCharacteristicValueTransitionConfiguration;
1171
- /**
1172
- * @group Characteristic Definitions
1173
- */
1174
- static SupportedDataStreamTransportConfiguration;
1175
- /**
1176
- * @group Characteristic Definitions
1177
- */
1178
- static SupportedDiagnosticsModes;
1179
- /**
1180
- * @group Characteristic Definitions
1181
- */
1182
- static SupportedDiagnosticsSnapshot;
1183
- /**
1184
- * @group Characteristic Definitions
1185
- */
1186
- static SupportedFirmwareUpdateConfiguration;
1187
- /**
1188
- * @group Characteristic Definitions
1189
- */
1190
- static SupportedMetrics;
1191
- /**
1192
- * @group Characteristic Definitions
1193
- */
1194
- static SupportedRouterConfiguration;
1195
- /**
1196
- * @group Characteristic Definitions
1197
- */
1198
- static SupportedRTPConfiguration;
1199
- /**
1200
- * @group Characteristic Definitions
1201
- */
1202
- static SupportedSessionKeepaliveConfigurationList;
1203
- /**
1204
- * @group Characteristic Definitions
1205
- */
1206
- static SupportedSleepConfiguration;
1207
- /**
1208
- * @group Characteristic Definitions
1209
- */
1210
- static SupportedTransferTransportConfiguration;
1211
- /**
1212
- * @group Characteristic Definitions
1213
- */
1214
- static SupportedVideoRecordingConfiguration;
1215
- /**
1216
- * @group Characteristic Definitions
1217
- */
1218
- static SupportedVideoStreamConfiguration;
1219
- /**
1220
- * @group Characteristic Definitions
1221
- */
1222
- static SupportedVideoStreamTiers;
1223
- /**
1224
- * @group Characteristic Definitions
1225
- */
1226
- static SwingMode;
1227
- /**
1228
- * @group Characteristic Definitions
1229
- * @deprecated Removed
1230
- */
1231
- static TapType;
1232
- /**
1233
- * @group Characteristic Definitions
1234
- */
1235
- static TargetAirPurifierState;
1236
- /**
1237
- * @group Characteristic Definitions
1238
- */
1239
- static TargetControlList;
1240
- /**
1241
- * @group Characteristic Definitions
1242
- */
1243
- static TargetControlSupportedConfiguration;
1244
- /**
1245
- * @group Characteristic Definitions
1246
- */
1247
- static TargetDoorState;
1248
- /**
1249
- * @group Characteristic Definitions
1250
- */
1251
- static TargetFanState;
1252
- /**
1253
- * @group Characteristic Definitions
1254
- */
1255
- static TargetHeaterCoolerState;
1256
- /**
1257
- * @group Characteristic Definitions
1258
- */
1259
- static TargetHeatingCoolingState;
1260
- /**
1261
- * @group Characteristic Definitions
1262
- */
1263
- static TargetHorizontalTiltAngle;
1264
- /**
1265
- * @group Characteristic Definitions
1266
- */
1267
- static TargetHumidifierDehumidifierState;
1268
- /**
1269
- * @group Characteristic Definitions
1270
- */
1271
- static TargetMediaState;
1272
- /**
1273
- * @group Characteristic Definitions
1274
- */
1275
- static TargetPosition;
1276
- /**
1277
- * @group Characteristic Definitions
1278
- */
1279
- static TargetRelativeHumidity;
1280
- /**
1281
- * @group Characteristic Definitions
1282
- */
1283
- static TargetTemperature;
1284
- /**
1285
- * @group Characteristic Definitions
1286
- */
1287
- static TargetTiltAngle;
1288
- /**
1289
- * @group Characteristic Definitions
1290
- */
1291
- static TargetVerticalTiltAngle;
1292
- /**
1293
- * @group Characteristic Definitions
1294
- */
1295
- static TargetVisibilityState;
1296
- /**
1297
- * @group Characteristic Definitions
1298
- */
1299
- static TemperatureDisplayUnits;
1300
- /**
1301
- * @group Characteristic Definitions
1302
- */
1303
- static ThirdPartyCameraActive;
1304
- /**
1305
- * @group Characteristic Definitions
1306
- */
1307
- static ThreadControlPoint;
1308
- /**
1309
- * @group Characteristic Definitions
1310
- */
1311
- static ThreadNodeCapabilities;
1312
- /**
1313
- * @group Characteristic Definitions
1314
- */
1315
- static ThreadOpenThreadVersion;
1316
- /**
1317
- * @group Characteristic Definitions
1318
- */
1319
- static ThreadStatus;
1320
- /**
1321
- * @group Characteristic Definitions
1322
- * @deprecated Removed
1323
- */
1324
- static Token;
1325
- /**
1326
- * @group Characteristic Definitions
1327
- */
1328
- static TransmitPower;
1329
- /**
1330
- * @group Characteristic Definitions
1331
- * @deprecated Removed
1332
- */
1333
- static TunnelConnectionTimeout;
1334
- /**
1335
- * @group Characteristic Definitions
1336
- * @deprecated Removed
1337
- */
1338
- static TunneledAccessoryAdvertising;
1339
- /**
1340
- * @group Characteristic Definitions
1341
- * @deprecated Removed
1342
- */
1343
- static TunneledAccessoryConnected;
1344
- /**
1345
- * @group Characteristic Definitions
1346
- * @deprecated Removed
1347
- */
1348
- static TunneledAccessoryStateNumber;
1349
- /**
1350
- * @group Characteristic Definitions
1351
- */
1352
- static ValveType;
1353
- /**
1354
- * @group Characteristic Definitions
1355
- */
1356
- static Version;
1357
- /**
1358
- * @group Characteristic Definitions
1359
- */
1360
- static VideoAnalysisActive;
1361
- /**
1362
- * @group Characteristic Definitions
1363
- */
1364
- static VOCDensity;
1365
- /**
1366
- * @group Characteristic Definitions
1367
- */
1368
- static Volume;
1369
- /**
1370
- * @group Characteristic Definitions
1371
- */
1372
- static VolumeControlType;
1373
- /**
1374
- * @group Characteristic Definitions
1375
- */
1376
- static VolumeSelector;
1377
- /**
1378
- * @group Characteristic Definitions
1379
- */
1380
- static WakeConfiguration;
1381
- /**
1382
- * @group Characteristic Definitions
1383
- */
1384
- static WANConfigurationList;
1385
- /**
1386
- * @group Characteristic Definitions
1387
- */
1388
- static WANStatusList;
1389
- /**
1390
- * @group Characteristic Definitions
1391
- */
1392
- static WaterLevel;
1393
- /**
1394
- * @group Characteristic Definitions
1395
- */
1396
- static WebRTCNumberOfActiveSessions;
1397
- /**
1398
- * @group Characteristic Definitions
1399
- */
1400
- static WebRTCProvideAnswer;
1401
- /**
1402
- * @group Characteristic Definitions
1403
- */
1404
- static WebRTCReoffer;
1405
- /**
1406
- * @group Characteristic Definitions
1407
- */
1408
- static WebRTCSolicitOffer;
1409
- /**
1410
- * @group Characteristic Definitions
1411
- */
1412
- static WebRTCStreamingControl;
1413
- /**
1414
- * @group Characteristic Definitions
1415
- */
1416
- static WebRTCSupportedAudioStreamTiers;
1417
- /**
1418
- * @group Characteristic Definitions
1419
- */
1420
- static WebRTCSupportedVideoStreamTiers;
1421
- /**
1422
- * @group Characteristic Definitions
1423
- */
1424
- static WebRTCUpdateSession;
1425
- /**
1426
- * @group Characteristic Definitions
1427
- */
1428
- static WiFiCapabilities;
1429
- /**
1430
- * @group Characteristic Definitions
1431
- */
1432
- static WiFiConfigurationControl;
1433
- /**
1434
- * @group Characteristic Definitions
1435
- */
1436
- static WiFiSatelliteStatus;
1437
- // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1438
- // NOTICE: when adding/changing properties, remember to possibly adjust the serialize/deserialize functions
1439
- displayName;
1440
- UUID;
1441
- iid = null;
1442
- value = null;
1443
- /**
1444
- * @private
1445
- */
1446
- statusCode = 0 /* HAPStatus.SUCCESS */;
1447
- props;
1448
- /**
1449
- * The {@link Characteristic.onGet} handler
1450
- */
1451
- getHandler;
1452
- /**
1453
- * The {@link Characteristic.onSet} handler
1454
- */
1455
- setHandler;
1456
- subscriptions = 0;
1457
- /**
1458
- * @private
1459
- */
1460
- additionalAuthorizationHandler;
1461
- constructor(displayName, UUID, props) {
1462
- super();
1463
- this.displayName = displayName;
1464
- this.UUID = UUID;
1465
- this.props = {
1466
- format: "int" /* Formats.INT */,
1467
- perms: ["ev" /* Perms.NOTIFY */],
1468
- };
1469
- this.setProps(props || {}); // ensure sanity checks are called
1470
- }
1471
- /**
1472
- * Accepts a function that will be called to retrieve the current value of a Characteristic.
1473
- * The function must return a valid Characteristic value for the Characteristic type.
1474
- * May optionally return a promise.
1475
- *
1476
- * @example
1477
- * ```ts
1478
- * Characteristic.onGet(async () => {
1479
- * return true;
1480
- * });
1481
- * ```
1482
- * @param handler
1483
- */
1484
- onGet(handler) {
1485
- if (typeof handler !== "function") {
1486
- this.characteristicWarning(".onGet handler must be a function");
1487
- return this;
1488
- }
1489
- this.getHandler = handler;
1490
- return this;
1491
- }
1492
- /**
1493
- * Removes the {@link CharacteristicGetHandler} handler which was configured using {@link onGet}.
1494
- */
1495
- removeOnGet() {
1496
- this.getHandler = undefined;
1497
- return this;
1498
- }
1499
- /**
1500
- * Accepts a function that will be called when setting the value of a Characteristic.
1501
- * If the characteristic supports {@link Perms.WRITE_RESPONSE} and the request requests a write-response value,
1502
- * the returned value will be used.
1503
- * May optionally return a promise.
1504
- *
1505
- * @example
1506
- * ```ts
1507
- * Characteristic.onSet(async (value: CharacteristicValue) => {
1508
- * console.log(value);
1509
- * });
1510
- * ```
1511
- * @param handler
1512
- */
1513
- onSet(handler) {
1514
- if (typeof handler !== "function") {
1515
- this.characteristicWarning(".onSet handler must be a function");
1516
- return this;
1517
- }
1518
- this.setHandler = handler;
1519
- return this;
1520
- }
1521
- /**
1522
- * Removes the {@link CharacteristicSetHandler} which was configured using {@link onSet}.
1523
- */
1524
- removeOnSet() {
1525
- this.setHandler = undefined;
1526
- return this;
1527
- }
1528
- /**
1529
- * Updates the properties of this characteristic.
1530
- * Properties passed via the parameter will be set. Any parameter set to null will be deleted.
1531
- * See {@link CharacteristicProps}.
1532
- *
1533
- * @param props - Partial properties object with the desired updates.
1534
- */
1535
- setProps(props) {
1536
- (0, assert_1.default)(props, "props cannot be undefined when setting props");
1537
- // TODO calling setProps after publish doesn't lead to a increment in the current configuration number
1538
- let formatDidChange = false;
1539
- // for every value "null" can be used to reset props, except for required props
1540
- if (props.format) {
1541
- formatDidChange = this.props.format !== props.format;
1542
- this.props.format = props.format;
1543
- }
1544
- /* A malformed permissions array is reported through the characteristic warning channel and assigned anyway, so the model holds exactly what the plugin
1545
- * declared and the accessories serving boundary - the one place that decides what HomeKit is shown - can quarantine the accessory until the permissions
1546
- * are corrected. A throw here would surface inside plugin characteristic constructors and inside cached accessory restore, neither of which is wrapped
1547
- * by anything that can recover.
1548
- */
1549
- if (props.perms) {
1550
- if (!isValidPerms(props.perms)) {
1551
- this.characteristicWarning(`characteristic contains invalid permissions: ${describePerms(props.perms)}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, undefined, true);
1552
- }
1553
- /* Everything downstream treats `props.perms` as an array. A non-array is the dangerous shape rather than merely an invalid one: on a string
1554
- * `includes` substring-matches, so a declared `"pr"` would answer true to a paired-read check and quietly grant access, and `push` would throw
1555
- * out of {@link setupAdditionalAuthorization}. An empty array fails {@link isValidPerms} exactly as the declared value does, so the accessory is
1556
- * still quarantined - it just fails closed on the way there. The warning above quotes what the plugin actually declared.
1557
- */
1558
- this.props.perms = Array.isArray(props.perms) ? props.perms : [];
1559
- }
1560
- if (props.unit !== undefined) {
1561
- this.props.unit = props.unit != null ? props.unit : undefined;
1562
- }
1563
- if (props.description !== undefined) {
1564
- this.props.description = props.description != null ? props.description : undefined;
1565
- }
1566
- // check minValue is valid for the format type
1567
- if (props.minValue !== undefined) {
1568
- if (props.minValue === null) {
1569
- props.minValue = undefined;
1570
- }
1571
- else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1572
- this.characteristicWarning("Characteristic Property 'minValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1573
- props.minValue = undefined;
1574
- }
1575
- else if (typeof props.minValue !== "number" || !Number.isFinite(props.minValue)) {
1576
- this.characteristicWarning(`Characteristic Property 'minValue' must be a finite number, received "${props.minValue}" (${typeof props.minValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1577
- props.minValue = undefined;
1578
- }
1579
- else {
1580
- if (props.minValue < (0, request_util_1.numericLowerBound)(this.props.format)) {
1581
- this.characteristicWarning("Characteristic Property 'minValue' was set to " + props.minValue + ", but for numeric format " +
1582
- this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1583
- props.minValue = (0, request_util_1.numericLowerBound)(this.props.format);
1584
- }
1585
- else if (props.minValue > (0, request_util_1.numericUpperBound)(this.props.format)) {
1586
- this.characteristicWarning("Characteristic Property 'minValue' was set to " + props.minValue + ", but for numeric format " +
1587
- this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1588
- props.minValue = (0, request_util_1.numericLowerBound)(this.props.format);
1589
- }
1590
- }
1591
- this.props.minValue = props.minValue;
1592
- }
1593
- // check maxValue is valid for the format type
1594
- if (props.maxValue !== undefined) {
1595
- if (props.maxValue === null) {
1596
- props.maxValue = undefined;
1597
- }
1598
- else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1599
- this.characteristicWarning("Characteristic Property 'maxValue' can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1600
- props.maxValue = undefined;
1601
- }
1602
- else if (typeof props.maxValue !== "number" || !Number.isFinite(props.maxValue)) {
1603
- this.characteristicWarning(`Characteristic Property 'maxValue' must be a finite number, received "${props.maxValue}" (${typeof props.maxValue})`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1604
- props.maxValue = undefined;
1605
- }
1606
- else {
1607
- if (props.maxValue > (0, request_util_1.numericUpperBound)(this.props.format)) {
1608
- this.characteristicWarning("Characteristic Property 'maxValue' was set to " + props.maxValue + ", but for numeric format " +
1609
- this.props.format + " maximum possible is " + (0, request_util_1.numericUpperBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1610
- props.maxValue = (0, request_util_1.numericUpperBound)(this.props.format);
1611
- }
1612
- else if (props.maxValue < (0, request_util_1.numericLowerBound)(this.props.format)) {
1613
- this.characteristicWarning("Characteristic Property 'maxValue' was set to " + props.maxValue + ", but for numeric format " +
1614
- this.props.format + " minimum possible is " + (0, request_util_1.numericLowerBound)(this.props.format), "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1615
- props.maxValue = (0, request_util_1.numericUpperBound)(this.props.format);
1616
- }
1617
- }
1618
- this.props.maxValue = props.maxValue;
1619
- }
1620
- if (props.minStep !== undefined) {
1621
- if (props.minStep === null) {
1622
- this.props.minStep = undefined;
1623
- }
1624
- else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1625
- this.characteristicWarning("Characteristic Property `minStep` can only be set for characteristics with numeric format, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1626
- }
1627
- else {
1628
- if (props.minStep < 1 && (0, request_util_1.isIntegerNumericFormat)(this.props.format)) {
1629
- this.characteristicWarning("Characteristic Property `minStep` was set to a value lower than 1, " +
1630
- "this will have no effect on format `" + this.props.format);
1631
- }
1632
- this.props.minStep = props.minStep;
1633
- }
1634
- }
1635
- if (props.maxLen !== undefined) {
1636
- if (props.maxLen === null) {
1637
- this.props.maxLen = undefined;
1638
- }
1639
- else if (this.props.format !== "string" /* Formats.STRING */) {
1640
- this.characteristicWarning("Characteristic Property `maxLen` can only be set for characteristics with format `STRING`, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1641
- }
1642
- else {
1643
- if (props.maxLen > 256) {
1644
- this.characteristicWarning("Characteristic Property string `maxLen` cannot be bigger than 256");
1645
- props.maxLen = 256;
1646
- }
1647
- this.props.maxLen = props.maxLen;
1648
- }
1649
- }
1650
- if (props.maxDataLen !== undefined) {
1651
- if (props.maxDataLen === null) {
1652
- this.props.maxDataLen = undefined;
1653
- }
1654
- else if (this.props.format !== "data" /* Formats.DATA */) {
1655
- this.characteristicWarning("Characteristic Property `maxDataLen` can only be set for characteristics with format `DATA`, but not for " + this.props.format, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
1656
- }
1657
- else {
1658
- this.props.maxDataLen = props.maxDataLen;
1659
- }
1660
- }
1661
- if (props.validValues !== undefined) {
1662
- if (props.validValues === null) {
1663
- this.props.validValues = undefined;
1664
- }
1665
- else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1666
- this.characteristicWarning("Characteristic Property `validValues` was supplied for non numeric format " + this.props.format);
1667
- }
1668
- else {
1669
- (0, assert_1.default)(props.validValues.length, "characteristic prop validValues cannot be empty array");
1670
- this.props.validValues = props.validValues;
1671
- }
1672
- }
1673
- if (props.validValueRanges !== undefined) {
1674
- if (props.validValueRanges === null) {
1675
- this.props.validValueRanges = undefined;
1676
- }
1677
- else if (!(0, request_util_1.isNumericFormat)(this.props.format)) {
1678
- this.characteristicWarning("Characteristic Property `validValueRanges` was supplied for non numeric format " + this.props.format);
1679
- }
1680
- else {
1681
- (0, assert_1.default)(props.validValueRanges.length === 2, "characteristic prop validValueRanges must have a length of 2");
1682
- this.props.validValueRanges = props.validValueRanges;
1683
- }
1684
- }
1685
- if (props.adminOnlyAccess !== undefined) {
1686
- this.props.adminOnlyAccess = props.adminOnlyAccess != null ? props.adminOnlyAccess : undefined;
1687
- }
1688
- if (this.props.minValue != null && this.props.maxValue != null) { // the eqeq instead of eqeqeq is important here
1689
- if (this.props.minValue > this.props.maxValue) { // see https://github.com/homebridge/HAP-NodeJS/issues/690
1690
- this.props.minValue = undefined;
1691
- this.props.maxValue = undefined;
1692
- throw new Error("Error setting CharacteristicsProps for '" + this.displayName + "': 'minValue' cannot be greater or equal the 'maxValue'!");
1693
- }
1694
- }
1695
- if (((0, request_util_1.isNumericFormat)(this.props.format) || this.props.format === "string" /* Formats.STRING */)
1696
- && this.value != null
1697
- && !formatDidChange
1698
- && this.statusCode === 0 /* HAPStatus.SUCCESS */
1699
- && this.UUID !== Characteristic.ProgrammableSwitchEvent.UUID) {
1700
- // explaining the if statement above:
1701
- // - We only do a check for numeric and string formats as they are the only ones affected by characteristic property restrictions.
1702
- // - There must be a value to begin with. Otherwise, it should just stay not having a value at all (anything else is guess work).
1703
- // - If the format is changed through `setProps` we rely on the user to supply a valid value after the `setProps` call!
1704
- // - If the characteristic is marked as erroneous the value is not considered valid anyway, and we must not remove the `statusCode`.
1705
- // - Special case for `ProgrammableSwitchEvent` where every change in value is considered an event which would result in ghost button presses
1706
- // validateUserInput when called from setProps is intended to clamp value withing allowed range. It is why warnings should not be displayed.
1707
- const correctedValue = this.validateUserInput(this.value, "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1708
- if (correctedValue !== this.value) {
1709
- // we don't want to emit a CHANGE event if the value didn't change at all!
1710
- this.updateValue(correctedValue);
1711
- }
1712
- }
1713
- return this;
1714
- }
1715
- /**
1716
- * This method can be used to gain an Iterator to loop over all valid values defined for this characteristic.
1717
- *
1718
- * The range of valid values can be defined using three different ways via the {@link CharacteristicProps} object
1719
- * (set via the {@link setProps} method):
1720
- * * First method is to specifically list every valid value inside {@link CharacteristicProps.validValues}
1721
- * * Second you can specify a range via {@link CharacteristicProps.minValue} and {@link CharacteristicProps.maxValue} (with optionally defining
1722
- * {@link CharacteristicProps.minStep})
1723
- * * And lastly you can specify a range via {@link CharacteristicProps.validValueRanges}
1724
- * * Implicitly a valid value range is predefined for characteristics with Format {@link Formats.UINT8}, {@link Formats.UINT16},
1725
- * {@link Formats.UINT32} and {@link Formats.UINT64}: starting by zero to their respective maximum number
1726
- *
1727
- * The method will automatically detect which type of valid values definition is used and provide
1728
- * the correct Iterator for that case.
1729
- *
1730
- * Note: This method is (obviously) only valid for numeric characteristics.
1731
- *
1732
- * @example
1733
- * ```ts
1734
- * // use the iterator to loop over every valid value...
1735
- * for (const value of characteristic.validValuesIterator()) {
1736
- * // Insert logic to run for every
1737
- * }
1738
- *
1739
- * // ... or collect them in an array for storage or manipulation
1740
- * const validValues = Array.from(characteristic.validValuesIterator());
1741
- * ```
1742
- */
1743
- validValuesIterator() {
1744
- return new ValidValuesIterable(this.props);
1745
- }
1746
- // noinspection JSUnusedGlobalSymbols
1747
- /**
1748
- * This method can be used to set up additional authorization for a characteristic.
1749
- * For one, it adds the {@link Perms.ADDITIONAL_AUTHORIZATION} permission to the characteristic
1750
- * (if it wasn't already) to signal support for additional authorization to HomeKit.
1751
- * Additionally, an {@link AdditionalAuthorizationHandler} is set up which is called
1752
- * before a write request is performed.
1753
- *
1754
- * Additional Authorization Data can be added to SET request via a custom iOS App.
1755
- * Before hap-nodejs executes a write request it will call the {@link AdditionalAuthorizationHandler}
1756
- * with 'authData' supplied in the write request. The 'authData' is a base64 encoded string
1757
- * (or undefined if no authData was supplied).
1758
- * The {@link AdditionalAuthorizationHandler} must then return true or false to indicate if the write request
1759
- * is authorized and should be accepted.
1760
- *
1761
- * @param handler - Handler called to check additional authorization data.
1762
- */
1763
- setupAdditionalAuthorization(handler) {
1764
- if (!this.props.perms.includes("aa" /* Perms.ADDITIONAL_AUTHORIZATION */)) {
1765
- this.props.perms.push("aa" /* Perms.ADDITIONAL_AUTHORIZATION */);
1766
- }
1767
- this.additionalAuthorizationHandler = handler;
1768
- }
1769
- setValue(value, callback, context) {
1770
- if (value instanceof Error) {
1771
- this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
1772
- if (callback) {
1773
- callback();
1774
- }
1775
- return this;
1776
- }
1777
- if (callback && !context && typeof callback !== "function") {
1778
- context = callback;
1779
- callback = undefined;
1780
- }
1781
- try {
1782
- value = this.validateUserInput(value);
1783
- }
1784
- catch (error) {
1785
- this.characteristicWarning(error?.message || "Unknown error", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1786
- if (callback) {
1787
- callback(error);
1788
- }
1789
- return this;
1790
- }
1791
- this.handleSetRequest(value, undefined, context).then(value => {
1792
- if (callback) {
1793
- if (value) { // possible write response
1794
- callback(null, value);
1795
- }
1796
- else {
1797
- callback(null);
1798
- }
1799
- }
1800
- }, reason => {
1801
- if (callback) {
1802
- callback(reason);
1803
- }
1804
- });
1805
- return this;
1806
- }
1807
- updateValue(value, callback, context) {
1808
- if (value instanceof Error) {
1809
- this.statusCode = value instanceof hapStatusError_1.HapStatusError ? value.hapStatus : extractHAPStatusFromError(value);
1810
- if (callback) {
1811
- callback();
1812
- }
1813
- return this;
1814
- }
1815
- if (callback && !context && typeof callback !== "function") {
1816
- context = callback;
1817
- callback = undefined;
1818
- }
1819
- try {
1820
- value = this.validateUserInput(value);
1821
- }
1822
- catch (error) {
1823
- this.characteristicWarning(error?.message || "Unknown error", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1824
- if (callback) {
1825
- callback();
1826
- }
1827
- return this;
1828
- }
1829
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
1830
- const oldValue = this.value;
1831
- this.value = value;
1832
- if (callback) {
1833
- callback();
1834
- }
1835
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "update" /* ChangeReason.UPDATE */, context: context });
1836
- return this; // for chaining
1837
- }
1838
- /**
1839
- * This method acts similarly to {@link updateValue} by setting the current value of the characteristic
1840
- * without calling any {@link CharacteristicEventTypes.SET} or {@link onSet} handlers.
1841
- * The difference is that this method forces an event notification sent (updateValue only sends one if the value changed).
1842
- * This is especially useful for characteristics like {@link Characteristic.ButtonEvent} or {@link Characteristic.ProgrammableSwitchEvent}.
1843
- *
1844
- * @param value - The new value.
1845
- * @param context - Passed to the {@link CharacteristicEventTypes.CHANGE} event handler.
1846
- */
1847
- sendEventNotification(value, context) {
1848
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
1849
- value = this.validateUserInput(value);
1850
- const oldValue = this.value;
1851
- this.value = value;
1852
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: undefined, oldValue: oldValue, newValue: value, reason: "event" /* ChangeReason.EVENT */, context: context });
1853
- return this; // for chaining
1854
- }
1855
- /**
1856
- * Called when a HAP requests wants to know the current value of the characteristic.
1857
- *
1858
- * @param connection - The HAP connection from which the request originated from.
1859
- * @param context - Deprecated parameter. There for backwards compatibility.
1860
- * @private Used by the Accessory to load the characteristic value
1861
- */
1862
- async handleGetRequest(connection, context) {
1863
- if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) { // check if we are allowed to read from this characteristic
1864
- throw -70405 /* HAPStatus.WRITE_ONLY_CHARACTERISTIC */;
1865
- }
1866
- if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
1867
- // special workaround for event only programmable switch event, which must always return null
1868
- return null;
1869
- }
1870
- if (this.getHandler) {
1871
- if (this.listeners("get" /* CharacteristicEventTypes.GET */).length > 0) {
1872
- this.characteristicWarning("Ignoring on('get') handler as onGet handler was defined instead");
1873
- }
1874
- try {
1875
- let value = await this.getHandler(context, connection);
1876
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
1877
- try {
1878
- value = this.validateUserInput(value);
1879
- }
1880
- catch (error) {
1881
- this.characteristicWarning(`An illegal value was supplied by the read handler for characteristic: ${error?.message}`, "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error?.stack);
1882
- this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1883
- return Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
1884
- }
1885
- const oldValue = this.value;
1886
- this.value = value;
1887
- if (oldValue !== value) { // emit a change event if necessary
1888
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
1889
- }
1890
- return value;
1891
- }
1892
- catch (error) {
1893
- if (typeof error === "number") {
1894
- const hapStatusError = new hapStatusError_1.HapStatusError(error);
1895
- this.statusCode = hapStatusError.hapStatus;
1896
- }
1897
- else if (error instanceof hapStatusError_1.HapStatusError) {
1898
- this.statusCode = error.hapStatus;
1899
- }
1900
- else {
1901
- this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1902
- this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1903
- }
1904
- throw this.statusCode;
1905
- }
1906
- }
1907
- if (this.listeners("get" /* CharacteristicEventTypes.GET */).length === 0) {
1908
- if (this.statusCode) {
1909
- throw this.statusCode;
1910
- }
1911
- try {
1912
- return this.validateUserInput(this.value);
1913
- }
1914
- catch (error) {
1915
- this.characteristicWarning(`An illegal value was supplied by setting \`value\` for characteristic: ${error?.message}`, "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, error?.stack);
1916
- return Promise.reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
1917
- }
1918
- }
1919
- return new Promise((resolve, reject) => {
1920
- try {
1921
- this.emit("get" /* CharacteristicEventTypes.GET */, (0, once_1.once)((status, value) => {
1922
- if (status) {
1923
- if (typeof status === "number") {
1924
- const hapStatusError = new hapStatusError_1.HapStatusError(status);
1925
- this.statusCode = hapStatusError.hapStatus;
1926
- }
1927
- else if (status instanceof hapStatusError_1.HapStatusError) {
1928
- this.statusCode = status.hapStatus;
1929
- }
1930
- else {
1931
- debug("[%s] Received error from get handler %s", this.displayName, status.stack);
1932
- this.statusCode = extractHAPStatusFromError(status);
1933
- }
1934
- reject(this.statusCode);
1935
- return;
1936
- }
1937
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
1938
- value = this.validateUserInput(value);
1939
- const oldValue = this.value;
1940
- this.value = value;
1941
- resolve(value);
1942
- if (oldValue !== value) { // emit a change event if necessary
1943
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "read" /* ChangeReason.READ */, context: context });
1944
- }
1945
- }), context, connection);
1946
- }
1947
- catch (error) {
1948
- this.characteristicWarning(`Unhandled error thrown inside read handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
1949
- this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
1950
- reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
1951
- }
1952
- });
1953
- }
1954
- /**
1955
- * Called when a HAP requests update the current value of the characteristic.
1956
- *
1957
- * @param value - The updated value
1958
- * @param connection - The connection from which the request originated from
1959
- * @param context - Deprecated parameter. There for backwards compatibility.
1960
- * @returns Promise resolve to void in normal operation. When characteristic supports write-response, HAP
1961
- * requests a write-response and the set handler returns a write-response value, the respective
1962
- * write response value is resolved.
1963
- * @private
1964
- */
1965
- async handleSetRequest(value, connection, context) {
1966
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
1967
- if (connection !== undefined) {
1968
- // if connection is undefined, the set "request" comes from the setValue method.
1969
- // for setValue a value of "null" is allowed and checked via validateUserInput.
1970
- try {
1971
- value = this.validateClientSuppliedValue(value);
1972
- }
1973
- catch (e) {
1974
- debug(`[${this.displayName}]`, e.message);
1975
- return Promise.reject(-70410 /* HAPStatus.INVALID_VALUE_IN_REQUEST */);
1976
- }
1977
- }
1978
- const oldValue = this.value;
1979
- if (this.setHandler) {
1980
- if (this.listeners("set" /* CharacteristicEventTypes.SET */).length > 0) {
1981
- this.characteristicWarning("Ignoring on('set') handler as onSet handler was defined instead");
1982
- }
1983
- try {
1984
- const writeResponse = await this.setHandler(value, context, connection);
1985
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
1986
- if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
1987
- this.value = this.validateUserInput(writeResponse);
1988
- return this.value;
1989
- }
1990
- else {
1991
- if (writeResponse != null) {
1992
- this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
1993
- }
1994
- this.value = value;
1995
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
1996
- return;
1997
- }
1998
- }
1999
- catch (error) {
2000
- if (typeof error === "number") {
2001
- const hapStatusError = new hapStatusError_1.HapStatusError(error);
2002
- this.statusCode = hapStatusError.hapStatus;
2003
- }
2004
- else if (error instanceof hapStatusError_1.HapStatusError) {
2005
- this.statusCode = error.hapStatus;
2006
- }
2007
- else {
2008
- this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
2009
- this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
2010
- }
2011
- throw this.statusCode;
2012
- }
2013
- }
2014
- if (this.listeners("set" /* CharacteristicEventTypes.SET */).length === 0) {
2015
- this.value = value;
2016
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
2017
- return Promise.resolve();
2018
- }
2019
- else {
2020
- return new Promise((resolve, reject) => {
2021
- try {
2022
- this.emit("set" /* CharacteristicEventTypes.SET */, value, (0, once_1.once)((status, writeResponse) => {
2023
- if (status) {
2024
- if (typeof status === "number") {
2025
- const hapStatusError = new hapStatusError_1.HapStatusError(status);
2026
- this.statusCode = hapStatusError.hapStatus;
2027
- }
2028
- else if (status instanceof hapStatusError_1.HapStatusError) {
2029
- this.statusCode = status.hapStatus;
2030
- }
2031
- else {
2032
- debug("[%s] Received error from set handler %s", this.displayName, status.stack);
2033
- this.statusCode = extractHAPStatusFromError(status);
2034
- }
2035
- reject(this.statusCode);
2036
- return;
2037
- }
2038
- this.statusCode = 0 /* HAPStatus.SUCCESS */;
2039
- if (writeResponse != null && this.props.perms.includes("wr" /* Perms.WRITE_RESPONSE */)) {
2040
- // support write response simply by letting the implementor pass the response as second argument to the callback
2041
- this.value = this.validateUserInput(writeResponse);
2042
- resolve(this.value);
2043
- }
2044
- else {
2045
- if (writeResponse != null) {
2046
- this.characteristicWarning("SET handler returned write response value, though the characteristic doesn't support write response", "debug-message" /* CharacteristicWarningType.DEBUG_MESSAGE */);
2047
- }
2048
- this.value = value;
2049
- resolve();
2050
- this.emit("change" /* CharacteristicEventTypes.CHANGE */, { originator: connection, oldValue: oldValue, newValue: value, reason: "write" /* ChangeReason.WRITE */, context: context });
2051
- }
2052
- }), context, connection);
2053
- }
2054
- catch (error) {
2055
- this.characteristicWarning(`Unhandled error thrown inside write handler for characteristic: ${error?.message}`, "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */, error?.stack);
2056
- this.statusCode = -70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */;
2057
- reject(-70402 /* HAPStatus.SERVICE_COMMUNICATION_FAILURE */);
2058
- }
2059
- });
2060
- }
2061
- }
2062
- /**
2063
- * Called once a HomeKit controller subscribes to events of this characteristic.
2064
- * @private
2065
- */
2066
- subscribe() {
2067
- if (this.subscriptions === 0) {
2068
- this.emit("subscribe" /* CharacteristicEventTypes.SUBSCRIBE */);
2069
- }
2070
- this.subscriptions++;
2071
- }
2072
- /**
2073
- * Called once a HomeKit controller unsubscribe to events of this characteristic or a HomeKit controller
2074
- * which was subscribed to this characteristic disconnects.
2075
- * @private
2076
- */
2077
- unsubscribe() {
2078
- const wasOne = this.subscriptions === 1;
2079
- this.subscriptions--;
2080
- this.subscriptions = Math.max(this.subscriptions, 0);
2081
- if (wasOne) {
2082
- this.emit("unsubscribe" /* CharacteristicEventTypes.UNSUBSCRIBE */);
2083
- }
2084
- }
2085
- getDefaultValue() {
2086
- // noinspection JSDeprecatedSymbols
2087
- switch (this.props.format) {
2088
- case "bool" /* Formats.BOOL */:
2089
- return false;
2090
- case "string" /* Formats.STRING */:
2091
- switch (this.UUID) {
2092
- case Characteristic.Manufacturer.UUID:
2093
- return "Default-Manufacturer";
2094
- case Characteristic.Model.UUID:
2095
- return "Default-Model";
2096
- case Characteristic.SerialNumber.UUID:
2097
- return "Default-SerialNumber";
2098
- case Characteristic.FirmwareRevision.UUID:
2099
- return "0.0.0";
2100
- default:
2101
- return "";
2102
- }
2103
- case "data" /* Formats.DATA */:
2104
- return ""; // who knows!
2105
- case "tlv8" /* Formats.TLV8 */:
2106
- return ""; // who knows!
2107
- case "int" /* Formats.INT */:
2108
- case "float" /* Formats.FLOAT */:
2109
- case "uint8" /* Formats.UINT8 */:
2110
- case "uint16" /* Formats.UINT16 */:
2111
- case "uint32" /* Formats.UINT32 */:
2112
- case "uint64" /* Formats.UINT64 */:
2113
- switch (this.UUID) {
2114
- case Characteristic.CurrentTemperature.UUID:
2115
- return 0; // some existing integrations expect this to be 0 by default
2116
- default: {
2117
- if (this.props.validValues?.length && typeof this.props.validValues[0] === "number") {
2118
- return this.props.validValues[0];
2119
- }
2120
- if (typeof this.props.minValue === "number" && Number.isFinite(this.props.minValue)) {
2121
- return this.props.minValue;
2122
- }
2123
- return 0;
2124
- }
2125
- }
2126
- default:
2127
- return 0;
2128
- }
2129
- }
2130
- /**
2131
- * Checks if the value received from the HAP request is valid.
2132
- * If returned false the received value is not valid and {@link HAPStatus.INVALID_VALUE_IN_REQUEST}
2133
- * must be returned.
2134
- * @param value - Value supplied by the HomeKit controller
2135
- */
2136
- validateClientSuppliedValue(value) {
2137
- if (value == null) {
2138
- throw new Error(`Client supplied invalid value for ${this.props.format}: ${value}`);
2139
- }
2140
- switch (this.props.format) {
2141
- case "bool" /* Formats.BOOL */: {
2142
- if (typeof value === "boolean") {
2143
- return value;
2144
- }
2145
- if (typeof value === "number" && (value === 1 || value === 0)) {
2146
- return Boolean(value);
2147
- }
2148
- throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
2149
- }
2150
- case "int" /* Formats.INT */:
2151
- case "float" /* Formats.FLOAT */:
2152
- case "uint8" /* Formats.UINT8 */:
2153
- case "uint16" /* Formats.UINT16 */:
2154
- case "uint32" /* Formats.UINT32 */:
2155
- case "uint64" /* Formats.UINT64 */: {
2156
- if (typeof value === "boolean") {
2157
- value = value ? 1 : 0;
2158
- }
2159
- if (typeof value !== "number" || !Number.isFinite(value)) {
2160
- throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
2161
- }
2162
- const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
2163
- const numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
2164
- if (typeof numericMin === "number" && value < numericMin) {
2165
- throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${numericMin}`);
2166
- }
2167
- if (typeof numericMax === "number" && value > numericMax) {
2168
- throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${numericMax}`);
2169
- }
2170
- if (this.props.validValues && !this.props.validValues.includes(value)) {
2171
- throw new Error(`Client supplied value of ${value} is not in ${this.props.validValues.toString()}`);
2172
- }
2173
- if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
2174
- if (value < this.props.validValueRanges[0]) {
2175
- throw new Error(`Client supplied value of ${value} is less than the minimum allowed value of ${this.props.validValueRanges[0]}`);
2176
- }
2177
- if (value > this.props.validValueRanges[1]) {
2178
- throw new Error(`Client supplied value of ${value} is greater than the maximum allowed value of ${this.props.validValueRanges[1]}`);
2179
- }
2180
- }
2181
- return value;
2182
- }
2183
- case "string" /* Formats.STRING */: {
2184
- if (typeof value !== "string") {
2185
- throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
2186
- }
2187
- const maxLength = this.props.maxLen != null ? this.props.maxLen : 64; // default is 64; max is 256 which is set in setProps
2188
- if (value.length > maxLength) {
2189
- throw new Error(`Client supplied value length of ${value.length} exceeds maximum length allowed of ${maxLength}`);
2190
- }
2191
- return value;
2192
- }
2193
- case "data" /* Formats.DATA */: {
2194
- if (typeof value !== "string") {
2195
- throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
2196
- }
2197
- // we don't validate base64 here
2198
- const maxLength = this.props.maxDataLen != null ? this.props.maxDataLen : 0x200000; // default is 0x200000
2199
- if (value.length > maxLength) {
2200
- throw new Error(`Client supplied value length of ${value.length} exceeds maximum length allowed of ${maxLength}`);
2201
- }
2202
- return value;
2203
- }
2204
- case "tlv8" /* Formats.TLV8 */:
2205
- if (typeof value !== "string") {
2206
- throw new Error(`Client supplied invalid type for ${this.props.format}: "${value}" (${typeof value})`);
2207
- }
2208
- return value;
2209
- }
2210
- return value;
2211
- }
2212
- /**
2213
- * Checks if the value received from the API call is valid.
2214
- * It adjusts the value where it makes sense, prints a warning where values may be rejected with an error
2215
- * in the future and throws an error which can't be converted to a valid value.
2216
- *
2217
- * @param value - The value received from the API call
2218
- * @param warningType - Optionally defines the warning type to use when raising a {@link CharacteristicEventTypes.CHARACTERISTIC_WARNING}.
2219
- */
2220
- validateUserInput(value, warningType = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */) {
2221
- if (value === null) {
2222
- if (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID) { // mirrors the statement in case: Formats.STRING
2223
- this.characteristicWarning("characteristic must have a non null value otherwise HomeKit will reject this accessory, ignoring new value", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
2224
- return this.value; // don't change the value
2225
- }
2226
- if (this.props.format === "data" /* Formats.DATA */ || this.props.format === "tlv8" /* Formats.TLV8 */) {
2227
- return value; // TLV8 and DATA formats are allowed to have null as a value
2228
- }
2229
- /**
2230
- * A short disclaimer here.
2231
- * null is actually a perfectly valid value for characteristics to have.
2232
- * The Home app will show "no response" for some characteristics for which it can't handle null
2233
- * but ultimately its valid and the developers decision what the return.
2234
- * BUT: out of history hap-nodejs did replace null with the last known value and thus
2235
- * homebridge devs started to adopting this method as a way of not changing the value in a GET handler.
2236
- * As an intermediate step we kept the behavior but added a warning printed to the console.
2237
- * In a future update we will do the breaking change of return null below!
2238
- */
2239
- if (this.UUID.endsWith(uuid_1.BASE_UUID)) { // we have an apple defined characteristic (at least assuming nobody else uses the UUID namespace)
2240
- if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
2241
- return value; // null is allowed as a value for ProgrammableSwitchEvent
2242
- }
2243
- this.characteristicWarning("characteristic was supplied illegal value: null! Home App will reject null for Apple defined characteristics", warningType);
2244
- // if the value has been set previously, return it now, otherwise continue with validation to have a default value set.
2245
- if (this.value !== null) {
2246
- return this.value;
2247
- }
2248
- }
2249
- else {
2250
- // we currently allow null for any non-custom defined characteristics
2251
- return value;
2252
- }
2253
- }
2254
- switch (this.props.format) {
2255
- case "bool" /* Formats.BOOL */: {
2256
- if (typeof value === "boolean") {
2257
- return value;
2258
- }
2259
- if (typeof value === "number") {
2260
- return value === 1;
2261
- }
2262
- if (typeof value === "string") {
2263
- return value === "1" || value === "true";
2264
- }
2265
- this.characteristicWarning("characteristic value expected boolean and received " + typeof value, warningType);
2266
- return false;
2267
- }
2268
- case "int" /* Formats.INT */:
2269
- case "float" /* Formats.FLOAT */:
2270
- case "uint8" /* Formats.UINT8 */:
2271
- case "uint16" /* Formats.UINT16 */:
2272
- case "uint32" /* Formats.UINT32 */:
2273
- case "uint64" /* Formats.UINT64 */: {
2274
- if (typeof value === "boolean") {
2275
- value = value ? 1 : 0;
2276
- }
2277
- if (typeof value === "string") {
2278
- value = this.props.format === "float" /* Formats.FLOAT */ ? parseFloat(value) : parseInt(value, 10);
2279
- }
2280
- if (typeof value !== "number" || !Number.isFinite(value)) {
2281
- this.characteristicWarning(`characteristic value expected valid finite number and received "${value}" (${typeof value})`, warningType);
2282
- value = typeof this.value === "number" ? this.value : this.props.minValue || 0;
2283
- }
2284
- const numericMin = maxWithUndefined(this.props.minValue, (0, request_util_1.numericLowerBound)(this.props.format));
2285
- let numericMax = minWithUndefined(this.props.maxValue, (0, request_util_1.numericUpperBound)(this.props.format));
2286
- let stepValue;
2287
- if (this.props.format === "float" /* Formats.FLOAT */) {
2288
- stepValue = this.props.minStep;
2289
- }
2290
- else {
2291
- stepValue = maxWithUndefined(this.props.minStep, 1);
2292
- }
2293
- if (stepValue != null && stepValue > 0) {
2294
- const minValue = this.props.minValue != null ? this.props.minValue : 0;
2295
- if (numericMax != null) {
2296
- numericMax = stepValue * Math.floor((numericMax - minValue) / stepValue) + minValue;
2297
- }
2298
- value = stepValue * Math.round((value - minValue) / stepValue) + minValue;
2299
- }
2300
- if (numericMin != null && value < numericMin) {
2301
- this.characteristicWarning(`characteristic was supplied illegal value: number ${value} exceeded minimum of ${numericMin}`, warningType);
2302
- value = numericMin;
2303
- }
2304
- if (numericMax != null && value > numericMax) {
2305
- this.characteristicWarning(`characteristic was supplied illegal value: number ${value} exceeded maximum of ${numericMax}`, warningType);
2306
- value = numericMax;
2307
- }
2308
- if (this.props.validValues && !this.props.validValues.includes(value)) {
2309
- this.characteristicWarning(`characteristic value ${value} is not contained in valid values array`, warningType);
2310
- return this.props.validValues.includes(this.value) ? this.value : (this.props.validValues[0] || 0);
2311
- }
2312
- if (this.props.validValueRanges && this.props.validValueRanges.length === 2) {
2313
- if (value < this.props.validValueRanges[0]) {
2314
- this.characteristicWarning(`characteristic was supplied illegal value: number ${value} not contained in valid value range of `
2315
- + `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
2316
- value = this.props.validValueRanges[0];
2317
- }
2318
- else if (value > this.props.validValueRanges[1]) {
2319
- this.characteristicWarning(`characteristic was supplied illegal value: number ${value} not contained in valid value range of `
2320
- + `${this.props.validValueRanges}, supplying illegal values will throw errors in the future`, warningType);
2321
- value = this.props.validValueRanges[1];
2322
- }
2323
- }
2324
- return value;
2325
- }
2326
- case "string" /* Formats.STRING */: {
2327
- if (typeof value === "number") {
2328
- this.characteristicWarning("characteristic was supplied illegal value: number instead of string, " +
2329
- "supplying illegal values will throw errors in the future", warningType);
2330
- value = String(value);
2331
- }
2332
- if (typeof value !== "string") {
2333
- this.characteristicWarning("characteristic value expected string and received " + (typeof value), warningType);
2334
- value = typeof this.value === "string" ? this.value : value + "";
2335
- }
2336
- // mirrors the case value = null at the beginning
2337
- if (value.length <= 1 && (this.UUID === Characteristic.Model.UUID || this.UUID === Characteristic.SerialNumber.UUID)) {
2338
- this.characteristicWarning(`[${this.displayName}] characteristic must have a length of more than 1 character otherwise`
2339
- + ` HomeKit will reject this accessory, ignoring new value ${warningType}`);
2340
- return this.value; // just return the current value
2341
- }
2342
- const maxLength = this.props.maxLen ?? 64; // default is 64 (max is 256 which is set in setProps)
2343
- if (value.length > maxLength) {
2344
- this.characteristicWarning(`characteristic was supplied illegal value: string '${value}' exceeded max length of ${maxLength}`, warningType);
2345
- value = value.substring(0, maxLength);
2346
- }
2347
- return value;
2348
- }
2349
- case "data" /* Formats.DATA */:
2350
- if (typeof value !== "string") {
2351
- throw new Error("characteristic with DATA format must have string value");
2352
- }
2353
- if (this.props.maxDataLen != null && value.length > this.props.maxDataLen) {
2354
- // can't cut it as we would basically set binary rubbish afterwards
2355
- throw new Error("characteristic with DATA format exceeds specified maxDataLen");
2356
- }
2357
- return value;
2358
- case "tlv8" /* Formats.TLV8 */:
2359
- if (value === undefined) {
2360
- this.characteristicWarning("characteristic was supplied illegal value: undefined", warningType);
2361
- return this.value;
2362
- }
2363
- return value; // we trust that this is valid tlv8
2364
- }
2365
- // hopefully it shouldn't get to this point
2366
- if (value === undefined) {
2367
- this.characteristicWarning("characteristic was supplied illegal value: undefined", "error-message" /* CharacteristicWarningType.ERROR_MESSAGE */);
2368
- return this.value;
2369
- }
2370
- return value;
2371
- }
2372
- /**
2373
- * @private used to assign iid to characteristic
2374
- */
2375
- _assignID(identifierCache, accessoryName, serviceUUID, serviceSubtype) {
2376
- // generate our IID based on our UUID
2377
- this.iid = identifierCache.getIID(accessoryName, serviceUUID, serviceSubtype, this.UUID);
2378
- }
2379
- /**
2380
- * @param message - what went wrong.
2381
- * @param type - the severity the subscribers see.
2382
- * @param stack - where it was raised.
2383
- * @param reportWhenUnheard - print to the console if nothing is subscribed. **Only for a message that describes how a characteristic was DECLARED.**
2384
- * A characteristic that is not part of a service yet has nothing subscribed to its warnings, and a declaration is made in the constructor, which is
2385
- * exactly where a plugin gets it wrong - so those warnings would otherwise vanish. Every other warning quotes the offending characteristic VALUE
2386
- * (see {@link validateUserInput}), and on something like {@link Characteristic.PasswordSetting} that value is the secret itself, so those keep the
2387
- * long-standing behaviour of going nowhere until an accessory is listening.
2388
- */
2389
- characteristicWarning(message, type = "warn-message" /* CharacteristicWarningType.WARN_MESSAGE */, stack = new Error().stack, reportWhenUnheard = false) {
2390
- const heard = this.emit("characteristic-warning" /* CharacteristicEventTypes.CHARACTERISTIC_WARNING */, type, message, stack);
2391
- if (!heard && reportWhenUnheard) {
2392
- // The stack the subscribers would have received goes with it: a characteristic with no service carries no accessory or service name, so it is
2393
- // the only thing that locates the fault.
2394
- console.warn(`HAP-NodeJS WARNING: [${this.displayName} (${this.UUID})] ${message}\nThrown at: ${stack ?? "unknown"}`);
2395
- }
2396
- }
2397
- /**
2398
- * @param event
2399
- * @private
2400
- */
2401
- removeAllListeners(event) {
2402
- if (!event) {
2403
- this.removeOnGet();
2404
- this.removeOnSet();
2405
- }
2406
- return super.removeAllListeners(event);
2407
- }
2408
- /**
2409
- * @param characteristic
2410
- * @private
2411
- */
2412
- replaceBy(characteristic) {
2413
- this.props = characteristic.props;
2414
- this.updateValue(characteristic.value);
2415
- const getListeners = characteristic.listeners("get" /* CharacteristicEventTypes.GET */);
2416
- if (getListeners.length) {
2417
- // the callback can only be called once, so we remove all old listeners
2418
- this.removeAllListeners("get" /* CharacteristicEventTypes.GET */);
2419
- getListeners.forEach(listener => this.addListener("get" /* CharacteristicEventTypes.GET */, listener));
2420
- }
2421
- this.removeOnGet();
2422
- if (characteristic.getHandler) {
2423
- this.onGet(characteristic.getHandler);
2424
- }
2425
- const setListeners = characteristic.listeners("set" /* CharacteristicEventTypes.SET */);
2426
- if (setListeners.length) {
2427
- // the callback can only be called once, so we remove all old listeners
2428
- this.removeAllListeners("set" /* CharacteristicEventTypes.SET */);
2429
- setListeners.forEach(listener => this.addListener("set" /* CharacteristicEventTypes.SET */, listener));
2430
- }
2431
- this.removeOnSet();
2432
- if (characteristic.setHandler) {
2433
- this.onSet(characteristic.setHandler);
2434
- }
2435
- }
2436
- /**
2437
- * Returns a JSON representation of this characteristic suitable for delivering to HAP clients.
2438
- * @private used to generate response to /accessories query
2439
- */
2440
- async toHAP(connection, contactGetHandlers = true) {
2441
- const object = this.internalHAPRepresentation();
2442
- if (!this.props.perms.includes("pr" /* Perms.PAIRED_READ */)) {
2443
- object.value = undefined;
2444
- }
2445
- else if (this.UUID === Characteristic.ProgrammableSwitchEvent.UUID) {
2446
- // special workaround for event only programmable switch event, which must always return null
2447
- object.value = null;
2448
- }
2449
- else { // query the current value
2450
- const value = contactGetHandlers
2451
- ? await this.handleGetRequest(connection).catch(() => {
2452
- const value = this.getDefaultValue();
2453
- debug("[%s] Error getting value for characteristic on /accessories request. Returning default value instead: %s", this.displayName, `${value}`);
2454
- return value; // use default value
2455
- })
2456
- : this.value;
2457
- object.value = (0, request_util_1.formatOutgoingCharacteristicValue)(value, this.props);
2458
- }
2459
- return object;
2460
- }
2461
- /**
2462
- * Returns a JSON representation of this characteristic without the value.
2463
- * @private used to generate the config hash
2464
- */
2465
- internalHAPRepresentation() {
2466
- (0, assert_1.default)(this.iid, "iid cannot be undefined for characteristic '" + this.displayName + "'");
2467
- // TODO include the value for characteristics of the AccessoryInformation service
2468
- return {
2469
- type: (0, uuid_1.toShortForm)(this.UUID),
2470
- iid: this.iid,
2471
- value: null,
2472
- perms: this.props.perms,
2473
- description: this.props.description || this.displayName,
2474
- format: this.props.format,
2475
- unit: this.props.unit,
2476
- minValue: this.props.minValue,
2477
- maxValue: this.props.maxValue,
2478
- minStep: this.props.minStep,
2479
- maxLen: this.props.maxLen,
2480
- maxDataLen: this.props.maxDataLen,
2481
- "valid-values": this.props.validValues,
2482
- "valid-values-range": this.props.validValueRanges,
2483
- };
2484
- }
2485
- /**
2486
- * Serialize characteristic into json string.
2487
- *
2488
- * @param characteristic - Characteristic object.
2489
- * @private used to store characteristic on disk
2490
- */
2491
- static serialize(characteristic) {
2492
- let constructorName;
2493
- if (characteristic.constructor.name !== "Characteristic") {
2494
- constructorName = characteristic.constructor.name;
2495
- }
2496
- return {
2497
- displayName: characteristic.displayName,
2498
- UUID: characteristic.UUID,
2499
- eventOnlyCharacteristic: characteristic.UUID === Characteristic.ProgrammableSwitchEvent.UUID, // support downgrades for now
2500
- constructorName: constructorName,
2501
- value: characteristic.value,
2502
- props: (0, clone_1.clone)({}, characteristic.props),
2503
- };
2504
- }
2505
- /**
2506
- * Deserialize characteristic from json string.
2507
- *
2508
- * @param json - Json string representing a characteristic.
2509
- * @private used to recreate characteristic from disk
2510
- */
2511
- static deserialize(json) {
2512
- let characteristic;
2513
- if (json.constructorName && json.constructorName.charAt(0).toUpperCase() === json.constructorName.charAt(0)
2514
- && Characteristic[json.constructorName]) { // MUST start with uppercase character and must exist on Characteristic object
2515
- const constructor = Characteristic[json.constructorName];
2516
- characteristic = new constructor();
2517
- characteristic.displayName = json.displayName;
2518
- characteristic.setProps(json.props);
2519
- }
2520
- else {
2521
- characteristic = new Characteristic(json.displayName, json.UUID, json.props);
2522
- }
2523
- characteristic.value = json.value;
2524
- return characteristic;
2525
- }
2526
- }
2527
- exports.Characteristic = Characteristic;
2528
- // We have a cyclic dependency problem. Within this file we have the definitions of "./definitions" as
2529
- // type imports only (in order to define the static properties). Setting those properties is done outside
2530
- // this file, within the definition files. Therefore, we import it at the end of this file. Seems weird, but is important.
2531
- require("./definitions/CharacteristicDefinitions");
2532
- //# sourceMappingURL=Characteristic.js.map