MCPcopy
hub / github.com/Koenkk/zigbee2mqtt / loadJS

Method loadJS

lib/extension/externalConverters.ts:41–66  ·  view source on GitHub ↗
(name: string, mod: TModule, newName?: string)

Source from the content-addressed store, hash-verified

39 }
40
41 protected async loadJS(name: string, mod: TModule, newName?: string): Promise<void> {
42 try {
43 removeExternalDefinitions(name);
44
45 const definitions = Array.isArray(mod) ? mod : [mod];
46
47 for (const definition of definitions) {
48 definition.externalConverterName = newName ?? name;
49
50 addExternalDefinition(definition);
51 logger.info(`Loaded external converter '${newName ?? name}'.`);
52 }
53
54 await this.zigbee.resolveDevicesDefinitions(true);
55 } catch (error) {
56 logger.error(
57 /* v8 ignore next */
58 `Failed to load external converter '${newName ?? name}'. Check the code for syntax error and make sure it is up to date with the current Zigbee2MQTT version.`,
59 );
60 logger.warning(
61 "External converters are not meant for long term usage, but for local testing after which a pull request should be created to add out-of-the-box support for the device",
62 );
63
64 throw error;
65 }
66 }
67}

Callers

nothing calls this directly

Calls 4

errorMethod · 0.80
warningMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected