Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: /lib/javascript.d.ts - Zeile 1222 #1760

Open
3 tasks done
Quarkmax opened this issue Nov 13, 2024 · 2 comments
Open
3 tasks done

[Bug]: /lib/javascript.d.ts - Zeile 1222 #1760

Quarkmax opened this issue Nov 13, 2024 · 2 comments

Comments

@Quarkmax
Copy link

I'm sure that

  • This issue is still present in the current beta version of this adapter
  • There is no other (open) issue with the same topic (use the search!)
  • This issue is not described in the adapter documentation / FAQ (read the docs!)

Script type

JavaScript

The problem

Senden an anderes Script (JS, nicht Blockly) erwartet einen String für die Instanz messageTo({ instance: 0, script: ....... . Übergebe ich die Instanz als String '0' oder "0" wird die Message nicht gesendet.
Sollte hier in Zeile 1222 instance?: string; nicht number erwartet werden?
Grundsätzlich ist die Funktion gegeben wenn man die Instanz als Number übergibt, aber unschön wegen des Hinweises beim schreiben.

iobroker.current.log (in debug mode!)

No response

Version of nodejs

20.18.0

Version of ioBroker js-controller

7.0.2

Version of adapter

8.8.3

@klein0r
Copy link
Collaborator

klein0r commented Nov 15, 2024

Documentation is also a string - the idea is that you provide the complete namespace. e.g. javascript.0:

messageTo({ instance: 'instance', script: 'script.js.common.scriptName', message: 'messageName' }, data, {timeout: 1000}, result =>
log(JSON.stringify(result)));

But yes, number should also work:

if (target.instance || target.instance === 0) {
if (typeof target.instance === 'string' && target.instance && target.instance.startsWith('system.adapter.')) {
target.instance = target.instance.substring('system.adapter.'.length);
} else if (typeof target.instance === 'number') {
target.instance = `javascript.${target.instance}`;
}

@Quarkmax
Copy link
Author

javascript.0 works without any problems, send and no red underlined. I had the snippet translated from Blockly, and it only said instance: 0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants