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

[jsscripting] Documentation of event object manually run from GUI is wrong #316

Open
FSeidinger opened this issue Dec 29, 2023 · 1 comment
Labels
documentation Improvements or additions to documentation

Comments

@FSeidinger
Copy link

Documentation of event object manually run from GUI is wrong

Expected behavior

The documentation states that this.event has the value undefined if manually run from the openHAB GUI.

Actual behavior

If run manually from the GUI (e.g. from the Run Now (CTRL-R button inside the script editor, this.event is not undefined but set to an instance of org.openhab.core.automation.events.ExecutionEvent.

Take for example the following script:

for (var prop in this.event) {
  console.log(prop);
}

console.log("toString: %s", this.event.toString());
console.log("getType: %s", this.event.getType());
console.log("getSource: %s", this.event.getSource());
console.log("getTopic: %s", this.event.getTopic());
console.log("getPayload: %s", this.event.getPayload());

It will produce the following output:

2023-12-29 22:00:49.888 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - toString
2023-12-29 22:00:49.889 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getType
2023-12-29 22:00:49.889 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getSource
2023-12-29 22:00:49.889 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getTopic
2023-12-29 22:00:49.889 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - equals
2023-12-29 22:00:49.889 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - hashCode
2023-12-29 22:00:49.889 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getPayload
2023-12-29 22:00:49.890 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - toString: Execution triggered by manual
2023-12-29 22:00:49.890 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getType: ExecutionEvent
2023-12-29 22:00:49.894 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getSource: manual
2023-12-29 22:00:49.894 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getTopic: openhab/execution/ea7175a2f9/triggered
2023-12-29 22:00:49.894 [INFO ] [nhab.automation.script.ui.ea7175a2f9] - getPayload: {}
@FSeidinger FSeidinger added the documentation Improvements or additions to documentation label Dec 29, 2023
@florian-h05
Copy link
Contributor

Since the documentation has been written, there were changes and it seems I forgot to update the UI event object docs (I never use the UI event object, all my JS rules are file-based).

I'm happy to accept a PR with a doc update!

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

No branches or pull requests

2 participants