diff --git a/README.md b/README.md index 5ff0ef264..627f7cb2a 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,8 @@ Executes Javascript, Typescript Scripts. ### **WORK IN PROGRESS** --> ### WORK IN PROGRESS +* (Eistee82) Fix: prevent duplicate 'Stopping script' log when script is not running +* (Eistee82) Fix: only restart scripts on the instance that owns them * (Eistee82) Added OID display mode toggle for Blockly editor: 4 display modes (Name, Name path, State ID, Full ID) with toolbar dropdown, context menu, optional object icons, and translations in 11 languages * Per-provider test buttons in adapter config (OpenAI, Anthropic, Gemini, DeepSeek, Custom API) * Optional API key field for custom base URL providers (e.g. Ollama without auth) diff --git a/build/main.js b/build/main.js index 1fbe944d1..554480f45 100644 --- a/build/main.js +++ b/build/main.js @@ -578,9 +578,9 @@ class JavaScript extends adapter_core_1.Adapter { await this.loadScriptById(id); } } - else { - // if (obj.common.source !== formerObj.common.source) { - // Source changed => restart the script + else if (obj.common.engine === `system.adapter.${this.namespace}` || + formerObj.common.engine === `system.adapter.${this.namespace}`) { + // Source changed => restart the script (only on the relevant instance) this.stopCounters[id] = this.stopCounters[id] ? this.stopCounters[id] + 1 : 1; void this.stopScript(id).then(() => { // only start again after stop when "last" object change to prevent problems on @@ -2179,6 +2179,9 @@ class JavaScript extends adapter_core_1.Adapter { } } async stopScript(name) { + if (!this.scripts[name]) { + return false; + } this.log.info(`${name}: Stopping script`); await this.setState(`scriptEnabled.${name.substring(SCRIPT_CODE_MARKER.length)}`, false, true); if (this.messageBusHandlers[name]) { diff --git a/src/main.ts b/src/main.ts index 9c2e002cf..c7b75c31d 100644 --- a/src/main.ts +++ b/src/main.ts @@ -675,9 +675,11 @@ class JavaScript extends Adapter { // Start script await this.loadScriptById(id); } - } else { - // if (obj.common.source !== formerObj.common.source) { - // Source changed => restart the script + } else if ( + obj.common.engine === `system.adapter.${this.namespace}` || + formerObj.common.engine === `system.adapter.${this.namespace}` + ) { + // Source changed => restart the script (only on the relevant instance) this.stopCounters[id] = this.stopCounters[id] ? this.stopCounters[id] + 1 : 1; void this.stopScript(id).then(() => { // only start again after stop when "last" object change to prevent problems on @@ -2601,6 +2603,10 @@ class JavaScript extends Adapter { } async stopScript(name: string): Promise { + if (!this.scripts[name]) { + return false; + } + this.log.info(`${name}: Stopping script`); await this.setState(`scriptEnabled.${name.substring(SCRIPT_CODE_MARKER.length)}`, false, true);