esphome-ts 5.0.0 → 5.1.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/dist/index.d.ts +65 -2
- package/dist/index.js +517 -0
- package/package.json +5 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { BinaryWriter, BinaryReader } from '@bufbuild/protobuf/wire';
|
|
2
2
|
import { Observable, BehaviorSubject, Subject } from 'rxjs';
|
|
3
3
|
|
|
4
|
+
declare enum LegacyCoverState {
|
|
5
|
+
LEGACY_COVER_STATE_OPEN = 0,
|
|
6
|
+
LEGACY_COVER_STATE_CLOSED = 1,
|
|
7
|
+
UNRECOGNIZED = -1
|
|
8
|
+
}
|
|
9
|
+
declare enum CoverOperation {
|
|
10
|
+
COVER_OPERATION_IDLE = 0,
|
|
11
|
+
COVER_OPERATION_IS_OPENING = 1,
|
|
12
|
+
COVER_OPERATION_IS_CLOSING = 2,
|
|
13
|
+
UNRECOGNIZED = -1
|
|
14
|
+
}
|
|
4
15
|
/**
|
|
5
16
|
* Message sent at the beginning of each connection
|
|
6
17
|
* Can only be sent by the client and only at the beginning of the connection
|
|
@@ -230,12 +241,18 @@ interface SensorEntity extends ListEntity {
|
|
|
230
241
|
interface BinarySensorEntity extends ListEntity {
|
|
231
242
|
deviceClass: string;
|
|
232
243
|
}
|
|
244
|
+
interface CoverEntity extends ListEntity {
|
|
245
|
+
assumedState: boolean;
|
|
246
|
+
supportsPosition: boolean;
|
|
247
|
+
supportsTilt: boolean;
|
|
248
|
+
deviceClass: string;
|
|
249
|
+
}
|
|
233
250
|
interface LightEntity extends ListEntity {
|
|
234
251
|
effects: string[];
|
|
235
252
|
supportsBrightness: boolean;
|
|
236
253
|
supportsRgb: boolean;
|
|
237
254
|
}
|
|
238
|
-
type ComponentType = 'light' | 'binarySensor' | 'sensor' | 'switch';
|
|
255
|
+
type ComponentType = 'light' | 'binarySensor' | 'sensor' | 'switch' | 'cover';
|
|
239
256
|
|
|
240
257
|
interface StateEvent {
|
|
241
258
|
key: number;
|
|
@@ -247,6 +264,12 @@ interface BinarySensorStateEvent extends StateEvent {
|
|
|
247
264
|
state?: boolean;
|
|
248
265
|
}
|
|
249
266
|
type SwitchStateEvent = BinarySensorStateEvent;
|
|
267
|
+
interface CoverStateEvent extends StateEvent {
|
|
268
|
+
legacyState?: LegacyCoverState;
|
|
269
|
+
position?: number;
|
|
270
|
+
tilt?: number;
|
|
271
|
+
currentOperation?: CoverOperation;
|
|
272
|
+
}
|
|
250
273
|
interface LightStateEvent extends StateEvent {
|
|
251
274
|
state?: boolean;
|
|
252
275
|
brightness?: number;
|
|
@@ -366,6 +389,46 @@ declare class BinarySensorComponent extends BaseComponent<BinarySensorEntity, Bi
|
|
|
366
389
|
get type(): ComponentType;
|
|
367
390
|
}
|
|
368
391
|
|
|
392
|
+
declare class CoverComponent extends BaseComponent<CoverEntity, CoverStateEvent> {
|
|
393
|
+
open(): void;
|
|
394
|
+
close(): void;
|
|
395
|
+
stop(): void;
|
|
396
|
+
setPosition(position: number): void;
|
|
397
|
+
setTilt(tilt: number): void;
|
|
398
|
+
get type(): ComponentType;
|
|
399
|
+
get assumedState(): boolean;
|
|
400
|
+
get supportsPosition(): boolean;
|
|
401
|
+
get supportsTilt(): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Current position between 0 (closed) and 1 (open). Undefined until the
|
|
404
|
+
* first state was received or when the cover does not support positions.
|
|
405
|
+
*/
|
|
406
|
+
get position(): number | undefined;
|
|
407
|
+
/**
|
|
408
|
+
* Current tilt between 0 and 1. Undefined until the first state was
|
|
409
|
+
* received or when the cover does not support tilt.
|
|
410
|
+
*/
|
|
411
|
+
get tilt(): number | undefined;
|
|
412
|
+
/**
|
|
413
|
+
* Whether the cover is fully closed. Derived from the position field the
|
|
414
|
+
* device always sends, exactly like aioesphomeapi derives is_closed
|
|
415
|
+
* (position == 0). Undefined until the first state was received.
|
|
416
|
+
*/
|
|
417
|
+
get isClosed(): boolean | undefined;
|
|
418
|
+
/**
|
|
419
|
+
* Whether the cover is fully open. Derived from the position field the
|
|
420
|
+
* device always sends. Undefined until the first state was received; a
|
|
421
|
+
* partially open cover is neither open nor closed.
|
|
422
|
+
*/
|
|
423
|
+
get isOpen(): boolean | undefined;
|
|
424
|
+
/**
|
|
425
|
+
* What the cover is currently doing. Undefined until the first state was
|
|
426
|
+
* received.
|
|
427
|
+
*/
|
|
428
|
+
get operation(): CoverOperation | undefined;
|
|
429
|
+
private sendCommand;
|
|
430
|
+
}
|
|
431
|
+
|
|
369
432
|
interface Rgb {
|
|
370
433
|
red: number;
|
|
371
434
|
green: number;
|
|
@@ -403,4 +466,4 @@ declare class SensorComponent extends BaseComponent<SensorEntity, SensorStateEve
|
|
|
403
466
|
get icon(): string;
|
|
404
467
|
}
|
|
405
468
|
|
|
406
|
-
export { BaseComponent, BinarySensorComponent, type BinarySensorEntity, type BinarySensorStateEvent, BinarySensorTypes, Client, type CommandInterface, type ComponentType, type Connection, EspDevice, EspSocket, type Hsv, InvalidPasswordError, LightComponent, type LightEntity, type LightStateEvent, type ListEntity, MessageTypes, type ReadData, type Rgb, SensorComponent, type SensorEntity, type SensorStateEvent, type StateEvent, SwitchComponent, type SwitchStateEvent, isFalse, isSwitchComponent, isTrue };
|
|
469
|
+
export { BaseComponent, BinarySensorComponent, type BinarySensorEntity, type BinarySensorStateEvent, BinarySensorTypes, Client, type CommandInterface, type ComponentType, type Connection, CoverComponent, type CoverEntity, CoverOperation, type CoverStateEvent, EspDevice, EspSocket, type Hsv, InvalidPasswordError, LegacyCoverState, LightComponent, type LightEntity, type LightStateEvent, type ListEntity, MessageTypes, type ReadData, type Rgb, SensorComponent, type SensorEntity, type SensorStateEvent, type StateEvent, SwitchComponent, type SwitchStateEvent, isFalse, isSwitchComponent, isTrue };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
// src/api/protobuf/api.ts
|
|
2
2
|
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
3
|
+
var LegacyCoverState = /* @__PURE__ */ ((LegacyCoverState2) => {
|
|
4
|
+
LegacyCoverState2[LegacyCoverState2["LEGACY_COVER_STATE_OPEN"] = 0] = "LEGACY_COVER_STATE_OPEN";
|
|
5
|
+
LegacyCoverState2[LegacyCoverState2["LEGACY_COVER_STATE_CLOSED"] = 1] = "LEGACY_COVER_STATE_CLOSED";
|
|
6
|
+
LegacyCoverState2[LegacyCoverState2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
7
|
+
return LegacyCoverState2;
|
|
8
|
+
})(LegacyCoverState || {});
|
|
3
9
|
function legacyCoverStateFromJSON(object) {
|
|
4
10
|
switch (object) {
|
|
5
11
|
case 0:
|
|
@@ -25,6 +31,13 @@ function legacyCoverStateToJSON(object) {
|
|
|
25
31
|
return "UNRECOGNIZED";
|
|
26
32
|
}
|
|
27
33
|
}
|
|
34
|
+
var CoverOperation = /* @__PURE__ */ ((CoverOperation2) => {
|
|
35
|
+
CoverOperation2[CoverOperation2["COVER_OPERATION_IDLE"] = 0] = "COVER_OPERATION_IDLE";
|
|
36
|
+
CoverOperation2[CoverOperation2["COVER_OPERATION_IS_OPENING"] = 1] = "COVER_OPERATION_IS_OPENING";
|
|
37
|
+
CoverOperation2[CoverOperation2["COVER_OPERATION_IS_CLOSING"] = 2] = "COVER_OPERATION_IS_CLOSING";
|
|
38
|
+
CoverOperation2[CoverOperation2["UNRECOGNIZED"] = -1] = "UNRECOGNIZED";
|
|
39
|
+
return CoverOperation2;
|
|
40
|
+
})(CoverOperation || {});
|
|
28
41
|
function coverOperationFromJSON(object) {
|
|
29
42
|
switch (object) {
|
|
30
43
|
case 0:
|
|
@@ -55,6 +68,36 @@ function coverOperationToJSON(object) {
|
|
|
55
68
|
return "UNRECOGNIZED";
|
|
56
69
|
}
|
|
57
70
|
}
|
|
71
|
+
function legacyCoverCommandFromJSON(object) {
|
|
72
|
+
switch (object) {
|
|
73
|
+
case 0:
|
|
74
|
+
case "LEGACY_COVER_COMMAND_OPEN":
|
|
75
|
+
return 0 /* LEGACY_COVER_COMMAND_OPEN */;
|
|
76
|
+
case 1:
|
|
77
|
+
case "LEGACY_COVER_COMMAND_CLOSE":
|
|
78
|
+
return 1 /* LEGACY_COVER_COMMAND_CLOSE */;
|
|
79
|
+
case 2:
|
|
80
|
+
case "LEGACY_COVER_COMMAND_STOP":
|
|
81
|
+
return 2 /* LEGACY_COVER_COMMAND_STOP */;
|
|
82
|
+
case -1:
|
|
83
|
+
case "UNRECOGNIZED":
|
|
84
|
+
default:
|
|
85
|
+
return -1 /* UNRECOGNIZED */;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function legacyCoverCommandToJSON(object) {
|
|
89
|
+
switch (object) {
|
|
90
|
+
case 0 /* LEGACY_COVER_COMMAND_OPEN */:
|
|
91
|
+
return "LEGACY_COVER_COMMAND_OPEN";
|
|
92
|
+
case 1 /* LEGACY_COVER_COMMAND_CLOSE */:
|
|
93
|
+
return "LEGACY_COVER_COMMAND_CLOSE";
|
|
94
|
+
case 2 /* LEGACY_COVER_COMMAND_STOP */:
|
|
95
|
+
return "LEGACY_COVER_COMMAND_STOP";
|
|
96
|
+
case -1 /* UNRECOGNIZED */:
|
|
97
|
+
default:
|
|
98
|
+
return "UNRECOGNIZED";
|
|
99
|
+
}
|
|
100
|
+
}
|
|
58
101
|
function createBaseHelloRequest() {
|
|
59
102
|
return { clientInfo: "" };
|
|
60
103
|
}
|
|
@@ -950,6 +993,182 @@ var BinarySensorStateResponse = {
|
|
|
950
993
|
return message;
|
|
951
994
|
}
|
|
952
995
|
};
|
|
996
|
+
function createBaseListEntitiesCoverResponse() {
|
|
997
|
+
return {
|
|
998
|
+
objectId: "",
|
|
999
|
+
key: 0,
|
|
1000
|
+
name: "",
|
|
1001
|
+
uniqueId: "",
|
|
1002
|
+
assumedState: false,
|
|
1003
|
+
supportsPosition: false,
|
|
1004
|
+
supportsTilt: false,
|
|
1005
|
+
deviceClass: ""
|
|
1006
|
+
};
|
|
1007
|
+
}
|
|
1008
|
+
var ListEntitiesCoverResponse = {
|
|
1009
|
+
encode(message, writer = new BinaryWriter()) {
|
|
1010
|
+
if (message.objectId !== "") {
|
|
1011
|
+
writer.uint32(10).string(message.objectId);
|
|
1012
|
+
}
|
|
1013
|
+
if (message.key !== 0) {
|
|
1014
|
+
writer.uint32(21).fixed32(message.key);
|
|
1015
|
+
}
|
|
1016
|
+
if (message.name !== "") {
|
|
1017
|
+
writer.uint32(26).string(message.name);
|
|
1018
|
+
}
|
|
1019
|
+
if (message.uniqueId !== "") {
|
|
1020
|
+
writer.uint32(34).string(message.uniqueId);
|
|
1021
|
+
}
|
|
1022
|
+
if (message.assumedState !== false) {
|
|
1023
|
+
writer.uint32(40).bool(message.assumedState);
|
|
1024
|
+
}
|
|
1025
|
+
if (message.supportsPosition !== false) {
|
|
1026
|
+
writer.uint32(48).bool(message.supportsPosition);
|
|
1027
|
+
}
|
|
1028
|
+
if (message.supportsTilt !== false) {
|
|
1029
|
+
writer.uint32(56).bool(message.supportsTilt);
|
|
1030
|
+
}
|
|
1031
|
+
if (message.deviceClass !== "") {
|
|
1032
|
+
writer.uint32(66).string(message.deviceClass);
|
|
1033
|
+
}
|
|
1034
|
+
return writer;
|
|
1035
|
+
},
|
|
1036
|
+
decode(input, length) {
|
|
1037
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1038
|
+
const previousRecursionDepth = reader.__tsProtoDecodeDepth ?? 0;
|
|
1039
|
+
if (previousRecursionDepth >= 100) {
|
|
1040
|
+
throw new globalThis.Error("protobuf decode recursion limit exceeded");
|
|
1041
|
+
}
|
|
1042
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth + 1;
|
|
1043
|
+
try {
|
|
1044
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1045
|
+
const message = createBaseListEntitiesCoverResponse();
|
|
1046
|
+
while (reader.pos < end) {
|
|
1047
|
+
const tag = reader.uint32();
|
|
1048
|
+
switch (tag >>> 3) {
|
|
1049
|
+
case 1: {
|
|
1050
|
+
if (tag !== 10) {
|
|
1051
|
+
break;
|
|
1052
|
+
}
|
|
1053
|
+
message.objectId = reader.string();
|
|
1054
|
+
continue;
|
|
1055
|
+
}
|
|
1056
|
+
case 2: {
|
|
1057
|
+
if (tag !== 21) {
|
|
1058
|
+
break;
|
|
1059
|
+
}
|
|
1060
|
+
message.key = reader.fixed32();
|
|
1061
|
+
continue;
|
|
1062
|
+
}
|
|
1063
|
+
case 3: {
|
|
1064
|
+
if (tag !== 26) {
|
|
1065
|
+
break;
|
|
1066
|
+
}
|
|
1067
|
+
message.name = reader.string();
|
|
1068
|
+
continue;
|
|
1069
|
+
}
|
|
1070
|
+
case 4: {
|
|
1071
|
+
if (tag !== 34) {
|
|
1072
|
+
break;
|
|
1073
|
+
}
|
|
1074
|
+
message.uniqueId = reader.string();
|
|
1075
|
+
continue;
|
|
1076
|
+
}
|
|
1077
|
+
case 5: {
|
|
1078
|
+
if (tag !== 40) {
|
|
1079
|
+
break;
|
|
1080
|
+
}
|
|
1081
|
+
message.assumedState = reader.bool();
|
|
1082
|
+
continue;
|
|
1083
|
+
}
|
|
1084
|
+
case 6: {
|
|
1085
|
+
if (tag !== 48) {
|
|
1086
|
+
break;
|
|
1087
|
+
}
|
|
1088
|
+
message.supportsPosition = reader.bool();
|
|
1089
|
+
continue;
|
|
1090
|
+
}
|
|
1091
|
+
case 7: {
|
|
1092
|
+
if (tag !== 56) {
|
|
1093
|
+
break;
|
|
1094
|
+
}
|
|
1095
|
+
message.supportsTilt = reader.bool();
|
|
1096
|
+
continue;
|
|
1097
|
+
}
|
|
1098
|
+
case 8: {
|
|
1099
|
+
if (tag !== 66) {
|
|
1100
|
+
break;
|
|
1101
|
+
}
|
|
1102
|
+
message.deviceClass = reader.string();
|
|
1103
|
+
continue;
|
|
1104
|
+
}
|
|
1105
|
+
}
|
|
1106
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1107
|
+
break;
|
|
1108
|
+
}
|
|
1109
|
+
reader.skip(tag & 7);
|
|
1110
|
+
}
|
|
1111
|
+
return message;
|
|
1112
|
+
} finally {
|
|
1113
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth;
|
|
1114
|
+
}
|
|
1115
|
+
},
|
|
1116
|
+
fromJSON(object) {
|
|
1117
|
+
return {
|
|
1118
|
+
objectId: isSet(object.objectId) ? globalThis.String(object.objectId) : isSet(object.object_id) ? globalThis.String(object.object_id) : "",
|
|
1119
|
+
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
|
|
1120
|
+
name: isSet(object.name) ? globalThis.String(object.name) : "",
|
|
1121
|
+
uniqueId: isSet(object.uniqueId) ? globalThis.String(object.uniqueId) : isSet(object.unique_id) ? globalThis.String(object.unique_id) : "",
|
|
1122
|
+
assumedState: isSet(object.assumedState) ? globalThis.Boolean(object.assumedState) : isSet(object.assumed_state) ? globalThis.Boolean(object.assumed_state) : false,
|
|
1123
|
+
supportsPosition: isSet(object.supportsPosition) ? globalThis.Boolean(object.supportsPosition) : isSet(object.supports_position) ? globalThis.Boolean(object.supports_position) : false,
|
|
1124
|
+
supportsTilt: isSet(object.supportsTilt) ? globalThis.Boolean(object.supportsTilt) : isSet(object.supports_tilt) ? globalThis.Boolean(object.supports_tilt) : false,
|
|
1125
|
+
deviceClass: isSet(object.deviceClass) ? globalThis.String(object.deviceClass) : isSet(object.device_class) ? globalThis.String(object.device_class) : ""
|
|
1126
|
+
};
|
|
1127
|
+
},
|
|
1128
|
+
toJSON(message) {
|
|
1129
|
+
const obj = {};
|
|
1130
|
+
if (message.objectId !== "") {
|
|
1131
|
+
obj.objectId = message.objectId;
|
|
1132
|
+
}
|
|
1133
|
+
if (message.key !== 0) {
|
|
1134
|
+
obj.key = Math.round(message.key);
|
|
1135
|
+
}
|
|
1136
|
+
if (message.name !== "") {
|
|
1137
|
+
obj.name = message.name;
|
|
1138
|
+
}
|
|
1139
|
+
if (message.uniqueId !== "") {
|
|
1140
|
+
obj.uniqueId = message.uniqueId;
|
|
1141
|
+
}
|
|
1142
|
+
if (message.assumedState !== false) {
|
|
1143
|
+
obj.assumedState = message.assumedState;
|
|
1144
|
+
}
|
|
1145
|
+
if (message.supportsPosition !== false) {
|
|
1146
|
+
obj.supportsPosition = message.supportsPosition;
|
|
1147
|
+
}
|
|
1148
|
+
if (message.supportsTilt !== false) {
|
|
1149
|
+
obj.supportsTilt = message.supportsTilt;
|
|
1150
|
+
}
|
|
1151
|
+
if (message.deviceClass !== "") {
|
|
1152
|
+
obj.deviceClass = message.deviceClass;
|
|
1153
|
+
}
|
|
1154
|
+
return obj;
|
|
1155
|
+
},
|
|
1156
|
+
create(base) {
|
|
1157
|
+
return ListEntitiesCoverResponse.fromPartial(base ?? {});
|
|
1158
|
+
},
|
|
1159
|
+
fromPartial(object) {
|
|
1160
|
+
const message = createBaseListEntitiesCoverResponse();
|
|
1161
|
+
message.objectId = object.objectId ?? "";
|
|
1162
|
+
message.key = object.key ?? 0;
|
|
1163
|
+
message.name = object.name ?? "";
|
|
1164
|
+
message.uniqueId = object.uniqueId ?? "";
|
|
1165
|
+
message.assumedState = object.assumedState ?? false;
|
|
1166
|
+
message.supportsPosition = object.supportsPosition ?? false;
|
|
1167
|
+
message.supportsTilt = object.supportsTilt ?? false;
|
|
1168
|
+
message.deviceClass = object.deviceClass ?? "";
|
|
1169
|
+
return message;
|
|
1170
|
+
}
|
|
1171
|
+
};
|
|
953
1172
|
function createBaseCoverStateResponse() {
|
|
954
1173
|
return { key: 0, legacyState: 0, position: 0, tilt: 0, currentOperation: 0 };
|
|
955
1174
|
}
|
|
@@ -1072,6 +1291,182 @@ var CoverStateResponse = {
|
|
|
1072
1291
|
return message;
|
|
1073
1292
|
}
|
|
1074
1293
|
};
|
|
1294
|
+
function createBaseCoverCommandRequest() {
|
|
1295
|
+
return {
|
|
1296
|
+
key: 0,
|
|
1297
|
+
hasLegacyCommand: false,
|
|
1298
|
+
legacyCommand: 0,
|
|
1299
|
+
hasPosition: false,
|
|
1300
|
+
position: 0,
|
|
1301
|
+
hasTilt: false,
|
|
1302
|
+
tilt: 0,
|
|
1303
|
+
stop: false
|
|
1304
|
+
};
|
|
1305
|
+
}
|
|
1306
|
+
var CoverCommandRequest = {
|
|
1307
|
+
encode(message, writer = new BinaryWriter()) {
|
|
1308
|
+
if (message.key !== 0) {
|
|
1309
|
+
writer.uint32(13).fixed32(message.key);
|
|
1310
|
+
}
|
|
1311
|
+
if (message.hasLegacyCommand !== false) {
|
|
1312
|
+
writer.uint32(16).bool(message.hasLegacyCommand);
|
|
1313
|
+
}
|
|
1314
|
+
if (message.legacyCommand !== 0) {
|
|
1315
|
+
writer.uint32(24).int32(message.legacyCommand);
|
|
1316
|
+
}
|
|
1317
|
+
if (message.hasPosition !== false) {
|
|
1318
|
+
writer.uint32(32).bool(message.hasPosition);
|
|
1319
|
+
}
|
|
1320
|
+
if (message.position !== 0) {
|
|
1321
|
+
writer.uint32(45).float(message.position);
|
|
1322
|
+
}
|
|
1323
|
+
if (message.hasTilt !== false) {
|
|
1324
|
+
writer.uint32(48).bool(message.hasTilt);
|
|
1325
|
+
}
|
|
1326
|
+
if (message.tilt !== 0) {
|
|
1327
|
+
writer.uint32(61).float(message.tilt);
|
|
1328
|
+
}
|
|
1329
|
+
if (message.stop !== false) {
|
|
1330
|
+
writer.uint32(64).bool(message.stop);
|
|
1331
|
+
}
|
|
1332
|
+
return writer;
|
|
1333
|
+
},
|
|
1334
|
+
decode(input, length) {
|
|
1335
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
1336
|
+
const previousRecursionDepth = reader.__tsProtoDecodeDepth ?? 0;
|
|
1337
|
+
if (previousRecursionDepth >= 100) {
|
|
1338
|
+
throw new globalThis.Error("protobuf decode recursion limit exceeded");
|
|
1339
|
+
}
|
|
1340
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth + 1;
|
|
1341
|
+
try {
|
|
1342
|
+
const end = length === void 0 ? reader.len : reader.pos + length;
|
|
1343
|
+
const message = createBaseCoverCommandRequest();
|
|
1344
|
+
while (reader.pos < end) {
|
|
1345
|
+
const tag = reader.uint32();
|
|
1346
|
+
switch (tag >>> 3) {
|
|
1347
|
+
case 1: {
|
|
1348
|
+
if (tag !== 13) {
|
|
1349
|
+
break;
|
|
1350
|
+
}
|
|
1351
|
+
message.key = reader.fixed32();
|
|
1352
|
+
continue;
|
|
1353
|
+
}
|
|
1354
|
+
case 2: {
|
|
1355
|
+
if (tag !== 16) {
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
message.hasLegacyCommand = reader.bool();
|
|
1359
|
+
continue;
|
|
1360
|
+
}
|
|
1361
|
+
case 3: {
|
|
1362
|
+
if (tag !== 24) {
|
|
1363
|
+
break;
|
|
1364
|
+
}
|
|
1365
|
+
message.legacyCommand = reader.int32();
|
|
1366
|
+
continue;
|
|
1367
|
+
}
|
|
1368
|
+
case 4: {
|
|
1369
|
+
if (tag !== 32) {
|
|
1370
|
+
break;
|
|
1371
|
+
}
|
|
1372
|
+
message.hasPosition = reader.bool();
|
|
1373
|
+
continue;
|
|
1374
|
+
}
|
|
1375
|
+
case 5: {
|
|
1376
|
+
if (tag !== 45) {
|
|
1377
|
+
break;
|
|
1378
|
+
}
|
|
1379
|
+
message.position = reader.float();
|
|
1380
|
+
continue;
|
|
1381
|
+
}
|
|
1382
|
+
case 6: {
|
|
1383
|
+
if (tag !== 48) {
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
1386
|
+
message.hasTilt = reader.bool();
|
|
1387
|
+
continue;
|
|
1388
|
+
}
|
|
1389
|
+
case 7: {
|
|
1390
|
+
if (tag !== 61) {
|
|
1391
|
+
break;
|
|
1392
|
+
}
|
|
1393
|
+
message.tilt = reader.float();
|
|
1394
|
+
continue;
|
|
1395
|
+
}
|
|
1396
|
+
case 8: {
|
|
1397
|
+
if (tag !== 64) {
|
|
1398
|
+
break;
|
|
1399
|
+
}
|
|
1400
|
+
message.stop = reader.bool();
|
|
1401
|
+
continue;
|
|
1402
|
+
}
|
|
1403
|
+
}
|
|
1404
|
+
if ((tag & 7) === 4 || tag === 0) {
|
|
1405
|
+
break;
|
|
1406
|
+
}
|
|
1407
|
+
reader.skip(tag & 7);
|
|
1408
|
+
}
|
|
1409
|
+
return message;
|
|
1410
|
+
} finally {
|
|
1411
|
+
reader.__tsProtoDecodeDepth = previousRecursionDepth;
|
|
1412
|
+
}
|
|
1413
|
+
},
|
|
1414
|
+
fromJSON(object) {
|
|
1415
|
+
return {
|
|
1416
|
+
key: isSet(object.key) ? globalThis.Number(object.key) : 0,
|
|
1417
|
+
hasLegacyCommand: isSet(object.hasLegacyCommand) ? globalThis.Boolean(object.hasLegacyCommand) : isSet(object.has_legacy_command) ? globalThis.Boolean(object.has_legacy_command) : false,
|
|
1418
|
+
legacyCommand: isSet(object.legacyCommand) ? legacyCoverCommandFromJSON(object.legacyCommand) : isSet(object.legacy_command) ? legacyCoverCommandFromJSON(object.legacy_command) : 0,
|
|
1419
|
+
hasPosition: isSet(object.hasPosition) ? globalThis.Boolean(object.hasPosition) : isSet(object.has_position) ? globalThis.Boolean(object.has_position) : false,
|
|
1420
|
+
position: isSet(object.position) ? globalThis.Number(object.position) : 0,
|
|
1421
|
+
hasTilt: isSet(object.hasTilt) ? globalThis.Boolean(object.hasTilt) : isSet(object.has_tilt) ? globalThis.Boolean(object.has_tilt) : false,
|
|
1422
|
+
tilt: isSet(object.tilt) ? globalThis.Number(object.tilt) : 0,
|
|
1423
|
+
stop: isSet(object.stop) ? globalThis.Boolean(object.stop) : false
|
|
1424
|
+
};
|
|
1425
|
+
},
|
|
1426
|
+
toJSON(message) {
|
|
1427
|
+
const obj = {};
|
|
1428
|
+
if (message.key !== 0) {
|
|
1429
|
+
obj.key = Math.round(message.key);
|
|
1430
|
+
}
|
|
1431
|
+
if (message.hasLegacyCommand !== false) {
|
|
1432
|
+
obj.hasLegacyCommand = message.hasLegacyCommand;
|
|
1433
|
+
}
|
|
1434
|
+
if (message.legacyCommand !== 0) {
|
|
1435
|
+
obj.legacyCommand = legacyCoverCommandToJSON(message.legacyCommand);
|
|
1436
|
+
}
|
|
1437
|
+
if (message.hasPosition !== false) {
|
|
1438
|
+
obj.hasPosition = message.hasPosition;
|
|
1439
|
+
}
|
|
1440
|
+
if (message.position !== 0) {
|
|
1441
|
+
obj.position = message.position;
|
|
1442
|
+
}
|
|
1443
|
+
if (message.hasTilt !== false) {
|
|
1444
|
+
obj.hasTilt = message.hasTilt;
|
|
1445
|
+
}
|
|
1446
|
+
if (message.tilt !== 0) {
|
|
1447
|
+
obj.tilt = message.tilt;
|
|
1448
|
+
}
|
|
1449
|
+
if (message.stop !== false) {
|
|
1450
|
+
obj.stop = message.stop;
|
|
1451
|
+
}
|
|
1452
|
+
return obj;
|
|
1453
|
+
},
|
|
1454
|
+
create(base) {
|
|
1455
|
+
return CoverCommandRequest.fromPartial(base ?? {});
|
|
1456
|
+
},
|
|
1457
|
+
fromPartial(object) {
|
|
1458
|
+
const message = createBaseCoverCommandRequest();
|
|
1459
|
+
message.key = object.key ?? 0;
|
|
1460
|
+
message.hasLegacyCommand = object.hasLegacyCommand ?? false;
|
|
1461
|
+
message.legacyCommand = object.legacyCommand ?? 0;
|
|
1462
|
+
message.hasPosition = object.hasPosition ?? false;
|
|
1463
|
+
message.position = object.position ?? 0;
|
|
1464
|
+
message.hasTilt = object.hasTilt ?? false;
|
|
1465
|
+
message.tilt = object.tilt ?? 0;
|
|
1466
|
+
message.stop = object.stop ?? false;
|
|
1467
|
+
return message;
|
|
1468
|
+
}
|
|
1469
|
+
};
|
|
1075
1470
|
function createBaseListEntitiesLightResponse() {
|
|
1076
1471
|
return {
|
|
1077
1472
|
objectId: "",
|
|
@@ -2919,6 +3314,113 @@ var BinarySensorComponent = class extends BaseComponent {
|
|
|
2919
3314
|
}
|
|
2920
3315
|
};
|
|
2921
3316
|
|
|
3317
|
+
// src/components/cover.ts
|
|
3318
|
+
var CoverComponent = class extends BaseComponent {
|
|
3319
|
+
open() {
|
|
3320
|
+
this.sendCommand({ position: 1 });
|
|
3321
|
+
}
|
|
3322
|
+
close() {
|
|
3323
|
+
this.sendCommand({ position: 0 });
|
|
3324
|
+
}
|
|
3325
|
+
stop() {
|
|
3326
|
+
this.sendCommand({ stop: true });
|
|
3327
|
+
}
|
|
3328
|
+
setPosition(position) {
|
|
3329
|
+
if (!this.supportsPosition) {
|
|
3330
|
+
return;
|
|
3331
|
+
}
|
|
3332
|
+
this.sendCommand({ position });
|
|
3333
|
+
}
|
|
3334
|
+
setTilt(tilt) {
|
|
3335
|
+
if (!this.supportsTilt) {
|
|
3336
|
+
return;
|
|
3337
|
+
}
|
|
3338
|
+
this.sendCommand({ tilt });
|
|
3339
|
+
}
|
|
3340
|
+
get type() {
|
|
3341
|
+
return "cover";
|
|
3342
|
+
}
|
|
3343
|
+
get assumedState() {
|
|
3344
|
+
return this.listEntity.assumedState;
|
|
3345
|
+
}
|
|
3346
|
+
get supportsPosition() {
|
|
3347
|
+
return this.listEntity.supportsPosition;
|
|
3348
|
+
}
|
|
3349
|
+
get supportsTilt() {
|
|
3350
|
+
return this.listEntity.supportsTilt;
|
|
3351
|
+
}
|
|
3352
|
+
/**
|
|
3353
|
+
* Current position between 0 (closed) and 1 (open). Undefined until the
|
|
3354
|
+
* first state was received or when the cover does not support positions.
|
|
3355
|
+
*/
|
|
3356
|
+
get position() {
|
|
3357
|
+
if (!this.supportsPosition) {
|
|
3358
|
+
return void 0;
|
|
3359
|
+
}
|
|
3360
|
+
return this.state.getValue()?.position;
|
|
3361
|
+
}
|
|
3362
|
+
/**
|
|
3363
|
+
* Current tilt between 0 and 1. Undefined until the first state was
|
|
3364
|
+
* received or when the cover does not support tilt.
|
|
3365
|
+
*/
|
|
3366
|
+
get tilt() {
|
|
3367
|
+
if (!this.supportsTilt) {
|
|
3368
|
+
return void 0;
|
|
3369
|
+
}
|
|
3370
|
+
return this.state.getValue()?.tilt;
|
|
3371
|
+
}
|
|
3372
|
+
/**
|
|
3373
|
+
* Whether the cover is fully closed. Derived from the position field the
|
|
3374
|
+
* device always sends, exactly like aioesphomeapi derives is_closed
|
|
3375
|
+
* (position == 0). Undefined until the first state was received.
|
|
3376
|
+
*/
|
|
3377
|
+
get isClosed() {
|
|
3378
|
+
const position = this.state.getValue()?.position;
|
|
3379
|
+
return position === void 0 ? void 0 : position === 0;
|
|
3380
|
+
}
|
|
3381
|
+
/**
|
|
3382
|
+
* Whether the cover is fully open. Derived from the position field the
|
|
3383
|
+
* device always sends. Undefined until the first state was received; a
|
|
3384
|
+
* partially open cover is neither open nor closed.
|
|
3385
|
+
*/
|
|
3386
|
+
get isOpen() {
|
|
3387
|
+
const position = this.state.getValue()?.position;
|
|
3388
|
+
return position === void 0 ? void 0 : position === 1;
|
|
3389
|
+
}
|
|
3390
|
+
/**
|
|
3391
|
+
* What the cover is currently doing. Undefined until the first state was
|
|
3392
|
+
* received.
|
|
3393
|
+
*/
|
|
3394
|
+
get operation() {
|
|
3395
|
+
return this.state.getValue()?.currentOperation;
|
|
3396
|
+
}
|
|
3397
|
+
sendCommand(command) {
|
|
3398
|
+
this.queueCommand(
|
|
3399
|
+
30 /* CoverCommandRequest */,
|
|
3400
|
+
() => CoverCommandRequest.encode({
|
|
3401
|
+
key: this.key,
|
|
3402
|
+
// The legacy command fields are dead: Home Assistant last
|
|
3403
|
+
// sent them to pre-2019 devices and firmware dropped their
|
|
3404
|
+
// handling in 2025.8.0. Only the values below reach the
|
|
3405
|
+
// wire; these two are wire-inert defaults that satisfy
|
|
3406
|
+
// the generated message type.
|
|
3407
|
+
hasLegacyCommand: false,
|
|
3408
|
+
legacyCommand: 0 /* LEGACY_COVER_COMMAND_OPEN */,
|
|
3409
|
+
hasPosition: command.position !== void 0,
|
|
3410
|
+
position: command.position ?? 0,
|
|
3411
|
+
hasTilt: command.tilt !== void 0,
|
|
3412
|
+
tilt: command.tilt ?? 0,
|
|
3413
|
+
stop: command.stop ?? false
|
|
3414
|
+
}).finish(),
|
|
3415
|
+
// Covers without position feedback never confirm a command with a
|
|
3416
|
+
// state response, so a serialized command would wait for the 30
|
|
3417
|
+
// second pipeline fallback. Like switch commands, cover commands
|
|
3418
|
+
// are cheap idempotent intents and go out immediately.
|
|
3419
|
+
true
|
|
3420
|
+
);
|
|
3421
|
+
}
|
|
3422
|
+
};
|
|
3423
|
+
|
|
2922
3424
|
// src/components/helpers.ts
|
|
2923
3425
|
var convertNumbers = (num, max = 255, fromEsp = false) => {
|
|
2924
3426
|
if (fromEsp) {
|
|
@@ -3173,6 +3675,17 @@ var createComponents = (data, stateEvents$, connection, knownComponents) => {
|
|
|
3173
3675
|
component: new BinarySensorComponent(response, state$, emptyCommandInterface)
|
|
3174
3676
|
};
|
|
3175
3677
|
}
|
|
3678
|
+
case 13 /* ListEntitiesCoverResponse */: {
|
|
3679
|
+
const response = ListEntitiesCoverResponse.decode(data.payload);
|
|
3680
|
+
const state$ = transformStates(stateEvents$, response);
|
|
3681
|
+
return knownComponents.has(response.objectId) ? {
|
|
3682
|
+
id: response.objectId,
|
|
3683
|
+
state$
|
|
3684
|
+
} : {
|
|
3685
|
+
id: response.objectId,
|
|
3686
|
+
component: new CoverComponent(response, state$, connection)
|
|
3687
|
+
};
|
|
3688
|
+
}
|
|
3176
3689
|
case 17 /* ListEntitiesSwitchResponse */: {
|
|
3177
3690
|
const response = ListEntitiesSwitchResponse.decode(data.payload);
|
|
3178
3691
|
const state$ = transformStates(stateEvents$, response);
|
|
@@ -3219,6 +3732,7 @@ var transformStates = (stateEvents$, listEntityResponse) => {
|
|
|
3219
3732
|
// src/api/responses.ts
|
|
3220
3733
|
var listResponses = /* @__PURE__ */ new Set([
|
|
3221
3734
|
12 /* ListEntitiesBinarySensorResponse */,
|
|
3735
|
+
13 /* ListEntitiesCoverResponse */,
|
|
3222
3736
|
15 /* ListEntitiesLightResponse */,
|
|
3223
3737
|
16 /* ListEntitiesSensorResponse */,
|
|
3224
3738
|
17 /* ListEntitiesSwitchResponse */,
|
|
@@ -3432,9 +3946,12 @@ export {
|
|
|
3432
3946
|
BinarySensorComponent,
|
|
3433
3947
|
BinarySensorTypes,
|
|
3434
3948
|
Client,
|
|
3949
|
+
CoverComponent,
|
|
3950
|
+
CoverOperation,
|
|
3435
3951
|
EspDevice,
|
|
3436
3952
|
EspSocket,
|
|
3437
3953
|
InvalidPasswordError,
|
|
3954
|
+
LegacyCoverState,
|
|
3438
3955
|
LightComponent,
|
|
3439
3956
|
MessageTypes,
|
|
3440
3957
|
SensorComponent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "esphome-ts",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "A TypeScript client for the Esphome Native API interface",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"test:watch": "vitest",
|
|
39
39
|
"test:coverage": "vitest run --coverage",
|
|
40
40
|
"prepack": "npm run cbuild",
|
|
41
|
-
"semantic-release": "semantic-release"
|
|
41
|
+
"semantic-release": "semantic-release",
|
|
42
|
+
"prepare": "husky"
|
|
42
43
|
},
|
|
43
44
|
"keywords": [
|
|
44
45
|
"esphome",
|
|
@@ -66,6 +67,8 @@
|
|
|
66
67
|
"eslint-import-resolver-typescript": "4.4.5",
|
|
67
68
|
"eslint-plugin-import-x": "4.17.1",
|
|
68
69
|
"eslint-plugin-unused-imports": "4.4.1",
|
|
70
|
+
"husky": "9.1.7",
|
|
71
|
+
"lint-staged": "17.6.0",
|
|
69
72
|
"prettier": "3.9.9",
|
|
70
73
|
"rxjs": "7.8.2",
|
|
71
74
|
"semantic-release": "25.0.9",
|