@nebulahome/integration-sdk 1.2.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.
- package/CHANGELOG.md +39 -0
- package/FILES.md +137 -18
- package/README.md +5 -3
- package/dist/chunks/node-dist.js +2781 -292
- package/dist/chunks/node-index.d.ts +219 -20
- package/dist/chunks/node-project.js +2 -1
- package/dist/index.d.ts +63 -12
- package/dist/schemas.d.ts +154 -19
- 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 +491 -0
- package/schemas/driver.schema.json +8 -1
- package/schemas/modbus-template.schema.json +285 -0
package/dist/schemas.d.ts
CHANGED
|
@@ -29,13 +29,13 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
29
29
|
transports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
30
30
|
module: z.ZodString;
|
|
31
31
|
wires: z.ZodArray<z.ZodEnum<{
|
|
32
|
-
udp: "udp";
|
|
33
32
|
matter: "matter";
|
|
34
|
-
|
|
33
|
+
modbus: "modbus";
|
|
35
34
|
mqtt: "mqtt";
|
|
35
|
+
http: "http";
|
|
36
36
|
ble: "ble";
|
|
37
37
|
zigbee: "zigbee";
|
|
38
|
-
|
|
38
|
+
udp: "udp";
|
|
39
39
|
}>>;
|
|
40
40
|
}, z.core.$strict>]>>>;
|
|
41
41
|
streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -113,15 +113,18 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
113
113
|
modelCodes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
114
114
|
modelSeries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
115
115
|
kind: z.ZodEnum<{
|
|
116
|
-
declarative: "declarative";
|
|
117
|
-
code: "code";
|
|
118
116
|
matter: "matter";
|
|
117
|
+
modbus: "modbus";
|
|
118
|
+
mqtt: "mqtt";
|
|
119
|
+
code: "code";
|
|
120
|
+
declarative: "declarative";
|
|
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;
|
|
@@ -382,22 +385,22 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
382
385
|
entities: z.ZodArray<z.ZodObject<{
|
|
383
386
|
domain: z.ZodEnum<{
|
|
384
387
|
number: "number";
|
|
385
|
-
image: "image";
|
|
386
388
|
custom: "custom";
|
|
387
|
-
light: "light";
|
|
388
|
-
switch: "switch";
|
|
389
389
|
sensor: "sensor";
|
|
390
390
|
binary_sensor: "binary_sensor";
|
|
391
|
+
switch: "switch";
|
|
392
|
+
light: "light";
|
|
393
|
+
select: "select";
|
|
394
|
+
button: "button";
|
|
395
|
+
image: "image";
|
|
391
396
|
cover: "cover";
|
|
392
397
|
lock: "lock";
|
|
393
|
-
climate: "climate";
|
|
394
398
|
media_player: "media_player";
|
|
395
399
|
camera: "camera";
|
|
396
|
-
button: "button";
|
|
397
400
|
update: "update";
|
|
398
401
|
lawn_mower: "lawn_mower";
|
|
399
|
-
select: "select";
|
|
400
402
|
vacuum: "vacuum";
|
|
403
|
+
climate: "climate";
|
|
401
404
|
alias: "alias";
|
|
402
405
|
}>;
|
|
403
406
|
objectId: z.ZodOptional<z.ZodString>;
|
|
@@ -405,25 +408,25 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
405
408
|
icon: z.ZodOptional<z.ZodString>;
|
|
406
409
|
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
407
410
|
number: "number";
|
|
408
|
-
|
|
411
|
+
custom: "custom";
|
|
412
|
+
image: "image";
|
|
409
413
|
level: "level";
|
|
414
|
+
select: "select";
|
|
415
|
+
button: "button";
|
|
416
|
+
sensor_numeric: "sensor_numeric";
|
|
417
|
+
sensor_text: "sensor_text";
|
|
418
|
+
sensor_binary: "sensor_binary";
|
|
419
|
+
on_off: "on_off";
|
|
410
420
|
color_hs: "color_hs";
|
|
411
421
|
color_temp: "color_temp";
|
|
412
422
|
cover: "cover";
|
|
413
423
|
lock: "lock";
|
|
414
424
|
thermostat: "thermostat";
|
|
415
|
-
sensor_numeric: "sensor_numeric";
|
|
416
|
-
sensor_binary: "sensor_binary";
|
|
417
|
-
sensor_text: "sensor_text";
|
|
418
425
|
media_player: "media_player";
|
|
419
426
|
camera: "camera";
|
|
420
|
-
button: "button";
|
|
421
427
|
update: "update";
|
|
422
428
|
lawn_mower: "lawn_mower";
|
|
423
|
-
select: "select";
|
|
424
429
|
vacuum: "vacuum";
|
|
425
|
-
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,68 @@ 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
|
+
domain: z.ZodEnum<{
|
|
835
|
+
number: "number";
|
|
836
|
+
sensor: "sensor";
|
|
837
|
+
binary_sensor: "binary_sensor";
|
|
838
|
+
switch: "switch";
|
|
839
|
+
light: "light";
|
|
840
|
+
select: "select";
|
|
841
|
+
button: "button";
|
|
842
|
+
}>;
|
|
843
|
+
capabilities: z.ZodRecord<z.ZodEnum<{
|
|
844
|
+
number: "number";
|
|
845
|
+
select: "select";
|
|
846
|
+
button: "button";
|
|
847
|
+
sensor_numeric: "sensor_numeric";
|
|
848
|
+
sensor_text: "sensor_text";
|
|
849
|
+
sensor_binary: "sensor_binary";
|
|
850
|
+
on_off: "on_off";
|
|
851
|
+
level: "level";
|
|
852
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
853
|
+
read: z.ZodOptional<z.ZodObject<{
|
|
854
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>, z.ZodLiteral<4>]>;
|
|
855
|
+
address: z.ZodUnion<readonly [z.ZodInt, z.ZodString]>;
|
|
856
|
+
type: z.ZodOptional<z.ZodEnum<{
|
|
857
|
+
string: "string";
|
|
858
|
+
u16: "u16";
|
|
859
|
+
s16: "s16";
|
|
860
|
+
u32: "u32";
|
|
861
|
+
s32: "s32";
|
|
862
|
+
f32: "f32";
|
|
863
|
+
}>>;
|
|
864
|
+
count: z.ZodOptional<z.ZodInt>;
|
|
865
|
+
bit: z.ZodOptional<z.ZodInt>;
|
|
866
|
+
scale: z.ZodOptional<z.ZodNumber>;
|
|
867
|
+
unit: z.ZodOptional<z.ZodString>;
|
|
868
|
+
options: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
869
|
+
}, z.core.$strict>>;
|
|
870
|
+
write: z.ZodOptional<z.ZodObject<{
|
|
871
|
+
function: z.ZodUnion<readonly [z.ZodLiteral<5>, z.ZodLiteral<6>, z.ZodLiteral<15>, z.ZodLiteral<16>]>;
|
|
872
|
+
address: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
873
|
+
on: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
874
|
+
off: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
875
|
+
min: z.ZodOptional<z.ZodNumber>;
|
|
876
|
+
max: z.ZodOptional<z.ZodNumber>;
|
|
877
|
+
step: z.ZodOptional<z.ZodNumber>;
|
|
878
|
+
value: z.ZodOptional<z.ZodUnion<readonly [z.ZodInt, z.ZodString]>>;
|
|
879
|
+
}, z.core.$strict>>;
|
|
880
|
+
}, z.core.$strict>>;
|
|
881
|
+
}, z.core.$strict>>;
|
|
882
|
+
}, z.core.$strict>;
|
|
748
883
|
};
|
|
749
884
|
/** The names of the files a JSON Schema is written for. */
|
|
750
885
|
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.
|
package/dist/testing.d.ts
CHANGED
|
@@ -228,6 +228,44 @@ type MatterIdentification = {
|
|
|
228
228
|
* @throws {Error} When the vendor has no discovery that loaded.
|
|
229
229
|
*/
|
|
230
230
|
export declare function identifyMatter(vendor: LoadedVendor, identity: Readonly<Record<string, unknown>>): MatterIdentification;
|
|
231
|
+
/** What discovery makes of one of the devices the house's MQTT broker hears. */
|
|
232
|
+
type MqttIdentification = {
|
|
233
|
+
/** Whether the vendor's `mqtt` rules take it: every condition holds. */
|
|
234
|
+
readonly matches: boolean;
|
|
235
|
+
/** The MQTT driver and the model it names; null when no driver takes the device. */
|
|
236
|
+
readonly association: Association | null;
|
|
237
|
+
};
|
|
238
|
+
/**
|
|
239
|
+
* Says what discovery makes of one of the devices the house's MQTT broker hears - one that
|
|
240
|
+
* announced itself, or one the owner mapped - by the vendor's `mqtt` rules. A device that another
|
|
241
|
+
* vendor's rules take too is the platform's own instead, which one vendor's test cannot see.
|
|
242
|
+
*
|
|
243
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
244
|
+
* @param identity - Who the device says it is: `manufacturer`, `model`, `originName`,
|
|
245
|
+
* `identifiers` and the rest of the fields FILES.md lists; a field left out is one it does not say.
|
|
246
|
+
* @returns What discovery makes of it.
|
|
247
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
248
|
+
*/
|
|
249
|
+
export declare function identifyMqtt(vendor: LoadedVendor, identity: Readonly<Record<string, unknown>>): MqttIdentification;
|
|
250
|
+
/** What discovery makes of one of the Modbus servers the house's network search found. */
|
|
251
|
+
type ModbusIdentification = {
|
|
252
|
+
/** Whether the vendor's `modbus` rules take it: every condition holds. */
|
|
253
|
+
readonly matches: boolean;
|
|
254
|
+
/** The Modbus driver and the model it names; null when no driver takes the server. */
|
|
255
|
+
readonly association: Association | null;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Says what discovery makes of one of the Modbus servers the network search found, by the
|
|
259
|
+
* vendor's `modbus` rules. The test says what the server answered to each value the block reads:
|
|
260
|
+
* the platform reads them through the house's Modbus client and matches the rules on
|
|
261
|
+
* `values.<name>`, `host`, `port` and `unitId`.
|
|
262
|
+
*
|
|
263
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
264
|
+
* @param identity - The server: `{ host, port, unitId, values: { serial: 'H34A10I1234567' } }`.
|
|
265
|
+
* @returns What discovery makes of it.
|
|
266
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
267
|
+
*/
|
|
268
|
+
export declare function identifyModbus(vendor: LoadedVendor, identity: Readonly<Record<string, unknown>>): ModbusIdentification;
|
|
231
269
|
//#endregion
|
|
232
270
|
//#region src/testing/load.d.ts
|
|
233
271
|
/** What loading takes. */
|
|
@@ -283,4 +321,4 @@ export declare class IntegrationError extends Error {
|
|
|
283
321
|
constructor(problems: readonly string[]);
|
|
284
322
|
}
|
|
285
323
|
//#endregion
|
|
286
|
-
export type { Association, BundleFailure, DriverHarness, DriverHarnessOptions, FakeSdk, FakeSdkOptions, FakeUdpSocket, FakeWebSocket, HarnessDevice, Identification, LoadIntegrationOptions, LoadedAccount, LoadedBundle, LoadedDiscovery, LoadedIntegration, LoadedListenSource, LoadedVendor, LogLevel, LogRecord, MatterIdentification, SentDatagram, SightingIdentity };
|
|
324
|
+
export type { Association, BundleFailure, DriverHarness, DriverHarnessOptions, FakeSdk, FakeSdkOptions, FakeUdpSocket, FakeWebSocket, HarnessDevice, Identification, LoadIntegrationOptions, LoadedAccount, LoadedBundle, LoadedDiscovery, LoadedIntegration, LoadedListenSource, LoadedVendor, LogLevel, LogRecord, MatterIdentification, ModbusIdentification, MqttIdentification, SentDatagram, SightingIdentity };
|
package/dist/testing.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { _ as composeEntityId, a as associateModel, c as matchesBroker, i as associateBroker, n as readVendorDirectory, o as identifySighting, s as matchesAnnouncement, t as instantiateVendor } from "./chunks/node-dist.js";
|
|
2
2
|
import { a as sourceModule, i as runtimeVersion, o as createFakeSdk, r as readProject, t as IntegrationError } from "./chunks/node-project.js";
|
|
3
3
|
import { pathToFileURL } from "node:url";
|
|
4
4
|
//#region src/testing/harness.ts
|
|
@@ -194,10 +194,50 @@ function identify(vendor, heard) {
|
|
|
194
194
|
function identifyMatter(vendor, identity) {
|
|
195
195
|
const plan = vendor.discovery?.plan;
|
|
196
196
|
if (plan === void 0) throw new Error(`${vendor.manifest.id} has no discovery.json that loaded`);
|
|
197
|
-
const matches =
|
|
197
|
+
const matches = matchesBroker(plan, "matter", identity);
|
|
198
198
|
return {
|
|
199
199
|
matches,
|
|
200
|
-
association: matches ?
|
|
200
|
+
association: matches ? associateBroker(plan, "matter", identity) : null
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Says what discovery makes of one of the devices the house's MQTT broker hears - one that
|
|
205
|
+
* announced itself, or one the owner mapped - by the vendor's `mqtt` rules. A device that another
|
|
206
|
+
* vendor's rules take too is the platform's own instead, which one vendor's test cannot see.
|
|
207
|
+
*
|
|
208
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
209
|
+
* @param identity - Who the device says it is: `manufacturer`, `model`, `originName`,
|
|
210
|
+
* `identifiers` and the rest of the fields FILES.md lists; a field left out is one it does not say.
|
|
211
|
+
* @returns What discovery makes of it.
|
|
212
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
213
|
+
*/
|
|
214
|
+
function identifyMqtt(vendor, identity) {
|
|
215
|
+
const plan = vendor.discovery?.plan;
|
|
216
|
+
if (plan === void 0) throw new Error(`${vendor.manifest.id} has no discovery.json that loaded`);
|
|
217
|
+
const matches = matchesBroker(plan, "mqtt", identity);
|
|
218
|
+
return {
|
|
219
|
+
matches,
|
|
220
|
+
association: matches ? associateBroker(plan, "mqtt", identity) : null
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Says what discovery makes of one of the Modbus servers the network search found, by the
|
|
225
|
+
* vendor's `modbus` rules. The test says what the server answered to each value the block reads:
|
|
226
|
+
* the platform reads them through the house's Modbus client and matches the rules on
|
|
227
|
+
* `values.<name>`, `host`, `port` and `unitId`.
|
|
228
|
+
*
|
|
229
|
+
* @param vendor - The vendor, loaded with `loadIntegration`.
|
|
230
|
+
* @param identity - The server: `{ host, port, unitId, values: { serial: 'H34A10I1234567' } }`.
|
|
231
|
+
* @returns What discovery makes of it.
|
|
232
|
+
* @throws {Error} When the vendor has no discovery that loaded.
|
|
233
|
+
*/
|
|
234
|
+
function identifyModbus(vendor, identity) {
|
|
235
|
+
const plan = vendor.discovery?.plan;
|
|
236
|
+
if (plan === void 0) throw new Error(`${vendor.manifest.id} has no discovery.json that loaded`);
|
|
237
|
+
const matches = matchesBroker(plan, "modbus", identity);
|
|
238
|
+
return {
|
|
239
|
+
matches,
|
|
240
|
+
association: matches ? associateBroker(plan, "modbus", identity) : null
|
|
201
241
|
};
|
|
202
242
|
}
|
|
203
243
|
//#endregion
|
|
@@ -268,4 +308,4 @@ async function loadIntegration(options = {}) {
|
|
|
268
308
|
};
|
|
269
309
|
}
|
|
270
310
|
//#endregion
|
|
271
|
-
export { IntegrationError, createFakeSdk, driverHarness, identify, identifyMatter, loadIntegration };
|
|
311
|
+
export { IntegrationError, createFakeSdk, driverHarness, identify, identifyMatter, identifyModbus, identifyMqtt, loadIntegration };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nebulahome/integration-sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "Write a NebulaHome integration: check it, build it, test it and release it for the platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -62,10 +62,10 @@
|
|
|
62
62
|
"tsdown": "^0.23.0",
|
|
63
63
|
"typescript": "^6.0.3",
|
|
64
64
|
"vitest": "^4.1.11",
|
|
65
|
-
"@nebulahome/contracts": "
|
|
66
|
-
"@nebulahome/
|
|
67
|
-
"@nebulahome/
|
|
68
|
-
"@nebulahome/tsconfig": "
|
|
65
|
+
"@nebulahome/contracts": "2026.10.0-alpha.4",
|
|
66
|
+
"@nebulahome/package-runtime": "2026.10.0-alpha.4",
|
|
67
|
+
"@nebulahome/eslint-config": "2026.10.0-alpha.4",
|
|
68
|
+
"@nebulahome/tsconfig": "2026.10.0-alpha.4"
|
|
69
69
|
},
|
|
70
70
|
"scripts": {
|
|
71
71
|
"build": "tsdown && node scripts/build-schemas.js",
|