Rule will not be startet

Hi,

i’m confused… none of my rules will be executed, eg:

val String filename = "heizung.rules"
rule "heizungen"
when
    Time cron "* * * ? * *"
then
    logDebug(filename,"starting...")
end

Nothing will be logged, only this after modify the rule file:

2018-01-23 16:26:46.815 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'heizung.rules'

Bfo

you might try to test your cron definition

http://cron.schlitt.info/index.php

or use some help to generate your cron

https://crontab.guru

1 Like

Also try logInfo. I am not sure without testing if DEBUG is set by default

Pay attention to: https://docs.openhab.org/configuration/rules-dsl.html#time-based-triggers

If you want really fire the Rule Every Second , than take this!

val String filename = "heizung.rules"
rule "heizungen"
when
    Time cron "* * * ? * * *"
then
    logDebug(filename,"starting...")
end

https://www.freeformatter.com/cron-expression-generator-quartz.html

It is not. You have to explicitly enable DEBUG logging for rules.

1 Like

Ok, the test every second is only for testing purpose.
Do i have forgotten a star? I have use the f… cron generator, but it has failed.

With the right format it will run.

The question is, why openhab do not say, that the cron line is in wrong format, like you have one star to much?

bfo

I think you have a wrong cron generator used … for Java you must use Quartz Cron Generator :slight_smile:

I think your cron expression is fine. The 7th character is optional and your rule should be firing (and probably is) every second but you’re not seeing any output because your debug logging is not activated.

All you have to do is type the following into your console:

log:set DEBUG org.eclipse.smarthome.model.script

See this thread for more details:
https://community.openhab.org/t/debug-logging-in-rules/38764/5

Hi rekoj and ei_Gelb_Geek,

after the test yesterday and no modifications, today the rule will not be executed again.
It is not important to me, to use debug output. It was only a test.
I have change my rules file now in that way:

val String filename = "heizung.rules"
rule "heizungen"
when
    Time cron "*/5 * * ? * * *"
then
    logInfo("heizung.rules","starting...")
    var String result = executeCommandLine("/usr/local/bin/checkMail.sh julia", 1000)
    logInfo(filename,"result : "+ result)
    if (result.startsWith("julia") ) {
        logInfo(filename,"Julia Heizung gesetzt")
        OGJULIA_HEIZUNG_SetTemp.postUpdate(7.0)
    }
end

The script “/usr/local/bin/checkMail.sh” is readable by “openhab” user and gives only the “Name” back (“julia” in that test case). I have executed it with “sudo -u openhab /usr/local/bin/checkMail.sh julia” and it works like expected.
But, and this is the main problem, it wont be executed. I see in openhab.log only this entries after saving the rule file:

2018-01-24 08:03:44.003 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'heizung.rules'

bfo

It looks like, that something is wrong with the file it self.
If i rewrite the fle with the same content, it works now. Hopefully it works the next time too :slight_smile:

bfo