Thanks for posting. Some comments on the Rules.
-
You do not need to import java.lang.String. Everything in java.lang is always available.
-
When you can hard code the name of the Item, it is best to use the method on the Item instead of the Action: e.g.
HW_ProductModel.postUpdate(transform("JSONPATH"...
. There are additional checks performed and it is often more effecient. -
Long running threads are a bad idea. Why the three second sleep in “Sync Thermostat time with Server time”? Use a Timer instead of the sleep.
-
I notice you have a sleep after all the calls to executeCommandLine. Is this to wait for the script to exit? If so, add a timeout to the call to executeCommandLine and the call will block until the script exits or the timeout time is reached. e.g.
executeCommandLine=("/home/openhab/heatmiser-wifi-read-only/openhabscripts/hw_settemp.sh "+HW_HeatingTarget.state, 5000)
will wait up to five seconds for the script to exit. -
what’s with the
=(
after every executeCommandLine -
rule “Lock Thermostat Screen Input” could be simplified to:
lock1.lock()
try {
val cmd = if(receivedCommand == ON) "1" else "2"
executeCommandLine("/home/openhab/heatmiser-wifi-read-only/openhabscripts/hw_keylock.sh " + cmd, 5000)
finally...
- The Design Pattern: Gate Keeper would be really helpful here. It would let you eliminate the lock (locks are dangerous) and centralize the enforcement of the delays between calls to all the scripts. It would result in less brittle and simpler overall code in the long run.
Overall the code looks good. Thanks for posting!