esphome-ts 3.2.0 → 3.3.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/dist/api/client.js +7 -7
- package/dist/api/connection.js +6 -6
- package/dist/api/espDevice.js +11 -11
- package/dist/api/espSocket.js +5 -5
- package/dist/api/helpers.js +14 -14
- package/dist/api/index.js +5 -1
- package/dist/api/interfaces.d.ts +3 -3
- package/dist/api/protobuf/api.d.ts +53 -53
- package/dist/api/protobuf/api_options.d.ts +3 -3
- package/dist/api/protobuf/google_descriptor.d.ts +29 -29
- package/dist/api/protobuf/google_descriptor.js +5 -21
- package/dist/api/socket.js +13 -13
- package/dist/components/base.js +5 -5
- package/dist/components/entities.d.ts +3 -2
- package/dist/components/index.js +5 -1
- package/dist/components/light.js +6 -6
- package/dist/components/sensor.d.ts +1 -0
- package/dist/components/sensor.js +3 -0
- package/dist/components/states.d.ts +1 -1
- package/dist/index.js +5 -1
- package/dist/run.js +4 -4
- package/package.json +27 -26
- package/CHANGELOG.md +0 -25
package/dist/api/client.js
CHANGED
|
@@ -16,7 +16,7 @@ class Client {
|
|
|
16
16
|
this.socket = socket;
|
|
17
17
|
this.subscription = new rxjs_1.Subscription();
|
|
18
18
|
this.subscription.add(this.socket.espData$
|
|
19
|
-
.pipe(operators_1.tap((data) => {
|
|
19
|
+
.pipe((0, operators_1.tap)((data) => {
|
|
20
20
|
if (data.type === requestResponseMatching_1.MessageTypes.PingRequest) {
|
|
21
21
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.PingResponse, api_1.PingResponse.encode({}).finish());
|
|
22
22
|
}
|
|
@@ -29,32 +29,32 @@ class Client {
|
|
|
29
29
|
hello(request) {
|
|
30
30
|
const data = api_1.HelloRequest.encode(request).finish();
|
|
31
31
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.HelloRequest, data);
|
|
32
|
-
return this.socket.espData$.pipe(operators_1.filter((value) => value.type === requestResponseMatching_1.MessageTypes.HelloResponse), operators_1.take(1), operators_1.switchMap((data) => rxjs_1.of(api_1.HelloResponse.decode(new minimal_1.Reader(data.payload)))));
|
|
32
|
+
return this.socket.espData$.pipe((0, operators_1.filter)((value) => value.type === requestResponseMatching_1.MessageTypes.HelloResponse), (0, operators_1.take)(1), (0, operators_1.switchMap)((data) => (0, rxjs_1.of)(api_1.HelloResponse.decode(new minimal_1.Reader(data.payload)))));
|
|
33
33
|
}
|
|
34
34
|
connect(request) {
|
|
35
35
|
const data = api_1.ConnectRequest.encode(request).finish();
|
|
36
36
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.ConnectRequest, data);
|
|
37
|
-
return this.socket.espData$.pipe(operators_1.filter((value) => value.type === requestResponseMatching_1.MessageTypes.ConnectResponse), operators_1.take(1), operators_1.switchMap((data) => rxjs_1.of(api_1.ConnectResponse.decode(new minimal_1.Reader(data.payload)))));
|
|
37
|
+
return this.socket.espData$.pipe((0, operators_1.filter)((value) => value.type === requestResponseMatching_1.MessageTypes.ConnectResponse), (0, operators_1.take)(1), (0, operators_1.switchMap)((data) => (0, rxjs_1.of)(api_1.ConnectResponse.decode(new minimal_1.Reader(data.payload)))));
|
|
38
38
|
}
|
|
39
39
|
ping() {
|
|
40
40
|
const data = api_1.PingRequest.encode({}).finish();
|
|
41
41
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.ConnectRequest, data);
|
|
42
|
-
return this.socket.espData$.pipe(operators_1.filter((value) => value.type === requestResponseMatching_1.MessageTypes.PingResponse), operators_1.take(1), operators_1.switchMap((data) => rxjs_1.of(api_1.PingResponse.decode(new minimal_1.Reader(data.payload)))));
|
|
42
|
+
return this.socket.espData$.pipe((0, operators_1.filter)((value) => value.type === requestResponseMatching_1.MessageTypes.PingResponse), (0, operators_1.take)(1), (0, operators_1.switchMap)((data) => (0, rxjs_1.of)(api_1.PingResponse.decode(new minimal_1.Reader(data.payload)))));
|
|
43
43
|
}
|
|
44
44
|
deviceInfo() {
|
|
45
45
|
const data = api_1.DeviceInfoRequest.encode({}).finish();
|
|
46
46
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.DeviceInfoRequest, data);
|
|
47
|
-
return this.socket.espData$.pipe(operators_1.filter(({ type }) => type === requestResponseMatching_1.MessageTypes.DeviceInfoResponse), operators_1.take(1), operators_1.switchMap(({ payload }) => rxjs_1.of(api_1.DeviceInfoResponse.decode(new minimal_1.Reader(payload)))));
|
|
47
|
+
return this.socket.espData$.pipe((0, operators_1.filter)(({ type }) => type === requestResponseMatching_1.MessageTypes.DeviceInfoResponse), (0, operators_1.take)(1), (0, operators_1.switchMap)(({ payload }) => (0, rxjs_1.of)(api_1.DeviceInfoResponse.decode(new minimal_1.Reader(payload)))));
|
|
48
48
|
}
|
|
49
49
|
listEntities() {
|
|
50
50
|
const data = api_1.ListEntitiesRequest.encode({}).finish();
|
|
51
51
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.ListEntitiesRequest, data);
|
|
52
|
-
return rxjs_1.of(api_options_1.voidMessage.decode(new minimal_1.Reader(new Uint8Array())));
|
|
52
|
+
return (0, rxjs_1.of)(api_options_1.voidMessage.decode(new minimal_1.Reader(new Uint8Array())));
|
|
53
53
|
}
|
|
54
54
|
subscribeStateChange() {
|
|
55
55
|
const data = api_1.SubscribeStatesRequest.encode({}).finish();
|
|
56
56
|
this.socket.sendEspMessage(requestResponseMatching_1.MessageTypes.SubscribeStatesRequest, data);
|
|
57
|
-
return rxjs_1.of(api_options_1.voidMessage.decode(new minimal_1.Reader(new Uint8Array())));
|
|
57
|
+
return (0, rxjs_1.of)(api_options_1.voidMessage.decode(new minimal_1.Reader(new Uint8Array())));
|
|
58
58
|
}
|
|
59
59
|
}
|
|
60
60
|
exports.Client = Client;
|
package/dist/api/connection.js
CHANGED
|
@@ -13,8 +13,8 @@ class Connection {
|
|
|
13
13
|
this.port = port;
|
|
14
14
|
this.subscription = new rxjs_1.Subscription();
|
|
15
15
|
this.socket = new net_1.Socket();
|
|
16
|
-
this.connected$ = rxjs_1.merge(rxjs_1.of(false), rxjs_1.fromEvent(this.socket, 'close').pipe(operators_1.mapTo(false)), rxjs_1.fromEvent(this.socket, 'ready').pipe(operators_1.mapTo(true))).pipe(operators_1.distinctUntilChanged(), operators_1.tap((connected) => (connected ? rxjs_1.noop() : this.subscription.unsubscribe())), operators_1.shareReplay(1));
|
|
17
|
-
this.data$ = rxjs_1.fromEvent(this.socket, 'data').pipe(operators_1.switchMap((buffer) => {
|
|
16
|
+
this.connected$ = (0, rxjs_1.merge)((0, rxjs_1.of)(false), (0, rxjs_1.fromEvent)(this.socket, 'close').pipe((0, operators_1.mapTo)(false)), (0, rxjs_1.fromEvent)(this.socket, 'ready').pipe((0, operators_1.mapTo)(true))).pipe((0, operators_1.distinctUntilChanged)(), (0, operators_1.tap)((connected) => (connected ? (0, rxjs_1.noop)() : this.subscription.unsubscribe())), (0, operators_1.shareReplay)(1));
|
|
17
|
+
this.data$ = (0, rxjs_1.fromEvent)(this.socket, 'data').pipe((0, operators_1.switchMap)((buffer) => {
|
|
18
18
|
let bytesTaken = 0;
|
|
19
19
|
const result = [];
|
|
20
20
|
while (bytesTaken < buffer.length) {
|
|
@@ -22,15 +22,15 @@ class Connection {
|
|
|
22
22
|
result.push(subBuffer);
|
|
23
23
|
bytesTaken += 3 + buffer[bytesTaken + bytePositions_1.BytePositions.LENGTH];
|
|
24
24
|
}
|
|
25
|
-
return rxjs_1.from(result);
|
|
26
|
-
}), operators_1.filter((buffer) => buffer.length >= 3), operators_1.filter((buffer) => buffer.readUInt8(bytePositions_1.BytePositions.ZERO) === bytePositions_1.HEADER_FIRST_BYTE), operators_1.map((buffer) => ({
|
|
25
|
+
return (0, rxjs_1.from)(result);
|
|
26
|
+
}), (0, operators_1.filter)((buffer) => buffer.length >= 3), (0, operators_1.filter)((buffer) => buffer.readUInt8(bytePositions_1.BytePositions.ZERO) === bytePositions_1.HEADER_FIRST_BYTE), (0, operators_1.map)((buffer) => ({
|
|
27
27
|
type: buffer.readUInt8(bytePositions_1.BytePositions.TYPE),
|
|
28
28
|
payload: buffer.slice(bytePositions_1.BytePositions.PAYLOAD, bytePositions_1.BytePositions.PAYLOAD + buffer.readUInt8(bytePositions_1.BytePositions.LENGTH)),
|
|
29
29
|
})));
|
|
30
30
|
}
|
|
31
31
|
open() {
|
|
32
32
|
this.subscription = new rxjs_1.Subscription();
|
|
33
|
-
this.subscription.add(rxjs_1.fromEvent(this.socket, 'error').subscribe());
|
|
33
|
+
this.subscription.add((0, rxjs_1.fromEvent)(this.socket, 'error').subscribe());
|
|
34
34
|
this.socket.connect(this.port, this.host);
|
|
35
35
|
return this.connected$;
|
|
36
36
|
}
|
|
@@ -41,7 +41,7 @@ class Connection {
|
|
|
41
41
|
}
|
|
42
42
|
send(type, payload) {
|
|
43
43
|
this.subscription.add(this.connected$
|
|
44
|
-
.pipe(operators_1.timeout(5000), operators_1.filter(helpers_1.isTrue), operators_1.take(1), operators_1.tap(() => {
|
|
44
|
+
.pipe((0, operators_1.timeout)(5000), (0, operators_1.filter)(helpers_1.isTrue), (0, operators_1.take)(1), (0, operators_1.tap)(() => {
|
|
45
45
|
const final = new Uint8Array([bytePositions_1.HEADER_FIRST_BYTE, payload.length, type, ...payload]);
|
|
46
46
|
this.socket.write(final);
|
|
47
47
|
}))
|
package/dist/api/espDevice.js
CHANGED
|
@@ -20,32 +20,32 @@ class EspDevice {
|
|
|
20
20
|
timeout: PING_TIMEOUT,
|
|
21
21
|
});
|
|
22
22
|
this.client = new _1.Client(this.socket);
|
|
23
|
-
this.stateEvents$ = this.socket.espData$.pipe(operators_1.filter((data) => _1.stateResponses.has(data.type)), operators_1.map((data) => _1.stateParser(data)), operators_1.filter((parsed) => !!parsed));
|
|
23
|
+
this.stateEvents$ = this.socket.espData$.pipe((0, operators_1.filter)((data) => _1.stateResponses.has(data.type)), (0, operators_1.map)((data) => (0, _1.stateParser)(data)), (0, operators_1.filter)((parsed) => !!parsed));
|
|
24
24
|
this.subscription.add(this.socket.espData$
|
|
25
|
-
.pipe(operators_1.tap((data) => {
|
|
25
|
+
.pipe((0, operators_1.tap)((data) => {
|
|
26
26
|
if (_1.listResponses.has(data.type)) {
|
|
27
27
|
this.parseListResponse(data);
|
|
28
28
|
}
|
|
29
29
|
else if (data.type === _1.MessageTypes.DeviceInfoResponse) {
|
|
30
|
-
this.deviceInfo = _1.decode(api_1.DeviceInfoResponse, data);
|
|
30
|
+
this.deviceInfo = (0, _1.decode)(api_1.DeviceInfoResponse, data);
|
|
31
31
|
}
|
|
32
32
|
}))
|
|
33
33
|
.subscribe());
|
|
34
34
|
this.subscription.add(this.socket.connected$
|
|
35
|
-
.pipe(operators_1.distinctUntilChanged(), operators_1.tap((connected) => {
|
|
35
|
+
.pipe((0, operators_1.distinctUntilChanged)(), (0, operators_1.tap)((connected) => {
|
|
36
36
|
if (!connected) {
|
|
37
37
|
this.socket.open();
|
|
38
38
|
}
|
|
39
|
-
}), operators_1.filter(_1.isTrue), operators_1.switchMap(() => this.client.hello({ clientInfo: 'esphome-ts' })), operators_1.switchMap(() => this.client.connect({ password })), operators_1.switchMap(() => this.client.deviceInfo()), operators_1.switchMap(() => this.client.listEntities()), operators_1.switchMap(() => this.client.subscribeStateChange()))
|
|
39
|
+
}), (0, operators_1.filter)(_1.isTrue), (0, operators_1.switchMap)(() => this.client.hello({ clientInfo: 'esphome-ts' })), (0, operators_1.switchMap)(() => this.client.connect({ password })), (0, operators_1.switchMap)(() => this.client.deviceInfo()), (0, operators_1.switchMap)(() => this.client.listEntities()), (0, operators_1.switchMap)(() => this.client.subscribeStateChange()))
|
|
40
40
|
.subscribe());
|
|
41
|
-
this.socket.timeout$.pipe(operators_1.tap(() => console.log('timeout'))).subscribe();
|
|
42
|
-
this.alive$ = rxjs_1.merge(this.socket.connected$, this.socket.espData$.pipe(operators_1.switchMap(() => {
|
|
43
|
-
return rxjs_1.concat(rxjs_1.of(true), this.socket.espData$.pipe(operators_1.mapTo(true), operators_1.timeout(PING_TIMEOUT), operators_1.catchError(() => rxjs_1.of(false)), operators_1.take(1)));
|
|
44
|
-
}))).pipe(operators_1.distinctUntilChanged(), operators_1.shareReplay(1));
|
|
41
|
+
this.socket.timeout$.pipe((0, operators_1.tap)(() => console.log('timeout'))).subscribe();
|
|
42
|
+
this.alive$ = (0, rxjs_1.merge)(this.socket.connected$, this.socket.espData$.pipe((0, operators_1.switchMap)(() => {
|
|
43
|
+
return (0, rxjs_1.concat)((0, rxjs_1.of)(true), this.socket.espData$.pipe((0, operators_1.mapTo)(true), (0, operators_1.timeout)(PING_TIMEOUT), (0, operators_1.catchError)(() => (0, rxjs_1.of)(false)), (0, operators_1.take)(1)));
|
|
44
|
+
}))).pipe((0, operators_1.distinctUntilChanged)(), (0, operators_1.shareReplay)(1));
|
|
45
45
|
}
|
|
46
46
|
provideRetryObservable(retryWhen$) {
|
|
47
47
|
this.subscription.add(this.alive$
|
|
48
|
-
.pipe(operators_1.filter(_1.isFalse), operators_1.switchMap(() => retryWhen$.pipe(operators_1.tap(() => this.socket.open()), operators_1.takeUntil(this.alive$.pipe(operators_1.filter(_1.isTrue))))))
|
|
48
|
+
.pipe((0, operators_1.filter)(_1.isFalse), (0, operators_1.switchMap)(() => retryWhen$.pipe((0, operators_1.tap)(() => this.socket.open()), (0, operators_1.takeUntil)(this.alive$.pipe((0, operators_1.filter)(_1.isTrue))))))
|
|
49
49
|
.subscribe());
|
|
50
50
|
}
|
|
51
51
|
terminate() {
|
|
@@ -63,7 +63,7 @@ class EspDevice {
|
|
|
63
63
|
}
|
|
64
64
|
else {
|
|
65
65
|
const knownComponents = new Set(Object.keys(this.components));
|
|
66
|
-
const { id, component, state$ } = _1.createComponents(data, this.stateEvents$, this.socket, knownComponents);
|
|
66
|
+
const { id, component, state$ } = (0, _1.createComponents)(data, this.stateEvents$, this.socket, knownComponents);
|
|
67
67
|
if (component) {
|
|
68
68
|
this.components[id] = (_a = this.components[id]) !== null && _a !== void 0 ? _a : component;
|
|
69
69
|
}
|
package/dist/api/espSocket.js
CHANGED
|
@@ -9,7 +9,7 @@ const helpers_1 = require("./helpers");
|
|
|
9
9
|
class EspSocket extends socket_1.RxjsSocket {
|
|
10
10
|
constructor(host, port, config) {
|
|
11
11
|
super(host, port, config);
|
|
12
|
-
this.espData$ = this.data$.pipe(operators_1.switchMap((buffer) => {
|
|
12
|
+
this.espData$ = this.data$.pipe((0, operators_1.switchMap)((buffer) => {
|
|
13
13
|
let bytesTaken = 0;
|
|
14
14
|
const result = [];
|
|
15
15
|
while (bytesTaken < buffer.length) {
|
|
@@ -17,18 +17,18 @@ class EspSocket extends socket_1.RxjsSocket {
|
|
|
17
17
|
result.push(subBuffer);
|
|
18
18
|
bytesTaken += bytePositions_1.HEADER_SIZE + buffer[bytesTaken + bytePositions_1.BytePositions.LENGTH];
|
|
19
19
|
}
|
|
20
|
-
return rxjs_1.from(result);
|
|
21
|
-
}), operators_1.filter((buffer) => buffer.length >= bytePositions_1.HEADER_SIZE), operators_1.filter((buffer) => buffer.readUInt8(bytePositions_1.BytePositions.ZERO) === bytePositions_1.HEADER_FIRST_BYTE), operators_1.map((buffer) => ({
|
|
20
|
+
return (0, rxjs_1.from)(result);
|
|
21
|
+
}), (0, operators_1.filter)((buffer) => buffer.length >= bytePositions_1.HEADER_SIZE), (0, operators_1.filter)((buffer) => buffer.readUInt8(bytePositions_1.BytePositions.ZERO) === bytePositions_1.HEADER_FIRST_BYTE), (0, operators_1.map)((buffer) => ({
|
|
22
22
|
type: buffer.readUInt8(bytePositions_1.BytePositions.TYPE),
|
|
23
23
|
payload: buffer.slice(bytePositions_1.BytePositions.PAYLOAD, bytePositions_1.BytePositions.PAYLOAD + buffer.readUInt8(bytePositions_1.BytePositions.LENGTH)),
|
|
24
24
|
})));
|
|
25
25
|
}
|
|
26
26
|
sendEspMessage(type, payload) {
|
|
27
27
|
this.connected$
|
|
28
|
-
.pipe(operators_1.timeout(5000), operators_1.filter(helpers_1.isTrue), operators_1.take(1), operators_1.switchMap(() => {
|
|
28
|
+
.pipe((0, operators_1.timeout)(5000), (0, operators_1.filter)(helpers_1.isTrue), (0, operators_1.take)(1), (0, operators_1.switchMap)(() => {
|
|
29
29
|
const final = new Uint8Array([bytePositions_1.HEADER_FIRST_BYTE, payload.length, type, ...payload]);
|
|
30
30
|
return this.send(final);
|
|
31
|
-
}), operators_1.takeUntil(this.terminate))
|
|
31
|
+
}), (0, operators_1.takeUntil)(this.terminate))
|
|
32
32
|
.subscribe();
|
|
33
33
|
}
|
|
34
34
|
}
|
package/dist/api/helpers.js
CHANGED
|
@@ -9,19 +9,19 @@ const __1 = require("..");
|
|
|
9
9
|
const stateParser = (data) => {
|
|
10
10
|
switch (data.type) {
|
|
11
11
|
case requestResponseMatching_1.MessageTypes.BinarySensorStateResponse: {
|
|
12
|
-
return client_1.decode(api_1.BinarySensorStateResponse, data);
|
|
12
|
+
return (0, client_1.decode)(api_1.BinarySensorStateResponse, data);
|
|
13
13
|
}
|
|
14
14
|
case requestResponseMatching_1.MessageTypes.LightStateResponse: {
|
|
15
|
-
return client_1.decode(api_1.LightStateResponse, data);
|
|
15
|
+
return (0, client_1.decode)(api_1.LightStateResponse, data);
|
|
16
16
|
}
|
|
17
17
|
case requestResponseMatching_1.MessageTypes.SensorStateResponse: {
|
|
18
|
-
return client_1.decode(api_1.SensorStateResponse, data);
|
|
18
|
+
return (0, client_1.decode)(api_1.SensorStateResponse, data);
|
|
19
19
|
}
|
|
20
20
|
case requestResponseMatching_1.MessageTypes.SwitchStateResponse: {
|
|
21
|
-
return client_1.decode(api_1.SwitchStateResponse, data);
|
|
21
|
+
return (0, client_1.decode)(api_1.SwitchStateResponse, data);
|
|
22
22
|
}
|
|
23
23
|
case requestResponseMatching_1.MessageTypes.CoverStateResponse: {
|
|
24
|
-
return client_1.decode(api_1.CoverStateResponse, data);
|
|
24
|
+
return (0, client_1.decode)(api_1.CoverStateResponse, data);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
return undefined;
|
|
@@ -30,8 +30,8 @@ exports.stateParser = stateParser;
|
|
|
30
30
|
const createComponents = (data, stateEvents$, connection, knownComponents) => {
|
|
31
31
|
switch (data.type) {
|
|
32
32
|
case requestResponseMatching_1.MessageTypes.ListEntitiesBinarySensorResponse: {
|
|
33
|
-
const response = client_1.decode(api_1.ListEntitiesBinarySensorResponse, data);
|
|
34
|
-
const state$ = exports.transformStates(stateEvents$, response);
|
|
33
|
+
const response = (0, client_1.decode)(api_1.ListEntitiesBinarySensorResponse, data);
|
|
34
|
+
const state$ = (0, exports.transformStates)(stateEvents$, response);
|
|
35
35
|
return knownComponents.has(response.objectId)
|
|
36
36
|
? {
|
|
37
37
|
id: response.objectId,
|
|
@@ -43,8 +43,8 @@ const createComponents = (data, stateEvents$, connection, knownComponents) => {
|
|
|
43
43
|
};
|
|
44
44
|
}
|
|
45
45
|
case requestResponseMatching_1.MessageTypes.ListEntitiesSwitchResponse: {
|
|
46
|
-
const response = client_1.decode(api_1.ListEntitiesSwitchResponse, data);
|
|
47
|
-
const state$ = exports.transformStates(stateEvents$, response);
|
|
46
|
+
const response = (0, client_1.decode)(api_1.ListEntitiesSwitchResponse, data);
|
|
47
|
+
const state$ = (0, exports.transformStates)(stateEvents$, response);
|
|
48
48
|
return knownComponents.has(response.objectId)
|
|
49
49
|
? {
|
|
50
50
|
id: response.objectId,
|
|
@@ -56,8 +56,8 @@ const createComponents = (data, stateEvents$, connection, knownComponents) => {
|
|
|
56
56
|
};
|
|
57
57
|
}
|
|
58
58
|
case requestResponseMatching_1.MessageTypes.ListEntitiesLightResponse: {
|
|
59
|
-
const response = client_1.decode(api_1.ListEntitiesLightResponse, data);
|
|
60
|
-
const state$ = exports.transformStates(stateEvents$, response);
|
|
59
|
+
const response = (0, client_1.decode)(api_1.ListEntitiesLightResponse, data);
|
|
60
|
+
const state$ = (0, exports.transformStates)(stateEvents$, response);
|
|
61
61
|
return knownComponents.has(response.objectId)
|
|
62
62
|
? {
|
|
63
63
|
id: response.objectId,
|
|
@@ -69,8 +69,8 @@ const createComponents = (data, stateEvents$, connection, knownComponents) => {
|
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
case requestResponseMatching_1.MessageTypes.ListEntitiesSensorResponse: {
|
|
72
|
-
const response = client_1.decode(api_1.ListEntitiesSensorResponse, data);
|
|
73
|
-
const state$ = exports.transformStates(stateEvents$, response);
|
|
72
|
+
const response = (0, client_1.decode)(api_1.ListEntitiesSensorResponse, data);
|
|
73
|
+
const state$ = (0, exports.transformStates)(stateEvents$, response);
|
|
74
74
|
return knownComponents.has(response.objectId)
|
|
75
75
|
? {
|
|
76
76
|
id: response.objectId,
|
|
@@ -89,7 +89,7 @@ exports.emptyCommandInterface = {
|
|
|
89
89
|
sendEspMessage: () => undefined,
|
|
90
90
|
};
|
|
91
91
|
const transformStates = (stateEvents$, listEntityResponse) => {
|
|
92
|
-
return stateEvents$.pipe(operators_1.filter((stateEvent) => stateEvent.key === listEntityResponse.key));
|
|
92
|
+
return stateEvents$.pipe((0, operators_1.filter)((stateEvent) => stateEvent.key === listEntityResponse.key));
|
|
93
93
|
};
|
|
94
94
|
exports.transformStates = transformStates;
|
|
95
95
|
const isTrue = (val) => val === true;
|
package/dist/api/index.js
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
package/dist/api/interfaces.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BinarySensorStateResponse, CoverCommandRequest, CoverStateResponse, FanCommandRequest, FanStateResponse, LightCommandRequest, LightStateResponse, ListEntitiesBinarySensorResponse, ListEntitiesCoverResponse, ListEntitiesFanResponse, ListEntitiesLightResponse, ListEntitiesSensorResponse, ListEntitiesSwitchResponse, ListEntitiesTextSensorResponse, SensorStateResponse, SwitchCommandRequest, SwitchStateResponse, TextSensorStateResponse } from './protobuf/api';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
4
|
-
export
|
|
2
|
+
export type ListEntityResponses = ListEntitiesBinarySensorResponse | ListEntitiesCoverResponse | ListEntitiesFanResponse | ListEntitiesLightResponse | ListEntitiesSensorResponse | ListEntitiesSwitchResponse | ListEntitiesTextSensorResponse;
|
|
3
|
+
export type StateResponses = BinarySensorStateResponse | CoverStateResponse | FanStateResponse | LightStateResponse | SensorStateResponse | SwitchStateResponse | TextSensorStateResponse;
|
|
4
|
+
export type CommandRequests = CoverCommandRequest | FanCommandRequest | LightCommandRequest | SwitchCommandRequest;
|