Rules execution speed

Hello,

I am executing multiple commands via single rule (like a mood or scene activation) but there is a lot of delay in this execution from pressing a button on IOS app the execution of rule and commands inside happens after 3-4 seconds this makes the user feels that nothing happened by pressing button and tend to press it again. Any pointers to improve this ?

I run system on Pi3 and “top” shows me Java taking up close to 100% of cpu most of time.
rule “LR_AllOff_Fast”… i have mix of Items from Hue to Zwave to lightwaverf in single rule as below -

//SITEMAP
Switch Item=LRAllOff mappings=[On=“All Off”]

//ITEMS
String LRAllOff “Living Room All Off”

//RULES
when
Item LRAllOff changed to ON or
Item LRBrightMood changed to OFF

then
sendCommand(PoppDimmer1LoadLevelStatus, 0)
sendCommand(PoppDimmer2LoadLevelStatus, 0)
sendCommand(LRDimmerBulb02_03, 0)
sendCommand(LRCornerLamp01, OFF)
sendCommand(LRCornerLamp02, OFF)
sendCommand(LRTallCabinetLight, OFF)
sendCommand(LRDiningAntiqueLight, OFF)
sendCommand(LRBookRackLight, OFF)

end

Mmh. A RPi3 is way fast enough and OH should need far less CPU.
Check logging, in particular increase it for rules.
<logger name="org.openhab.model.script.rules" level="DEBUG" />

Reinitializations use 100% CPU They’re taking place after you change items, rules or sitemaps.
While this is normally accomplished in less than seconds, if a rule fails to load or crashes during execution, this can become a repetitive process, resulting in permanent CPU load you’re seeing.

Thanks for the pointer … however i am using OH2 and i cannot figure out where to put the logging statement for “rules” as there is no logbook.xml in OH2 … can you suggest further.

hi Rich,

thanks i tried this - with the following updated to my logging file
the rules.log file is generated by no entries are wrttend in it … :frowning: … any help.

openHAB specific logger configuration

log4j.logger.org.openhab.model.script.rules = ALL, rules, osgi:*
log4j.additivity.org.openhab.model.script.rules = false

File appender - rules.log

log4j.appender.rules=org.apache.log4j.RollingFileAppender
log4j.appender.rules.layout=org.apache.log4j.PatternLayout
log4j.appender.rules.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss.SSS} [%-26.26c{1}] - %m%n
log4j.appender.rules.file=${openhab.logdir}/rules.log
log4j.appender.rules.append=true
log4j.appender.rules.maxFileSize=5MB
log4j.appender.rules.maxBackupIndex=5

You should use

log4j.logger.org.eclipse.smarthome.model.script = ALL, rules, osgi: *

All of the core classes have changed packages in OH 2.

I tried

openHAB specific logger configuration

log4j.logger.org.eclipse.smarthome.model.script = ALL, rules, osgi: *
log4j.additivity.org.eclipse.smarthome.model.script = false

also i tried

openHAB specific logger configuration

log4j.logger.org.eclipse.smarthome.model.script.rules = ALL, rules, osgi: *
log4j.additivity.org.eclipse.smarthome.model.script.rules = false

but both doesnt generate any logs from rules :confused:

Not sure what is wrong. The sum total of my knowledge on the subject is captured by the link I provided.