@homebridge/hap-nodejs 2.0.0-beta.3

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 (265) hide show
  1. package/@types/bonjour-hap.d.ts +66 -0
  2. package/@types/simple-plist.d.ts +4 -0
  3. package/LICENSE +176 -0
  4. package/README.md +86 -0
  5. package/dist/accessories/AirConditioner_accessory.d.ts +2 -0
  6. package/dist/accessories/AirConditioner_accessory.d.ts.map +1 -0
  7. package/dist/accessories/AirConditioner_accessory.js +128 -0
  8. package/dist/accessories/AirConditioner_accessory.js.map +1 -0
  9. package/dist/accessories/AppleTVRemote_accessory.d.ts +2 -0
  10. package/dist/accessories/AppleTVRemote_accessory.d.ts.map +1 -0
  11. package/dist/accessories/AppleTVRemote_accessory.js +159 -0
  12. package/dist/accessories/AppleTVRemote_accessory.js.map +1 -0
  13. package/dist/accessories/Camera_accessory.d.ts +2 -0
  14. package/dist/accessories/Camera_accessory.d.ts.map +1 -0
  15. package/dist/accessories/Camera_accessory.js +545 -0
  16. package/dist/accessories/Camera_accessory.js.map +1 -0
  17. package/dist/accessories/Fan_accessory.d.ts +2 -0
  18. package/dist/accessories/Fan_accessory.d.ts.map +1 -0
  19. package/dist/accessories/Fan_accessory.js +74 -0
  20. package/dist/accessories/Fan_accessory.js.map +1 -0
  21. package/dist/accessories/GarageDoorOpener_accessory.d.ts +2 -0
  22. package/dist/accessories/GarageDoorOpener_accessory.d.ts.map +1 -0
  23. package/dist/accessories/GarageDoorOpener_accessory.js +78 -0
  24. package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -0
  25. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts +2 -0
  26. package/dist/accessories/Light-AdaptiveLighting_accessory.d.ts.map +1 -0
  27. package/dist/accessories/Light-AdaptiveLighting_accessory.js +106 -0
  28. package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -0
  29. package/dist/accessories/Light_accessory.d.ts +2 -0
  30. package/dist/accessories/Light_accessory.d.ts.map +1 -0
  31. package/dist/accessories/Light_accessory.js +145 -0
  32. package/dist/accessories/Light_accessory.js.map +1 -0
  33. package/dist/accessories/Lock_accessory.d.ts +2 -0
  34. package/dist/accessories/Lock_accessory.d.ts.map +1 -0
  35. package/dist/accessories/Lock_accessory.js +76 -0
  36. package/dist/accessories/Lock_accessory.js.map +1 -0
  37. package/dist/accessories/MotionSensor_accessory.d.ts +2 -0
  38. package/dist/accessories/MotionSensor_accessory.d.ts.map +1 -0
  39. package/dist/accessories/MotionSensor_accessory.js +45 -0
  40. package/dist/accessories/MotionSensor_accessory.js.map +1 -0
  41. package/dist/accessories/Outlet_accessory.d.ts +2 -0
  42. package/dist/accessories/Outlet_accessory.d.ts.map +1 -0
  43. package/dist/accessories/Outlet_accessory.js +79 -0
  44. package/dist/accessories/Outlet_accessory.js.map +1 -0
  45. package/dist/accessories/SmartSpeaker_accessory.d.ts +2 -0
  46. package/dist/accessories/SmartSpeaker_accessory.d.ts.map +1 -0
  47. package/dist/accessories/SmartSpeaker_accessory.js +44 -0
  48. package/dist/accessories/SmartSpeaker_accessory.js.map +1 -0
  49. package/dist/accessories/Sprinkler_accessory.d.ts +2 -0
  50. package/dist/accessories/Sprinkler_accessory.d.ts.map +1 -0
  51. package/dist/accessories/Sprinkler_accessory.js +128 -0
  52. package/dist/accessories/Sprinkler_accessory.js.map +1 -0
  53. package/dist/accessories/TV_accessory.d.ts +2 -0
  54. package/dist/accessories/TV_accessory.d.ts.map +1 -0
  55. package/dist/accessories/TV_accessory.js +101 -0
  56. package/dist/accessories/TV_accessory.js.map +1 -0
  57. package/dist/accessories/TemperatureSensor_accessory.d.ts +2 -0
  58. package/dist/accessories/TemperatureSensor_accessory.d.ts.map +1 -0
  59. package/dist/accessories/TemperatureSensor_accessory.js +44 -0
  60. package/dist/accessories/TemperatureSensor_accessory.js.map +1 -0
  61. package/dist/accessories/Wi-FiRouter_accessory.d.ts +3 -0
  62. package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -0
  63. package/dist/accessories/Wi-FiRouter_accessory.js +17 -0
  64. package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -0
  65. package/dist/accessories/Wi-FiSatellite_accessory.d.ts +3 -0
  66. package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -0
  67. package/dist/accessories/Wi-FiSatellite_accessory.js +19 -0
  68. package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -0
  69. package/dist/accessories/gstreamer-audioProducer.d.ts +25 -0
  70. package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -0
  71. package/dist/accessories/gstreamer-audioProducer.js +145 -0
  72. package/dist/accessories/gstreamer-audioProducer.js.map +1 -0
  73. package/dist/accessories/types.d.ts +78 -0
  74. package/dist/accessories/types.d.ts.map +1 -0
  75. package/dist/accessories/types.js +88 -0
  76. package/dist/accessories/types.js.map +1 -0
  77. package/dist/index.d.ts +49 -0
  78. package/dist/index.d.ts.map +1 -0
  79. package/dist/index.js +53 -0
  80. package/dist/index.js.map +1 -0
  81. package/dist/internal-types.d.ts +76 -0
  82. package/dist/internal-types.d.ts.map +1 -0
  83. package/dist/internal-types.js +80 -0
  84. package/dist/internal-types.js.map +1 -0
  85. package/dist/lib/Accessory.d.ts +492 -0
  86. package/dist/lib/Accessory.d.ts.map +1 -0
  87. package/dist/lib/Accessory.js +1642 -0
  88. package/dist/lib/Accessory.js.map +1 -0
  89. package/dist/lib/Advertiser.d.ts +190 -0
  90. package/dist/lib/Advertiser.d.ts.map +1 -0
  91. package/dist/lib/Advertiser.js +594 -0
  92. package/dist/lib/Advertiser.js.map +1 -0
  93. package/dist/lib/Bridge.d.ts +12 -0
  94. package/dist/lib/Bridge.d.ts.map +1 -0
  95. package/dist/lib/Bridge.js +19 -0
  96. package/dist/lib/Bridge.js.map +1 -0
  97. package/dist/lib/Characteristic.d.ts +1604 -0
  98. package/dist/lib/Characteristic.d.ts.map +1 -0
  99. package/dist/lib/Characteristic.js +2318 -0
  100. package/dist/lib/Characteristic.js.map +1 -0
  101. package/dist/lib/HAPServer.d.ts +302 -0
  102. package/dist/lib/HAPServer.d.ts.map +1 -0
  103. package/dist/lib/HAPServer.js +849 -0
  104. package/dist/lib/HAPServer.js.map +1 -0
  105. package/dist/lib/Service.d.ts +568 -0
  106. package/dist/lib/Service.d.ts.map +1 -0
  107. package/dist/lib/Service.js +764 -0
  108. package/dist/lib/Service.js.map +1 -0
  109. package/dist/lib/camera/RTPProxy.d.ts +59 -0
  110. package/dist/lib/camera/RTPProxy.d.ts.map +1 -0
  111. package/dist/lib/camera/RTPProxy.js +267 -0
  112. package/dist/lib/camera/RTPProxy.js.map +1 -0
  113. package/dist/lib/camera/RTPStreamManagement.d.ts +378 -0
  114. package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -0
  115. package/dist/lib/camera/RTPStreamManagement.js +1007 -0
  116. package/dist/lib/camera/RTPStreamManagement.js.map +1 -0
  117. package/dist/lib/camera/RecordingManagement.d.ts +325 -0
  118. package/dist/lib/camera/RecordingManagement.d.ts.map +1 -0
  119. package/dist/lib/camera/RecordingManagement.js +766 -0
  120. package/dist/lib/camera/RecordingManagement.js.map +1 -0
  121. package/dist/lib/camera/index.d.ts +4 -0
  122. package/dist/lib/camera/index.d.ts.map +1 -0
  123. package/dist/lib/camera/index.js +7 -0
  124. package/dist/lib/camera/index.js.map +1 -0
  125. package/dist/lib/controller/AdaptiveLightingController.d.ts +455 -0
  126. package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -0
  127. package/dist/lib/controller/AdaptiveLightingController.js +868 -0
  128. package/dist/lib/controller/AdaptiveLightingController.js.map +1 -0
  129. package/dist/lib/controller/CameraController.d.ts +411 -0
  130. package/dist/lib/controller/CameraController.d.ts.map +1 -0
  131. package/dist/lib/controller/CameraController.js +658 -0
  132. package/dist/lib/controller/CameraController.js.map +1 -0
  133. package/dist/lib/controller/Controller.d.ts +175 -0
  134. package/dist/lib/controller/Controller.d.ts.map +1 -0
  135. package/dist/lib/controller/Controller.js +24 -0
  136. package/dist/lib/controller/Controller.js.map +1 -0
  137. package/dist/lib/controller/DoorbellController.d.ts +59 -0
  138. package/dist/lib/controller/DoorbellController.d.ts.map +1 -0
  139. package/dist/lib/controller/DoorbellController.js +102 -0
  140. package/dist/lib/controller/DoorbellController.js.map +1 -0
  141. package/dist/lib/controller/RemoteController.d.ts +440 -0
  142. package/dist/lib/controller/RemoteController.d.ts.map +1 -0
  143. package/dist/lib/controller/RemoteController.js +1178 -0
  144. package/dist/lib/controller/RemoteController.js.map +1 -0
  145. package/dist/lib/controller/index.d.ts +6 -0
  146. package/dist/lib/controller/index.d.ts.map +1 -0
  147. package/dist/lib/controller/index.js +9 -0
  148. package/dist/lib/controller/index.js.map +1 -0
  149. package/dist/lib/datastream/DataStreamManagement.d.ts +73 -0
  150. package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -0
  151. package/dist/lib/datastream/DataStreamManagement.js +205 -0
  152. package/dist/lib/datastream/DataStreamManagement.js.map +1 -0
  153. package/dist/lib/datastream/DataStreamParser.d.ts +186 -0
  154. package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -0
  155. package/dist/lib/datastream/DataStreamParser.js +879 -0
  156. package/dist/lib/datastream/DataStreamParser.js.map +1 -0
  157. package/dist/lib/datastream/DataStreamServer.d.ts +357 -0
  158. package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -0
  159. package/dist/lib/datastream/DataStreamServer.js +878 -0
  160. package/dist/lib/datastream/DataStreamServer.js.map +1 -0
  161. package/dist/lib/datastream/index.d.ts +4 -0
  162. package/dist/lib/datastream/index.d.ts.map +1 -0
  163. package/dist/lib/datastream/index.js +7 -0
  164. package/dist/lib/datastream/index.js.map +1 -0
  165. package/dist/lib/definitions/CharacteristicDefinitions.d.ts +1984 -0
  166. package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -0
  167. package/dist/lib/definitions/CharacteristicDefinitions.js +4422 -0
  168. package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -0
  169. package/dist/lib/definitions/ServiceDefinitions.d.ts +519 -0
  170. package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -0
  171. package/dist/lib/definitions/ServiceDefinitions.js +1361 -0
  172. package/dist/lib/definitions/ServiceDefinitions.js.map +1 -0
  173. package/dist/lib/definitions/generate-definitions.d.ts +34 -0
  174. package/dist/lib/definitions/generate-definitions.d.ts.map +1 -0
  175. package/dist/lib/definitions/generate-definitions.js +624 -0
  176. package/dist/lib/definitions/generate-definitions.js.map +1 -0
  177. package/dist/lib/definitions/generator-configuration.d.ts +22 -0
  178. package/dist/lib/definitions/generator-configuration.d.ts.map +1 -0
  179. package/dist/lib/definitions/generator-configuration.js +371 -0
  180. package/dist/lib/definitions/generator-configuration.js.map +1 -0
  181. package/dist/lib/definitions/index.d.ts +3 -0
  182. package/dist/lib/definitions/index.d.ts.map +1 -0
  183. package/dist/lib/definitions/index.js +6 -0
  184. package/dist/lib/definitions/index.js.map +1 -0
  185. package/dist/lib/gen/HomeKit.d.ts +7 -0
  186. package/dist/lib/gen/HomeKit.d.ts.map +1 -0
  187. package/dist/lib/gen/HomeKit.js +8 -0
  188. package/dist/lib/gen/HomeKit.js.map +1 -0
  189. package/dist/lib/model/AccessoryInfo.d.ts +82 -0
  190. package/dist/lib/model/AccessoryInfo.d.ts.map +1 -0
  191. package/dist/lib/model/AccessoryInfo.js +277 -0
  192. package/dist/lib/model/AccessoryInfo.js.map +1 -0
  193. package/dist/lib/model/ControllerStorage.d.ts +45 -0
  194. package/dist/lib/model/ControllerStorage.d.ts.map +1 -0
  195. package/dist/lib/model/ControllerStorage.js +245 -0
  196. package/dist/lib/model/ControllerStorage.js.map +1 -0
  197. package/dist/lib/model/HAPStorage.d.ts +15 -0
  198. package/dist/lib/model/HAPStorage.d.ts.map +1 -0
  199. package/dist/lib/model/HAPStorage.js +43 -0
  200. package/dist/lib/model/HAPStorage.js.map +1 -0
  201. package/dist/lib/model/IdentifierCache.d.ts +33 -0
  202. package/dist/lib/model/IdentifierCache.d.ts.map +1 -0
  203. package/dist/lib/model/IdentifierCache.js +114 -0
  204. package/dist/lib/model/IdentifierCache.js.map +1 -0
  205. package/dist/lib/tv/AccessControlManagement.d.ts +86 -0
  206. package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -0
  207. package/dist/lib/tv/AccessControlManagement.js +127 -0
  208. package/dist/lib/tv/AccessControlManagement.js.map +1 -0
  209. package/dist/lib/util/checkName.d.ts +8 -0
  210. package/dist/lib/util/checkName.d.ts.map +1 -0
  211. package/dist/lib/util/checkName.js +17 -0
  212. package/dist/lib/util/checkName.js.map +1 -0
  213. package/dist/lib/util/clone.d.ts +7 -0
  214. package/dist/lib/util/clone.d.ts.map +1 -0
  215. package/dist/lib/util/clone.js +22 -0
  216. package/dist/lib/util/clone.js.map +1 -0
  217. package/dist/lib/util/color-utils.d.ts +18 -0
  218. package/dist/lib/util/color-utils.d.ts.map +1 -0
  219. package/dist/lib/util/color-utils.js +442 -0
  220. package/dist/lib/util/color-utils.js.map +1 -0
  221. package/dist/lib/util/eventedhttp.d.ts +251 -0
  222. package/dist/lib/util/eventedhttp.d.ts.map +1 -0
  223. package/dist/lib/util/eventedhttp.js +706 -0
  224. package/dist/lib/util/eventedhttp.js.map +1 -0
  225. package/dist/lib/util/hapCrypto.d.ts +42 -0
  226. package/dist/lib/util/hapCrypto.d.ts.map +1 -0
  227. package/dist/lib/util/hapCrypto.js +144 -0
  228. package/dist/lib/util/hapCrypto.js.map +1 -0
  229. package/dist/lib/util/hapStatusError.d.ts +16 -0
  230. package/dist/lib/util/hapStatusError.d.ts.map +1 -0
  231. package/dist/lib/util/hapStatusError.js +29 -0
  232. package/dist/lib/util/hapStatusError.js.map +1 -0
  233. package/dist/lib/util/net-utils.d.ts +21 -0
  234. package/dist/lib/util/net-utils.d.ts.map +1 -0
  235. package/dist/lib/util/net-utils.js +79 -0
  236. package/dist/lib/util/net-utils.js.map +1 -0
  237. package/dist/lib/util/once.d.ts +7 -0
  238. package/dist/lib/util/once.d.ts.map +1 -0
  239. package/dist/lib/util/once.js +22 -0
  240. package/dist/lib/util/once.js.map +1 -0
  241. package/dist/lib/util/promise-utils.d.ts +14 -0
  242. package/dist/lib/util/promise-utils.d.ts.map +1 -0
  243. package/dist/lib/util/promise-utils.js +29 -0
  244. package/dist/lib/util/promise-utils.js.map +1 -0
  245. package/dist/lib/util/request-util.d.ts +36 -0
  246. package/dist/lib/util/request-util.d.ts.map +1 -0
  247. package/dist/lib/util/request-util.js +108 -0
  248. package/dist/lib/util/request-util.js.map +1 -0
  249. package/dist/lib/util/time.d.ts +9 -0
  250. package/dist/lib/util/time.d.ts.map +1 -0
  251. package/dist/lib/util/time.js +23 -0
  252. package/dist/lib/util/time.js.map +1 -0
  253. package/dist/lib/util/tlv.d.ts +90 -0
  254. package/dist/lib/util/tlv.d.ts.map +1 -0
  255. package/dist/lib/util/tlv.js +312 -0
  256. package/dist/lib/util/tlv.js.map +1 -0
  257. package/dist/lib/util/uuid.d.ts +23 -0
  258. package/dist/lib/util/uuid.d.ts.map +1 -0
  259. package/dist/lib/util/uuid.js +78 -0
  260. package/dist/lib/util/uuid.js.map +1 -0
  261. package/dist/types.d.ts +276 -0
  262. package/dist/types.d.ts.map +1 -0
  263. package/dist/types.js +11 -0
  264. package/dist/types.js.map +1 -0
  265. package/package.json +91 -0
