hap-nodejs 1.1.0 → 1.1.1-alpha.1
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.
- package/@types/bonjour-hap.d.ts +50 -53
- package/README.md +16 -19
- package/dist/accessories/AirConditioner_accessory.js +28 -30
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +69 -81
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +159 -144
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +18 -22
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +33 -35
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +42 -44
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +32 -34
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +25 -26
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +13 -16
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +20 -22
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +18 -20
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +34 -37
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +43 -45
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +12 -15
- package/dist/accessories/TemperatureSensor_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiRouter_accessory.js +9 -12
- package/dist/accessories/Wi-FiRouter_accessory.js.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.d.ts.map +1 -1
- package/dist/accessories/Wi-FiSatellite_accessory.js +11 -14
- package/dist/accessories/Wi-FiSatellite_accessory.js.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.d.ts +3 -3
- package/dist/accessories/gstreamer-audioProducer.d.ts.map +1 -1
- package/dist/accessories/gstreamer-audioProducer.js +45 -46
- package/dist/accessories/gstreamer-audioProducer.js.map +1 -1
- package/dist/accessories/types.d.ts +63 -63
- package/dist/accessories/types.d.ts.map +1 -1
- package/dist/accessories/types.js +83 -87
- package/dist/accessories/types.js.map +1 -1
- package/dist/index.d.ts +26 -28
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +40 -34
- package/dist/index.js.map +1 -1
- package/dist/internal-types.d.ts +1 -1
- package/dist/internal-types.d.ts.map +1 -1
- package/dist/internal-types.js +19 -21
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +39 -38
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +313 -296
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +16 -13
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +147 -153
- package/dist/lib/Advertiser.js.map +1 -1
- package/dist/lib/Bridge.d.ts +1 -1
- package/dist/lib/Bridge.d.ts.map +1 -1
- package/dist/lib/Bridge.js +2 -6
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +48 -69
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +212 -236
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +31 -30
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +220 -229
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +22 -30
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +63 -75
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +2 -1
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +28 -44
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +34 -33
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +181 -149
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +19 -17
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +160 -151
- package/dist/lib/camera/RecordingManagement.js.map +1 -1
- package/dist/lib/camera/index.d.ts +3 -3
- package/dist/lib/camera/index.d.ts.map +1 -1
- package/dist/lib/camera/index.js +3 -6
- package/dist/lib/camera/index.js.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.d.ts +33 -33
- package/dist/lib/controller/AdaptiveLightingController.d.ts.map +1 -1
- package/dist/lib/controller/AdaptiveLightingController.js +152 -144
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +22 -20
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +74 -78
- package/dist/lib/controller/CameraController.js.map +1 -1
- package/dist/lib/controller/Controller.d.ts +4 -4
- package/dist/lib/controller/Controller.d.ts.map +1 -1
- package/dist/lib/controller/Controller.js +5 -8
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +5 -4
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +9 -13
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +39 -37
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +208 -197
- package/dist/lib/controller/RemoteController.js.map +1 -1
- package/dist/lib/controller/index.d.ts +5 -5
- package/dist/lib/controller/index.d.ts.map +1 -1
- package/dist/lib/controller/index.js +5 -8
- package/dist/lib/controller/index.js.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.d.ts +2 -2
- package/dist/lib/datastream/DataStreamManagement.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamManagement.js +39 -39
- package/dist/lib/datastream/DataStreamManagement.js.map +1 -1
- package/dist/lib/datastream/DataStreamParser.d.ts +1 -0
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +57 -77
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +23 -22
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +154 -164
- package/dist/lib/datastream/DataStreamServer.js.map +1 -1
- package/dist/lib/datastream/index.d.ts +3 -3
- package/dist/lib/datastream/index.d.ts.map +1 -1
- package/dist/lib/datastream/index.js +3 -6
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +15 -60
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +978 -1317
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -15
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +621 -726
- package/dist/lib/definitions/ServiceDefinitions.js.map +1 -1
- package/dist/lib/definitions/generate-definitions.d.ts +3 -3
- package/dist/lib/definitions/generate-definitions.d.ts.map +1 -1
- package/dist/lib/definitions/generate-definitions.js +246 -251
- package/dist/lib/definitions/generate-definitions.js.map +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts +1 -1
- package/dist/lib/definitions/generator-configuration.d.ts.map +1 -1
- package/dist/lib/definitions/generator-configuration.js +160 -354
- package/dist/lib/definitions/generator-configuration.js.map +1 -1
- package/dist/lib/definitions/index.d.ts +2 -2
- package/dist/lib/definitions/index.d.ts.map +1 -1
- package/dist/lib/definitions/index.js +2 -5
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/model/AccessoryInfo.d.ts +4 -3
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +50 -53
- package/dist/lib/model/AccessoryInfo.js.map +1 -1
- package/dist/lib/model/ControllerStorage.d.ts +3 -3
- package/dist/lib/model/ControllerStorage.d.ts.map +1 -1
- package/dist/lib/model/ControllerStorage.js +18 -23
- package/dist/lib/model/ControllerStorage.js.map +1 -1
- package/dist/lib/model/HAPStorage.d.ts +2 -2
- package/dist/lib/model/HAPStorage.d.ts.map +1 -1
- package/dist/lib/model/HAPStorage.js +4 -11
- package/dist/lib/model/HAPStorage.js.map +1 -1
- package/dist/lib/model/IdentifierCache.d.ts +1 -1
- package/dist/lib/model/IdentifierCache.d.ts.map +1 -1
- package/dist/lib/model/IdentifierCache.js +19 -27
- package/dist/lib/model/IdentifierCache.js.map +1 -1
- package/dist/lib/tv/AccessControlManagement.d.ts +9 -9
- package/dist/lib/tv/AccessControlManagement.d.ts.map +1 -1
- package/dist/lib/tv/AccessControlManagement.js +27 -29
- package/dist/lib/tv/AccessControlManagement.js.map +1 -1
- package/dist/lib/util/checkName.d.ts +2 -2
- package/dist/lib/util/checkName.d.ts.map +1 -1
- package/dist/lib/util/checkName.js +6 -9
- package/dist/lib/util/checkName.js.map +1 -1
- package/dist/lib/util/clone.d.ts.map +1 -1
- package/dist/lib/util/clone.js +1 -5
- package/dist/lib/util/clone.js.map +1 -1
- package/dist/lib/util/color-utils.d.ts +1 -1
- package/dist/lib/util/color-utils.d.ts.map +1 -1
- package/dist/lib/util/color-utils.js +4 -9
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +23 -22
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +109 -116
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +3 -2
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +31 -40
- package/dist/lib/util/hapCrypto.js.map +1 -1
- package/dist/lib/util/hapStatusError.d.ts +1 -1
- package/dist/lib/util/hapStatusError.d.ts.map +1 -1
- package/dist/lib/util/hapStatusError.js +4 -8
- package/dist/lib/util/hapStatusError.js.map +1 -1
- package/dist/lib/util/net-utils.d.ts +1 -1
- package/dist/lib/util/net-utils.js +17 -23
- package/dist/lib/util/net-utils.js.map +1 -1
- package/dist/lib/util/once.d.ts.map +1 -1
- package/dist/lib/util/once.js +2 -6
- package/dist/lib/util/once.js.map +1 -1
- package/dist/lib/util/promise-utils.d.ts +1 -1
- package/dist/lib/util/promise-utils.d.ts.map +1 -1
- package/dist/lib/util/promise-utils.js +3 -10
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +3 -2
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +11 -19
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +1 -0
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +6 -11
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +1 -0
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +28 -43
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +1 -0
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +26 -38
- package/dist/lib/util/uuid.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +3 -5
- package/dist/types.js.map +1 -1
- package/package.json +49 -47
- package/@types/simple-plist.d.ts +0 -4
- package/dist/lib/gen/HomeKit.d.ts +0 -7
- package/dist/lib/gen/HomeKit.d.ts.map +0 -1
- package/dist/lib/gen/HomeKit.js +0 -8
- package/dist/lib/gen/HomeKit.js.map +0 -1
package/@types/bonjour-hap.d.ts
CHANGED
|
@@ -1,66 +1,63 @@
|
|
|
1
|
-
declare module
|
|
2
|
-
|
|
1
|
+
declare module 'bonjour-hap' {
|
|
3
2
|
export const enum Protocols {
|
|
4
|
-
TCP =
|
|
5
|
-
UDP =
|
|
3
|
+
TCP = 'tcp',
|
|
4
|
+
UDP = 'udp',
|
|
6
5
|
}
|
|
7
6
|
|
|
8
|
-
export type Nullable<T> = T | null
|
|
9
|
-
export type TxtRecord = Record<string, string
|
|
7
|
+
export type Nullable<T> = T | null
|
|
8
|
+
export type TxtRecord = Record<string, string>
|
|
10
9
|
|
|
11
10
|
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
|
|
11
|
+
name: string
|
|
12
|
+
type: string
|
|
13
|
+
subtypes: Nullable<string[]>
|
|
14
|
+
protocol: Protocols
|
|
15
|
+
host: string
|
|
16
|
+
port: number
|
|
17
|
+
fqdn: string
|
|
18
|
+
txt: Nullable<Record<string, string>>
|
|
19
|
+
published: boolean
|
|
20
|
+
|
|
21
|
+
start(): void
|
|
22
|
+
stop(callback?: () => void): void
|
|
23
|
+
destroy(): void
|
|
24
|
+
updateTxt(txt: TxtRecord, silent?: boolean): void
|
|
26
25
|
}
|
|
27
26
|
|
|
28
|
-
export
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
27
|
+
export interface PublishOptions {
|
|
28
|
+
category?: any
|
|
29
|
+
host?: string
|
|
30
|
+
name?: string
|
|
31
|
+
pincode?: string
|
|
32
|
+
port: number
|
|
33
|
+
protocol?: Protocols
|
|
34
|
+
subtypes?: string[]
|
|
35
|
+
txt?: Record<string, string>
|
|
36
|
+
type?: string
|
|
37
|
+
username?: string
|
|
38
|
+
|
|
39
|
+
addUnsafeServiceEnumerationRecord?: boolean
|
|
40
|
+
|
|
41
|
+
restrictedAddresses?: string[]
|
|
42
|
+
disabledIpv6?: boolean
|
|
43
|
+
}
|
|
46
44
|
|
|
47
45
|
export class BonjourHAP {
|
|
48
|
-
publish(options: PublishOptions): BonjourHAPService
|
|
49
|
-
unpublishAll(callback: () => void): void
|
|
50
|
-
destroy(): void
|
|
46
|
+
publish(options: PublishOptions): BonjourHAPService
|
|
47
|
+
unpublishAll(callback: () => void): void
|
|
48
|
+
destroy(): void
|
|
51
49
|
}
|
|
52
50
|
|
|
51
|
+
export interface MulticastOptions {
|
|
52
|
+
multicast?: boolean
|
|
53
|
+
interface?: string
|
|
54
|
+
port?: number
|
|
55
|
+
ip?: string
|
|
56
|
+
ttl?: number
|
|
57
|
+
loopback?: boolean
|
|
58
|
+
reuseAddr?: boolean
|
|
59
|
+
}
|
|
60
|
+
function createWithOptions(options?: MulticastOptions): BonjourHAP
|
|
53
61
|
|
|
54
|
-
export
|
|
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;
|
|
62
|
+
export default createWithOptions
|
|
66
63
|
}
|
package/README.md
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
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
3
|
</p>
|
|
4
4
|
<span align="center">
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
# HAP-NodeJS
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
7
|
+
|
|
8
|
+
<a href="https://www.npmjs.com/package/hap-nodejs"><img title="npm version" src="https://badgen.net/npm/v/hap-nodejs" ></a>
|
|
9
|
+
<a href="https://www.npmjs.com/package/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/hap-nodejs/v/alpha"><img title="npm version apha" src="https://badgen.net/npm/v/hap-nodejs/alpha" ></a><br>
|
|
11
|
+
<a href="https://www.npmjs.com/package/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
14
|
|
|
15
15
|
</span>
|
|
16
16
|
|
|
@@ -18,9 +18,9 @@ HAP-NodeJS is an implementation of the HomeKit Accessory Server as specified in
|
|
|
18
18
|
which is defined by Apple as part of the HomeKit Framework.
|
|
19
19
|
|
|
20
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 :)
|
|
21
|
+
Intel Edison, or any other platform that can run Node.js :)
|
|
22
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
|
|
23
|
+
support to devices which do not support HomeKit out of the box, you may want to look at the
|
|
24
24
|
[homebridge][project-homebridge] project (which also uses HAP-NodeJS internally).
|
|
25
25
|
|
|
26
26
|
The implementation tries to follow the HAP specification as close as it can, but may differ in some cases.
|
|
@@ -28,7 +28,7 @@ HAP-NodeJS is not an Apple certified HAP implementation, as this is only availab
|
|
|
28
28
|
|
|
29
29
|
## Getting started
|
|
30
30
|
|
|
31
|
-
You may start by having a look at our [Wiki][wiki], especially have a look at the
|
|
31
|
+
You may start by having a look at our [Wiki][wiki], especially have a look at the
|
|
32
32
|
[Important HomeKit Terminology][hk-terminology] used in this project.
|
|
33
33
|
|
|
34
34
|
There is also a pretty detailed guide on [how to start developing with HAP-NodeJS][dev-guide].
|
|
@@ -43,11 +43,11 @@ If you wish to do a contribution please read through our [CONTRIBUTING][contribu
|
|
|
43
43
|
|
|
44
44
|
## Projects based on HAP-NodeJS
|
|
45
45
|
|
|
46
|
-
- [Homebridge][project-homebridge] - HomeKit support for the impatient - Pluggable HomeKit Bridge.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
- [OpenHAB-HomeKit-Bridge][project-openhab-homekit-bridge] - OpenHAB HomeKit Bridge bridges openHAB items to
|
|
50
|
-
|
|
46
|
+
- [Homebridge][project-homebridge] - HomeKit support for the impatient - Pluggable HomeKit Bridge.
|
|
47
|
+
Plugins available for e.g. Pilight, Telldus TDtool, Savant, Netatmo, Open Pixel Control, HomeWizard, Fritz!Box,
|
|
48
|
+
LG WebOS TV, Home Assistant, HomeMatic and many more.
|
|
49
|
+
- [OpenHAB-HomeKit-Bridge][project-openhab-homekit-bridge] - OpenHAB HomeKit Bridge bridges openHAB items to
|
|
50
|
+
Apples HomeKit Accessory Protocol.
|
|
51
51
|
- [homekit2mqtt][project-homekit2mqtt] - HomeKit to MQTT bridge.
|
|
52
52
|
- [pimatic-hap][project-pimatic-hap] - Pimatic homekit bridge.
|
|
53
53
|
- [node-red-contrib-homekit][project-node-red-contrib-homekit] - Node-RED nodes to simulate Apple HomeKit devices.
|
|
@@ -71,10 +71,8 @@ If you are interested in HAP over BTLE, you might want to check [this][link-hap-
|
|
|
71
71
|
[dev-guide]: https://github.com/homebridge/HAP-NodeJS/wiki/Using-HAP-NodeJS-as-a-library
|
|
72
72
|
[faq-debug]: https://github.com/homebridge/HAP-NodeJS/wiki/FAQ#debug-mode
|
|
73
73
|
[contributing]: https://github.com/homebridge/HAP-NodeJS/blob/master/CONTRIBUTING.md
|
|
74
|
-
|
|
75
74
|
[examples-repo]: https://github.com/homebridge/HAP-NodeJS-examples
|
|
76
75
|
[example-accessories]: https://github.com/homebridge/HAP-NodeJS/tree/master/src/accessories
|
|
77
|
-
|
|
78
76
|
[project-homebridge]: https://github.com/homebridge/homebridge
|
|
79
77
|
[project-openhab-homekit-bridge]: https://github.com/htreu/OpenHAB-HomeKit-Bridge
|
|
80
78
|
[project-homekit2mqtt]: https://github.com/hobbyquaker/homekit2mqtt
|
|
@@ -82,7 +80,6 @@ If you are interested in HAP over BTLE, you might want to check [this][link-hap-
|
|
|
82
80
|
[project-node-red-contrib-homekit]: https://github.com/NRCHKB/node-red-contrib-homekit-bridged
|
|
83
81
|
[project-ioBroker-homekit]: https://github.com/ioBroker/ioBroker.homekit2
|
|
84
82
|
[project-accessoryserver]: https://github.com/Appyx/AccessoryServer
|
|
85
|
-
|
|
86
83
|
[link-alex-skalozub]: https://twitter.com/pieceofsummer
|
|
87
84
|
[link-homekit-research]: https://gist.github.com/pieceofsummer/13272bf76ac1d6b58a30
|
|
88
85
|
[link-apple-dmca]: https://github.com/github/dmca/blob/master/2014/2014-11-04-Apple.md
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
2
|
// In This example we create an air conditioner Accessory that Has a Thermostat linked to a Fan Service.
|
|
3
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
4
|
// It is to show how to hide services.
|
|
5
5
|
// The linking and Hiding does NOT appear to be reflected in Home
|
|
6
|
-
|
|
7
|
-
// here's a fake hardware device that we'll expose to HomeKit
|
|
8
|
-
const __1 = require("..");
|
|
6
|
+
import { Accessory, Characteristic, Service, uuid, } from '../index.js';
|
|
9
7
|
const ACTest_data = {
|
|
10
8
|
fanPowerOn: false,
|
|
11
9
|
rSpeed: 100,
|
|
@@ -17,33 +15,33 @@ const ACTest_data = {
|
|
|
17
15
|
LightOn: false,
|
|
18
16
|
};
|
|
19
17
|
// This is the Accessory that we'll return to HAP-NodeJS that represents our fake fan.
|
|
20
|
-
const ACTest = exports.accessory = new
|
|
18
|
+
const ACTest = exports.accessory = new Accessory('Air Conditioner', uuid.generate('hap-nodejs:accessories:airconditioner'));
|
|
21
19
|
// Add properties for publishing (in case we're using Core.js and not BridgedCore.js)
|
|
22
20
|
// @ts-expect-error: Core/BridgeCore API
|
|
23
|
-
ACTest.username =
|
|
21
|
+
ACTest.username = '1A:2B:3C:4D:5E:FF';
|
|
24
22
|
// @ts-expect-error: Core/BridgeCore API
|
|
25
|
-
ACTest.pincode =
|
|
23
|
+
ACTest.pincode = '031-45-154';
|
|
26
24
|
ACTest.category = 9 /* Categories.THERMOSTAT */;
|
|
27
25
|
// set some basic properties (these values are arbitrary and setting them is optional)
|
|
28
26
|
ACTest
|
|
29
|
-
.getService(
|
|
30
|
-
.setCharacteristic(
|
|
27
|
+
.getService(Service.AccessoryInformation)
|
|
28
|
+
.setCharacteristic(Characteristic.Manufacturer, 'Sample Company');
|
|
31
29
|
// listen for the "identify" event for this Accessory
|
|
32
30
|
ACTest.on("identify" /* AccessoryEventTypes.IDENTIFY */, (paired, callback) => {
|
|
33
|
-
console.log(
|
|
31
|
+
console.log('Fan Identified!');
|
|
34
32
|
callback(); // success
|
|
35
33
|
});
|
|
36
34
|
// Add the actual Fan Service and listen for change events from iOS.
|
|
37
|
-
const FanService = ACTest.addService(
|
|
38
|
-
FanService.getCharacteristic(
|
|
35
|
+
const FanService = ACTest.addService(Service.Fan, 'Blower'); // services exposed to the user should have "names" like "Fake Light" for us
|
|
36
|
+
FanService.getCharacteristic(Characteristic.On)
|
|
39
37
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
40
|
-
console.log(
|
|
38
|
+
console.log(`Fan Power Changed To ${value}`);
|
|
41
39
|
ACTest_data.fanPowerOn = value;
|
|
42
40
|
callback(); // Our fake Fan is synchronous - this value has been successfully set
|
|
43
41
|
});
|
|
44
42
|
// We want to intercept requests for our current power state so we can query the hardware itself instead of
|
|
45
43
|
// allowing HAP-NodeJS to return the cached Characteristic.value.
|
|
46
|
-
FanService.getCharacteristic(
|
|
44
|
+
FanService.getCharacteristic(Characteristic.On)
|
|
47
45
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
48
46
|
// this event is emitted when you ask Siri directly whether your fan is on or not. you might query
|
|
49
47
|
// the fan hardware itself to find this out, then call the callback. But if you take longer than a
|
|
@@ -57,71 +55,71 @@ FanService.getCharacteristic(__1.Characteristic.On)
|
|
|
57
55
|
}
|
|
58
56
|
});
|
|
59
57
|
// also add an "optional" Characteristic for speed
|
|
60
|
-
FanService.addCharacteristic(
|
|
58
|
+
FanService.addCharacteristic(Characteristic.RotationSpeed)
|
|
61
59
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
62
60
|
callback(null, ACTest_data.rSpeed);
|
|
63
61
|
})
|
|
64
62
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
65
|
-
console.log(
|
|
63
|
+
console.log('Setting fan rSpeed to %s', value);
|
|
66
64
|
ACTest_data.rSpeed = value;
|
|
67
65
|
callback();
|
|
68
66
|
});
|
|
69
|
-
const ThermostatService = ACTest.addService(
|
|
67
|
+
const ThermostatService = ACTest.addService(Service.Thermostat, 'Thermostat');
|
|
70
68
|
ThermostatService.addLinkedService(FanService);
|
|
71
69
|
ThermostatService.setPrimaryService();
|
|
72
|
-
ThermostatService.getCharacteristic(
|
|
70
|
+
ThermostatService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
73
71
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
74
72
|
callback(null, ACTest_data.CurrentHeatingCoolingState);
|
|
75
73
|
})
|
|
76
74
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
77
75
|
ACTest_data.CurrentHeatingCoolingState = value;
|
|
78
|
-
console.log(
|
|
76
|
+
console.log('Characteristic CurrentHeatingCoolingState changed to %s', value);
|
|
79
77
|
callback();
|
|
80
78
|
});
|
|
81
|
-
ThermostatService.getCharacteristic(
|
|
79
|
+
ThermostatService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
82
80
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
83
81
|
callback(null, ACTest_data.TargetHeatingCoolingState);
|
|
84
82
|
})
|
|
85
83
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
86
84
|
ACTest_data.TargetHeatingCoolingState = value;
|
|
87
|
-
console.log(
|
|
85
|
+
console.log('Characteristic TargetHeatingCoolingState changed to %s', value);
|
|
88
86
|
callback();
|
|
89
87
|
});
|
|
90
|
-
ThermostatService.getCharacteristic(
|
|
88
|
+
ThermostatService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
91
89
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
92
90
|
callback(null, ACTest_data.CurrentTemperature);
|
|
93
91
|
})
|
|
94
92
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
95
93
|
ACTest_data.CurrentTemperature = value;
|
|
96
|
-
console.log(
|
|
94
|
+
console.log('Characteristic CurrentTemperature changed to %s', value);
|
|
97
95
|
callback();
|
|
98
96
|
});
|
|
99
|
-
ThermostatService.getCharacteristic(
|
|
97
|
+
ThermostatService.getCharacteristic(Characteristic.TargetTemperature)
|
|
100
98
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
101
99
|
callback(null, ACTest_data.TargetTemperature);
|
|
102
100
|
})
|
|
103
101
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
104
102
|
ACTest_data.TargetTemperature = value;
|
|
105
|
-
console.log(
|
|
103
|
+
console.log('Characteristic TargetTemperature changed to %s', value);
|
|
106
104
|
callback();
|
|
107
105
|
});
|
|
108
|
-
ThermostatService.getCharacteristic(
|
|
106
|
+
ThermostatService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
|
109
107
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
110
108
|
callback(null, ACTest_data.TemperatureDisplayUnits);
|
|
111
109
|
})
|
|
112
110
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
113
111
|
ACTest_data.TemperatureDisplayUnits = value;
|
|
114
|
-
console.log(
|
|
112
|
+
console.log('Characteristic TemperatureDisplayUnits changed to %s', value);
|
|
115
113
|
callback();
|
|
116
114
|
});
|
|
117
|
-
const LightService = ACTest.addService(
|
|
118
|
-
LightService.getCharacteristic(
|
|
115
|
+
const LightService = ACTest.addService(Service.Lightbulb, 'AC Light');
|
|
116
|
+
LightService.getCharacteristic(Characteristic.On)
|
|
119
117
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
120
118
|
callback(null, ACTest_data.LightOn);
|
|
121
119
|
})
|
|
122
120
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
123
121
|
ACTest_data.LightOn = value;
|
|
124
|
-
console.log(
|
|
122
|
+
console.log('Characteristic Light On changed to %s', value);
|
|
125
123
|
callback();
|
|
126
124
|
});
|
|
127
125
|
LightService.setHiddenService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirConditioner_accessory.js","sourceRoot":"","sources":["../../src/accessories/AirConditioner_accessory.ts"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"AirConditioner_accessory.js","sourceRoot":"","sources":["../../src/accessories/AirConditioner_accessory.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,wGAAwG;AACxG,8HAA8H;AAC9H,sCAAsC;AACtC,iEAAiE;AAMjE,OAAO,EACL,SAAS,EAGT,cAAc,EAEd,OAAO,EACP,IAAI,GACL,MAAM,aAAa,CAAA;AAEpB,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,CAAA;AAED,sFAAsF;AACtF,MAAM,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,iBAAiB,EAAE,IAAI,CAAC,QAAQ,CAAC,uCAAuC,CAAC,CAAC,CAAA;AAE3H,qFAAqF;AACrF,wCAAwC;AACxC,MAAM,CAAC,QAAQ,GAAG,mBAAmB,CAAA;AACrC,wCAAwC;AACxC,MAAM,CAAC,OAAO,GAAG,YAAY,CAAA;AAC7B,MAAM,CAAC,QAAQ,gCAAwB,CAAA;AAEvC,sFAAsF;AACtF,MAAM;KACH,UAAU,CAAC,OAAO,CAAC,oBAAoB,CAAE;KACzC,iBAAiB,CAAC,cAAc,CAAC,YAAY,EAAE,gBAAgB,CAAC,CAAA;AAEnE,qDAAqD;AACrD,MAAM,CAAC,EAAE,gDAA+B,CAAC,MAAe,EAAE,QAAsB,E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AY,CAAC,iBAAiB,CAAC,cAAc,CAAC,EAAE,CAAE;KAC/C,EAAE,2CAA+B,CAAC,QAAmC,EAAE,EAAE;IACxE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,CAAA;AACrC,CAAC,CAAC;KACD,EAAE,2CAA+B,CAAC,KAA0B,EAAE,QAAmC,EAAE,EAAE;IACpG,WAAW,CAAC,OAAO,GAAG,KAAK,CAAA;IAC3B,OAAO,CAAC,GAAG,CAAC,uCAAuC,EAAE,KAAK,CAAC,CAAA;IAC3D,QAAQ,EAAE,CAAA;AACZ,CAAC,CAAC,CAAA;AACJ,YAAY,CAAC,gBAAgB,EAAE,CAAA"}
|
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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);
|
|
1
|
+
import { createServer } from 'node:http';
|
|
2
|
+
import escapeHTML from 'escape-html';
|
|
3
|
+
import { Accessory, RemoteController, uuid } from '../index.js';
|
|
4
|
+
import { GStreamerAudioProducer } from './gstreamer-audioProducer.js';
|
|
5
|
+
const remoteUUID = uuid.generate('hap-nodejs:accessories:remote');
|
|
6
|
+
const remote = exports.accessory = new Accessory('Remote', remoteUUID);
|
|
11
7
|
// @ts-expect-error: Core/BridgeCore API
|
|
12
|
-
remote.username =
|
|
8
|
+
remote.username = 'DB:AF:E0:5C:69:76';
|
|
13
9
|
// @ts-expect-error: Core/BridgeCore API
|
|
14
|
-
remote.pincode =
|
|
10
|
+
remote.pincode = '874-23-897';
|
|
15
11
|
remote.category = 32 /* Categories.TARGET_CONTROLLER */;
|
|
16
12
|
// ----------------- for siri support -----------------
|
|
17
13
|
// CHANGE this to enable siri support. Read docs in 'gstreamer-audioProducer.ts' for necessary package dependencies
|
|
@@ -20,88 +16,85 @@ const gstreamerOptions = { // any configuration regarding the producer can be ma
|
|
|
20
16
|
};
|
|
21
17
|
// ----------------------------------------------------
|
|
22
18
|
const controller = siriSupport
|
|
23
|
-
? new
|
|
24
|
-
: new
|
|
19
|
+
? new RemoteController(GStreamerAudioProducer, gstreamerOptions)
|
|
20
|
+
: new RemoteController();
|
|
25
21
|
remote.configureController(controller);
|
|
26
22
|
/*
|
|
27
|
-
This example plugin exposes
|
|
23
|
+
This example plugin exposes a simple http api to interact with the remote and play around.
|
|
28
24
|
The supported routes are listed below. The http server runs on port 8080 as default.
|
|
29
25
|
This example should not be used except for testing as the http server is unsecured.
|
|
30
26
|
|
|
31
27
|
/listTargets - list all currently configured apple tvs and their respective configuration
|
|
32
28
|
/getActiveTarget - return the current target id of the controlled device
|
|
33
|
-
/getActive - get the value of the active characteristic (active means the
|
|
29
|
+
/getActive - get the value of the active characteristic (active means the Apple TV for the activeTarget is listening)
|
|
34
30
|
|
|
35
31
|
/press?button=<buttonId>&time=<timeInMS> - presses a given button for a given time. Time is optional and defaults to 200ms
|
|
36
32
|
/button?button=<buttonId>&state=<stateId> - send a single button event
|
|
37
|
-
/getTargetId?name=<name of
|
|
38
|
-
/setActiveTarget?identifier=<id> - set currently controlled
|
|
33
|
+
/getTargetId?name=<name of Apple TV> - get the target identifier for the given name of the Apple TV
|
|
34
|
+
/setActiveTarget?identifier=<id> - set currently controlled Apple TV
|
|
39
35
|
*/
|
|
40
|
-
|
|
41
|
-
if (request.method !==
|
|
42
|
-
response.writeHead(405, {
|
|
43
|
-
response.end(
|
|
36
|
+
createServer((request, response) => {
|
|
37
|
+
if (request.method !== 'GET') {
|
|
38
|
+
response.writeHead(405, { 'Content-Type': 'text/html' });
|
|
39
|
+
response.end('Method Not Allowed');
|
|
44
40
|
return;
|
|
45
41
|
}
|
|
46
|
-
const
|
|
47
|
-
const pathname =
|
|
48
|
-
const query =
|
|
49
|
-
if (pathname ===
|
|
42
|
+
const parsedUrl = new URL(request.url, `http://${request.headers.host}`);
|
|
43
|
+
const pathname = parsedUrl.pathname.substring(1);
|
|
44
|
+
const query = Object.fromEntries(parsedUrl.searchParams.entries());
|
|
45
|
+
if (pathname === 'setActiveTarget') {
|
|
50
46
|
if (query === undefined || query.identifier === undefined) {
|
|
51
|
-
response.writeHead(400, {
|
|
52
|
-
response.end(
|
|
47
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
48
|
+
response.end('Bad request. Must include \'identifier\' in query string!');
|
|
53
49
|
return;
|
|
54
50
|
}
|
|
55
|
-
const targetIdentifier = parseInt(query.identifier, 10);
|
|
51
|
+
const targetIdentifier = Number.parseInt(query.identifier, 10);
|
|
56
52
|
if (!controller.isConfigured(targetIdentifier)) {
|
|
57
|
-
response.writeHead(400, {
|
|
58
|
-
response.end(
|
|
53
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
54
|
+
response.end(`Bad request. No target found for given identifier ${targetIdentifier}`);
|
|
59
55
|
return;
|
|
60
56
|
}
|
|
61
57
|
controller.setActiveIdentifier(targetIdentifier);
|
|
62
|
-
response.writeHead(200, {
|
|
63
|
-
response.end(
|
|
64
|
-
return;
|
|
58
|
+
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
59
|
+
response.end('OK');
|
|
65
60
|
}
|
|
66
|
-
else if (pathname ===
|
|
67
|
-
response.writeHead(200, {
|
|
68
|
-
response.end(controller.activeIdentifier
|
|
69
|
-
return;
|
|
61
|
+
else if (pathname === 'getActiveTarget') {
|
|
62
|
+
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
63
|
+
response.end(`${controller.activeIdentifier}`);
|
|
70
64
|
}
|
|
71
|
-
else if (pathname ===
|
|
65
|
+
else if (pathname === 'getTargetId') {
|
|
72
66
|
if (query === undefined || query.name === undefined) {
|
|
73
|
-
response.writeHead(400, {
|
|
74
|
-
response.end(
|
|
67
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
68
|
+
response.end('Bad request. Must include \'name\' in query string!');
|
|
75
69
|
return;
|
|
76
70
|
}
|
|
77
71
|
const targetIdentifier = controller.getTargetIdentifierByName(query.name);
|
|
78
72
|
if (targetIdentifier === undefined) {
|
|
79
|
-
response.writeHead(400, {
|
|
80
|
-
response.end(
|
|
73
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
74
|
+
response.end(`Bad request. No target found for given name ${escapeHTML(`${query.name}`)}`);
|
|
81
75
|
return;
|
|
82
76
|
}
|
|
83
|
-
response.writeHead(200, {
|
|
84
|
-
response.end(
|
|
85
|
-
return;
|
|
77
|
+
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
78
|
+
response.end(`${targetIdentifier}`);
|
|
86
79
|
}
|
|
87
|
-
else if (pathname ===
|
|
80
|
+
else if (pathname === 'button') {
|
|
88
81
|
if (query === undefined || query.state === undefined || query.button === undefined) {
|
|
89
|
-
response.writeHead(400, {
|
|
90
|
-
response.end(
|
|
82
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
83
|
+
response.end('Bad request. Must include \'state\' and \'button\' in query string!');
|
|
91
84
|
return;
|
|
92
85
|
}
|
|
93
|
-
const buttonState = parseInt(query.state, 10);
|
|
94
|
-
const button = parseInt(query.button, 10);
|
|
86
|
+
const buttonState = Number.parseInt(query.state, 10);
|
|
87
|
+
const button = Number.parseInt(query.button, 10);
|
|
95
88
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
96
|
-
if (
|
|
97
|
-
response.writeHead(400, {
|
|
98
|
-
response.end(
|
|
89
|
+
if (ButtonState[buttonState] === undefined) {
|
|
90
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
91
|
+
response.end(`Bad request. Unknown button state ${escapeHTML(`${query.state}`)}`);
|
|
99
92
|
return;
|
|
100
93
|
}
|
|
101
94
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
102
|
-
if (
|
|
103
|
-
response.writeHead(400, {
|
|
104
|
-
response.end(
|
|
95
|
+
if (ButtonType[button] === undefined) {
|
|
96
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
97
|
+
response.end(`Bad request. Unknown button ${escapeHTML(`${query.button}`)}`);
|
|
105
98
|
return;
|
|
106
99
|
}
|
|
107
100
|
if (buttonState === 0 /* ButtonState.UP */) {
|
|
@@ -110,50 +103,45 @@ http.createServer((request, response) => {
|
|
|
110
103
|
else if (buttonState === 1 /* ButtonState.DOWN */) {
|
|
111
104
|
controller.pushButton(button);
|
|
112
105
|
}
|
|
113
|
-
response.writeHead(200, {
|
|
114
|
-
response.end(
|
|
115
|
-
return;
|
|
106
|
+
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
107
|
+
response.end('OK');
|
|
116
108
|
}
|
|
117
|
-
else if (pathname ===
|
|
109
|
+
else if (pathname === 'press') {
|
|
118
110
|
if (query === undefined || query.button === undefined) {
|
|
119
|
-
response.writeHead(400, {
|
|
120
|
-
response.end(
|
|
111
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
112
|
+
response.end('Bad request. Must include \'button\' in query string!');
|
|
121
113
|
return;
|
|
122
114
|
}
|
|
123
115
|
let time = 200;
|
|
124
116
|
if (query.time !== undefined) {
|
|
125
|
-
const parsedTime = parseInt(query.time, 10);
|
|
117
|
+
const parsedTime = Number.parseInt(query.time, 10);
|
|
126
118
|
if (parsedTime) {
|
|
127
119
|
time = parsedTime;
|
|
128
120
|
}
|
|
129
121
|
}
|
|
130
|
-
const button = parseInt(query.button, 10);
|
|
122
|
+
const button = Number.parseInt(query.button, 10);
|
|
131
123
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
132
|
-
if (
|
|
133
|
-
response.writeHead(400, {
|
|
134
|
-
response.end(
|
|
124
|
+
if (ButtonType[button] === undefined) {
|
|
125
|
+
response.writeHead(400, { 'Content-Type': 'text/html' });
|
|
126
|
+
response.end(`Bad request. Unknown button ${escapeHTML(`${query.button}`)}`);
|
|
135
127
|
return;
|
|
136
128
|
}
|
|
137
129
|
controller.pushAndReleaseButton(button, time);
|
|
138
|
-
response.writeHead(200, {
|
|
139
|
-
response.end(
|
|
140
|
-
return;
|
|
130
|
+
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
131
|
+
response.end('OK');
|
|
141
132
|
}
|
|
142
|
-
else if (pathname ===
|
|
133
|
+
else if (pathname === 'listTargets') {
|
|
143
134
|
const targets = controller.targetConfigurations;
|
|
144
|
-
response.writeHead(200, {
|
|
135
|
+
response.writeHead(200, { 'Content-Type': 'application/json' });
|
|
145
136
|
response.end(JSON.stringify(targets, undefined, 4));
|
|
146
|
-
return;
|
|
147
137
|
}
|
|
148
|
-
else if (pathname ===
|
|
149
|
-
response.writeHead(200, {
|
|
150
|
-
response.end(controller.isActive() ?
|
|
151
|
-
return;
|
|
138
|
+
else if (pathname === 'getActive') {
|
|
139
|
+
response.writeHead(200, { 'Content-Type': 'text/html' });
|
|
140
|
+
response.end(controller.isActive() ? 'true' : 'false');
|
|
152
141
|
}
|
|
153
142
|
else {
|
|
154
|
-
response.writeHead(404, {
|
|
155
|
-
response.end(
|
|
156
|
-
return;
|
|
143
|
+
response.writeHead(404, { 'Content-Type': 'text/html' });
|
|
144
|
+
response.end(`Not Found. No path found for ${escapeHTML(pathname)}`);
|
|
157
145
|
}
|
|
158
146
|
}).listen(8080);
|
|
159
147
|
//# sourceMappingURL=AppleTVRemote_accessory.js.map
|