hap-nodejs 1.1.1-beta.4 → 1.1.1-beta.6
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 +53 -50
- package/@types/simple-plist.d.ts +4 -0
- package/README.md +19 -16
- package/dist/accessories/AirConditioner_accessory.js +30 -28
- package/dist/accessories/AirConditioner_accessory.js.map +1 -1
- package/dist/accessories/AppleTVRemote_accessory.js +81 -69
- package/dist/accessories/AppleTVRemote_accessory.js.map +1 -1
- package/dist/accessories/Camera_accessory.js +136 -141
- package/dist/accessories/Camera_accessory.js.map +1 -1
- package/dist/accessories/Fan_accessory.js +22 -18
- package/dist/accessories/Fan_accessory.js.map +1 -1
- package/dist/accessories/GarageDoorOpener_accessory.js +35 -33
- package/dist/accessories/GarageDoorOpener_accessory.js.map +1 -1
- package/dist/accessories/Light-AdaptiveLighting_accessory.js +44 -42
- package/dist/accessories/Light-AdaptiveLighting_accessory.js.map +1 -1
- package/dist/accessories/Light_accessory.js +34 -32
- package/dist/accessories/Light_accessory.js.map +1 -1
- package/dist/accessories/Lock_accessory.js +26 -25
- package/dist/accessories/Lock_accessory.js.map +1 -1
- package/dist/accessories/MotionSensor_accessory.js +16 -13
- package/dist/accessories/MotionSensor_accessory.js.map +1 -1
- package/dist/accessories/Outlet_accessory.js +22 -20
- package/dist/accessories/Outlet_accessory.js.map +1 -1
- package/dist/accessories/SmartSpeaker_accessory.js +20 -18
- package/dist/accessories/SmartSpeaker_accessory.js.map +1 -1
- package/dist/accessories/Sprinkler_accessory.js +37 -34
- package/dist/accessories/Sprinkler_accessory.js.map +1 -1
- package/dist/accessories/TV_accessory.js +45 -43
- package/dist/accessories/TV_accessory.js.map +1 -1
- package/dist/accessories/TemperatureSensor_accessory.js +15 -12
- 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 +12 -9
- 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 +14 -11
- 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 +38 -37
- 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 +87 -83
- package/dist/accessories/types.js.map +1 -1
- package/dist/index.d.ts +28 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -40
- 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 +21 -19
- package/dist/internal-types.js.map +1 -1
- package/dist/lib/Accessory.d.ts +37 -38
- package/dist/lib/Accessory.d.ts.map +1 -1
- package/dist/lib/Accessory.js +296 -286
- package/dist/lib/Accessory.js.map +1 -1
- package/dist/lib/Advertiser.d.ts +7 -7
- package/dist/lib/Advertiser.d.ts.map +1 -1
- package/dist/lib/Advertiser.js +136 -128
- 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 +6 -2
- package/dist/lib/Bridge.js.map +1 -1
- package/dist/lib/Characteristic.d.ts +41 -40
- package/dist/lib/Characteristic.d.ts.map +1 -1
- package/dist/lib/Characteristic.js +208 -204
- package/dist/lib/Characteristic.js.map +1 -1
- package/dist/lib/HAPServer.d.ts +30 -31
- package/dist/lib/HAPServer.d.ts.map +1 -1
- package/dist/lib/HAPServer.js +229 -220
- package/dist/lib/HAPServer.js.map +1 -1
- package/dist/lib/Service.d.ts +22 -22
- package/dist/lib/Service.d.ts.map +1 -1
- package/dist/lib/Service.js +67 -63
- package/dist/lib/Service.js.map +1 -1
- package/dist/lib/camera/RTPProxy.d.ts +1 -2
- package/dist/lib/camera/RTPProxy.d.ts.map +1 -1
- package/dist/lib/camera/RTPProxy.js +44 -28
- package/dist/lib/camera/RTPProxy.js.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.d.ts +33 -34
- package/dist/lib/camera/RTPStreamManagement.d.ts.map +1 -1
- package/dist/lib/camera/RTPStreamManagement.js +149 -181
- package/dist/lib/camera/RTPStreamManagement.js.map +1 -1
- package/dist/lib/camera/RecordingManagement.d.ts +17 -19
- package/dist/lib/camera/RecordingManagement.d.ts.map +1 -1
- package/dist/lib/camera/RecordingManagement.js +151 -160
- 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 +6 -3
- 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 +144 -152
- package/dist/lib/controller/AdaptiveLightingController.js.map +1 -1
- package/dist/lib/controller/CameraController.d.ts +20 -22
- package/dist/lib/controller/CameraController.d.ts.map +1 -1
- package/dist/lib/controller/CameraController.js +78 -74
- 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 +8 -5
- package/dist/lib/controller/Controller.js.map +1 -1
- package/dist/lib/controller/DoorbellController.d.ts +4 -5
- package/dist/lib/controller/DoorbellController.d.ts.map +1 -1
- package/dist/lib/controller/DoorbellController.js +13 -9
- package/dist/lib/controller/DoorbellController.js.map +1 -1
- package/dist/lib/controller/RemoteController.d.ts +37 -39
- package/dist/lib/controller/RemoteController.d.ts.map +1 -1
- package/dist/lib/controller/RemoteController.js +197 -208
- 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 +8 -5
- 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 +0 -1
- package/dist/lib/datastream/DataStreamParser.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamParser.js +77 -57
- package/dist/lib/datastream/DataStreamParser.js.map +1 -1
- package/dist/lib/datastream/DataStreamServer.d.ts +22 -23
- package/dist/lib/datastream/DataStreamServer.d.ts.map +1 -1
- package/dist/lib/datastream/DataStreamServer.js +164 -154
- 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 +6 -3
- package/dist/lib/datastream/index.js.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts +11 -1
- package/dist/lib/definitions/CharacteristicDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/CharacteristicDefinitions.js +1218 -957
- package/dist/lib/definitions/CharacteristicDefinitions.js.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts +1 -1
- package/dist/lib/definitions/ServiceDefinitions.d.ts.map +1 -1
- package/dist/lib/definitions/ServiceDefinitions.js +695 -620
- 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 +256 -244
- 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 +170 -160
- 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 +5 -2
- package/dist/lib/definitions/index.js.map +1 -1
- package/dist/lib/gen/HomeKit.d.ts +7 -0
- package/dist/lib/gen/HomeKit.d.ts.map +1 -0
- package/dist/lib/gen/HomeKit.js +8 -0
- package/dist/lib/gen/HomeKit.js.map +1 -0
- package/dist/lib/model/AccessoryInfo.d.ts +3 -4
- package/dist/lib/model/AccessoryInfo.d.ts.map +1 -1
- package/dist/lib/model/AccessoryInfo.js +53 -50
- 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 +23 -18
- 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 +11 -4
- 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 +27 -19
- 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 +29 -27
- 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 +9 -6
- 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 +5 -1
- 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 +9 -4
- package/dist/lib/util/color-utils.js.map +1 -1
- package/dist/lib/util/eventedhttp.d.ts +22 -23
- package/dist/lib/util/eventedhttp.d.ts.map +1 -1
- package/dist/lib/util/eventedhttp.js +116 -109
- package/dist/lib/util/eventedhttp.js.map +1 -1
- package/dist/lib/util/hapCrypto.d.ts +2 -3
- package/dist/lib/util/hapCrypto.d.ts.map +1 -1
- package/dist/lib/util/hapCrypto.js +40 -31
- 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 +8 -4
- 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 +23 -17
- 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 +6 -2
- 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 +10 -3
- package/dist/lib/util/promise-utils.js.map +1 -1
- package/dist/lib/util/request-util.d.ts +2 -3
- package/dist/lib/util/request-util.d.ts.map +1 -1
- package/dist/lib/util/request-util.js +19 -11
- package/dist/lib/util/request-util.js.map +1 -1
- package/dist/lib/util/time.d.ts +0 -1
- package/dist/lib/util/time.d.ts.map +1 -1
- package/dist/lib/util/time.js +11 -6
- package/dist/lib/util/time.js.map +1 -1
- package/dist/lib/util/tlv.d.ts +0 -1
- package/dist/lib/util/tlv.d.ts.map +1 -1
- package/dist/lib/util/tlv.js +43 -28
- package/dist/lib/util/tlv.js.map +1 -1
- package/dist/lib/util/uuid.d.ts +0 -1
- package/dist/lib/util/uuid.d.ts.map +1 -1
- package/dist/lib/util/uuid.js +38 -26
- 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 +5 -3
- package/dist/types.js.map +1 -1
- package/package.json +45 -50
- package/dist/lib/dbus/align.d.ts +0 -2
- package/dist/lib/dbus/align.d.ts.map +0 -1
- package/dist/lib/dbus/align.js +0 -12
- package/dist/lib/dbus/align.js.map +0 -1
- package/dist/lib/dbus/bus.d.ts +0 -38
- package/dist/lib/dbus/bus.d.ts.map +0 -1
- package/dist/lib/dbus/bus.js +0 -222
- package/dist/lib/dbus/bus.js.map +0 -1
- package/dist/lib/dbus/constants.d.ts +0 -43
- package/dist/lib/dbus/constants.d.ts.map +0 -1
- package/dist/lib/dbus/constants.js +0 -53
- package/dist/lib/dbus/constants.js.map +0 -1
- package/dist/lib/dbus/dbus-buffer.d.ts +0 -30
- package/dist/lib/dbus/dbus-buffer.d.ts.map +0 -1
- package/dist/lib/dbus/dbus-buffer.js +0 -175
- package/dist/lib/dbus/dbus-buffer.js.map +0 -1
- package/dist/lib/dbus/handshake.d.ts +0 -2
- package/dist/lib/dbus/handshake.d.ts.map +0 -1
- package/dist/lib/dbus/handshake.js +0 -130
- package/dist/lib/dbus/handshake.js.map +0 -1
- package/dist/lib/dbus/index.d.ts +0 -3
- package/dist/lib/dbus/index.d.ts.map +0 -1
- package/dist/lib/dbus/index.js +0 -123
- package/dist/lib/dbus/index.js.map +0 -1
- package/dist/lib/dbus/introspect.d.ts +0 -30
- package/dist/lib/dbus/introspect.d.ts.map +0 -1
- package/dist/lib/dbus/introspect.js +0 -208
- package/dist/lib/dbus/introspect.js.map +0 -1
- package/dist/lib/dbus/marshall.d.ts +0 -2
- package/dist/lib/dbus/marshall.d.ts.map +0 -1
- package/dist/lib/dbus/marshall.js +0 -97
- package/dist/lib/dbus/marshall.js.map +0 -1
- package/dist/lib/dbus/marshallers.d.ts +0 -10
- package/dist/lib/dbus/marshallers.d.ts.map +0 -1
- package/dist/lib/dbus/marshallers.js +0 -329
- package/dist/lib/dbus/marshallers.js.map +0 -1
- package/dist/lib/dbus/message.d.ts +0 -4
- package/dist/lib/dbus/message.d.ts.map +0 -1
- package/dist/lib/dbus/message.js +0 -116
- package/dist/lib/dbus/message.js.map +0 -1
- package/dist/lib/dbus/put.d.ts +0 -21
- package/dist/lib/dbus/put.d.ts.map +0 -1
- package/dist/lib/dbus/put.js +0 -120
- package/dist/lib/dbus/put.js.map +0 -1
- package/dist/lib/dbus/readline.d.ts +0 -2
- package/dist/lib/dbus/readline.d.ts.map +0 -1
- package/dist/lib/dbus/readline.js +0 -27
- package/dist/lib/dbus/readline.js.map +0 -1
- package/dist/lib/dbus/signature.d.ts +0 -2
- package/dist/lib/dbus/signature.d.ts.map +0 -1
- package/dist/lib/dbus/signature.js +0 -59
- package/dist/lib/dbus/signature.js.map +0 -1
- package/dist/lib/dbus/stdifaces.d.ts +0 -3
- package/dist/lib/dbus/stdifaces.d.ts.map +0 -1
- package/dist/lib/dbus/stdifaces.js +0 -206
- package/dist/lib/dbus/stdifaces.js.map +0 -1
package/@types/bonjour-hap.d.ts
CHANGED
|
@@ -1,63 +1,66 @@
|
|
|
1
|
-
declare module
|
|
1
|
+
declare module "bonjour-hap" {
|
|
2
|
+
|
|
2
3
|
export const enum Protocols {
|
|
3
|
-
TCP =
|
|
4
|
-
UDP =
|
|
4
|
+
TCP = "tcp",
|
|
5
|
+
UDP = "udp",
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
export type Nullable<T> = T | null
|
|
8
|
-
export type TxtRecord = Record<string, string
|
|
8
|
+
export type Nullable<T> = T | null;
|
|
9
|
+
export type TxtRecord = Record<string, string>;
|
|
9
10
|
|
|
10
11
|
export class BonjourHAPService {
|
|
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
|
|
25
|
-
}
|
|
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;
|
|
26
21
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
|
22
|
+
start(): void;
|
|
23
|
+
stop(callback?: () => void): void;
|
|
24
|
+
destroy(): void;
|
|
25
|
+
updateTxt(txt: TxtRecord, silent?: boolean): void;
|
|
43
26
|
}
|
|
44
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
|
+
|
|
45
47
|
export class BonjourHAP {
|
|
46
|
-
publish(options: PublishOptions): BonjourHAPService
|
|
47
|
-
unpublishAll(callback: () => void): void
|
|
48
|
-
destroy(): void
|
|
48
|
+
publish(options: PublishOptions): BonjourHAPService;
|
|
49
|
+
unpublishAll(callback: () => void): void;
|
|
50
|
+
destroy(): void;
|
|
49
51
|
}
|
|
50
52
|
|
|
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
|
|
61
53
|
|
|
62
|
-
export
|
|
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;
|
|
63
66
|
}
|
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
|
-
<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>
|
|
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,8 +71,10 @@ 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
|
+
|
|
74
75
|
[examples-repo]: https://github.com/homebridge/HAP-NodeJS-examples
|
|
75
76
|
[example-accessories]: https://github.com/homebridge/HAP-NodeJS/tree/master/src/accessories
|
|
77
|
+
|
|
76
78
|
[project-homebridge]: https://github.com/homebridge/homebridge
|
|
77
79
|
[project-openhab-homekit-bridge]: https://github.com/htreu/OpenHAB-HomeKit-Bridge
|
|
78
80
|
[project-homekit2mqtt]: https://github.com/hobbyquaker/homekit2mqtt
|
|
@@ -80,6 +82,7 @@ If you are interested in HAP over BTLE, you might want to check [this][link-hap-
|
|
|
80
82
|
[project-node-red-contrib-homekit]: https://github.com/NRCHKB/node-red-contrib-homekit-bridged
|
|
81
83
|
[project-ioBroker-homekit]: https://github.com/ioBroker/ioBroker.homekit2
|
|
82
84
|
[project-accessoryserver]: https://github.com/Appyx/AccessoryServer
|
|
85
|
+
|
|
83
86
|
[link-alex-skalozub]: https://twitter.com/pieceofsummer
|
|
84
87
|
[link-homekit-research]: https://gist.github.com/pieceofsummer/13272bf76ac1d6b58a30
|
|
85
88
|
[link-apple-dmca]: https://github.com/github/dmca/blob/master/2014/2014-11-04-Apple.md
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
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
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
// here's a fake hardware device that we'll expose to HomeKit
|
|
8
|
+
const __1 = require("..");
|
|
7
9
|
const ACTest_data = {
|
|
8
10
|
fanPowerOn: false,
|
|
9
11
|
rSpeed: 100,
|
|
@@ -15,33 +17,33 @@ const ACTest_data = {
|
|
|
15
17
|
LightOn: false,
|
|
16
18
|
};
|
|
17
19
|
// This is the Accessory that we'll return to HAP-NodeJS that represents our fake fan.
|
|
18
|
-
const ACTest = exports.accessory = new Accessory(
|
|
20
|
+
const ACTest = exports.accessory = new __1.Accessory("Air Conditioner", __1.uuid.generate("hap-nodejs:accessories:airconditioner"));
|
|
19
21
|
// Add properties for publishing (in case we're using Core.js and not BridgedCore.js)
|
|
20
22
|
// @ts-expect-error: Core/BridgeCore API
|
|
21
|
-
ACTest.username =
|
|
23
|
+
ACTest.username = "1A:2B:3C:4D:5E:FF";
|
|
22
24
|
// @ts-expect-error: Core/BridgeCore API
|
|
23
|
-
ACTest.pincode =
|
|
25
|
+
ACTest.pincode = "031-45-154";
|
|
24
26
|
ACTest.category = 9 /* Categories.THERMOSTAT */;
|
|
25
27
|
// set some basic properties (these values are arbitrary and setting them is optional)
|
|
26
28
|
ACTest
|
|
27
|
-
.getService(Service.AccessoryInformation)
|
|
28
|
-
.setCharacteristic(Characteristic.Manufacturer,
|
|
29
|
+
.getService(__1.Service.AccessoryInformation)
|
|
30
|
+
.setCharacteristic(__1.Characteristic.Manufacturer, "Sample Company");
|
|
29
31
|
// listen for the "identify" event for this Accessory
|
|
30
32
|
ACTest.on("identify" /* AccessoryEventTypes.IDENTIFY */, (paired, callback) => {
|
|
31
|
-
console.log(
|
|
33
|
+
console.log("Fan Identified!");
|
|
32
34
|
callback(); // success
|
|
33
35
|
});
|
|
34
36
|
// Add the actual Fan Service and listen for change events from iOS.
|
|
35
|
-
const FanService = ACTest.addService(Service.Fan,
|
|
36
|
-
FanService.getCharacteristic(Characteristic.On)
|
|
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)
|
|
37
39
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
38
|
-
console.log(
|
|
40
|
+
console.log("Fan Power Changed To " + value);
|
|
39
41
|
ACTest_data.fanPowerOn = value;
|
|
40
42
|
callback(); // Our fake Fan is synchronous - this value has been successfully set
|
|
41
43
|
});
|
|
42
44
|
// We want to intercept requests for our current power state so we can query the hardware itself instead of
|
|
43
45
|
// allowing HAP-NodeJS to return the cached Characteristic.value.
|
|
44
|
-
FanService.getCharacteristic(Characteristic.On)
|
|
46
|
+
FanService.getCharacteristic(__1.Characteristic.On)
|
|
45
47
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
46
48
|
// this event is emitted when you ask Siri directly whether your fan is on or not. you might query
|
|
47
49
|
// the fan hardware itself to find this out, then call the callback. But if you take longer than a
|
|
@@ -55,71 +57,71 @@ FanService.getCharacteristic(Characteristic.On)
|
|
|
55
57
|
}
|
|
56
58
|
});
|
|
57
59
|
// also add an "optional" Characteristic for speed
|
|
58
|
-
FanService.addCharacteristic(Characteristic.RotationSpeed)
|
|
60
|
+
FanService.addCharacteristic(__1.Characteristic.RotationSpeed)
|
|
59
61
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
60
62
|
callback(null, ACTest_data.rSpeed);
|
|
61
63
|
})
|
|
62
64
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
63
|
-
console.log(
|
|
65
|
+
console.log("Setting fan rSpeed to %s", value);
|
|
64
66
|
ACTest_data.rSpeed = value;
|
|
65
67
|
callback();
|
|
66
68
|
});
|
|
67
|
-
const ThermostatService = ACTest.addService(Service.Thermostat,
|
|
69
|
+
const ThermostatService = ACTest.addService(__1.Service.Thermostat, "Thermostat");
|
|
68
70
|
ThermostatService.addLinkedService(FanService);
|
|
69
71
|
ThermostatService.setPrimaryService();
|
|
70
|
-
ThermostatService.getCharacteristic(Characteristic.CurrentHeatingCoolingState)
|
|
72
|
+
ThermostatService.getCharacteristic(__1.Characteristic.CurrentHeatingCoolingState)
|
|
71
73
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
72
74
|
callback(null, ACTest_data.CurrentHeatingCoolingState);
|
|
73
75
|
})
|
|
74
76
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
75
77
|
ACTest_data.CurrentHeatingCoolingState = value;
|
|
76
|
-
console.log(
|
|
78
|
+
console.log("Characteristic CurrentHeatingCoolingState changed to %s", value);
|
|
77
79
|
callback();
|
|
78
80
|
});
|
|
79
|
-
ThermostatService.getCharacteristic(Characteristic.TargetHeatingCoolingState)
|
|
81
|
+
ThermostatService.getCharacteristic(__1.Characteristic.TargetHeatingCoolingState)
|
|
80
82
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
81
83
|
callback(null, ACTest_data.TargetHeatingCoolingState);
|
|
82
84
|
})
|
|
83
85
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
84
86
|
ACTest_data.TargetHeatingCoolingState = value;
|
|
85
|
-
console.log(
|
|
87
|
+
console.log("Characteristic TargetHeatingCoolingState changed to %s", value);
|
|
86
88
|
callback();
|
|
87
89
|
});
|
|
88
|
-
ThermostatService.getCharacteristic(Characteristic.CurrentTemperature)
|
|
90
|
+
ThermostatService.getCharacteristic(__1.Characteristic.CurrentTemperature)
|
|
89
91
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
90
92
|
callback(null, ACTest_data.CurrentTemperature);
|
|
91
93
|
})
|
|
92
94
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
93
95
|
ACTest_data.CurrentTemperature = value;
|
|
94
|
-
console.log(
|
|
96
|
+
console.log("Characteristic CurrentTemperature changed to %s", value);
|
|
95
97
|
callback();
|
|
96
98
|
});
|
|
97
|
-
ThermostatService.getCharacteristic(Characteristic.TargetTemperature)
|
|
99
|
+
ThermostatService.getCharacteristic(__1.Characteristic.TargetTemperature)
|
|
98
100
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
99
101
|
callback(null, ACTest_data.TargetTemperature);
|
|
100
102
|
})
|
|
101
103
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
102
104
|
ACTest_data.TargetTemperature = value;
|
|
103
|
-
console.log(
|
|
105
|
+
console.log("Characteristic TargetTemperature changed to %s", value);
|
|
104
106
|
callback();
|
|
105
107
|
});
|
|
106
|
-
ThermostatService.getCharacteristic(Characteristic.TemperatureDisplayUnits)
|
|
108
|
+
ThermostatService.getCharacteristic(__1.Characteristic.TemperatureDisplayUnits)
|
|
107
109
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
108
110
|
callback(null, ACTest_data.TemperatureDisplayUnits);
|
|
109
111
|
})
|
|
110
112
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
111
113
|
ACTest_data.TemperatureDisplayUnits = value;
|
|
112
|
-
console.log(
|
|
114
|
+
console.log("Characteristic TemperatureDisplayUnits changed to %s", value);
|
|
113
115
|
callback();
|
|
114
116
|
});
|
|
115
|
-
const LightService = ACTest.addService(Service.Lightbulb,
|
|
116
|
-
LightService.getCharacteristic(Characteristic.On)
|
|
117
|
+
const LightService = ACTest.addService(__1.Service.Lightbulb, "AC Light");
|
|
118
|
+
LightService.getCharacteristic(__1.Characteristic.On)
|
|
117
119
|
.on("get" /* CharacteristicEventTypes.GET */, (callback) => {
|
|
118
120
|
callback(null, ACTest_data.LightOn);
|
|
119
121
|
})
|
|
120
122
|
.on("set" /* CharacteristicEventTypes.SET */, (value, callback) => {
|
|
121
123
|
ACTest_data.LightOn = value;
|
|
122
|
-
console.log(
|
|
124
|
+
console.log("Characteristic Light On changed to %s", value);
|
|
123
125
|
callback();
|
|
124
126
|
});
|
|
125
127
|
LightService.setHiddenService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AirConditioner_accessory.js","sourceRoot":"","sources":["../../src/accessories/AirConditioner_accessory.ts"],"names":[],"mappings":"AAAA
|
|
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,gCAAw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IAC1C,OAAO,CAAC,GAAG,CAAE,sDAAsD,EAAC,KAAK,CAAC,CAAC;IAC3E,QAAQ,EAAE,CAAC;AACb,CAAC,CAAC,CAAC;AAGN,MAAM,YAAY,GAAG,MAAM,CAAC,UAAU,CAAC,WAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;AACtE,YAAY,CAAC,iBAAiB,CAAC,kBAAc,CAAC,EAAE,CAAE;KAC/C,EAAE,2CAA+B,CAAC,QAAmC,EAAE,EAAE;IACxE,QAAQ,CAAC,IAAI,EAAE,WAAW,CAAC,OAAO,CAAC,CAAC;AACtC,CAAC,CAAC;KACD,EAAE,2CAA+B,CAAC,KAA0B,EAAE,QAAmC,EAAE,EAAE;IACpG,WAAW,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"}
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
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);
|
|
7
11
|
// @ts-expect-error: Core/BridgeCore API
|
|
8
|
-
remote.username =
|
|
12
|
+
remote.username = "DB:AF:E0:5C:69:76";
|
|
9
13
|
// @ts-expect-error: Core/BridgeCore API
|
|
10
|
-
remote.pincode =
|
|
14
|
+
remote.pincode = "874-23-897";
|
|
11
15
|
remote.category = 32 /* Categories.TARGET_CONTROLLER */;
|
|
12
16
|
// ----------------- for siri support -----------------
|
|
13
17
|
// CHANGE this to enable siri support. Read docs in 'gstreamer-audioProducer.ts' for necessary package dependencies
|
|
@@ -16,85 +20,88 @@ const gstreamerOptions = { // any configuration regarding the producer can be ma
|
|
|
16
20
|
};
|
|
17
21
|
// ----------------------------------------------------
|
|
18
22
|
const controller = siriSupport
|
|
19
|
-
? new RemoteController(GStreamerAudioProducer, gstreamerOptions)
|
|
20
|
-
: new RemoteController();
|
|
23
|
+
? new __1.RemoteController(gstreamer_audioProducer_1.GStreamerAudioProducer, gstreamerOptions)
|
|
24
|
+
: new __1.RemoteController();
|
|
21
25
|
remote.configureController(controller);
|
|
22
26
|
/*
|
|
23
|
-
This example plugin exposes
|
|
27
|
+
This example plugin exposes an simple http api to interact with the remote and play around.
|
|
24
28
|
The supported routes are listed below. The http server runs on port 8080 as default.
|
|
25
29
|
This example should not be used except for testing as the http server is unsecured.
|
|
26
30
|
|
|
27
31
|
/listTargets - list all currently configured apple tvs and their respective configuration
|
|
28
32
|
/getActiveTarget - return the current target id of the controlled device
|
|
29
|
-
/getActive - get the value of the active characteristic (active means the
|
|
33
|
+
/getActive - get the value of the active characteristic (active means the apple tv for the activeTarget is listening)
|
|
30
34
|
|
|
31
35
|
/press?button=<buttonId>&time=<timeInMS> - presses a given button for a given time. Time is optional and defaults to 200ms
|
|
32
36
|
/button?button=<buttonId>&state=<stateId> - send a single button event
|
|
33
|
-
/getTargetId?name=<name of
|
|
34
|
-
/setActiveTarget?identifier=<id> - set currently controlled
|
|
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
|
|
35
39
|
*/
|
|
36
|
-
createServer((request, response) => {
|
|
37
|
-
if (request.method !==
|
|
38
|
-
response.writeHead(405, {
|
|
39
|
-
response.end(
|
|
40
|
+
http.createServer((request, response) => {
|
|
41
|
+
if (request.method !== "GET") {
|
|
42
|
+
response.writeHead(405, { "Content-Type": "text/html" });
|
|
43
|
+
response.end("Method Not Allowed");
|
|
40
44
|
return;
|
|
41
45
|
}
|
|
42
|
-
const
|
|
43
|
-
const pathname =
|
|
44
|
-
const query =
|
|
45
|
-
if (pathname ===
|
|
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") {
|
|
46
50
|
if (query === undefined || query.identifier === undefined) {
|
|
47
|
-
response.writeHead(400, {
|
|
48
|
-
response.end(
|
|
51
|
+
response.writeHead(400, { "Content-Type": "text/html" });
|
|
52
|
+
response.end("Bad request. Must include 'identifier' in query string!");
|
|
49
53
|
return;
|
|
50
54
|
}
|
|
51
|
-
const targetIdentifier =
|
|
55
|
+
const targetIdentifier = parseInt(query.identifier, 10);
|
|
52
56
|
if (!controller.isConfigured(targetIdentifier)) {
|
|
53
|
-
response.writeHead(400, {
|
|
54
|
-
response.end(
|
|
57
|
+
response.writeHead(400, { "Content-Type": "text/html" });
|
|
58
|
+
response.end("Bad request. No target found for given identifier " + targetIdentifier);
|
|
55
59
|
return;
|
|
56
60
|
}
|
|
57
61
|
controller.setActiveIdentifier(targetIdentifier);
|
|
58
|
-
response.writeHead(200, {
|
|
59
|
-
response.end(
|
|
62
|
+
response.writeHead(200, { "Content-Type": "text/html" });
|
|
63
|
+
response.end("OK");
|
|
64
|
+
return;
|
|
60
65
|
}
|
|
61
|
-
else if (pathname ===
|
|
62
|
-
response.writeHead(200, {
|
|
63
|
-
response.end(
|
|
66
|
+
else if (pathname === "getActiveTarget") {
|
|
67
|
+
response.writeHead(200, { "Content-Type": "text/html" });
|
|
68
|
+
response.end(controller.activeIdentifier + "");
|
|
69
|
+
return;
|
|
64
70
|
}
|
|
65
|
-
else if (pathname ===
|
|
71
|
+
else if (pathname === "getTargetId") {
|
|
66
72
|
if (query === undefined || query.name === undefined) {
|
|
67
|
-
response.writeHead(400, {
|
|
68
|
-
response.end(
|
|
73
|
+
response.writeHead(400, { "Content-Type": "text/html" });
|
|
74
|
+
response.end("Bad request. Must include 'name' in query string!");
|
|
69
75
|
return;
|
|
70
76
|
}
|
|
71
77
|
const targetIdentifier = controller.getTargetIdentifierByName(query.name);
|
|
72
78
|
if (targetIdentifier === undefined) {
|
|
73
|
-
response.writeHead(400, {
|
|
74
|
-
response.end(
|
|
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 + ""));
|
|
75
81
|
return;
|
|
76
82
|
}
|
|
77
|
-
response.writeHead(200, {
|
|
78
|
-
response.end(
|
|
83
|
+
response.writeHead(200, { "Content-Type": "text/html" });
|
|
84
|
+
response.end("" + targetIdentifier);
|
|
85
|
+
return;
|
|
79
86
|
}
|
|
80
|
-
else if (pathname ===
|
|
87
|
+
else if (pathname === "button") {
|
|
81
88
|
if (query === undefined || query.state === undefined || query.button === undefined) {
|
|
82
|
-
response.writeHead(400, {
|
|
83
|
-
response.end(
|
|
89
|
+
response.writeHead(400, { "Content-Type": "text/html" });
|
|
90
|
+
response.end("Bad request. Must include 'state' and 'button' in query string!");
|
|
84
91
|
return;
|
|
85
92
|
}
|
|
86
|
-
const buttonState =
|
|
87
|
-
const button =
|
|
93
|
+
const buttonState = parseInt(query.state, 10);
|
|
94
|
+
const button = parseInt(query.button, 10);
|
|
88
95
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
89
|
-
if (ButtonState[buttonState] === undefined) {
|
|
90
|
-
response.writeHead(400, {
|
|
91
|
-
response.end(
|
|
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 + ""));
|
|
92
99
|
return;
|
|
93
100
|
}
|
|
94
101
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
95
|
-
if (ButtonType[button] === undefined) {
|
|
96
|
-
response.writeHead(400, {
|
|
97
|
-
response.end(
|
|
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 + ""));
|
|
98
105
|
return;
|
|
99
106
|
}
|
|
100
107
|
if (buttonState === 0 /* ButtonState.UP */) {
|
|
@@ -103,45 +110,50 @@ createServer((request, response) => {
|
|
|
103
110
|
else if (buttonState === 1 /* ButtonState.DOWN */) {
|
|
104
111
|
controller.pushButton(button);
|
|
105
112
|
}
|
|
106
|
-
response.writeHead(200, {
|
|
107
|
-
response.end(
|
|
113
|
+
response.writeHead(200, { "Content-Type": "text/html" });
|
|
114
|
+
response.end("OK");
|
|
115
|
+
return;
|
|
108
116
|
}
|
|
109
|
-
else if (pathname ===
|
|
117
|
+
else if (pathname === "press") {
|
|
110
118
|
if (query === undefined || query.button === undefined) {
|
|
111
|
-
response.writeHead(400, {
|
|
112
|
-
response.end(
|
|
119
|
+
response.writeHead(400, { "Content-Type": "text/html" });
|
|
120
|
+
response.end("Bad request. Must include 'button' in query string!");
|
|
113
121
|
return;
|
|
114
122
|
}
|
|
115
123
|
let time = 200;
|
|
116
124
|
if (query.time !== undefined) {
|
|
117
|
-
const parsedTime =
|
|
125
|
+
const parsedTime = parseInt(query.time, 10);
|
|
118
126
|
if (parsedTime) {
|
|
119
127
|
time = parsedTime;
|
|
120
128
|
}
|
|
121
129
|
}
|
|
122
|
-
const button =
|
|
130
|
+
const button = parseInt(query.button, 10);
|
|
123
131
|
// @ts-expect-error: forceConsistentCasingInFileNames compiler option
|
|
124
|
-
if (ButtonType[button] === undefined) {
|
|
125
|
-
response.writeHead(400, {
|
|
126
|
-
response.end(
|
|
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 + ""));
|
|
127
135
|
return;
|
|
128
136
|
}
|
|
129
137
|
controller.pushAndReleaseButton(button, time);
|
|
130
|
-
response.writeHead(200, {
|
|
131
|
-
response.end(
|
|
138
|
+
response.writeHead(200, { "Content-Type": "text/html" });
|
|
139
|
+
response.end("OK");
|
|
140
|
+
return;
|
|
132
141
|
}
|
|
133
|
-
else if (pathname ===
|
|
142
|
+
else if (pathname === "listTargets") {
|
|
134
143
|
const targets = controller.targetConfigurations;
|
|
135
|
-
response.writeHead(200, {
|
|
144
|
+
response.writeHead(200, { "Content-Type": "application/json" });
|
|
136
145
|
response.end(JSON.stringify(targets, undefined, 4));
|
|
146
|
+
return;
|
|
137
147
|
}
|
|
138
|
-
else if (pathname ===
|
|
139
|
-
response.writeHead(200, {
|
|
140
|
-
response.end(controller.isActive() ?
|
|
148
|
+
else if (pathname === "getActive") {
|
|
149
|
+
response.writeHead(200, { "Content-Type": "text/html" });
|
|
150
|
+
response.end(controller.isActive() ? "true" : "false");
|
|
151
|
+
return;
|
|
141
152
|
}
|
|
142
153
|
else {
|
|
143
|
-
response.writeHead(404, {
|
|
144
|
-
response.end(
|
|
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;
|
|
145
157
|
}
|
|
146
158
|
}).listen(8080);
|
|
147
159
|
//# sourceMappingURL=AppleTVRemote_accessory.js.map
|