forked from momodalo/broadlinkjs
-
Notifications
You must be signed in to change notification settings - Fork 9
/
index.d.ts
109 lines (84 loc) · 2.54 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/// <reference types="node" />
import { EventEmitter } from "events";
export = Broadlink;
/**
* Class representing the Broadlink library
*/
declare class Broadlink extends EventEmitter {
constructor();
/**
* Returns a found Broadlink device. Cast this to a specific
* device type class to get more functions
*/
on(event: "deviceReady", listener: (device: Broadlink.Device) => void): this;
/**
* Start the discovery procedure
*/
discover(local_ip_address?: string): void;
}
declare namespace Broadlink {
/**
* Class representing a generic Broadlink device
*/
class Device {
constructor(host: string, mac: Buffer, timeout?: number);
/**
* Authenticate before use (this is done automatically)
*/
auth();
/**
* Get the device type
*/
getType(): string;
/**
* Send a raw binary packet
* @param command - command in little-endian 16 bit integer
* @param payload - binary content of the command
*/
sendPacket(command: number, payload: Buffer): void;
}
export class MP1 extends Device {
}
export class SP1 extends Device {
}
export class SP2 extends Device {
}
export class A1 extends Device {
}
/**
* Class representing Broadlink RM2 remote control devices
* and similar devices
*/
export class RM2 extends Device {
/**
* Let the device enter learning mode
*/
enterLearning(): void;
/**
* Request the device to send the data
* that was captured while in learning mode
*/
checkData(): void;
/**
* Send a remote control command to the device.
* @param data - data that was captured in learning mode
*/
sendData(data: Buffer): void;
/**
* Request the device to send the temperature
*/
checkTemperature(): void;
/**
* Event that is triggered when a temperature response is
* received from the device
* @param listener - callback with temperature in Celcius as parameter
*/
on(event: 'temperature', listener: (temp: number) => void): this;
/**
* Event that is triggered when a learning data response is
* received from the device
* @param listener - callback with binary data as parameter
*/
on(event: 'rawData', listener: (data: Buffer) => void): this;
}
}