esphome-ts 3.3.1 → 4.0.0
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/README.md +33 -1
- package/dist/index.d.ts +379 -2
- package/dist/index.js +3355 -18
- package/package.json +58 -39
- package/dist/api/bytePositions.d.ts +0 -8
- package/dist/api/bytePositions.js +0 -12
- package/dist/api/client.d.ts +0 -22
- package/dist/api/client.js +0 -60
- package/dist/api/connection.d.ts +0 -18
- package/dist/api/connection.js +0 -51
- package/dist/api/espDevice.d.ts +0 -23
- package/dist/api/espDevice.js +0 -76
- package/dist/api/espSocket.d.ts +0 -13
- package/dist/api/espSocket.js +0 -35
- package/dist/api/helpers.d.ts +0 -17
- package/dist/api/helpers.js +0 -102
- package/dist/api/index.d.ts +0 -10
- package/dist/api/index.js +0 -26
- package/dist/api/interfaces.d.ts +0 -4
- package/dist/api/interfaces.js +0 -2
- package/dist/api/protobuf/api.d.ts +0 -922
- package/dist/api/protobuf/api.js +0 -6678
- package/dist/api/protobuf/api_options.d.ts +0 -24
- package/dist/api/protobuf/api_options.js +0 -76
- package/dist/api/protobuf/google_descriptor.d.ts +0 -1022
- package/dist/api/protobuf/google_descriptor.js +0 -3980
- package/dist/api/requestResponseMatching.d.ts +0 -50
- package/dist/api/requestResponseMatching.js +0 -54
- package/dist/api/responses.d.ts +0 -3
- package/dist/api/responses.js +0 -23
- package/dist/api/socket.d.ts +0 -29
- package/dist/api/socket.js +0 -109
- package/dist/api/typeGuards.d.ts +0 -5
- package/dist/api/typeGuards.js +0 -7
- package/dist/components/base.d.ts +0 -23
- package/dist/components/base.js +0 -51
- package/dist/components/binarySensor.d.ts +0 -9
- package/dist/components/binarySensor.js +0 -19
- package/dist/components/binarySensorTypes.d.ts +0 -26
- package/dist/components/binarySensorTypes.js +0 -30
- package/dist/components/commandInterface.d.ts +0 -4
- package/dist/components/commandInterface.js +0 -2
- package/dist/components/entities.d.ts +0 -21
- package/dist/components/entities.js +0 -2
- package/dist/components/helpers.d.ts +0 -1
- package/dist/components/helpers.js +0 -12
- package/dist/components/index.d.ts +0 -11
- package/dist/components/index.js +0 -27
- package/dist/components/interfaces.d.ts +0 -10
- package/dist/components/interfaces.js +0 -2
- package/dist/components/light.d.ts +0 -22
- package/dist/components/light.js +0 -159
- package/dist/components/sensor.d.ts +0 -10
- package/dist/components/sensor.js +0 -23
- package/dist/components/states.d.ts +0 -18
- package/dist/components/states.js +0 -2
- package/dist/components/switch.d.ts +0 -9
- package/dist/components/switch.js +0 -28
- package/dist/run.d.ts +0 -1
- package/dist/run.js +0 -17
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
export declare enum MessageTypes {
|
|
2
|
-
HelloRequest = 1,
|
|
3
|
-
HelloResponse = 2,
|
|
4
|
-
ConnectRequest = 3,
|
|
5
|
-
ConnectResponse = 4,
|
|
6
|
-
DisconnectRequest = 5,
|
|
7
|
-
DisconnectResponse = 6,
|
|
8
|
-
PingRequest = 7,
|
|
9
|
-
PingResponse = 8,
|
|
10
|
-
DeviceInfoRequest = 9,
|
|
11
|
-
DeviceInfoResponse = 10,
|
|
12
|
-
ListEntitiesRequest = 11,
|
|
13
|
-
ListEntitiesBinarySensorResponse = 12,
|
|
14
|
-
ListEntitiesCoverResponse = 13,
|
|
15
|
-
ListEntitiesFanResponse = 14,
|
|
16
|
-
ListEntitiesLightResponse = 15,
|
|
17
|
-
ListEntitiesSensorResponse = 16,
|
|
18
|
-
ListEntitiesSwitchResponse = 17,
|
|
19
|
-
ListEntitiesTextSensorResponse = 18,
|
|
20
|
-
ListEntitiesDoneResponse = 19,
|
|
21
|
-
SubscribeStatesRequest = 20,
|
|
22
|
-
BinarySensorStateResponse = 21,
|
|
23
|
-
CoverStateResponse = 22,
|
|
24
|
-
FanStateResponse = 23,
|
|
25
|
-
LightStateResponse = 24,
|
|
26
|
-
SensorStateResponse = 25,
|
|
27
|
-
SwitchStateResponse = 26,
|
|
28
|
-
TextSensorStateResponse = 27,
|
|
29
|
-
SubscribeLogsRequest = 28,
|
|
30
|
-
SubscribeLogsResponse = 29,
|
|
31
|
-
CoverCommandRequest = 30,
|
|
32
|
-
FanCommandRequest = 31,
|
|
33
|
-
LightCommandRequest = 32,
|
|
34
|
-
SwitchCommandRequest = 33,
|
|
35
|
-
SubscribeHomeassistantServicesRequest = 34,
|
|
36
|
-
HomeassistantServiceResponse = 35,
|
|
37
|
-
GetTimeRequest = 36,
|
|
38
|
-
GetTimeResponse = 37,
|
|
39
|
-
SubscribeHomeAssistantStatesRequest = 38,
|
|
40
|
-
SubscribeHomeAssistantStateResponse = 39,
|
|
41
|
-
HomeAssistantStateResponse = 40,
|
|
42
|
-
ListEntitiesServicesResponse = 41,
|
|
43
|
-
ExecuteServiceRequest = 42,
|
|
44
|
-
ListEntitiesCameraResponse = 43,
|
|
45
|
-
CameraImageResponse = 44,
|
|
46
|
-
CameraImageRequest = 45,
|
|
47
|
-
ListEntitiesClimateResponse = 46,
|
|
48
|
-
ClimateStateResponse = 47,
|
|
49
|
-
ClimateCommandRequest = 48
|
|
50
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MessageTypes = void 0;
|
|
4
|
-
var MessageTypes;
|
|
5
|
-
(function (MessageTypes) {
|
|
6
|
-
MessageTypes[MessageTypes["HelloRequest"] = 1] = "HelloRequest";
|
|
7
|
-
MessageTypes[MessageTypes["HelloResponse"] = 2] = "HelloResponse";
|
|
8
|
-
MessageTypes[MessageTypes["ConnectRequest"] = 3] = "ConnectRequest";
|
|
9
|
-
MessageTypes[MessageTypes["ConnectResponse"] = 4] = "ConnectResponse";
|
|
10
|
-
MessageTypes[MessageTypes["DisconnectRequest"] = 5] = "DisconnectRequest";
|
|
11
|
-
MessageTypes[MessageTypes["DisconnectResponse"] = 6] = "DisconnectResponse";
|
|
12
|
-
MessageTypes[MessageTypes["PingRequest"] = 7] = "PingRequest";
|
|
13
|
-
MessageTypes[MessageTypes["PingResponse"] = 8] = "PingResponse";
|
|
14
|
-
MessageTypes[MessageTypes["DeviceInfoRequest"] = 9] = "DeviceInfoRequest";
|
|
15
|
-
MessageTypes[MessageTypes["DeviceInfoResponse"] = 10] = "DeviceInfoResponse";
|
|
16
|
-
MessageTypes[MessageTypes["ListEntitiesRequest"] = 11] = "ListEntitiesRequest";
|
|
17
|
-
MessageTypes[MessageTypes["ListEntitiesBinarySensorResponse"] = 12] = "ListEntitiesBinarySensorResponse";
|
|
18
|
-
MessageTypes[MessageTypes["ListEntitiesCoverResponse"] = 13] = "ListEntitiesCoverResponse";
|
|
19
|
-
MessageTypes[MessageTypes["ListEntitiesFanResponse"] = 14] = "ListEntitiesFanResponse";
|
|
20
|
-
MessageTypes[MessageTypes["ListEntitiesLightResponse"] = 15] = "ListEntitiesLightResponse";
|
|
21
|
-
MessageTypes[MessageTypes["ListEntitiesSensorResponse"] = 16] = "ListEntitiesSensorResponse";
|
|
22
|
-
MessageTypes[MessageTypes["ListEntitiesSwitchResponse"] = 17] = "ListEntitiesSwitchResponse";
|
|
23
|
-
MessageTypes[MessageTypes["ListEntitiesTextSensorResponse"] = 18] = "ListEntitiesTextSensorResponse";
|
|
24
|
-
MessageTypes[MessageTypes["ListEntitiesDoneResponse"] = 19] = "ListEntitiesDoneResponse";
|
|
25
|
-
MessageTypes[MessageTypes["SubscribeStatesRequest"] = 20] = "SubscribeStatesRequest";
|
|
26
|
-
MessageTypes[MessageTypes["BinarySensorStateResponse"] = 21] = "BinarySensorStateResponse";
|
|
27
|
-
MessageTypes[MessageTypes["CoverStateResponse"] = 22] = "CoverStateResponse";
|
|
28
|
-
MessageTypes[MessageTypes["FanStateResponse"] = 23] = "FanStateResponse";
|
|
29
|
-
MessageTypes[MessageTypes["LightStateResponse"] = 24] = "LightStateResponse";
|
|
30
|
-
MessageTypes[MessageTypes["SensorStateResponse"] = 25] = "SensorStateResponse";
|
|
31
|
-
MessageTypes[MessageTypes["SwitchStateResponse"] = 26] = "SwitchStateResponse";
|
|
32
|
-
MessageTypes[MessageTypes["TextSensorStateResponse"] = 27] = "TextSensorStateResponse";
|
|
33
|
-
MessageTypes[MessageTypes["SubscribeLogsRequest"] = 28] = "SubscribeLogsRequest";
|
|
34
|
-
MessageTypes[MessageTypes["SubscribeLogsResponse"] = 29] = "SubscribeLogsResponse";
|
|
35
|
-
MessageTypes[MessageTypes["CoverCommandRequest"] = 30] = "CoverCommandRequest";
|
|
36
|
-
MessageTypes[MessageTypes["FanCommandRequest"] = 31] = "FanCommandRequest";
|
|
37
|
-
MessageTypes[MessageTypes["LightCommandRequest"] = 32] = "LightCommandRequest";
|
|
38
|
-
MessageTypes[MessageTypes["SwitchCommandRequest"] = 33] = "SwitchCommandRequest";
|
|
39
|
-
MessageTypes[MessageTypes["SubscribeHomeassistantServicesRequest"] = 34] = "SubscribeHomeassistantServicesRequest";
|
|
40
|
-
MessageTypes[MessageTypes["HomeassistantServiceResponse"] = 35] = "HomeassistantServiceResponse";
|
|
41
|
-
MessageTypes[MessageTypes["GetTimeRequest"] = 36] = "GetTimeRequest";
|
|
42
|
-
MessageTypes[MessageTypes["GetTimeResponse"] = 37] = "GetTimeResponse";
|
|
43
|
-
MessageTypes[MessageTypes["SubscribeHomeAssistantStatesRequest"] = 38] = "SubscribeHomeAssistantStatesRequest";
|
|
44
|
-
MessageTypes[MessageTypes["SubscribeHomeAssistantStateResponse"] = 39] = "SubscribeHomeAssistantStateResponse";
|
|
45
|
-
MessageTypes[MessageTypes["HomeAssistantStateResponse"] = 40] = "HomeAssistantStateResponse";
|
|
46
|
-
MessageTypes[MessageTypes["ListEntitiesServicesResponse"] = 41] = "ListEntitiesServicesResponse";
|
|
47
|
-
MessageTypes[MessageTypes["ExecuteServiceRequest"] = 42] = "ExecuteServiceRequest";
|
|
48
|
-
MessageTypes[MessageTypes["ListEntitiesCameraResponse"] = 43] = "ListEntitiesCameraResponse";
|
|
49
|
-
MessageTypes[MessageTypes["CameraImageResponse"] = 44] = "CameraImageResponse";
|
|
50
|
-
MessageTypes[MessageTypes["CameraImageRequest"] = 45] = "CameraImageRequest";
|
|
51
|
-
MessageTypes[MessageTypes["ListEntitiesClimateResponse"] = 46] = "ListEntitiesClimateResponse";
|
|
52
|
-
MessageTypes[MessageTypes["ClimateStateResponse"] = 47] = "ClimateStateResponse";
|
|
53
|
-
MessageTypes[MessageTypes["ClimateCommandRequest"] = 48] = "ClimateCommandRequest";
|
|
54
|
-
})(MessageTypes = exports.MessageTypes || (exports.MessageTypes = {}));
|
package/dist/api/responses.d.ts
DELETED
package/dist/api/responses.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stateResponses = exports.listResponses = void 0;
|
|
4
|
-
const requestResponseMatching_1 = require("./requestResponseMatching");
|
|
5
|
-
exports.listResponses = new Set([
|
|
6
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesBinarySensorResponse,
|
|
7
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesCoverResponse,
|
|
8
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesFanResponse,
|
|
9
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesLightResponse,
|
|
10
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesSensorResponse,
|
|
11
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesSwitchResponse,
|
|
12
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesTextSensorResponse,
|
|
13
|
-
requestResponseMatching_1.MessageTypes.ListEntitiesDoneResponse,
|
|
14
|
-
]);
|
|
15
|
-
exports.stateResponses = new Set([
|
|
16
|
-
requestResponseMatching_1.MessageTypes.BinarySensorStateResponse,
|
|
17
|
-
requestResponseMatching_1.MessageTypes.CoverStateResponse,
|
|
18
|
-
requestResponseMatching_1.MessageTypes.FanStateResponse,
|
|
19
|
-
requestResponseMatching_1.MessageTypes.LightStateResponse,
|
|
20
|
-
requestResponseMatching_1.MessageTypes.SensorStateResponse,
|
|
21
|
-
requestResponseMatching_1.MessageTypes.SwitchStateResponse,
|
|
22
|
-
requestResponseMatching_1.MessageTypes.TextSensorStateResponse,
|
|
23
|
-
]);
|
package/dist/api/socket.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/// <reference types="node" />
|
|
2
|
-
import { Observable, Subject } from 'rxjs';
|
|
3
|
-
export interface RxjsSocketConfiguration {
|
|
4
|
-
reconnectOnTimeout?: boolean;
|
|
5
|
-
timeout?: number;
|
|
6
|
-
disconnectOnTimeout?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export declare class RxjsSocket {
|
|
9
|
-
private readonly host;
|
|
10
|
-
private readonly port;
|
|
11
|
-
private socket?;
|
|
12
|
-
private readonly config;
|
|
13
|
-
private readonly data;
|
|
14
|
-
readonly data$: Observable<Buffer>;
|
|
15
|
-
private readonly connected;
|
|
16
|
-
readonly connected$: Observable<boolean>;
|
|
17
|
-
private readonly timeout;
|
|
18
|
-
readonly timeout$: Observable<void>;
|
|
19
|
-
private readonly error;
|
|
20
|
-
readonly error$: Observable<Error>;
|
|
21
|
-
protected readonly terminate: Subject<void>;
|
|
22
|
-
constructor(host: string, port: number, config?: RxjsSocketConfiguration);
|
|
23
|
-
open(): void;
|
|
24
|
-
close(forceDestroy?: boolean): void;
|
|
25
|
-
send(data: string | Uint8Array, encoding?: BufferEncoding): Observable<void>;
|
|
26
|
-
private setupSocketEvents;
|
|
27
|
-
private reconnect;
|
|
28
|
-
private destroySocket;
|
|
29
|
-
}
|
package/dist/api/socket.js
DELETED
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RxjsSocket = void 0;
|
|
4
|
-
const net_1 = require("net");
|
|
5
|
-
const rxjs_1 = require("rxjs");
|
|
6
|
-
const operators_1 = require("rxjs/operators");
|
|
7
|
-
const defaultConfig = {
|
|
8
|
-
reconnectOnTimeout: false,
|
|
9
|
-
disconnectOnTimeout: true,
|
|
10
|
-
};
|
|
11
|
-
class RxjsSocket {
|
|
12
|
-
constructor(host, port, config) {
|
|
13
|
-
this.host = host;
|
|
14
|
-
this.port = port;
|
|
15
|
-
// RxJS
|
|
16
|
-
this.data = new rxjs_1.Subject();
|
|
17
|
-
this.connected = new rxjs_1.BehaviorSubject(false);
|
|
18
|
-
this.timeout = new rxjs_1.Subject();
|
|
19
|
-
this.error = new rxjs_1.Subject();
|
|
20
|
-
this.terminate = new rxjs_1.Subject();
|
|
21
|
-
this.config = Object.assign(Object.assign({}, defaultConfig), config);
|
|
22
|
-
this.data$ = this.data.asObservable();
|
|
23
|
-
this.connected$ = this.connected.asObservable();
|
|
24
|
-
this.timeout$ = this.timeout.asObservable();
|
|
25
|
-
this.error$ = this.error.asObservable();
|
|
26
|
-
}
|
|
27
|
-
open() {
|
|
28
|
-
var _a;
|
|
29
|
-
if ((_a = this.socket) === null || _a === void 0 ? void 0 : _a.connecting) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
this.close(true);
|
|
33
|
-
this.socket = new net_1.Socket();
|
|
34
|
-
if (this.config.timeout) {
|
|
35
|
-
this.socket.setTimeout(this.config.timeout);
|
|
36
|
-
}
|
|
37
|
-
this.setupSocketEvents();
|
|
38
|
-
this.socket.connect(this.port, this.host);
|
|
39
|
-
}
|
|
40
|
-
close(forceDestroy) {
|
|
41
|
-
if (!this.socket) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
this.socket.end();
|
|
45
|
-
if (forceDestroy) {
|
|
46
|
-
this.destroySocket();
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
send(data, encoding) {
|
|
50
|
-
return new rxjs_1.Observable((subscriber) => {
|
|
51
|
-
if (this.connected.getValue() && this.socket) {
|
|
52
|
-
this.socket.write(data, encoding, (err) => {
|
|
53
|
-
if (err) {
|
|
54
|
-
throw err;
|
|
55
|
-
}
|
|
56
|
-
subscriber.next();
|
|
57
|
-
subscriber.complete();
|
|
58
|
-
});
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
subscriber.next();
|
|
62
|
-
subscriber.complete();
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
setupSocketEvents() {
|
|
66
|
-
if (!this.socket) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
(0, rxjs_1.fromEvent)(this.socket, 'error')
|
|
70
|
-
.pipe((0, operators_1.tap)((err) => this.error.next(err)), (0, operators_1.takeUntil)(this.terminate))
|
|
71
|
-
.subscribe();
|
|
72
|
-
(0, rxjs_1.fromEvent)(this.socket, 'data')
|
|
73
|
-
.pipe((0, operators_1.tap)((buffer) => this.data.next(buffer)), (0, operators_1.takeUntil)(this.terminate))
|
|
74
|
-
.subscribe();
|
|
75
|
-
(0, rxjs_1.fromEvent)(this.socket, 'connect')
|
|
76
|
-
.pipe((0, operators_1.take)(1), (0, operators_1.tap)(() => this.connected.next(true)), (0, operators_1.takeUntil)(this.terminate))
|
|
77
|
-
.subscribe();
|
|
78
|
-
(0, rxjs_1.fromEvent)(this.socket, 'close')
|
|
79
|
-
.pipe((0, operators_1.take)(1), (0, operators_1.tap)(() => this.connected.next(false)), (0, operators_1.takeUntil)(this.terminate))
|
|
80
|
-
.subscribe();
|
|
81
|
-
(0, rxjs_1.fromEvent)(this.socket, 'end')
|
|
82
|
-
.pipe((0, operators_1.take)(1), (0, operators_1.tap)(() => { var _a; return (_a = this.socket) === null || _a === void 0 ? void 0 : _a.end(); }), (0, operators_1.tap)(() => this.connected.next(false)), (0, operators_1.takeUntil)(this.terminate))
|
|
83
|
-
.subscribe();
|
|
84
|
-
if (this.config.timeout && this.config.timeout > 0) {
|
|
85
|
-
(0, rxjs_1.fromEvent)(this.socket, 'timeout')
|
|
86
|
-
.pipe((0, operators_1.tap)(() => this.timeout.next()), (0, operators_1.tap)(() => {
|
|
87
|
-
if (this.config.disconnectOnTimeout) {
|
|
88
|
-
this.destroySocket();
|
|
89
|
-
}
|
|
90
|
-
if (this.config.reconnectOnTimeout) {
|
|
91
|
-
this.reconnect();
|
|
92
|
-
}
|
|
93
|
-
}), (0, operators_1.takeUntil)(this.terminate))
|
|
94
|
-
.subscribe();
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
reconnect() {
|
|
98
|
-
this.terminate.next();
|
|
99
|
-
this.destroySocket();
|
|
100
|
-
this.open();
|
|
101
|
-
}
|
|
102
|
-
destroySocket() {
|
|
103
|
-
var _a;
|
|
104
|
-
(_a = this.socket) === null || _a === void 0 ? void 0 : _a.destroy();
|
|
105
|
-
this.socket = undefined;
|
|
106
|
-
this.connected.next(false);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
exports.RxjsSocket = RxjsSocket;
|
package/dist/api/typeGuards.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from '../components/base';
|
|
2
|
-
import { SwitchComponent } from '../components/switch';
|
|
3
|
-
import { LightComponent } from '../components/light';
|
|
4
|
-
export declare const isSwitchComponent: (component: BaseComponent) => component is SwitchComponent;
|
|
5
|
-
export declare const isLightComponent: (component: BaseComponent) => component is LightComponent;
|
package/dist/api/typeGuards.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isLightComponent = exports.isSwitchComponent = void 0;
|
|
4
|
-
const isSwitchComponent = (component) => component.type === 'switch';
|
|
5
|
-
exports.isSwitchComponent = isSwitchComponent;
|
|
6
|
-
const isLightComponent = (component) => component.type === 'light';
|
|
7
|
-
exports.isLightComponent = isLightComponent;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { ComponentType, ListEntity } from './entities';
|
|
2
|
-
import { StateEvent } from './states';
|
|
3
|
-
import { BehaviorSubject, Observable, Subject } from 'rxjs';
|
|
4
|
-
import { CommandInterface } from './commandInterface';
|
|
5
|
-
import { MessageTypes } from '../api';
|
|
6
|
-
export declare abstract class BaseComponent<L extends ListEntity = ListEntity, S extends StateEvent = StateEvent> {
|
|
7
|
-
protected readonly listEntity: L;
|
|
8
|
-
private readonly commandInterface;
|
|
9
|
-
protected readonly state: BehaviorSubject<S | undefined>;
|
|
10
|
-
readonly state$: Observable<S>;
|
|
11
|
-
private readonly terminatePreviousStateSubscription;
|
|
12
|
-
private readonly commandInPipeline;
|
|
13
|
-
protected readonly teardown: Subject<void>;
|
|
14
|
-
constructor(listEntity: L, state: Observable<S>, commandInterface: CommandInterface);
|
|
15
|
-
provideStateObservable(state$: Observable<S>): void;
|
|
16
|
-
get ready(): boolean;
|
|
17
|
-
get name(): string;
|
|
18
|
-
get key(): number;
|
|
19
|
-
toString(): string;
|
|
20
|
-
terminate(): void;
|
|
21
|
-
protected queueCommand(type: MessageTypes, dataFn: () => Uint8Array, disableSerialise?: boolean): void;
|
|
22
|
-
abstract get type(): ComponentType;
|
|
23
|
-
}
|
package/dist/components/base.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BaseComponent = void 0;
|
|
4
|
-
const rxjs_1 = require("rxjs");
|
|
5
|
-
const operators_1 = require("rxjs/operators");
|
|
6
|
-
const api_1 = require("../api");
|
|
7
|
-
class BaseComponent {
|
|
8
|
-
constructor(listEntity, state, commandInterface) {
|
|
9
|
-
this.listEntity = listEntity;
|
|
10
|
-
this.commandInterface = commandInterface;
|
|
11
|
-
this.state = new rxjs_1.BehaviorSubject(undefined);
|
|
12
|
-
this.terminatePreviousStateSubscription = new rxjs_1.Subject();
|
|
13
|
-
this.teardown = new rxjs_1.Subject();
|
|
14
|
-
this.commandInPipeline = new rxjs_1.BehaviorSubject(false);
|
|
15
|
-
this.state$ = this.state.pipe((0, operators_1.filter)((state) => state !== undefined));
|
|
16
|
-
this.provideStateObservable(state);
|
|
17
|
-
this.commandInPipeline
|
|
18
|
-
.pipe((0, operators_1.debounceTime)(30 * 1000), (0, operators_1.filter)(api_1.isTrue), (0, operators_1.tap)(() => this.commandInPipeline.next(false)), (0, operators_1.takeUntil)(this.teardown))
|
|
19
|
-
.subscribe();
|
|
20
|
-
}
|
|
21
|
-
provideStateObservable(state$) {
|
|
22
|
-
this.terminatePreviousStateSubscription.next();
|
|
23
|
-
state$
|
|
24
|
-
.pipe((0, operators_1.tap)((state) => this.state.next(state)), (0, operators_1.tap)(() => this.commandInPipeline.next(false)), (0, operators_1.takeUntil)(this.terminatePreviousStateSubscription), (0, operators_1.takeUntil)(this.teardown))
|
|
25
|
-
.subscribe();
|
|
26
|
-
}
|
|
27
|
-
get ready() {
|
|
28
|
-
return this.state.getValue() !== undefined;
|
|
29
|
-
}
|
|
30
|
-
get name() {
|
|
31
|
-
return this.listEntity.name;
|
|
32
|
-
}
|
|
33
|
-
get key() {
|
|
34
|
-
return this.listEntity.key;
|
|
35
|
-
}
|
|
36
|
-
toString() {
|
|
37
|
-
return this.listEntity.name;
|
|
38
|
-
}
|
|
39
|
-
terminate() {
|
|
40
|
-
this.teardown.next();
|
|
41
|
-
}
|
|
42
|
-
queueCommand(type, dataFn, disableSerialise = false) {
|
|
43
|
-
this.commandInPipeline
|
|
44
|
-
.pipe((0, operators_1.filter)((x) => !x || disableSerialise), (0, operators_1.take)(1), (0, operators_1.tap)(() => {
|
|
45
|
-
this.commandInterface.sendEspMessage(type, dataFn());
|
|
46
|
-
this.commandInPipeline.next(true);
|
|
47
|
-
}), (0, operators_1.takeUntil)(this.teardown))
|
|
48
|
-
.subscribe();
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
exports.BaseComponent = BaseComponent;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { BaseComponent } from './base';
|
|
2
|
-
import { BinarySensorEntity, ComponentType } from './entities';
|
|
3
|
-
import { BinarySensorStateEvent } from './states';
|
|
4
|
-
import { BinarySensorTypes } from './binarySensorTypes';
|
|
5
|
-
export declare class BinarySensorComponent extends BaseComponent<BinarySensorEntity, BinarySensorStateEvent> {
|
|
6
|
-
get deviceClass(): BinarySensorTypes;
|
|
7
|
-
get status(): boolean;
|
|
8
|
-
get type(): ComponentType;
|
|
9
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinarySensorComponent = void 0;
|
|
4
|
-
const base_1 = require("./base");
|
|
5
|
-
const binarySensorTypes_1 = require("./binarySensorTypes");
|
|
6
|
-
class BinarySensorComponent extends base_1.BaseComponent {
|
|
7
|
-
get deviceClass() {
|
|
8
|
-
var _a;
|
|
9
|
-
return (_a = this.listEntity.deviceClass) !== null && _a !== void 0 ? _a : binarySensorTypes_1.BinarySensorTypes.NONE;
|
|
10
|
-
}
|
|
11
|
-
get status() {
|
|
12
|
-
const state = this.state.getValue();
|
|
13
|
-
return !!(state === null || state === void 0 ? void 0 : state.state);
|
|
14
|
-
}
|
|
15
|
-
get type() {
|
|
16
|
-
return 'binarySensor';
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
exports.BinarySensorComponent = BinarySensorComponent;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export declare enum BinarySensorTypes {
|
|
2
|
-
NONE = "None",
|
|
3
|
-
BATTERY = "battery",
|
|
4
|
-
COLD = "cold",
|
|
5
|
-
CONNECTIVITY = "connectivity",
|
|
6
|
-
DOOR = "door",
|
|
7
|
-
GARAGE_DOOR = "garage_door",
|
|
8
|
-
GAS = "gas",
|
|
9
|
-
HEAT = "heat",
|
|
10
|
-
LIGHT = "light",
|
|
11
|
-
LOCK = "lock",
|
|
12
|
-
MOISTURE = "moisture",
|
|
13
|
-
MOTION = "motion",
|
|
14
|
-
MOVING = "moving",
|
|
15
|
-
OCCUPANCY = "occupancy",
|
|
16
|
-
OPENING = "opening",
|
|
17
|
-
PLUG = "plug",
|
|
18
|
-
POWER = "power",
|
|
19
|
-
PRESENCE = "presence",
|
|
20
|
-
PROBLEM = "problem",
|
|
21
|
-
SAFETY = "safety",
|
|
22
|
-
SMOKE = "smoke",
|
|
23
|
-
SOUND = "sound",
|
|
24
|
-
VIBRATION = "vibration",
|
|
25
|
-
WINDOW = "window"
|
|
26
|
-
}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BinarySensorTypes = void 0;
|
|
4
|
-
var BinarySensorTypes;
|
|
5
|
-
(function (BinarySensorTypes) {
|
|
6
|
-
BinarySensorTypes["NONE"] = "None";
|
|
7
|
-
BinarySensorTypes["BATTERY"] = "battery";
|
|
8
|
-
BinarySensorTypes["COLD"] = "cold";
|
|
9
|
-
BinarySensorTypes["CONNECTIVITY"] = "connectivity";
|
|
10
|
-
BinarySensorTypes["DOOR"] = "door";
|
|
11
|
-
BinarySensorTypes["GARAGE_DOOR"] = "garage_door";
|
|
12
|
-
BinarySensorTypes["GAS"] = "gas";
|
|
13
|
-
BinarySensorTypes["HEAT"] = "heat";
|
|
14
|
-
BinarySensorTypes["LIGHT"] = "light";
|
|
15
|
-
BinarySensorTypes["LOCK"] = "lock";
|
|
16
|
-
BinarySensorTypes["MOISTURE"] = "moisture";
|
|
17
|
-
BinarySensorTypes["MOTION"] = "motion";
|
|
18
|
-
BinarySensorTypes["MOVING"] = "moving";
|
|
19
|
-
BinarySensorTypes["OCCUPANCY"] = "occupancy";
|
|
20
|
-
BinarySensorTypes["OPENING"] = "opening";
|
|
21
|
-
BinarySensorTypes["PLUG"] = "plug";
|
|
22
|
-
BinarySensorTypes["POWER"] = "power";
|
|
23
|
-
BinarySensorTypes["PRESENCE"] = "presence";
|
|
24
|
-
BinarySensorTypes["PROBLEM"] = "problem";
|
|
25
|
-
BinarySensorTypes["SAFETY"] = "safety";
|
|
26
|
-
BinarySensorTypes["SMOKE"] = "smoke";
|
|
27
|
-
BinarySensorTypes["SOUND"] = "sound";
|
|
28
|
-
BinarySensorTypes["VIBRATION"] = "vibration";
|
|
29
|
-
BinarySensorTypes["WINDOW"] = "window";
|
|
30
|
-
})(BinarySensorTypes = exports.BinarySensorTypes || (exports.BinarySensorTypes = {}));
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface ListEntity {
|
|
2
|
-
key: number;
|
|
3
|
-
name: string;
|
|
4
|
-
uniqueId: string;
|
|
5
|
-
objectId: string;
|
|
6
|
-
}
|
|
7
|
-
export interface SensorEntity extends ListEntity {
|
|
8
|
-
accuracyDecimals: number;
|
|
9
|
-
deviceClass?: 'temperature' | 'humidity' | string;
|
|
10
|
-
icon: string;
|
|
11
|
-
unitOfMeasurement: string;
|
|
12
|
-
}
|
|
13
|
-
export interface BinarySensorEntity extends ListEntity {
|
|
14
|
-
deviceClass: string;
|
|
15
|
-
}
|
|
16
|
-
export interface LightEntity extends ListEntity {
|
|
17
|
-
effects: string[];
|
|
18
|
-
supportsBrightness: boolean;
|
|
19
|
-
supportsRgb: boolean;
|
|
20
|
-
}
|
|
21
|
-
export type ComponentType = 'light' | 'binarySensor' | 'sensor' | 'switch';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const convertNumbers: (num: number, max?: number, fromEsp?: boolean) => number;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.convertNumbers = void 0;
|
|
4
|
-
const convertNumbers = (num, max = 255, fromEsp = false) => {
|
|
5
|
-
if (fromEsp) {
|
|
6
|
-
return Math.floor(num * max);
|
|
7
|
-
}
|
|
8
|
-
else {
|
|
9
|
-
return Math.min(Math.max(num, 0), max) / max;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
exports.convertNumbers = convertNumbers;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from './base';
|
|
2
|
-
export * from './binarySensor';
|
|
3
|
-
export * from './binarySensorTypes';
|
|
4
|
-
export * from './commandInterface';
|
|
5
|
-
export * from './entities';
|
|
6
|
-
export * from './helpers';
|
|
7
|
-
export * from './interfaces';
|
|
8
|
-
export * from './light';
|
|
9
|
-
export * from './sensor';
|
|
10
|
-
export * from './states';
|
|
11
|
-
export * from './switch';
|
package/dist/components/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./base"), exports);
|
|
18
|
-
__exportStar(require("./binarySensor"), exports);
|
|
19
|
-
__exportStar(require("./binarySensorTypes"), exports);
|
|
20
|
-
__exportStar(require("./commandInterface"), exports);
|
|
21
|
-
__exportStar(require("./entities"), exports);
|
|
22
|
-
__exportStar(require("./helpers"), exports);
|
|
23
|
-
__exportStar(require("./interfaces"), exports);
|
|
24
|
-
__exportStar(require("./light"), exports);
|
|
25
|
-
__exportStar(require("./sensor"), exports);
|
|
26
|
-
__exportStar(require("./states"), exports);
|
|
27
|
-
__exportStar(require("./switch"), exports);
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { ComponentType, LightEntity } from './entities';
|
|
2
|
-
import { LightStateEvent } from './states';
|
|
3
|
-
import { BaseComponent } from './base';
|
|
4
|
-
import { Hsv, Rgb } from './interfaces';
|
|
5
|
-
export declare const DEFAULT_NO_EFFECT = "None";
|
|
6
|
-
export declare class LightComponent extends BaseComponent<LightEntity, LightStateEvent> {
|
|
7
|
-
turnOn(): void;
|
|
8
|
-
turnOff(): void;
|
|
9
|
-
getBrightness(): number | undefined;
|
|
10
|
-
setBrightness(brightness: number): void;
|
|
11
|
-
get hsv(): Hsv;
|
|
12
|
-
set hsv(hsv: Hsv);
|
|
13
|
-
get rgb(): Rgb;
|
|
14
|
-
set rgb({ red, green, blue }: Rgb);
|
|
15
|
-
get type(): ComponentType;
|
|
16
|
-
get supportsRgb(): boolean;
|
|
17
|
-
get supportsBrightness(): boolean;
|
|
18
|
-
availableEffects(): string[];
|
|
19
|
-
get effect(): string;
|
|
20
|
-
set effect(effect: string);
|
|
21
|
-
private generateState;
|
|
22
|
-
}
|