@nebulahome/integration-sdk 1.2.0 → 1.5.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/CHANGELOG.md +48 -0
- package/FILES.md +139 -18
- package/README.md +5 -3
- package/dist/chunks/node-dist.js +2786 -291
- package/dist/chunks/node-index.d.ts +215 -15
- package/dist/chunks/node-project.js +2 -1
- package/dist/index.d.ts +61 -10
- package/dist/schemas.d.ts +144 -8
- package/dist/schemas.js +3 -2
- package/dist/testing.d.ts +39 -1
- package/dist/testing.js +44 -4
- package/package.json +5 -5
- package/schemas/discovery.schema.json +490 -0
- package/schemas/driver.schema.json +8 -1
- package/schemas/modbus-template.schema.json +288 -0
|
@@ -199,6 +199,12 @@ type EntityStateClass = (typeof ENTITY_STATE_CLASSES)[number];
|
|
|
199
199
|
*/
|
|
200
200
|
declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
201
201
|
number: "number";
|
|
202
|
+
custom: "custom";
|
|
203
|
+
select: "select";
|
|
204
|
+
button: "button";
|
|
205
|
+
sensor_numeric: "sensor_numeric";
|
|
206
|
+
sensor_text: "sensor_text";
|
|
207
|
+
sensor_binary: "sensor_binary";
|
|
202
208
|
on_off: "on_off";
|
|
203
209
|
level: "level";
|
|
204
210
|
color_hs: "color_hs";
|
|
@@ -206,18 +212,12 @@ declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
|
206
212
|
cover: "cover";
|
|
207
213
|
lock: "lock";
|
|
208
214
|
thermostat: "thermostat";
|
|
209
|
-
sensor_numeric: "sensor_numeric";
|
|
210
|
-
sensor_binary: "sensor_binary";
|
|
211
|
-
sensor_text: "sensor_text";
|
|
212
215
|
media_player: "media_player";
|
|
213
216
|
camera: "camera";
|
|
214
|
-
button: "button";
|
|
215
217
|
update: "update";
|
|
216
218
|
lawn_mower: "lawn_mower";
|
|
217
|
-
select: "select";
|
|
218
219
|
vacuum: "vacuum";
|
|
219
220
|
image: "image";
|
|
220
|
-
custom: "custom";
|
|
221
221
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
222
222
|
/** What an entity declares it can do, with the device's own limits for each. */
|
|
223
223
|
type DeclaredCapabilities = z.output<typeof declaredCapabilitiesSchema>;
|
|
@@ -723,6 +723,80 @@ declare const integrationInstallSchema: z.ZodObject<{
|
|
|
723
723
|
/** How the platform installed a vendor. */
|
|
724
724
|
type IntegrationInstall = z.output<typeof integrationInstallSchema>;
|
|
725
725
|
//#endregion
|
|
726
|
+
//#region ../contracts/dist/modbus.d.ts
|
|
727
|
+
/**
|
|
728
|
+
* A template: the device's entities, each capability mapped to the register it is read from and
|
|
729
|
+
* the command it is written with.
|
|
730
|
+
*
|
|
731
|
+
* Every rule that ties fields together is here, so the editor's blocks, its file and the hub
|
|
732
|
+
* refuse the same templates with the same words.
|
|
733
|
+
*/
|
|
734
|
+
declare const modbusTemplateSchema: z.ZodObject<{
|
|
735
|
+
name: z.ZodString;
|
|
736
|
+
device: z.ZodDefault<z.ZodString>;
|
|
737
|
+
port: z.ZodDefault<z.ZodInt>;
|
|
738
|
+
unitId: z.ZodDefault<z.ZodInt>;
|
|
739
|
+
wordOrder: z.ZodDefault<z.ZodEnum<{
|
|
740
|
+
high: "high";
|
|
741
|
+
low: "low";
|
|
742
|
+
}>>;
|
|
743
|
+
pollSeconds: z.ZodDefault<z.ZodInt>;
|
|
744
|
+
entities: z.ZodArray<z.ZodObject<{
|
|
745
|
+
id: z.ZodOptional<z.ZodString>;
|
|
746
|
+
name: z.ZodString;
|
|
747
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
748
|
+
domain: z.ZodEnum<{
|
|
749
|
+
number: "number";
|
|
750
|
+
sensor: "sensor";
|
|
751
|
+
binary_sensor: "binary_sensor";
|
|
752
|
+
switch: "switch";
|
|
753
|
+
light: "light";
|
|
754
|
+
select: "select";
|
|
755
|
+
button: "button";
|
|
756
|
+
}>;
|
|
757
|
+
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
758
|
+
number: "number";
|
|
759
|
+
select: "select";
|
|
760
|
+
button: "button";
|
|
761
|
+
sensor_numeric: "sensor_numeric";
|
|
762
|
+
sensor_text: "sensor_text";
|
|
763
|
+
sensor_binary: "sensor_binary";
|
|
764
|
+
on_off: "on_off";
|
|
765
|
+
level: "level";
|
|
766
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
767
|
+
read: z.ZodOptional<z.ZodObject<{
|
|
768
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
769
|
+
address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
770
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
771
|
+
string: "string";
|
|
772
|
+
u16: "u16";
|
|
773
|
+
s16: "s16";
|
|
774
|
+
u32: "u32";
|
|
775
|
+
s32: "s32";
|
|
776
|
+
f32: "f32";
|
|
777
|
+
}>>;
|
|
778
|
+
count: z.ZodOptional<z.ZodInt>;
|
|
779
|
+
bit: z.ZodOptional<z.ZodInt>;
|
|
780
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
781
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
782
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
783
|
+
}, z.core.$strict>>;
|
|
784
|
+
write: z.ZodOptional<z.ZodObject<{
|
|
785
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<15>, z.ZodLiteral<16>]>;
|
|
786
|
+
address: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
787
|
+
on: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
788
|
+
off: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
789
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
790
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
791
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
792
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
793
|
+
}, z.core.$strict>>;
|
|
794
|
+
}, z.core.$strict>>;
|
|
795
|
+
}, z.core.$strict>>;
|
|
796
|
+
}, z.core.$strict>;
|
|
797
|
+
/** A template, checked. */
|
|
798
|
+
type ModbusTemplate = z.output<typeof modbusTemplateSchema>;
|
|
799
|
+
//#endregion
|
|
726
800
|
//#region ../package-runtime/dist/transport.d.ts
|
|
727
801
|
/** What an integration asks a transport to do, expressed as data. */
|
|
728
802
|
type TransportRequest = {
|
|
@@ -1350,10 +1424,59 @@ type ManagedMqtt = {
|
|
|
1350
1424
|
};
|
|
1351
1425
|
/** Opens a managed MQTT session. */
|
|
1352
1426
|
type OpenMqtt = (options: ManagedMqttOptions) => ManagedMqtt;
|
|
1427
|
+
/** A Modbus server, as a session to it is opened: where it is, and how frames travel. */
|
|
1428
|
+
type ModbusServerOptions = {
|
|
1429
|
+
readonly host: string;
|
|
1430
|
+
/** 502 unless said. */
|
|
1431
|
+
readonly port?: number;
|
|
1432
|
+
/** `tcp` (MBAP) unless said; `rtu` for RTU frames a transparent adapter carries over TCP. */
|
|
1433
|
+
readonly framing?: 'tcp' | 'rtu';
|
|
1434
|
+
};
|
|
1435
|
+
/** One read: a run of coils, inputs or registers of one unit. */
|
|
1436
|
+
type ModbusReadOptions = {
|
|
1437
|
+
readonly unitId: number;
|
|
1438
|
+
readonly function: 1 | 2 | 3 | 4;
|
|
1439
|
+
readonly address: number;
|
|
1440
|
+
/** How many bits or registers, 1 to 125. */
|
|
1441
|
+
readonly count: number;
|
|
1442
|
+
/** How long to wait for the answer; 3 s unless said. */
|
|
1443
|
+
readonly timeoutMs?: number;
|
|
1444
|
+
};
|
|
1445
|
+
/** One write: a coil, a register, coils or registers of one unit. */
|
|
1446
|
+
type ModbusWriteOptions = {
|
|
1447
|
+
readonly unitId: number;
|
|
1448
|
+
readonly function: 5 | 6 | 15 | 16;
|
|
1449
|
+
readonly address: number;
|
|
1450
|
+
/** The word for 05 (0xFF00 on, 0 off) and 06; the bits for 15; the registers for 16. */
|
|
1451
|
+
readonly values: readonly number[];
|
|
1452
|
+
readonly timeoutMs?: number;
|
|
1453
|
+
};
|
|
1454
|
+
/**
|
|
1455
|
+
* A session to a Modbus server through the hub's one connection to it: requests of every
|
|
1456
|
+
* session to the same server wait their turn, so a gateway that answers one client at a time is
|
|
1457
|
+
* never asked twice at once.
|
|
1458
|
+
*
|
|
1459
|
+
* A failed request rejects with an error whose `name` says why: `ModbusException` - the server
|
|
1460
|
+
* refused, its `code` the exception - `ModbusNoConnection` or `ModbusSilence`.
|
|
1461
|
+
*/
|
|
1462
|
+
type ModbusSession = {
|
|
1463
|
+
/**
|
|
1464
|
+
* Reads bits or registers.
|
|
1465
|
+
*
|
|
1466
|
+
* @returns One number per bit (0 or 1) or register (a 16-bit word).
|
|
1467
|
+
*/
|
|
1468
|
+
read: (options: ModbusReadOptions, signal?: AbortSignal) => Promise<number[]>;
|
|
1469
|
+
/** Writes a coil, a register, coils or registers. */
|
|
1470
|
+
write: (options: ModbusWriteOptions, signal?: AbortSignal) => Promise<void>;
|
|
1471
|
+
/** Lets go of the server; the connection closes once nothing else holds it. */
|
|
1472
|
+
close: () => Promise<void>;
|
|
1473
|
+
};
|
|
1474
|
+
/** Opens a session to a Modbus server. */
|
|
1475
|
+
type OpenModbus = (server: ModbusServerOptions) => ModbusSession;
|
|
1353
1476
|
/**
|
|
1354
|
-
* The house's MQTT broker, as the hub reaches it: the
|
|
1355
|
-
*
|
|
1356
|
-
*
|
|
1477
|
+
* The house's MQTT broker, as the hub reaches it: the one the hub runs, with the hub's own
|
|
1478
|
+
* username - or the broker `NEBULA_MQTT_URL` names. Read again each time it is needed: a session
|
|
1479
|
+
* opened while the broker is still coming up retries until it listens.
|
|
1357
1480
|
*/
|
|
1358
1481
|
type PlatformMqtt = {
|
|
1359
1482
|
readonly url: string;
|
|
@@ -1364,7 +1487,7 @@ type PlatformMqtt = {
|
|
|
1364
1487
|
type PlatformServices = {
|
|
1365
1488
|
/**
|
|
1366
1489
|
* The house's broker, for a vendor whose devices report through it - zigbee2mqtt - and which
|
|
1367
|
-
* runs its own program beside the platform. Null
|
|
1490
|
+
* runs its own program beside the platform. Null only while the hub cannot run one.
|
|
1368
1491
|
*/
|
|
1369
1492
|
readonly mqtt: PlatformMqtt | null;
|
|
1370
1493
|
};
|
|
@@ -1411,6 +1534,8 @@ type BundleSdk = {
|
|
|
1411
1534
|
readonly openUdpSocket: OpenUdpSocket;
|
|
1412
1535
|
/** An MQTT session, for a vendor whose devices report through a broker of its own. */
|
|
1413
1536
|
readonly openMqtt: OpenMqtt;
|
|
1537
|
+
/** A session to a Modbus server, through the hub's one connection to it. */
|
|
1538
|
+
readonly openModbus: OpenModbus;
|
|
1414
1539
|
/** How a camera's stream source is written, as defineTransport is for a transport. */
|
|
1415
1540
|
readonly defineStreamSource: typeof defineStreamSource;
|
|
1416
1541
|
/** An RTSP session over TCP, yielding a camera's H.264 as it comes. */
|
|
@@ -1678,11 +1803,11 @@ declare const vendorManifestSchema: z.ZodObject<{
|
|
|
1678
1803
|
wires: z.ZodArray<z.ZodEnum<{
|
|
1679
1804
|
udp: "udp";
|
|
1680
1805
|
matter: "matter";
|
|
1681
|
-
http: "http";
|
|
1682
1806
|
mqtt: "mqtt";
|
|
1807
|
+
modbus: "modbus";
|
|
1808
|
+
http: "http";
|
|
1683
1809
|
ble: "ble";
|
|
1684
1810
|
zigbee: "zigbee";
|
|
1685
|
-
modbus: "modbus";
|
|
1686
1811
|
}>>;
|
|
1687
1812
|
}, z.core.$strict>]>>>;
|
|
1688
1813
|
streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -1774,12 +1899,15 @@ declare const bundleManifestSchema: z.ZodObject<{
|
|
|
1774
1899
|
declarative: "declarative";
|
|
1775
1900
|
code: "code";
|
|
1776
1901
|
matter: "matter";
|
|
1902
|
+
mqtt: "mqtt";
|
|
1903
|
+
modbus: "modbus";
|
|
1777
1904
|
}>;
|
|
1778
1905
|
defaultIcon: z.ZodOptional<z.ZodString>;
|
|
1779
1906
|
webPagePort: z.ZodOptional<z.ZodInt>;
|
|
1780
1907
|
webPagePath: z.ZodOptional<z.ZodString>;
|
|
1781
1908
|
profile: z.ZodOptional<z.ZodString>;
|
|
1782
1909
|
entry: z.ZodOptional<z.ZodString>;
|
|
1910
|
+
template: z.ZodOptional<z.ZodString>;
|
|
1783
1911
|
setup: z.ZodString;
|
|
1784
1912
|
id: z.ZodString;
|
|
1785
1913
|
version: z.ZodString;
|
|
@@ -1889,6 +2017,76 @@ declare const vendorDiscoverySchema: z.ZodObject<{
|
|
|
1889
2017
|
}, z.core.$strict>]>>;
|
|
1890
2018
|
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
1891
2019
|
}, z.core.$strict>>;
|
|
2020
|
+
mqtt: z.ZodOptional<z.ZodObject<{
|
|
2021
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2022
|
+
path: z.ZodString;
|
|
2023
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
2024
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2025
|
+
path: z.ZodString;
|
|
2026
|
+
exists: z.ZodLiteral<true>;
|
|
2027
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2028
|
+
path: z.ZodString;
|
|
2029
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
2030
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2031
|
+
path: z.ZodString;
|
|
2032
|
+
startsWith: z.ZodString;
|
|
2033
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2034
|
+
path: z.ZodString;
|
|
2035
|
+
endsWith: z.ZodString;
|
|
2036
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2037
|
+
path: z.ZodString;
|
|
2038
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
2039
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2040
|
+
path: z.ZodString;
|
|
2041
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
2042
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
2043
|
+
}, z.core.$strict>]>>;
|
|
2044
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
2045
|
+
}, z.core.$strict>>;
|
|
2046
|
+
modbus: z.ZodOptional<z.ZodObject<{
|
|
2047
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
2048
|
+
path: z.ZodString;
|
|
2049
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
2050
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2051
|
+
path: z.ZodString;
|
|
2052
|
+
exists: z.ZodLiteral<true>;
|
|
2053
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2054
|
+
path: z.ZodString;
|
|
2055
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
2056
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2057
|
+
path: z.ZodString;
|
|
2058
|
+
startsWith: z.ZodString;
|
|
2059
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2060
|
+
path: z.ZodString;
|
|
2061
|
+
endsWith: z.ZodString;
|
|
2062
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2063
|
+
path: z.ZodString;
|
|
2064
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
2065
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
2066
|
+
path: z.ZodString;
|
|
2067
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
2068
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
2069
|
+
}, z.core.$strict>]>>;
|
|
2070
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
2071
|
+
unitId: z.ZodDefault<z.ZodInt>;
|
|
2072
|
+
read: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
2073
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
2074
|
+
address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
2075
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
2076
|
+
string: "string";
|
|
2077
|
+
u16: "u16";
|
|
2078
|
+
s16: "s16";
|
|
2079
|
+
u32: "u32";
|
|
2080
|
+
s32: "s32";
|
|
2081
|
+
f32: "f32";
|
|
2082
|
+
}>>;
|
|
2083
|
+
count: z.ZodOptional<z.ZodInt>;
|
|
2084
|
+
bit: z.ZodOptional<z.ZodInt>;
|
|
2085
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
2086
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
2087
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
2088
|
+
}, z.core.$strict>>>;
|
|
2089
|
+
}, z.core.$strict>>;
|
|
1892
2090
|
adopt: z.ZodDefault<z.ZodEnum<{
|
|
1893
2091
|
owner: "owner";
|
|
1894
2092
|
automatic: "automatic";
|
|
@@ -1908,8 +2106,8 @@ type DiscoveryDriver = {
|
|
|
1908
2106
|
/** The driver's own name, offered as its one model when it lists none. */
|
|
1909
2107
|
readonly name: string;
|
|
1910
2108
|
/**
|
|
1911
|
-
* What reaches its devices. A driver on
|
|
1912
|
-
* other driver does.
|
|
2109
|
+
* What reaches its devices. A driver on a broker's transport - `matter`, `mqtt-house` - takes
|
|
2110
|
+
* only that broker's devices, and no other driver does.
|
|
1913
2111
|
*/
|
|
1914
2112
|
readonly transport: string;
|
|
1915
2113
|
readonly models: readonly string[];
|
|
@@ -2042,6 +2240,8 @@ type LoadedBundle = {
|
|
|
2042
2240
|
readonly setup: IntegrationSetup;
|
|
2043
2241
|
/** Where it was read from, for a message that has to name it. */
|
|
2044
2242
|
readonly directory: string;
|
|
2243
|
+
/** The template a Modbus driver reads its devices through, every entity with its id. */
|
|
2244
|
+
readonly modbusTemplate?: ModbusTemplate;
|
|
2045
2245
|
};
|
|
2046
2246
|
/**
|
|
2047
2247
|
* Which of the two places a vendor was read from.
|
|
@@ -2050,7 +2250,7 @@ type LoadedBundle = {
|
|
|
2050
2250
|
* from the integrations index or its local folder, and the only place a production hub reads.
|
|
2051
2251
|
* `development` is a directory of bundles under development - an integration repository's
|
|
2052
2252
|
* `dist/`, named in the hub's `HUB_DEV_BUNDLE_DIR` - read beside it. `platform` is no place at
|
|
2053
|
-
* all: the
|
|
2253
|
+
* all: the vendors the hub is itself, `matter` and `mqtt`, built in code.
|
|
2054
2254
|
*/
|
|
2055
2255
|
type BundleOrigin = 'development' | 'installed' | 'platform';
|
|
2056
2256
|
/** Where a vendor's devices announce themselves, ready to listen to. */
|
|
@@ -89,7 +89,7 @@ function defineTransport(spec) {
|
|
|
89
89
|
* bundle built with this SDK says `^<major>.<minor>.0`.
|
|
90
90
|
*/
|
|
91
91
|
/** The SDK's own version: `1.0.0`, or a prerelease of it. */
|
|
92
|
-
const SDK_VERSION = "1.
|
|
92
|
+
const SDK_VERSION = "1.5.0";
|
|
93
93
|
/**
|
|
94
94
|
* The runtime range a bundle built with this SDK declares: this version's major and minor, so a
|
|
95
95
|
* platform with the same contract or a later one of the same major loads it.
|
|
@@ -391,6 +391,7 @@ function createFakeSdk(options = {}) {
|
|
|
391
391
|
openUdpSocket,
|
|
392
392
|
openWebSocket,
|
|
393
393
|
openMqtt: notFaked("openMqtt"),
|
|
394
|
+
openModbus: notFaked("openModbus"),
|
|
394
395
|
openRtsp: notFaked("openRtsp"),
|
|
395
396
|
platform: options.platform ?? { mqtt: null },
|
|
396
397
|
codecs: { lzma: notFaked("codecs.lzma") },
|
package/dist/index.d.ts
CHANGED
|
@@ -199,6 +199,12 @@ type EntityStateClass = (typeof ENTITY_STATE_CLASSES)[number];
|
|
|
199
199
|
*/
|
|
200
200
|
declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
201
201
|
number: "number";
|
|
202
|
+
custom: "custom";
|
|
203
|
+
select: "select";
|
|
204
|
+
button: "button";
|
|
205
|
+
sensor_numeric: "sensor_numeric";
|
|
206
|
+
sensor_text: "sensor_text";
|
|
207
|
+
sensor_binary: "sensor_binary";
|
|
202
208
|
on_off: "on_off";
|
|
203
209
|
level: "level";
|
|
204
210
|
color_hs: "color_hs";
|
|
@@ -206,18 +212,12 @@ declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
|
|
|
206
212
|
cover: "cover";
|
|
207
213
|
lock: "lock";
|
|
208
214
|
thermostat: "thermostat";
|
|
209
|
-
sensor_numeric: "sensor_numeric";
|
|
210
|
-
sensor_binary: "sensor_binary";
|
|
211
|
-
sensor_text: "sensor_text";
|
|
212
215
|
media_player: "media_player";
|
|
213
216
|
camera: "camera";
|
|
214
|
-
button: "button";
|
|
215
217
|
update: "update";
|
|
216
218
|
lawn_mower: "lawn_mower";
|
|
217
|
-
select: "select";
|
|
218
219
|
vacuum: "vacuum";
|
|
219
220
|
image: "image";
|
|
220
|
-
custom: "custom";
|
|
221
221
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
222
222
|
/** What an entity declares it can do, with the device's own limits for each. */
|
|
223
223
|
type DeclaredCapabilities = z.output<typeof declaredCapabilitiesSchema>;
|
|
@@ -1115,10 +1115,59 @@ type ManagedMqtt = {
|
|
|
1115
1115
|
};
|
|
1116
1116
|
/** Opens a managed MQTT session. */
|
|
1117
1117
|
type OpenMqtt = (options: ManagedMqttOptions) => ManagedMqtt;
|
|
1118
|
+
/** A Modbus server, as a session to it is opened: where it is, and how frames travel. */
|
|
1119
|
+
type ModbusServerOptions = {
|
|
1120
|
+
readonly host: string;
|
|
1121
|
+
/** 502 unless said. */
|
|
1122
|
+
readonly port?: number;
|
|
1123
|
+
/** `tcp` (MBAP) unless said; `rtu` for RTU frames a transparent adapter carries over TCP. */
|
|
1124
|
+
readonly framing?: 'tcp' | 'rtu';
|
|
1125
|
+
};
|
|
1126
|
+
/** One read: a run of coils, inputs or registers of one unit. */
|
|
1127
|
+
type ModbusReadOptions = {
|
|
1128
|
+
readonly unitId: number;
|
|
1129
|
+
readonly function: 1 | 2 | 3 | 4;
|
|
1130
|
+
readonly address: number;
|
|
1131
|
+
/** How many bits or registers, 1 to 125. */
|
|
1132
|
+
readonly count: number;
|
|
1133
|
+
/** How long to wait for the answer; 3 s unless said. */
|
|
1134
|
+
readonly timeoutMs?: number;
|
|
1135
|
+
};
|
|
1136
|
+
/** One write: a coil, a register, coils or registers of one unit. */
|
|
1137
|
+
type ModbusWriteOptions = {
|
|
1138
|
+
readonly unitId: number;
|
|
1139
|
+
readonly function: 5 | 6 | 15 | 16;
|
|
1140
|
+
readonly address: number;
|
|
1141
|
+
/** The word for 05 (0xFF00 on, 0 off) and 06; the bits for 15; the registers for 16. */
|
|
1142
|
+
readonly values: readonly number[];
|
|
1143
|
+
readonly timeoutMs?: number;
|
|
1144
|
+
};
|
|
1145
|
+
/**
|
|
1146
|
+
* A session to a Modbus server through the hub's one connection to it: requests of every
|
|
1147
|
+
* session to the same server wait their turn, so a gateway that answers one client at a time is
|
|
1148
|
+
* never asked twice at once.
|
|
1149
|
+
*
|
|
1150
|
+
* A failed request rejects with an error whose `name` says why: `ModbusException` - the server
|
|
1151
|
+
* refused, its `code` the exception - `ModbusNoConnection` or `ModbusSilence`.
|
|
1152
|
+
*/
|
|
1153
|
+
type ModbusSession = {
|
|
1154
|
+
/**
|
|
1155
|
+
* Reads bits or registers.
|
|
1156
|
+
*
|
|
1157
|
+
* @returns One number per bit (0 or 1) or register (a 16-bit word).
|
|
1158
|
+
*/
|
|
1159
|
+
read: (options: ModbusReadOptions, signal?: AbortSignal) => Promise<number[]>;
|
|
1160
|
+
/** Writes a coil, a register, coils or registers. */
|
|
1161
|
+
write: (options: ModbusWriteOptions, signal?: AbortSignal) => Promise<void>;
|
|
1162
|
+
/** Lets go of the server; the connection closes once nothing else holds it. */
|
|
1163
|
+
close: () => Promise<void>;
|
|
1164
|
+
};
|
|
1165
|
+
/** Opens a session to a Modbus server. */
|
|
1166
|
+
type OpenModbus = (server: ModbusServerOptions) => ModbusSession;
|
|
1118
1167
|
/**
|
|
1119
|
-
* The house's MQTT broker, as the hub reaches it: the
|
|
1120
|
-
*
|
|
1121
|
-
*
|
|
1168
|
+
* The house's MQTT broker, as the hub reaches it: the one the hub runs, with the hub's own
|
|
1169
|
+
* username - or the broker `NEBULA_MQTT_URL` names. Read again each time it is needed: a session
|
|
1170
|
+
* opened while the broker is still coming up retries until it listens.
|
|
1122
1171
|
*/
|
|
1123
1172
|
type PlatformMqtt = {
|
|
1124
1173
|
readonly url: string;
|
|
@@ -1129,7 +1178,7 @@ type PlatformMqtt = {
|
|
|
1129
1178
|
type PlatformServices = {
|
|
1130
1179
|
/**
|
|
1131
1180
|
* The house's broker, for a vendor whose devices report through it - zigbee2mqtt - and which
|
|
1132
|
-
* runs its own program beside the platform. Null
|
|
1181
|
+
* runs its own program beside the platform. Null only while the hub cannot run one.
|
|
1133
1182
|
*/
|
|
1134
1183
|
readonly mqtt: PlatformMqtt | null;
|
|
1135
1184
|
};
|
|
@@ -1176,6 +1225,8 @@ type BundleSdk = {
|
|
|
1176
1225
|
readonly openUdpSocket: OpenUdpSocket;
|
|
1177
1226
|
/** An MQTT session, for a vendor whose devices report through a broker of its own. */
|
|
1178
1227
|
readonly openMqtt: OpenMqtt;
|
|
1228
|
+
/** A session to a Modbus server, through the hub's one connection to it. */
|
|
1229
|
+
readonly openModbus: OpenModbus;
|
|
1179
1230
|
/** How a camera's stream source is written, as defineTransport is for a transport. */
|
|
1180
1231
|
readonly defineStreamSource: typeof defineStreamSource;
|
|
1181
1232
|
/** An RTSP session over TCP, yielding a camera's H.264 as it comes. */
|
package/dist/schemas.d.ts
CHANGED
|
@@ -31,11 +31,11 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
31
31
|
wires: z.ZodArray<z.ZodEnum<{
|
|
32
32
|
udp: "udp";
|
|
33
33
|
matter: "matter";
|
|
34
|
-
http: "http";
|
|
35
34
|
mqtt: "mqtt";
|
|
35
|
+
modbus: "modbus";
|
|
36
|
+
http: "http";
|
|
36
37
|
ble: "ble";
|
|
37
38
|
zigbee: "zigbee";
|
|
38
|
-
modbus: "modbus";
|
|
39
39
|
}>>;
|
|
40
40
|
}, z.core.$strict>]>>>;
|
|
41
41
|
streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -116,12 +116,15 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
116
116
|
declarative: "declarative";
|
|
117
117
|
code: "code";
|
|
118
118
|
matter: "matter";
|
|
119
|
+
mqtt: "mqtt";
|
|
120
|
+
modbus: "modbus";
|
|
119
121
|
}>;
|
|
120
122
|
defaultIcon: z.ZodOptional<z.ZodString>;
|
|
121
123
|
webPagePort: z.ZodOptional<z.ZodInt>;
|
|
122
124
|
webPagePath: z.ZodOptional<z.ZodString>;
|
|
123
125
|
profile: z.ZodOptional<z.ZodString>;
|
|
124
126
|
entry: z.ZodOptional<z.ZodString>;
|
|
127
|
+
template: z.ZodOptional<z.ZodString>;
|
|
125
128
|
setup: z.ZodString;
|
|
126
129
|
id: z.ZodString;
|
|
127
130
|
name: z.ZodString;
|
|
@@ -405,6 +408,12 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
405
408
|
icon: z.ZodOptional<z.ZodString>;
|
|
406
409
|
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
407
410
|
number: "number";
|
|
411
|
+
custom: "custom";
|
|
412
|
+
select: "select";
|
|
413
|
+
button: "button";
|
|
414
|
+
sensor_numeric: "sensor_numeric";
|
|
415
|
+
sensor_text: "sensor_text";
|
|
416
|
+
sensor_binary: "sensor_binary";
|
|
408
417
|
on_off: "on_off";
|
|
409
418
|
level: "level";
|
|
410
419
|
color_hs: "color_hs";
|
|
@@ -412,18 +421,12 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
412
421
|
cover: "cover";
|
|
413
422
|
lock: "lock";
|
|
414
423
|
thermostat: "thermostat";
|
|
415
|
-
sensor_numeric: "sensor_numeric";
|
|
416
|
-
sensor_binary: "sensor_binary";
|
|
417
|
-
sensor_text: "sensor_text";
|
|
418
424
|
media_player: "media_player";
|
|
419
425
|
camera: "camera";
|
|
420
|
-
button: "button";
|
|
421
426
|
update: "update";
|
|
422
427
|
lawn_mower: "lawn_mower";
|
|
423
|
-
select: "select";
|
|
424
428
|
vacuum: "vacuum";
|
|
425
429
|
image: "image";
|
|
426
|
-
custom: "custom";
|
|
427
430
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
428
431
|
state: z.ZodRecord<z.ZodEnum<{
|
|
429
432
|
number: "number";
|
|
@@ -630,6 +633,76 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
630
633
|
}, z.core.$strict>]>>;
|
|
631
634
|
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
632
635
|
}, z.core.$strict>>;
|
|
636
|
+
mqtt: z.ZodOptional<z.ZodObject<{
|
|
637
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
638
|
+
path: z.ZodString;
|
|
639
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
640
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
641
|
+
path: z.ZodString;
|
|
642
|
+
exists: z.ZodLiteral<true>;
|
|
643
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
644
|
+
path: z.ZodString;
|
|
645
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
646
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
647
|
+
path: z.ZodString;
|
|
648
|
+
startsWith: z.ZodString;
|
|
649
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
650
|
+
path: z.ZodString;
|
|
651
|
+
endsWith: z.ZodString;
|
|
652
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
653
|
+
path: z.ZodString;
|
|
654
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
655
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
656
|
+
path: z.ZodString;
|
|
657
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
658
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
659
|
+
}, z.core.$strict>]>>;
|
|
660
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
661
|
+
}, z.core.$strict>>;
|
|
662
|
+
modbus: z.ZodOptional<z.ZodObject<{
|
|
663
|
+
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
664
|
+
path: z.ZodString;
|
|
665
|
+
equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
666
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
667
|
+
path: z.ZodString;
|
|
668
|
+
exists: z.ZodLiteral<true>;
|
|
669
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
670
|
+
path: z.ZodString;
|
|
671
|
+
oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
|
|
672
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
673
|
+
path: z.ZodString;
|
|
674
|
+
startsWith: z.ZodString;
|
|
675
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
676
|
+
path: z.ZodString;
|
|
677
|
+
endsWith: z.ZodString;
|
|
678
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
679
|
+
path: z.ZodString;
|
|
680
|
+
contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
|
|
681
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
682
|
+
path: z.ZodString;
|
|
683
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
684
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
685
|
+
}, z.core.$strict>]>>;
|
|
686
|
+
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
687
|
+
unitId: z.ZodDefault<z.ZodInt>;
|
|
688
|
+
read: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
|
|
689
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
690
|
+
address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
691
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
692
|
+
string: "string";
|
|
693
|
+
u16: "u16";
|
|
694
|
+
s16: "s16";
|
|
695
|
+
u32: "u32";
|
|
696
|
+
s32: "s32";
|
|
697
|
+
f32: "f32";
|
|
698
|
+
}>>;
|
|
699
|
+
count: z.ZodOptional<z.ZodInt>;
|
|
700
|
+
bit: z.ZodOptional<z.ZodInt>;
|
|
701
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
702
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
703
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
704
|
+
}, z.core.$strict>>>;
|
|
705
|
+
}, z.core.$strict>>;
|
|
633
706
|
adopt: z.ZodDefault<z.ZodEnum<{
|
|
634
707
|
owner: "owner";
|
|
635
708
|
automatic: "automatic";
|
|
@@ -745,6 +818,69 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
745
818
|
identity: z.ZodString;
|
|
746
819
|
module: z.ZodString;
|
|
747
820
|
}, z.core.$strict>;
|
|
821
|
+
readonly 'modbus-template': z.ZodObject<{
|
|
822
|
+
name: z.ZodString;
|
|
823
|
+
device: z.ZodDefault<z.ZodString>;
|
|
824
|
+
port: z.ZodDefault<z.ZodInt>;
|
|
825
|
+
unitId: z.ZodDefault<z.ZodInt>;
|
|
826
|
+
wordOrder: z.ZodDefault<z.ZodEnum<{
|
|
827
|
+
high: "high";
|
|
828
|
+
low: "low";
|
|
829
|
+
}>>;
|
|
830
|
+
pollSeconds: z.ZodDefault<z.ZodInt>;
|
|
831
|
+
entities: z.ZodArray<z.ZodObject<{
|
|
832
|
+
id: z.ZodOptional<z.ZodString>;
|
|
833
|
+
name: z.ZodString;
|
|
834
|
+
icon: z.ZodOptional<z.ZodString>;
|
|
835
|
+
domain: z.ZodEnum<{
|
|
836
|
+
number: "number";
|
|
837
|
+
sensor: "sensor";
|
|
838
|
+
binary_sensor: "binary_sensor";
|
|
839
|
+
switch: "switch";
|
|
840
|
+
light: "light";
|
|
841
|
+
select: "select";
|
|
842
|
+
button: "button";
|
|
843
|
+
}>;
|
|
844
|
+
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
845
|
+
number: "number";
|
|
846
|
+
select: "select";
|
|
847
|
+
button: "button";
|
|
848
|
+
sensor_numeric: "sensor_numeric";
|
|
849
|
+
sensor_text: "sensor_text";
|
|
850
|
+
sensor_binary: "sensor_binary";
|
|
851
|
+
on_off: "on_off";
|
|
852
|
+
level: "level";
|
|
853
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
854
|
+
read: z.ZodOptional<z.ZodObject<{
|
|
855
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
856
|
+
address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
857
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
858
|
+
string: "string";
|
|
859
|
+
u16: "u16";
|
|
860
|
+
s16: "s16";
|
|
861
|
+
u32: "u32";
|
|
862
|
+
s32: "s32";
|
|
863
|
+
f32: "f32";
|
|
864
|
+
}>>;
|
|
865
|
+
count: z.ZodOptional<z.ZodInt>;
|
|
866
|
+
bit: z.ZodOptional<z.ZodInt>;
|
|
867
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
868
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
869
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
870
|
+
}, z.core.$strict>>;
|
|
871
|
+
write: z.ZodOptional<z.ZodObject<{
|
|
872
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<15>, z.ZodLiteral<16>]>;
|
|
873
|
+
address: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
874
|
+
on: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
875
|
+
off: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
876
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
877
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
878
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
879
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
880
|
+
}, z.core.$strict>>;
|
|
881
|
+
}, z.core.$strict>>;
|
|
882
|
+
}, z.core.$strict>>;
|
|
883
|
+
}, z.core.$strict>;
|
|
748
884
|
};
|
|
749
885
|
/** The names of the files a JSON Schema is written for. */
|
|
750
886
|
export type BundleFileName = keyof typeof BUNDLE_FILE_SCHEMAS;
|
package/dist/schemas.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as accountDeclarationSchema,
|
|
1
|
+
import { d as accountDeclarationSchema, g as integrationSetupSchema, h as modbusTemplateSchema, l as vendorDiscoverySchema, m as vendorManifestSchema, p as driverManifestSchema, u as integrationProfileSchema } from "./chunks/node-dist.js";
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
//#region src/schemas.ts
|
|
4
4
|
/**
|
|
@@ -23,7 +23,8 @@ const BUNDLE_FILE_SCHEMAS = {
|
|
|
23
23
|
setup: integrationSetupSchema,
|
|
24
24
|
profile: integrationProfileSchema,
|
|
25
25
|
discovery: vendorDiscoverySchema,
|
|
26
|
-
account: accountDeclarationSchema
|
|
26
|
+
account: accountDeclarationSchema,
|
|
27
|
+
"modbus-template": modbusTemplateSchema
|
|
27
28
|
};
|
|
28
29
|
/**
|
|
29
30
|
* One file's JSON Schema, with room for the `$schema` that points at it.
|