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

[rules] Add event information for time-based and manual/rule-run triggers #286

Merged
merged 4 commits into from
Sep 4, 2023

Conversation

florian-h05
Copy link
Contributor

@florian-h05 florian-h05 commented Aug 1, 2023

Refs openhab/openhab-core#2965, therefore requires openHAB 4.0 Milestone 4 or newer.

@florian-h05 florian-h05 requested a review from a team as a code owner August 1, 2023 17:04
@florian-h05 florian-h05 added the enhancement New feature or request label Aug 1, 2023
@florian-h05 florian-h05 added this to the to be released milestone Aug 1, 2023
@digitaldan
Copy link
Contributor

Hi @florian-h05 sorry about being MIA the last few weeks. Work and life got really busy for me, hoping things calm down at the end of the month and i can start dedicating time to openHAB again. In the mean time, let me read up on the core change and I will give a review shortly.

Copy link
Contributor

@digitaldan digitaldan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, i'm just upgrading to snapshots today so i might give this a try on my cron based rules.

@florian-h05
Copy link
Contributor Author

florian-h05 commented Aug 9, 2023

@digitaldan Have you had the time to test this?

Signed-off-by: Florian Hotze <[email protected]>
Signed-off-by: Florian Hotze <[email protected]>
@digitaldan
Copy link
Contributor

Hmm, i'm not sure i am actually using this version of openhab.js, hard to tell from my logs (prob need to enable debugging). I have the binding set to "Do Not Use Included Library" and have this branch deployed to node_modules in my automation folder, but i am getting the following output for this test rule:

rules.when().cron("1 * * * * ?").then(e => {
    console.log(e);
}).build("CRON TEST");
{
  "eventClass": "org.openhab.core.automation.events.TimerEvent",
  "payload": {
    "GenericCronTrigger": "1 * * * * ?"
  },
  "module": "9d41475f-68cd-4e26-99ad-d130e4db770b"
}

Looking through the changes, I would expect to have a TriggerType and CronExpression member on the main event object ? I might poke at it some more today unless you have another idea?

@florian-h05
Copy link
Contributor Author

Hmm, when I tested this it worked fine.

I have uses JSRule and manually imported with require

Have you tried restarting the add-on or openHAB in general?

@digitaldan
Copy link
Contributor

Yeah, i think the code is fine, my system refuses to not use the shipped js library, even after a restart. Sounds like a different issue. I would say merge this as i'm not going to be able to test until i figure out this other issue.

image

@florian-h05 florian-h05 merged commit 7d5ec26 into openhab:main Sep 4, 2023
4 checks passed
@florian-h05 florian-h05 deleted the rules-event-info branch September 4, 2023 21:28
florian-h05 added a commit to florian-h05/openhab-js that referenced this pull request Sep 17, 2023
Regression of openhab#286.

event.getClass() was called even when event was null.

Signed-off-by: Florian Hotze <[email protected]>
florian-h05 added a commit that referenced this pull request Sep 17, 2023
Regression of #286.

event.getClass() was called even when event was null.

Signed-off-by: Florian Hotze <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants