@nebulahome/integration-sdk 1.1.0 → 1.4.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.
@@ -202,25 +202,39 @@ declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
202
202
  custom: "custom";
203
203
  image: "image";
204
204
  level: "level";
205
+ select: "select";
206
+ button: "button";
207
+ sensor_numeric: "sensor_numeric";
208
+ sensor_text: "sensor_text";
209
+ sensor_binary: "sensor_binary";
205
210
  on_off: "on_off";
206
211
  color_hs: "color_hs";
207
212
  color_temp: "color_temp";
208
213
  cover: "cover";
209
214
  lock: "lock";
210
215
  thermostat: "thermostat";
211
- sensor_numeric: "sensor_numeric";
212
- sensor_binary: "sensor_binary";
213
- sensor_text: "sensor_text";
214
216
  media_player: "media_player";
215
217
  camera: "camera";
216
- button: "button";
217
218
  update: "update";
218
219
  lawn_mower: "lawn_mower";
219
- select: "select";
220
220
  vacuum: "vacuum";
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>;
224
+ /**
225
+ * What lets an entity be told apart from the same reading reached another way: its own key in its
226
+ * transport's terms - `switch:0` on a Shelly - and where it sits in Matter.
227
+ */
228
+ declare const entityLinkHintSchema: z.ZodObject<{
229
+ key: z.ZodOptional<z.ZodString>;
230
+ matter: z.ZodOptional<z.ZodObject<{
231
+ endpoint: z.ZodInt;
232
+ cluster: z.ZodInt;
233
+ attribute: z.ZodInt;
234
+ }, z.core.$strict>>;
235
+ }, z.core.$strict>;
236
+ /** What lets an entity be told apart from the same reading reached another way. */
237
+ type EntityLinkHint = z.output<typeof entityLinkHintSchema>;
224
238
  //#endregion
225
239
  //#region ../contracts/dist/entity-state.d.ts
226
240
  /**
@@ -709,6 +723,79 @@ declare const integrationInstallSchema: z.ZodObject<{
709
723
  /** How the platform installed a vendor. */
710
724
  type IntegrationInstall = z.output<typeof integrationInstallSchema>;
711
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
+ domain: z.ZodEnum<{
748
+ number: "number";
749
+ sensor: "sensor";
750
+ binary_sensor: "binary_sensor";
751
+ switch: "switch";
752
+ light: "light";
753
+ select: "select";
754
+ button: "button";
755
+ }>;
756
+ capabilities: z.ZodRecord<z.ZodEnum<{
757
+ number: "number";
758
+ select: "select";
759
+ button: "button";
760
+ sensor_numeric: "sensor_numeric";
761
+ sensor_text: "sensor_text";
762
+ sensor_binary: "sensor_binary";
763
+ on_off: "on_off";
764
+ level: "level";
765
+ }> & z.core.$partial, z.ZodObject<{
766
+ read: z.ZodOptional<z.ZodObject<{
767
+ function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
768
+ address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
769
+ type: z.ZodOptional<z.ZodEnum<{
770
+ string: "string";
771
+ u16: "u16";
772
+ s16: "s16";
773
+ u32: "u32";
774
+ s32: "s32";
775
+ f32: "f32";
776
+ }>>;
777
+ count: z.ZodOptional<z.ZodInt>;
778
+ bit: z.ZodOptional<z.ZodInt>;
779
+ scale: z.ZodOptional<z.ZodNumber>;
780
+ unit: z.ZodOptional<z.ZodString>;
781
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
782
+ }, z.core.$strict>>;
783
+ write: z.ZodOptional<z.ZodObject<{
784
+ function: z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<15>, z.ZodLiteral<16>]>;
785
+ address: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
786
+ on: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
787
+ off: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
788
+ min: z.ZodOptional<z.ZodNumber>;
789
+ max: z.ZodOptional<z.ZodNumber>;
790
+ step: z.ZodOptional<z.ZodNumber>;
791
+ value: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
792
+ }, z.core.$strict>>;
793
+ }, z.core.$strict>>;
794
+ }, z.core.$strict>>;
795
+ }, z.core.$strict>;
796
+ /** A template, checked. */
797
+ type ModbusTemplate = z.output<typeof modbusTemplateSchema>;
798
+ //#endregion
712
799
  //#region ../package-runtime/dist/transport.d.ts
