@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.
- package/CHANGELOG.md +54 -0
- package/FILES.md +164 -21
- package/README.md +5 -3
- package/dist/chunks/node-dist.js +3066 -222
- package/dist/chunks/node-index.d.ts +247 -17
- package/dist/chunks/node-project.js +2 -1
- package/dist/index.d.ts +79 -9
- package/dist/schemas.d.ts +168 -16
- 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 +554 -0
- package/schemas/driver.schema.json +8 -1
- package/schemas/manifest.schema.json +12 -0
- package/schemas/modbus-template.schema.json +285 -0
- package/schemas/profile.schema.json +49 -0
package/dist/schemas.d.ts
CHANGED
|
@@ -20,18 +20,22 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
20
20
|
padding: number;
|
|
21
21
|
}>>>;
|
|
22
22
|
internetRequired: z.ZodDefault<z.ZodBoolean>;
|
|
23
|
+
twins: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
24
|
+
mac: "mac";
|
|
25
|
+
serial: "serial";
|
|
26
|
+
}>>>;
|
|
23
27
|
setup: z.ZodOptional<z.ZodString>;
|
|
24
28
|
account: z.ZodOptional<z.ZodString>;
|
|
25
29
|
transports: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodObject<{
|
|
26
30
|
module: z.ZodString;
|
|
27
31
|
wires: z.ZodArray<z.ZodEnum<{
|
|
28
|
-
udp: "udp";
|
|
29
32
|
matter: "matter";
|
|
30
|
-
|
|
33
|
+
modbus: "modbus";
|
|
31
34
|
mqtt: "mqtt";
|
|
35
|
+
http: "http";
|
|
32
36
|
ble: "ble";
|
|
33
37
|
zigbee: "zigbee";
|
|
34
|
-
|
|
38
|
+
udp: "udp";
|
|
35
39
|
}>>;
|
|
36
40
|
}, z.core.$strict>]>>>;
|
|
37
41
|
streams: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
@@ -109,15 +113,18 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
109
113
|
modelCodes: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>>;
|
|
110
114
|
modelSeries: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
111
115
|
kind: z.ZodEnum<{
|
|
112
|
-
declarative: "declarative";
|
|
113
|
-
code: "code";
|
|
114
116
|
matter: "matter";
|
|
117
|
+
modbus: "modbus";
|
|
118
|
+
mqtt: "mqtt";
|
|
119
|
+
code: "code";
|
|
120
|
+
declarative: "declarative";
|
|
115
121
|
}>;
|
|
116
122
|
defaultIcon: z.ZodOptional<z.ZodString>;
|
|
117
123
|
webPagePort: z.ZodOptional<z.ZodInt>;
|
|
118
124
|
webPagePath: z.ZodOptional<z.ZodString>;
|
|
119
125
|
profile: z.ZodOptional<z.ZodString>;
|
|
120
126
|
entry: z.ZodOptional<z.ZodString>;
|
|
127
|
+
template: z.ZodOptional<z.ZodString>;
|
|
121
128
|
setup: z.ZodString;
|
|
122
129
|
id: z.ZodString;
|
|
123
130
|
name: z.ZodString;
|
|
@@ -363,6 +370,8 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
363
370
|
model: z.ZodOptional<z.ZodString>;
|
|
364
371
|
swVersion: z.ZodOptional<z.ZodString>;
|
|
365
372
|
hwVersion: z.ZodOptional<z.ZodString>;
|
|
373
|
+
mac: z.ZodOptional<z.ZodString>;
|
|
374
|
+
serialNumber: z.ZodOptional<z.ZodString>;
|
|
366
375
|
}, z.core.$strict>;
|
|
367
376
|
}, z.core.$strict>;
|
|
368
377
|
subscriptions: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
@@ -376,22 +385,22 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
376
385
|
entities: z.ZodArray<z.ZodObject<{
|
|
377
386
|
domain: z.ZodEnum<{
|
|
378
387
|
number: "number";
|
|
379
|
-
image: "image";
|
|
380
388
|
custom: "custom";
|
|
381
|
-
light: "light";
|
|
382
|
-
switch: "switch";
|
|
383
389
|
sensor: "sensor";
|
|
384
390
|
binary_sensor: "binary_sensor";
|
|
391
|
+
switch: "switch";
|
|
392
|
+
light: "light";
|
|
393
|
+
select: "select";
|
|
394
|
+
button: "button";
|
|
395
|
+
image: "image";
|
|
385
396
|
cover: "cover";
|
|
386
397
|
lock: "lock";
|
|
387
|
-
climate: "climate";
|
|
388
398
|
media_player: "media_player";
|
|
389
399
|
camera: "camera";
|
|
390
|
-
button: "button";
|
|
391
400
|
update: "update";
|
|
392
401
|
lawn_mower: "lawn_mower";
|
|
393
|
-
select: "select";
|
|
394
402
|
vacuum: "vacuum";
|
|
403
|
+
climate: "climate";
|
|
395
404
|
alias: "alias";
|
|
396
405
|
}>;
|
|
397
406
|
objectId: z.ZodOptional<z.ZodString>;
|
|
@@ -402,21 +411,21 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
402
411
|
custom: "custom";
|
|
403
412
|
image: "image";
|
|
404
413
|
level: "level";
|
|
414
|
+
select: "select";
|
|
415
|
+
button: "button";
|
|
416
|
+
sensor_numeric: "sensor_numeric";
|
|
417
|
+
sensor_text: "sensor_text";
|
|
418
|
+
sensor_binary: "sensor_binary";
|
|
405
419
|
on_off: "on_off";
|
|
406
420
|
color_hs: "color_hs";
|
|
407
421
|
color_temp: "color_temp";
|
|
408
422
|
cover: "cover";
|
|
409
423
|
lock: "lock";
|
|
410
424
|
thermostat: "thermostat";
|
|
411
|
-
sensor_numeric: "sensor_numeric";
|
|
412
|
-
sensor_binary: "sensor_binary";
|
|
413
|
-
sensor_text: "sensor_text";
|
|
414
425
|
media_player: "media_player";
|
|
415
426
|
camera: "camera";
|
|
416
|
-
button: "button";
|
|
417
427
|
update: "update";
|
|
418
428
|
lawn_mower: "lawn_mower";
|
|
419
|
-
select: "select";
|
|
420
429
|
vacuum: "vacuum";
|
|
421
430
|
}> & z.core.$partial, z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
422
431
|
state: z.ZodRecord<z.ZodEnum<{
|
|
@@ -526,6 +535,14 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
526
535
|
total_increasing: "total_increasing";
|
|
527
536
|
}>>;
|
|
528
537
|
displayPrecision: z.ZodOptional<z.ZodInt>;
|
|
538
|
+
link: z.ZodOptional<z.ZodObject<{
|
|
539
|
+
key: z.ZodOptional<z.ZodString>;
|
|
540
|
+
matter: z.ZodOptional<z.ZodObject<{
|
|
541
|
+
endpoint: z.ZodInt;
|
|
542
|
+
cluster: z.ZodInt;
|
|
543
|
+
attribute: z.ZodInt;
|
|
544
|
+
}, z.core.$strict>>;
|
|
545
|
+
}, z.core.$strict>>;
|
|
529
546
|
stream: z.ZodOptional<z.ZodObject<{
|
|
530
547
|
source: z.ZodString;
|
|
531
548
|
args: z.ZodDefault<z.ZodType<JsonObject, unknown, z.core.$ZodTypeInternals<JsonObject, unknown>>>;
|
|
@@ -586,6 +603,9 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
586
603
|
externalId: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
587
604
|
name: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
588
605
|
swVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
606
|
+
mac: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
607
|
+
serialNumber: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
608
|
+
auth: z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
589
609
|
}, z.core.$strict>>;
|
|
590
610
|
matter: z.ZodOptional<z.ZodObject<{
|
|
591
611
|
match: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -613,6 +633,76 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
613
633
|
}, z.core.$strict>]>>;
|
|
614
634
|
model: z.ZodDefault<z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>>;
|
|
615
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>>;
|
|
616
706
|
adopt: z.ZodDefault<z.ZodEnum<{
|
|
617
707
|
owner: "owner";
|
|
618
708
|
automatic: "automatic";
|
|
@@ -728,6 +818,68 @@ export declare const BUNDLE_FILE_SCHEMAS: {
|
|
|
728
818
|
identity: z.ZodString;
|
|
729
819
|
module: z.ZodString;
|
|
730
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>;
|
|
731
883
|
};
|
|
732
884
|
/** The names of the files a JSON Schema is written for. */
|
|
733
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/
|
|
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",
|