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

Feature support for DateTime trigger #47

Open
cvdenzen opened this issue Sep 18, 2022 · 1 comment
Open

Feature support for DateTime trigger #47

cvdenzen opened this issue Sep 18, 2022 · 1 comment

Comments

@cvdenzen
Copy link

In Openhab 3 it is possible to trigger a rule with a DateTime item. It is a nice and neat feature, I would like to see it in JRule.

As an experiment, I have tried to program some code, see branch AtTrigger at https://github.com/cvdenzen/jrule/tree/AtTrigger. What is missing is a listener to reschedule the rule if the DateTime item changes.

@seaside1
Copy link
Owner

seaside1 commented Sep 19, 2022

Hi!
It seems like you already have some of code for it, so once you are ready you could submit a PR.
I'm a bit curious how this is to be used?

I take it, It could be done manually in a rule like this:

    @JRuleName("testDateTimeTrigger")
    @JRuleWhen(item = _TestDateTime.ITEM, trigger = _TestDateTime.TRIGGER_CHANGED)
    public synchronized void testDateTimeItem(JRuleEvent event) {
        logInfo("TestDataTmeItem changed from: {} to: {}", event.getOldValue(), event.getNewValue());
       // Create a timer with a lambda that triggers given the dateTime change
    }

But I take it you want this to be built in like:

    @JRuleName("testDateTimeTrigger")
    @JRuleWhen(item = _TestDateTime.ITEM, trigger = _TestDateTime.TRIGGER_AT)
    public synchronized void testDateTimeItem(JRuleEvent event) {
                // Triggered at TestDateTime value   
    }

You could look at the cron and time based code (Example 11 and 16), to see how they are rescheduled the timer, should be something similar that has to be done.

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

No branches or pull requests

2 participants