713
800
  /** What an integration asks a transport to do, expressed as data. */
714
801
  type TransportRequest = {
@@ -915,6 +1002,8 @@ type EntityDescriptor = {
915
1002
  readonly deviceClass?: string;
916
1003
  readonly stateClass?: EntityStateClass;
917
1004
  readonly displayPrecision?: number;
1005
+ /** What links it to the same reading reached another way. */
1006
+ readonly link?: EntityLinkHint;
918
1007
  };
919
1008
  /** What a claimed device turns out to be. */
920
1009
  type DeviceDescriptor = {
@@ -924,6 +1013,9 @@ type DeviceDescriptor = {
924
1013
  readonly model?: string;
925
1014
  readonly swVersion?: string;
926
1015
  readonly hwVersion?: string;
1016
+ /** The hardware's MAC address, lower case with colons, when it says one. */
1017
+ readonly mac?: string;
1018
+ readonly serialNumber?: string;
927
1019
  /**
928
1020
  * The device this one is reached through, named the way this integration names devices.
929
1021
  *
@@ -1331,10 +1423,59 @@ type ManagedMqtt = {
1331
1423
  };
1332
1424
  /** Opens a managed MQTT session. */
1333
1425
  type OpenMqtt = (options: ManagedMqttOptions) => ManagedMqtt;
1426
+ /** A Modbus server, as a session to it is opened: where it is, and how frames travel. */
1427
+ type ModbusServerOptions = {
1428
+ readonly host: string;
1429
+ /** 502 unless said. */
1430
+ readonly port?: number;
1431
+ /** `tcp` (MBAP) unless said; `rtu` for RTU frames a transparent adapter carries over TCP. */
1432
+ readonly framing?: 'tcp' | 'rtu';
1433
+ };
1434
+ /** One read: a run of coils, inputs or registers of one unit. */
1435
+ type ModbusReadOptions = {
1436
+ readonly unitId: number;
1437
+ readonly function: 1 | 2 | 3 | 4;
1438
+ readonly address: number;
1439
+ /** How many bits or registers, 1 to 125. */
1440
+ readonly count: number;
1441
+ /** How long to wait for the answer; 3 s unless said. */
1442
+ readonly timeoutMs?: number;
1443
+ };
1444
+ /** One write: a coil, a register, coils or registers of one unit. */
1445
+ type ModbusWriteOptions = {
1446
+ readonly unitId: number;
1447
+ readonly function: 5 | 6 | 15 | 16;
1448
+ readonly address: number;
1449
+ /** The word for 05 (0xFF00 on, 0 off) and 06; the bits for 15; the registers for 16. */
1450
+ readonly values: readonly number[];
1451
+ readonly timeoutMs?: number;
1452
+ };
1334
1453
  /**
1335
- * The house's MQTT broker, as the hub reaches it: the package that provides `mqtt-broker`, with
1336
- * the hub's own username - or the broker `NEBULA_MQTT_URL` names. Read again each time it is needed: the broker may start after
1337
- * the hub, and a bundle that opens a session later finds it then.
1454
+ * A session to a Modbus server through the hub's one connection to it: requests of every
1455
+ * session to the same server wait their turn, so a gateway that answers one client at a time is
1456
+ * never asked twice at once.
1457
+ *
1458
+ * A failed request rejects with an error whose `name` says why: `ModbusException` - the server
1459
+ * refused, its `code` the exception - `ModbusNoConnection` or `ModbusSilence`.
1460
+ */
1461
+ type ModbusSession = {
1462
+ /**
1463
+ * Reads bits or registers.
1464
+ *
1465
+ * @returns One number per bit (0 or 1) or register (a 16-bit word).
1466
+ */
1467
+ read: (options: ModbusReadOptions, signal?: AbortSignal) => Promise<number[]>;
1468
+ /** Writes a coil, a register, coils or registers. */
1469
+ write: (options: ModbusWriteOptions, signal?: AbortSignal) => Promise<void>;
1470
+ /** Lets go of the server; the connection closes once nothing else holds it. */
1471
+ close: () => Promise<void>;
1472
+ };
1473
+ /** Opens a session to a Modbus server. */
1474
+ type OpenModbus = (server: ModbusServerOptions) => ModbusSession;
1475
+ /**
1476
+ * The house's MQTT broker, as the hub reaches it: the one the hub runs, with the hub's own
1477
+ * username - or the broker `NEBULA_MQTT_URL` names. Read again each time it is needed: a session
1478
+ * opened while the broker is still coming up retries until it listens.
1338
1479
  */
1339
1480
  type PlatformMqtt = {
1340
1481
  readonly url: string;
@@ -1345,7 +1486,7 @@ type PlatformMqtt = {
1345
1486
  type PlatformServices = {
1346
1487
  /**
1347
1488
  * The house's broker, for a vendor whose devices report through it - zigbee2mqtt - and which
1348
- * runs its own program beside the platform. Null on an installation without one.
1489
+ * runs its own program beside the platform. Null only while the hub cannot run one.
1349
1490
  */
1350
1491
  readonly mqtt: PlatformMqtt | null;
1351
1492
  };
@@ -1392,6 +1533,8 @@ type BundleSdk = {
1392
1533
  readonly openUdpSocket: OpenUdpSocket;
1393
1534
  /** An MQTT session, for a vendor whose devices report through a broker of its own. */
1394
1535
  readonly openMqtt: OpenMqtt;
1536
+ /** A session to a Modbus server, through the hub's one connection to it. */
1537
+ readonly openModbus: OpenModbus;
1395
1538
  /** How a camera's stream source is written, as defineTransport is for a transport. */
1396
1539
  readonly defineStreamSource: typeof defineStreamSource;
1397
1540
  /** An RTSP session over TCP, yielding a camera's H.264 as it comes. */
@@ -1648,18 +1791,22 @@ declare const vendorManifestSchema: z.ZodObject<{
1648
1791
  padding: number;
1649
1792
  }>>>;
1650
1793
  internetRequired: z.ZodDefault<z.ZodBoolean>;
1794
+ twins: z.ZodOptional<z.ZodArray<z.ZodEnum<{
1795
+ mac: "mac";
1796
+ serial: "serial";
1797
+ }>>>;
1651
1798
  setup: z.ZodOptional<z.ZodString>;
1652
1799
  account: z.ZodOptional<z.ZodString>;
1653
1800
  transports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
1654
1801
  module: z.ZodString;
1655
1802
  wires: z.ZodArray<z.ZodEnum<{
1656
- udp: "udp";
1657
1803
  matter: "matter";
1658
- http: "http";
1804
+ modbus: "modbus";
1659
1805
  mqtt: "mqtt";
1806
+ http: "http";
1660
1807
  ble: "ble";
1661
1808
  zigbee: "zigbee";
1662
- modbus: "modbus";
1809
+ udp: "udp";
1663
1810
  }>>;
1664
1811
  }, z.core.$strict>]>>>;
1665
1812
  streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
@@ -1748,15 +1895,18 @@ declare const bundleManifestSchema: z.ZodObject<{
1748
1895
  modelCodes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
1749
1896
  modelSeries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
1750
1897
  kind: z.ZodEnum<{
1751
- declarative: "declarative";
1752
- code: "code";
1753
1898
  matter: "matter";
1899
+ modbus: "modbus";
1900
+ mqtt: "mqtt";
1901
+ code: "code";
1902
+ declarative: "declarative";
1754
1903
  }>;
1755
1904
  defaultIcon: z.ZodOptional<z.ZodString>;
1756
1905
  webPagePort: z.ZodOptional<z.ZodInt>;
1757
1906
  webPagePath: z.ZodOptional<z.ZodString>;
1758
1907
  profile: z.ZodOptional<z.ZodString>;
1759
1908
  entry: z.ZodOptional<z.ZodString>;
1909
+ template: z.ZodOptional<z.ZodString>;
1760
1910
  setup: z.ZodString;
1761
1911
  id: z.ZodString;
1762
1912
  version: z.ZodString;
@@ -1836,6 +1986,9 @@ declare const vendorDiscoverySchema: z.ZodObject<{
1836
1986
  externalId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1837
1987
  name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1838
1988
  swVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1989
+ mac: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1990
+ serialNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1991
+ auth: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1839
1992
  }, z.core.$strict>>;
1840
1993
  matter: z.ZodOptional<z.ZodObject<{
1841
1994
  match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
@@ -1863,6 +2016,76 @@ declare const vendorDiscoverySchema: z.ZodObject<{
1863
2016
  }, z.core.$strict>]>>;
1864
2017
  model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
1865
2018
  }, z.core.$strict>>;
2019
+ mqtt: z.ZodOptional<z.ZodObject<{
2020
+ match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
2021
+ path: z.ZodString;
2022
+ equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
2023
+ }, z.core.$strict>, z.ZodObject<{
2024
+ path: z.ZodString;
2025
+ exists: z.ZodLiteral<true>;
2026
+ }, z.core.$strict>, z.ZodObject<{
2027
+ path: z.ZodString;
2028
+ oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
2029
+ }, z.core.$strict>, z.ZodObject<{
2030
+ path: z.ZodString;
2031
+ startsWith: z.ZodString;
2032
+ }, z.core.$strict>, z.ZodObject<{
2033
+ path: z.ZodString;
2034
+ endsWith: z.ZodString;
2035
+ }, z.core.$strict>, z.ZodObject<{
2036
+ path: z.ZodString;
2037
+ contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
2038
+ }, z.core.$strict>, z.ZodObject<{
2039
+ path: z.ZodString;
2040
+ min: z.ZodOptional<z.ZodNumber>;
2041
+ max: z.ZodOptional<z.ZodNumber>;
2042
+ }, z.core.$strict>]>>;
2043
+ model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
2044
+ }, z.core.$strict>>;
2045
+ modbus: z.ZodOptional<z.ZodObject<{
2046
+ match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
2047
+ path: z.ZodString;
2048
+ equals: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
2049
+ }, z.core.$strict>, z.ZodObject<{
2050
+ path: z.ZodString;
2051
+ exists: z.ZodLiteral<true>;
2052
+ }, z.core.$strict>, z.ZodObject<{
2053
+ path: z.ZodString;
2054
+ oneOf: z.ZodArray<z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>>;
2055
+ }, z.core.$strict>, z.ZodObject<{
2056
+ path: z.ZodString;
2057
+ startsWith: z.ZodString;
2058
+ }, z.core.$strict>, z.ZodObject<{
2059
+ path: z.ZodString;
2060
+ endsWith: z.ZodString;
2061
+ }, z.core.$strict>, z.ZodObject<{
2062
+ path: z.ZodString;
2063
+ contains: z.ZodUnion<readonly [z.ZodString, z.ZodNumber, z.ZodBoolean]>;
2064
+ }, z.core.$strict>, z.ZodObject<{
2065
+ path: z.ZodString;
2066
+ min: z.ZodOptional<z.ZodNumber>;
2067
+ max: z.ZodOptional<z.ZodNumber>;
2068
+ }, z.core.$strict>]>>;
2069
+ model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
2070
+ unitId: z.ZodDefault<z.ZodInt>;
2071
+ read: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
2072
+ function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
2073
+ address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
2074
+ type: z.ZodOptional<z.ZodEnum<{
2075
+ string: "string";
2076
+ u16: "u16";
2077
+ s16: "s16";
2078
+ u32: "u32";
2079
+ s32: "s32";
2080
+ f32: "f32";
2081
+ }>>;
2082
+ count: z.ZodOptional<z.ZodInt>;
2083
+ bit: z.ZodOptional<z.ZodInt>;
2084
+ scale: z.ZodOptional<z.ZodNumber>;
2085
+ unit: z.ZodOptional<z.ZodString>;
2086
+ options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
2087
+ }, z.core.$strict>>>;
2088
+ }, z.core.$strict>>;
1866
2089
  adopt: z.ZodDefault<z.ZodEnum<{
1867
2090
  owner: "owner";
1868
2091
  automatic: "automatic";
@@ -1882,8 +2105,8 @@ type DiscoveryDriver = {
1882
2105
  /** The driver's own name, offered as its one model when it lists none. */
1883
2106
  readonly name: string;
1884
2107
  /**
1885
- * What reaches its devices. A driver on the `matter` transport takes only Matter devices, and no
1886
- * other driver does.
2108
+ * What reaches its devices. A driver on a broker's transport - `matter`, `mqtt-house` - takes
2109
+ * only that broker's devices, and no other driver does.
1887
2110
  */
1888
2111
  readonly transport: string;
1889
2112
  readonly models: readonly string[];
@@ -1908,6 +2131,11 @@ type SightingIdentity = {
1908
2131
  readonly name: string | null;
1909
2132
  readonly modelCode: string | null;
1910
2133
  readonly swVersion: string | null;
2134
+ /** Lower case with colons. */
2135
+ readonly mac: string | null;
2136
+ readonly serialNumber: string | null;
2137
+ /** Whether it said it is behind a password; false when it did not say. */
2138
+ readonly needsPassword: boolean;
1911
2139
  };
1912
2140
  /** The driver a device belongs to, and which of its models it is. */
1913
2141
  type Association = {
@@ -2011,6 +2239,8 @@ type LoadedBundle = {
2011
2239
  readonly setup: IntegrationSetup;
2012
2240
  /** Where it was read from, for a message that has to name it. */
2013
2241
  readonly directory: string;
2242
+ /** The template a Modbus driver reads its devices through, every entity with its id. */
2243
+ readonly modbusTemplate?: ModbusTemplate;
2014
2244
  };
2015
2245
  /**
2016
2246
  * Which of the two places a vendor was read from.
@@ -2019,7 +2249,7 @@ type LoadedBundle = {
2019
2249
  * from the integrations index or its local folder, and the only place a production hub reads.
2020
2250
  * `development` is a directory of bundles under development - an integration repository's
2021
2251
  * `dist/`, named in the hub's `HUB_DEV_BUNDLE_DIR` - read beside it. `platform` is no place at
2022
- * all: the vendor the hub is itself, `matter`, built in code.
2252
+ * all: the vendors the hub is itself, `matter` and `mqtt`, built in code.
2023
2253
  */
2024
2254
  type BundleOrigin = 'development' | 'installed' | 'platform';
2025
2255
  /** 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.1.0";
92
+ const SDK_VERSION = "1.4.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
@@ -202,25 +202,39 @@ declare const declaredCapabilitiesSchema: z.ZodRecord<z.ZodEnum<{
202
202
  custom: "custom";
203
203
  image: "image";
204
204
  level: "level";
205
+ select: "select";
206
+ button: "button";
207
+ sensor_numeric: "sensor_numeric";
208
+ sensor_text: "sensor_text";
209
+ sensor_binary: "sensor_binary";
205
210
  on_off: "on_off";
206
211
  color_hs: "color_hs";
207
212
  color_temp: "color_temp";
208
213
  cover: "cover";
209
214
  lock: "lock";
210
215
  thermostat: "thermostat";
211
- sensor_numeric: "sensor_numeric";
212
- sensor_binary: "sensor_binary";
213
- sensor_text: "sensor_text";
214
216
  media_player: "media_player";
215
217
  camera: "camera";
216
- button: "button";
217
218
  update: "update";
218
219
  lawn_mower: "lawn_mower";
219
- select: "select";
220
220
  vacuum: "vacuum";
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>;
224
+ /**
225
+ * What lets an entity be told apart from the same reading reached another way: its own key in its
226
+ * transport's terms - `switch:0` on a Shelly - and where it sits in Matter.
227
+ */
228
+ declare const entityLinkHintSchema: z.ZodObject<{
229
+ key: z.ZodOptional<z.ZodString>;
230
+ matter: z.ZodOptional<z.ZodObject<{
231
+ endpoint: z.ZodInt;
232
+ cluster: z.ZodInt;
233
+ attribute: z.ZodInt;
234
+ }, z.core.$strict>>;
235
+ }, z.core.$strict>;
236
+ /** What lets an entity be told apart from the same reading reached another way. */
237
+ type EntityLinkHint = z.output<typeof entityLinkHintSchema>;
224
238
  //#endregion
225
239
  //#region ../contracts/dist/entity-state.d.ts
226
240
  /**
@@ -680,6 +694,8 @@ type EntityDescriptor = {
680
694
  readonly deviceClass?: string;
681
695
  readonly stateClass?: EntityStateClass;
682
696
  readonly displayPrecision?: number;
697
+ /** What links it to the same reading reached another way. */
698
+ readonly link?: EntityLinkHint;
683
699
  };
684
700
  /** What a claimed device turns out to be. */
685
701
  type DeviceDescriptor = {
@@ -689,6 +705,9 @@ type DeviceDescriptor = {
689
705
  readonly model?: string;
690
706
  readonly swVersion?: string;
691
707
  readonly hwVersion?: string;
708
+ /** The hardware's MAC address, lower case with colons, when it says one. */
709
+ readonly mac?: string;
710
+ readonly serialNumber?: string;
692
711
  /**
693
712
  * The device this one is reached through, named the way this integration names devices.
694
713
  *
@@ -1096,10 +1115,59 @@ type ManagedMqtt = {
1096
1115
  };
1097
1116
  /** Opens a managed MQTT session. */
1098
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;
1099
1167
  /**
1100
- * The house's MQTT broker, as the hub reaches it: the package that provides `mqtt-broker`, with
1101
- * the hub's own username - or the broker `NEBULA_MQTT_URL` names. Read again each time it is needed: the broker may start after
1102
- * the hub, and a bundle that opens a session later finds it then.
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.
1103
1171
  */
1104
1172
  type PlatformMqtt = {
1105
1173
  readonly url: string;
@@ -1110,7 +1178,7 @@ type PlatformMqtt = {
1110
1178
  type PlatformServices = {
1111
1179
  /**
1112
1180
  * The house's broker, for a vendor whose devices report through it - zigbee2mqtt - and which
1113
- * runs its own program beside the platform. Null on an installation without one.
1181
+ * runs its own program beside the platform. Null only while the hub cannot run one.
1114
1182
  */
1115
1183
  readonly mqtt: PlatformMqtt | null;
1116
1184
  };
@@ -1157,6 +1225,8 @@ type BundleSdk = {
1157
1225
  readonly openUdpSocket: OpenUdpSocket;
1158
1226
  /** An MQTT session, for a vendor whose devices report through a broker of its own. */
1159
1227
  readonly openMqtt: OpenMqtt;
1228
+ /** A session to a Modbus server, through the hub's one connection to it. */
1229
+ readonly openModbus: OpenModbus;
1160
1230
  /** How a camera's stream source is written, as defineTransport is for a transport. */
1161
1231
  readonly defineStreamSource: typeof defineStreamSource;
1162
1232
  /** An RTSP session over TCP, yielding a camera's H.264 as it comes. */