First what I try to accomplish: I have a small fountain in the garden, and I would like to make it every half hour for one minute to turn on so the freezing cold (-10) doesn’t break the pump and the casing. Taking it all apart is lots of work, so I would like to avoid that. When it’s not freezing, I want a switch to turn the rule on and off. Even better would be that I can do it automatically based on the forecast, but that’s a next step.
What I made:
A switch:
Switch Winterrule "Winter in de tuin"
The rule:
rule "WinterTimer"
when
Time cron "0 */30 * ? * * "
then
if (Winterrule.state == OFF) return false
light_Zithoek_Schilderij.sendCommand(ON)
createTimer(now.plusMinutes(1) [ |
light_Zithoek_Schilderij.sendCommand(OFF)
]
sendTelegram("OHBot", "Fontein draait nu")
end
I based this on Disabling a rule with a switch and My first Rule - light on and off every 10 seconds (can't make most basic rule work) - #12 by KevinHab with code from @5iver and @watou and @Spaceman_Spiff
rule “Coffee on 630am”
when
Time cron “00 30 06 * * ?”
then
if (coffeetimer.state == OFF) return falsesendCommand(plug5, ON)
end
Try going even simpler…
rule "My first rule" when Time cron "0/10 0 0 ? * * *" //Every 10 seconds starting at second 00, at minute :00, at 00am, of every day then logInfo("Test","My first rule just ran") end
Now tail the openhab.log and you should see the log entry every 10s. If that works, then add in your command with another logInfo after it, and see if the rule still runs.
I already have different succesfull rules, the Telegram bot works no problem, but
- the simple rule does not show up. in my logging, while everything else shows up prefectly.
2019-01-21 22:52:04.672 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'cron.rules'
==> /var/log/openhab2/events.log <==
2019-01-21 22:52:49.493 [vent.ItemStateChangedEvent] - Time changed from 2019-01-21T22:51:49.431+0100 to 2019-01-21T22:52:49.452+0100
2019-01-21 22:52:49.506 [vent.ItemStateChangedEvent] - Date changed from 2019-01-21T22:51:49.431+0100 to 2019-01-21T22:52:49.452+0100
2019-01-21 22:53:49.514 [vent.ItemStateChangedEvent] - Time changed from 2019-01-21T22:52:49.452+0100 to 2019-01-21T22:53:49.461+0100
2019-01-21 22:53:49.526 [vent.ItemStateChangedEvent] - Date changed from 2019-01-21T22:52:49.452+0100 to 2019-01-21T22:53:49.461+0100
2019-01-21 22:54:49.511 [vent.ItemStateChangedEvent] - Time changed from 2019-01-21T22:53:49.461+0100 to 2019-01-21T22:54:49.470+0100
2019-01-21 22:54:49.523 [vent.ItemStateChangedEvent] - Date changed from 2019-01-21T22:53:49.461+0100 to 2019-01-21T22:54:49.470+0100
2019-01-21 22:55:49.528 [vent.ItemStateChangedEvent] - Time changed from 2019-01-21T22:54:49.470+0100 to 2019-01-21T22:55:49.492+0100
2019-01-21 22:55:49.534 [vent.ItemStateChangedEvent] - Date changed from 2019-01-21T22:54:49.470+0100 to 2019-01-21T22:55:49.492+0100
2019-01-21 22:56:49.542 [vent.ItemStateChangedEvent] - Time changed from 2019-01-21T22:55:49.492+0100 to 2019-01-21T22:56:49.506+0100
2019-01-21 22:56:49.557 [vent.ItemStateChangedEvent] - Date changed from 2019-01-21T22:55:49.492+0100 to 2019-01-21T22:56:49.506+0100
2019-01-21 22:57:49.556 [vent.ItemStateChangedEvent] - Time changed from 2019-01-21T22:56:49.506+0100 to 2019-01-21T22:57:49.518+0100
2019-01-21 22:57:49.568 [vent.ItemStateChangedEvent] - Date changed from 2019-01-21T22:56:49.506+0100 to 2019-01-21T22:57:49.518+0100
- I copy pasted the code together, but it doesn’t do a darn thing.
Any pointers please?