ioBroker.javascript icon indicating copy to clipboard operation
ioBroker.javascript copied to clipboard

[enhancement]: add "object script path" to a block

Open darkiop opened this issue 11 months ago • 7 comments

Describe the solution you'd like image

add the path of the current script to this block (first below "System"), like

javascript.0.scriptEnabled.example-script

Why? If the script (start, restart) itself is used as a trigger, you are more flexible with an automatically determined script path in case the script is renamed.

darkiop avatar Jan 12 '25 20:01 darkiop

But javascript.0.scriptEnabled.example-script is not the ID of the script. I don't get the use case of this request. Name of script already provides the object id

klein0r avatar Jan 13 '25 07:01 klein0r

Hi Matthias, for something like this, for example - a block that generates javascript.0.scriptEnabled.PRODUKTIV.VIS.Statustexte.01_Muell, the script name in the script itself would be dynamic (if renamed). I have a few scripts like this that should trigger initially when the script is restarted.

image image

darkiop avatar Jan 13 '25 18:01 darkiop

Example: The object id of a script is script.js.Web.Instagram-Followers. You can use the following Block to get this ID:

Screenshot 2025-01-14 at 10 40 56

If you want to know the current state of the script (running), you need to use this state: javascript.0.scriptEnabled.Web.Instagram-Followers. Just replace the parts in the string.

Screenshot 2025-01-14 at 10 43 39

the script name in the script itself would be dynamic

The name is not the problem. The object ID is the problem. And there is no option to "rename" an object. It's always delete + create new. So there is technically no solution for your problem.

klein0r avatar Jan 14 '25 09:01 klein0r

You could use message to other script when the script starts (which has a trigger). In that case you don't need to know the object id of the other script.

klein0r avatar Jan 14 '25 09:01 klein0r

Thanks for you help Matthias.

With Image i get what i need. But I should have come up with the solution myself ;)

I just thought that thematically this output would fit well into the mentioned block.

darkiop avatar Jan 14 '25 19:01 darkiop

But in which case is a trigger (on the enabled state) useful for the current script?

klein0r avatar Jan 15 '25 11:01 klein0r

The script above generates a text from various DPs from different sources. On the one hand, the trigger directly on the script makes it easier to work on the script (make adjustments, restart script, texts are generated) and on the other hand, it also ensures that the texts are up-to-date when the JS instance or the entire system is restarted. This has worked quite well so far.

darkiop avatar Jan 15 '25 19:01 darkiop