@@ -0,0 +1,66 @@
1
+ declare module "bonjour-hap" {
2
+
3
+ export const enum Protocols {
4
+ TCP = "tcp",
5
+ UDP = "udp",
6
+ }
7
+
8
+ export type Nullable<T> = T | null;
9
+ export type TxtRecord = Record<string, string>;
10
+
11
+ export class BonjourHAPService {
12
+ name: string;
13
+ type: string;
14
+ subtypes: Nullable<string[]>;
15
+ protocol: Protocols;
16
+ host: string;
17
+ port: number;
18
+ fqdn: string;
19
+ txt: Nullable<Record<string, string>>;
20
+ published: boolean;
21
+
22
+ start(): void;
23
+ stop(callback?: () => void): void;
24
+ destroy(): void;
25
+ updateTxt(txt: TxtRecord, silent?: boolean): void;
26
+ }
27
+
28
+ export type PublishOptions = {
29
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
30
+ category?: any,
31
+ host?: string;
32
+ name?: string;
33
+ pincode?: string;
34
+ port: number;
35
+ protocol?: Protocols;
36
+ subtypes?: string[];
37
+ txt?: Record<string, string>;
38
+ type?: string;
39
+ username?: string;
40
+
41
+ addUnsafeServiceEnumerationRecord?: boolean,
42
+
43
+ restrictedAddresses?: string[];
44
+ disabledIpv6?: boolean;
45
+ };
46
+
47
+ export class BonjourHAP {
48
+ publish(options: PublishOptions): BonjourHAPService;
49
+ unpublishAll(callback: () => void): void;
50
+ destroy(): void;
51
+ }
52
+
53
+
54
+ export type MulticastOptions = {
55
+ multicast?: boolean;
56
+ interface?: string;
57
+ port?: number;
58
+ ip?: string;
59
+ ttl?: number;
60
+ loopback?: boolean;
61
+ reuseAddr?: boolean;
62
+ };
63
+ function createWithOptions(options?: MulticastOptions): BonjourHAP;
64
+
65
+ export default createWithOptions;
66
+ }
@@ -0,0 +1,4 @@
1
+ declare module "simple-plist" {
2
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
3
+ export function readFileSync(path: string): Record<string, any>;
4
+ }
package/LICENSE ADDED
@@ -0,0 +1,176 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
package/README.md ADDED
@@ -0,0 +1,86 @@
1
+ <p align="center">
2
+ <a href="https://homebridge.io"><img src="https://raw.githubusercontent.com/homebridge/branding/latest/logos/homebridge-color-round-stylized.png" height="140"></a>
3
+ </p>
4
+ <span align="center">
5
+
6
+ # HAP-NodeJS
7
+
8
+ <a href="https://www.npmjs.com/package/@homebridge/hap-nodejs"><img title="npm version" src="https://badgen.net/npm/v/hap-nodejs" ></a>
9
+ <a href="https://www.npmjs.com/package/@homebridge/hap-nodejs/v/beta"><img title="npm version beta" src="https://badgen.net/npm/v/hap-nodejs/beta" ></a>
10
+ <a href="https://www.npmjs.com/package/@homebridge/hap-nodejs/v/alpha"><img title="npm version alpha" src="https://badgen.net/npm/v/hap-nodejs/alpha" ></a><br>
11
+ <a href="https://www.npmjs.com/package/@homebridge/hap-nodejs"><img title="npm downloads" src="https://badgen.net/npm/dt/hap-nodejs" ></a>
12
+ <a href="https://github.com/homebridge/HAP-NodeJS/actions/workflows/build.yml"><img title="Node Build" src="https://github.com/homebridge/HAP-NodeJS/actions/workflows/build.yml/badge.svg" ></a>
13
+ <a href='https://coveralls.io/github/homebridge/HAP-NodeJS'><img src='https://coveralls.io/repos/github/homebridge/HAP-NodeJS/badge.svg' alt='Coverage Status' /></a>
14
+
15
+ </span>
16
+
17
+ HAP-NodeJS is an implementation of the HomeKit Accessory Server as specified in the HomeKit Accessory Protocol (HAP),
18
+ which is defined by Apple as part of the HomeKit Framework.
19
+
20
+ HAP-NodeJS is intended to be used as a library to easily create your own HomeKit Accessory on a Raspberry Pi,
21
+ Intel Edison, or any other platform that can run Node.js :)
22
+ If you are searching for a pluggable HomeKit bridge with over a thousand community driven plugins to bring HomeKit
23
+ support to devices which do not support HomeKit out of the box, you may want to look at the
24
+ [homebridge][project-homebridge] project (which also uses HAP-NodeJS internally).
25
+
26
+ The implementation tries to follow the HAP specification as close as it can, but may differ in some cases.
27
+ HAP-NodeJS is not an Apple certified HAP implementation, as this is only available to members of the MFi program.
28
+
29
+ ## Getting started
30
+
31
+ You may start by having a look at our [Wiki][wiki], especially have a look at the
32
+ [Important HomeKit Terminology][hk-terminology] used in this project.
33
+
34
+ There is also a pretty detailed guide on [how to start developing with HAP-NodeJS][dev-guide].
35
+ Or you may just have a look at our [examples][examples-repo] repository
36
+ (or some of the old [accessory examples][example-accessories]).
37
+
38
+ The documentation (WIP) can be found [here](https://developers.homebridge.io/HAP-NodeJS/modules.html).
39
+
40
+ See the FAQ on how to enable [debug output][faq-debug] for HAP-NodeJS.
41
+
42
+ ## Projects based on HAP-NodeJS
43
+
44
+ - [Homebridge][project-homebridge] - HomeKit support for the impatient - Pluggable HomeKit Bridge.
45
+ Plugins available for e.g. Pilight, Telldus TDtool, Savant, Netatmo, Open Pixel Control, HomeWizard, Fritz!Box,
46
+ LG WebOS TV, Home Assistant, HomeMatic and many more.
47
+ - [OpenHAB-HomeKit-Bridge][project-openhab-homekit-bridge] - OpenHAB HomeKit Bridge bridges openHAB items to
48
+ Apples HomeKit Accessory Protocol.
49
+ - [homekit2mqtt][project-homekit2mqtt] - HomeKit to MQTT bridge.
50
+ - [pimatic-hap][project-pimatic-hap] - Pimatic homekit bridge.
51
+ - [node-red-contrib-homekit][project-node-red-contrib-homekit] - Node-RED nodes to simulate Apple HomeKit devices.
52
+ - [ioBroker.homekit][project-ioBroker-homekit] - connect ioBroker to HomeKit.
53
+ - [AccessoryServer][project-accessoryserver] - HomeKit integration for IR/RF/IP-devices
54
+
55
+ ## Notes
56
+
57
+ Special thanks to [Alex Skalozub][link-alex-skalozub], who reverse-engineered the server side HAP.
58
+ ~~You can find his research [here][link-homekit-research].~~
59
+ (Sadly, on Nov 4 2014, Apple sent the [DMCA][link-apple-dmca] request to GitHub to remove the research.)
60
+
61
+ [There](https://www.instagram.com/p/t4cPlcDksQ/) is a video demo running this project on Intel Edison.
62
+
63
+ If you are interested in HAP over BTLE, you might want to check [this][link-hap-over-btle].
64
+
65
+ <!-- links -->
66
+
67
+ [wiki]: https://github.com/homebridge/HAP-NodeJS/wiki
68
+ [hk-terminology]: https://github.com/homebridge/HAP-NodeJS/wiki/HomeKit-Terminology
69
+ [dev-guide]: https://github.com/homebridge/HAP-NodeJS/wiki/Using-HAP-NodeJS-as-a-library
70
+ [faq-debug]: https://github.com/homebridge/HAP-NodeJS/wiki/FAQ#debug-mode
71
+
72
+ [examples-repo]: https://github.com/homebridge/HAP-NodeJS-examples
73
+ [example-accessories]: https://github.com/homebridge/HAP-NodeJS/tree/latest/src/accessories
74
+
75
+ [project-homebridge]: https://github.com/homebridge/homebridge
76
+ [project-openhab-homekit-bridge]: https://github.com/htreu/OpenHAB-HomeKit-Bridge
77
+ [project-homekit2mqtt]: https://github.com/hobbyquaker/homekit2mqtt
78
+ [project-pimatic-hap]: https://github.com/michbeck100/pimatic-hap
79
+ [project-node-red-contrib-homekit]: https://github.com/NRCHKB/node-red-contrib-homekit-bridged
80
+ [project-ioBroker-homekit]: https://github.com/ioBroker/ioBroker.homekit2
81
+ [project-accessoryserver]: https://github.com/Appyx/AccessoryServer
82
+
83
+ [link-alex-skalozub]: https://twitter.com/pieceofsummer
84
+ [link-homekit-research]: https://gist.github.com/pieceofsummer/13272bf76ac1d6b58a30
85
+ [link-apple-dmca]: https://github.com/github/dmca/blob/master/2014/2014-11-04-Apple.md
86
+ [link-hap-over-btle]: https://gist.github.com/KhaosT/6ff09ba71d306d4c1079
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AirConditioner_accessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AirConditioner_accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/AirConditioner_accessory.ts"],"names":[],"mappings":""}
@@ -0,0 +1,128 @@
1
+ "use strict";
2
+ // In This example we create an air conditioner Accessory that Has a Thermostat linked to a Fan Service.
3
+ // For example, I've also put a Light Service that should be hidden to represent a light in the closet that is part of the AC.
4
+ // It is to show how to hide services.
5
+ // The linking and Hiding does NOT appear to be reflected in Home
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ // here's a fake hardware device that we'll expose to HomeKit
8
+ const __1 = require("..");
9
+ const ACTest_data = {
10
+ fanPowerOn: false,
11
+ rSpeed: 100,
12
+ CurrentHeatingCoolingState: 1,
13
+ TargetHeatingCoolingState: 1,
14
+ CurrentTemperature: 33,
15
+ TargetTemperature: 32,
16
+ TemperatureDisplayUnits: 1,
17
+ LightOn: false,
18
+ };
19
+ // This is the Accessory that we'll return to HAP-NodeJS that represents our fake fan.
20
+ const ACTest = exports.accessory = new __1.Accessory("Air Conditioner", __1.uuid.generate("hap-nodejs:accessories:airconditioner"));
21
+ // Add properties for publishing (in case we're using Core.js and not BridgedCore.js)
22
+ // @ts-expect-error: Core/BridgeCore API
23
+ ACTest.username = "1A:2B:3C:4D:5E:FF";
24
+ // @ts-expect-error: Core/BridgeCore API
25
+ ACTest.pincode = "031-45-154";
26
+ ACTest.category = 9 /* Categories.THERMOSTAT */;
27
+ // set some basic properties (these values are arbitrary and setting them is optional)
28
+ ACTest
29
+ .getService(__1.Service.AccessoryInformation)
30
+ .setCharacteristic(__1.Characteristic.Manufacturer, "Sample Company");
31
+ // listen for the "identify" event for this Accessory
32
+ ACTest.on("identify" /* AccessoryEventTypes.IDENTIFY */, (paired, callback) => {
33
+ console.log("Fan Identified!");
34
+ callback(); // success
35
+ });
36
+ // Add the actual Fan Service and listen for change events from iOS.
37
+ const FanService = ACTest.addService(__1.Service.Fan, "Blower"); // services exposed to the user should have "names" like "Fake Light" for us
38
+ FanService.getCharacteristic(__1.Characteristic.On)
39
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
40
+ console.log("Fan Power Changed To " + value);
41
+ ACTest_data.fanPowerOn = value;
42
+ callback(); // Our fake Fan is synchronous - this value has been successfully set
43
+ });
44
+ // We want to intercept requests for our current power state so we can query the hardware itself instead of
45
+ // allowing HAP-NodeJS to return the cached Characteristic.value.
46
+ FanService.getCharacteristic(__1.Characteristic.On)
47
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
48
+ // this event is emitted when you ask Siri directly whether your fan is on or not. you might query
49
+ // the fan hardware itself to find this out, then call the callback. But if you take longer than a
50
+ // few seconds to respond, Siri will give up.
51
+ const err = null; // in case there were any problems
52
+ if (ACTest_data.fanPowerOn) {
53
+ callback(err, true);
54
+ }
55
+ else {
56
+ callback(err, false);
57
+ }
58
+ });
59
+ // also add an "optional" Characteristic for speed
60
+ FanService.addCharacteristic(__1.Characteristic.RotationSpeed)
61
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
62
+ callback(null, ACTest_data.rSpeed);
63
+ })
64
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
65
+ console.log("Setting fan rSpeed to %s", value);
66
+ ACTest_data.rSpeed = value;
67
+ callback();
68
+ });
69
+ const ThermostatService = ACTest.addService(__1.Service.Thermostat, "Thermostat");
70
+ ThermostatService.addLinkedService(FanService);
71
+ ThermostatService.setPrimaryService();
72
+ ThermostatService.getCharacteristic(__1.Characteristic.CurrentHeatingCoolingState)
73
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
74
+ callback(null, ACTest_data.CurrentHeatingCoolingState);
75
+ })
76
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
77
+ ACTest_data.CurrentHeatingCoolingState = value;
78
+ console.log("Characteristic CurrentHeatingCoolingState changed to %s", value);
79
+ callback();
80
+ });
81
+ ThermostatService.getCharacteristic(__1.Characteristic.TargetHeatingCoolingState)
82
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
83
+ callback(null, ACTest_data.TargetHeatingCoolingState);
84
+ })
85
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
86
+ ACTest_data.TargetHeatingCoolingState = value;
87
+ console.log("Characteristic TargetHeatingCoolingState changed to %s", value);
88
+ callback();
89
+ });
90
+ ThermostatService.getCharacteristic(__1.Characteristic.CurrentTemperature)
91
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
92
+ callback(null, ACTest_data.CurrentTemperature);
93
+ })
94
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
95
+ ACTest_data.CurrentTemperature = value;
96
+ console.log("Characteristic CurrentTemperature changed to %s", value);
97
+ callback();
98
+ });
99
+ ThermostatService.getCharacteristic(__1.Characteristic.TargetTemperature)
100
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
101
+ callback(null, ACTest_data.TargetTemperature);
102
+ })
103
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
104
+ ACTest_data.TargetTemperature = value;
105
+ console.log("Characteristic TargetTemperature changed to %s", value);
106
+ callback();
107
+ });
108
+ ThermostatService.getCharacteristic(__1.Characteristic.TemperatureDisplayUnits)
109
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
110
+ callback(null, ACTest_data.TemperatureDisplayUnits);
111
+ })
112
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
113
+ ACTest_data.TemperatureDisplayUnits = value;
114
+ console.log("Characteristic TemperatureDisplayUnits changed to %s", value);
115
+ callback();
116
+ });
117
+ const LightService = ACTest.addService(__1.Service.Lightbulb, "AC Light");
118
+ LightService.getCharacteristic(__1.Characteristic.On)
119
+ .on("get" /* CharacteristicEventTypes.GET */, (callback) => {
120
+ callback(null, ACTest_data.LightOn);
121
+ })
122
+ .on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
123
+ ACTest_data.LightOn = value;
124
+ console.log("Characteristic Light On changed to %s", value);
125
+ callback();
126
+ });
127
+ LightService.setHiddenService();
128
+ //# sourceMappingURL=AirConditioner_accessory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AirConditioner_accessory.js","sourceRoot":"","sources":["../../src/accessories/AirConditioner_accessory.ts"],"names":[],"mappings":";AAAA,wGAAwG;AACxG,8HAA8H;AAC9H,sCAAsC;AACtC,iEAAiE;;AAEjE,6DAA6D;AAC7D,0BAWY;AAGZ,MAAM,WAAW,GAAwC;IACvD,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,GAAG;IACX,0BAA0B,EAAE,CAAC;IAC7B,yBAAyB,EAAE,CAAC;IAC5B,kBAAkB,EAAE,EAAE;IACtB,iBAAiB,EAAE,EAAE;IACrB,uBAAuB,EAAE,CAAC;IAC1B,OAAO,EAAE,KAAK;CACf,CAAC;AAEF,sFAAsF;AACtF,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,aAAS,CAAC,iBAAiB,EAAE,QAAI,CAAC,QAAQ,CAAC,uCAAuC,CAAC,CAAC,CAAC;AAE5H,qFAAqF;AACrF,wCAAwC;AACxC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAC;AACtC,wCAAwC;AACxC,MAAM,CAAC,OAAO,GAAG,YAAY,CAAC;AAC9B,MAAM,CAAC,QAAQ,gCAAwB,CAAC;AAExC,sFAAsF;AACtF,MAAM;KACH,UAAU,CAAC,WAAO,CAAC,oBAAoB,CAAE;KACzC,iBAAiB,CAAC,kBAAc,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAEpE,qDAAqD;AACrD,MAAM,CAAC,EAAE,gDAA+B,CAAC,MAAe,EAAE,QAAsB,EAAE,EAAE;IAClF,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,CAAC,UAAU;AACxB,CAAC,CAAC,CAAC;AAEH,oEAAoE;AAEpE,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,CAAC,WAAO,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CA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AAW,CAAC,OAAO,GAAC,KAAK,CAAC;IAC1B,OAAO,CAAC,GAAG,CAAE,uCAAuC,EAAC,KAAK,CAAC,CAAC;IAC5D,QAAQ,EAAE,CAAC;AACb,CAAC,CAAC,CAAC;AACL,YAAY,CAAC,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=AppleTVRemote_accessory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AppleTVRemote_accessory.d.ts","sourceRoot":"","sources":["../../src/accessories/AppleTVRemote_accessory.ts"],"names":[],"mappings":""}
@@ -0,0 +1,159 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ const escape_html_1 = tslib_1.__importDefault(require("escape-html"));
5
+ const __1 = require("..");
6
+ const http = tslib_1.__importStar(require("http"));
7
+ const url_1 = tslib_1.__importDefault(require("url"));
8
+ const gstreamer_audioProducer_1 = require("./gstreamer-audioProducer");
9
+ const remoteUUID = __1.uuid.generate("hap-nodejs:accessories:remote");
10
+ const remote = exports.accessory = new __1.Accessory("Remote", remoteUUID);
11
+ // @ts-expect-error: Core/BridgeCore API
12
+ remote.username = "DB:AF:E0:5C:69:76";
13
+ // @ts-expect-error: Core/BridgeCore API
14
+ remote.pincode = "874-23-897";
15
+ remote.category = 32 /* Categories.TARGET_CONTROLLER */;
16
+ // ----------------- for siri support -----------------
17
+ // CHANGE this to enable siri support. Read docs in 'gstreamer-audioProducer.ts' for necessary package dependencies
18
+ const siriSupport = false;
19
+ const gstreamerOptions = { // any configuration regarding the producer can be made here
20
+ };
21
+ // ----------------------------------------------------
22
+ const controller = siriSupport
23
+ ? new __1.RemoteController(gstreamer_audioProducer_1.GStreamerAudioProducer, gstreamerOptions)
24
+ : new __1.RemoteController();
25
+ remote.configureController(controller);
26
+ /*
27
+ This example plugin exposes an simple http api to interact with the remote and play around.
28
+ The supported routes are listed below. The http server runs on port 8080 as default.
29
+ This example should not be used except for testing as the http server is unsecured.
30
+
31
+ /listTargets - list all currently configured apple tvs and their respective configuration
32
+ /getActiveTarget - return the current target id of the controlled device
33
+ /getActive - get the value of the active characteristic (active means the apple tv for the activeTarget is listening)
34
+
35
+ /press?button=<buttonId>&time=<timeInMS> - presses a given button for a given time. Time is optional and defaults to 200ms
36
+ /button?button=<buttonId>&state=<stateId> - send a single button event
37
+ /getTargetId?name=<name of apple TV> - get the target identifier for the given name of the apple tv
38
+ /setActiveTarget?identifier=<id> - set currently controlled apple tv
39
+ */
40
+ http.createServer((request, response) => {
41
+ if (request.method !== "GET") {
42
+ response.writeHead(405, { "Content-Type": "text/html" });
43
+ response.end("Method Not Allowed");
44
+ return;
45
+ }
46
+ const parsedPath = url_1.default.parse(request.url, true);
47
+ const pathname = parsedPath.pathname.substring(1, parsedPath.pathname.length);
48
+ const query = parsedPath.query;
49
+ if (pathname === "setActiveTarget") {
50
+ if (query === undefined || query.identifier === undefined) {
51
+ response.writeHead(400, { "Content-Type": "text/html" });
52
+ response.end("Bad request. Must include 'identifier' in query string!");
53
+ return;
54
+ }
55
+ const targetIdentifier = parseInt(query.identifier, 10);
56
+ if (!controller.isConfigured(targetIdentifier)) {
57
+ response.writeHead(400, { "Content-Type": "text/html" });
58
+ response.end("Bad request. No target found for given identifier " + targetIdentifier);
59
+ return;
60
+ }
61
+ controller.setActiveIdentifier(targetIdentifier);
62
+ response.writeHead(200, { "Content-Type": "text/html" });
63
+ response.end("OK");
64
+ return;
65
+ }
66
+ else if (pathname === "getActiveTarget") {
67
+ response.writeHead(200, { "Content-Type": "text/html" });
68
+ response.end(controller.activeIdentifier + "");
69
+ return;
70
+ }
71
+ else if (pathname === "getTargetId") {
72
+ if (query === undefined || query.name === undefined) {
73
+ response.writeHead(400, { "Content-Type": "text/html" });
74
+ response.end("Bad request. Must include 'name' in query string!");
75
+ return;
76
+ }
77
+ const targetIdentifier = controller.getTargetIdentifierByName(query.name);
78
+ if (targetIdentifier === undefined) {
79
+ response.writeHead(400, { "Content-Type": "text/html" });
80
+ response.end("Bad request. No target found for given name " + (0, escape_html_1.default)(query.name + ""));
81
+ return;
82
+ }
83
+ response.writeHead(200, { "Content-Type": "text/html" });
84
+ response.end("" + targetIdentifier);
85
+ return;
86
+ }
87
+ else if (pathname === "button") {
88
+ if (query === undefined || query.state === undefined || query.button === undefined) {
89
+ response.writeHead(400, { "Content-Type": "text/html" });
90
+ response.end("Bad request. Must include 'state' and 'button' in query string!");
91
+ return;
92
+ }
93
+ const buttonState = parseInt(query.state, 10);
94
+ const button = parseInt(query.button, 10);
95
+ // @ts-expect-error: forceConsistentCasingInFileNames compiler option
96
+ if (__1.ButtonState[buttonState] === undefined) {
97
+ response.writeHead(400, { "Content-Type": "text/html" });
98
+ response.end("Bad request. Unknown button state " + (0, escape_html_1.default)(query.state + ""));
99
+ return;
100
+ }
101
+ // @ts-expect-error: forceConsistentCasingInFileNames compiler option
102
+ if (__1.ButtonType[button] === undefined) {
103
+ response.writeHead(400, { "Content-Type": "text/html" });
104
+ response.end("Bad request. Unknown button " + (0, escape_html_1.default)(query.button + ""));
105
+ return;
106
+ }
107
+ if (buttonState === 0 /* ButtonState.UP */) {
108
+ controller.releaseButton(button);
109
+ }
110
+ else if (buttonState === 1 /* ButtonState.DOWN */) {
111
+ controller.pushButton(button);
112
+ }
113
+ response.writeHead(200, { "Content-Type": "text/html" });
114
+ response.end("OK");
115
+ return;
116
+ }
117
+ else if (pathname === "press") {
118
+ if (query === undefined || query.button === undefined) {
119
+ response.writeHead(400, { "Content-Type": "text/html" });
120
+ response.end("Bad request. Must include 'button' in query string!");
121
+ return;
122
+ }
123
+ let time = 200;
124
+ if (query.time !== undefined) {
125
+ const parsedTime = parseInt(query.time, 10);
126
+ if (parsedTime) {
127
+ time = parsedTime;
128
+ }
129
+ }
130
+ const button = parseInt(query.button, 10);
131
+ // @ts-expect-error: forceConsistentCasingInFileNames compiler option
132
+ if (__1.ButtonType[button] === undefined) {
133
+ response.writeHead(400, { "Content-Type": "text/html" });
134
+ response.end("Bad request. Unknown button " + (0, escape_html_1.default)(query.button + ""));
135
+ return;
136
+ }
137
+ controller.pushAndReleaseButton(button, time);
138
+ response.writeHead(200, { "Content-Type": "text/html" });
139
+ response.end("OK");
140
+ return;
141
+ }
142
+ else if (pathname === "listTargets") {
143
+ const targets = controller.targetConfigurations;
144
+ response.writeHead(200, { "Content-Type": "application/json" });
145
+ response.end(JSON.stringify(targets, undefined, 4));
146
+ return;
147
+ }
148
+ else if (pathname === "getActive") {
149
+ response.writeHead(200, { "Content-Type": "text/html" });
150
+ response.end(controller.isActive() ? "true" : "false");
151
+ return;
152
+ }
153
+ else {
154
+ response.writeHead(404, { "Content-Type": "text/html" });
155
+ response.end("Not Found. No path found for " + (0, escape_html_1.default)(pathname));
156
+ return;
157
+ }
158
+ }).listen(8080);
159
+ //# sourceMappingURL=AppleTVRemote_accessory.js.map