Hi,
I’m newbie in OH at all, just started last week with OH2. I have a strange behavior of rules. I see in log file rules are loaded at startup but they are not working (not active). No other errors in log
I have one rule for polling z-wave devices, which is invoked on system startup. I can see that this rule is working, but not all others.
GUI and all other things are working, i can switch on/off my z-wave devices, but rules are not invoked for example when a movement detected by sensor or if i turn a switch GUI control (i see in event.log, something like this "switchAllOff received command ON). Only if for example i do “touch /opt/openhab2/conf/rules/scenes.rules” or open a file with rules, add a blank and save the file, all rules are reloaded by OH2 and then are working very well.
here are the sample rule for polling (working) and one for scenes which is not working after startup, but after the corresponding file gets new timestamp and is reloaded by OH2.
OH2 Snapshot i just downloaded last week from main download website. Should be latest snapshot.
Thanks for any suggestions, my be i just do somewhat basic wrong? No other rules are defined over habmin. Only in files on disk.
GNU nano 2.2.6 File: rules/polling.rules
// Imports
import org.openhab.core.library.types.*
import org.openhab.core.persistence.*
import org.openhab.model.script.actions.*
import org.eclipse.smarthome.core.types.RefreshType
var Number WAIT_INITIALIZATION = 120000
var Number POLLING_PERIOD = 30 * 60 * 1000
var Number doPolling = 0
rule "polling"
when
System started
then
logInfo("Polling", "Start polling in " + WAIT_INITIALIZATION + " milliseconds" )
//wait intialization 2 mins
Thread::sleep(WAIT_INITIALIZATION)
while(1 == 1) {
logInfo("Polling", "refreshing")
groupPollingSensors.members.forEach[ item |
sendCommand(item, RefreshType.REFRESH)
]
logInfo("Polling", "to sleep")
Thread::sleep(POLLING_PERIOD)
}
end
GNU nano 2.2.6 File: rules/scenes.rules
///
rule "Rule_AllOff"
when
Item sceneAllOff received command ON
then
logInfo("Scenes", "do AllOff")
groupKuecheLights.members.forEach[ item |
sendCommand(item, OFF)
]
groupWohnzimmerLights.members.forEach[ item |
sendCommand(item, OFF)
]
Thread::sleep(2000)
sendCommand(sceneAllOff, OFF)
end