I’m getting an error I don’t understand why this is an error.
[me.internal.engine.RuleContextHelper] - Variable ‘start_boost’ on rule file ‘hotwater.rules’ cannot be initialized with value ‘.millis’: The name ‘now’ cannot be resolved to an item or type; line 9, column 24, length 3
// rules
//import org.joda.time.DateTime
var ESP_URL = 'http://esp8266-1950B1/rpc/relay'
var String HWupdateURL= "http://localhost/hotwaterbooster.php"
var Timer myTimer = null
var HotwaterLow = 37.0
var BoostTime = 60
var HotwaterTempBefore = 0.0
var long start_boost = now.millis
var email = "home@xxxxx"
Thinks; this seems to a global variable. Note that “now” would be evaluated once only, at the time of the rule file being loaded. And the variable would remain set to that same value until next reload.
From past experience, trying to do evaluations in the rule file global context doesn’t seem to work as you expect anyway.
var xx = 1 // works
var yy = xx + 1 // does not work I think
// xx is available to rules but not in global context
// I guess same applies to 'now'
Note weirdly enough I refreshed the rule by doing a edit save without changing anything and it works now as usual, it only happen after restart of openhab the other day
2018-06-15 21:33:01.594 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Records last thermostat update time': The name 'postUpdate' cannot be resolved to an item or type; line 47, column 3, length 48
2018-06-15 21:33:03.426 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'John's Phone': The name 'NULL' cannot be resolved to an item or type; line 66, column 23, length 4
My rule is quite simple and shouldn’t fail - it’s the check with NULL that it complains about:
rule "John's Phone"
when
Item Johns_Phone changed
then
logInfo("John's Phone", "John's Phone State Updated: " + Johns_Phone.state)
if (previousState == NULL) return;