2021-13-06 05:13:10.010 [ERROR] [org.eclipse.smarthome.model.rule.runtime.internal.engine.ExecuteRuleJob ] - Error during the execution of rule 'Water Rate': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.LogAction.logInfo(java.lang.String,java.lang.String,java.lang.Object[]) on instance: null
However, I see from my MySQL log that it is not null:
06-Jan-2021 17:14:03.889 [DEBUG] [persistence.mysql.internal.MysqlPersistenceService] - mySQL: query: INSERT INTO Item6 (TIME, VALUE) VALUES(?,?) ON DUPLICATE KEY UPDATE VALUE=?;
06-Jan-2021 17:14:05.002 [DEBUG] [persistence.mysql.internal.MysqlPersistenceService] - mySQL query: item is RO_Water_Meter
06-Jan-2021 17:14:05.002 [DEBUG] [persistence.mysql.internal.MysqlPersistenceService] - mySQL: query:SELECT Time, Value FROM Item11 WHERE TIME<'2021-01-06 17:09:05' ORDER BY Time DESC LIMIT 0,1
06-Jan-2021 17:14:05.004 [DEBUG] [persistence.mysql.internal.MysqlPersistenceService] - mySQL: query returned 1 rows in 2ms
Well, yes. For the logInfo() you want it as a string, to go in a message. If you want to do maths, yep you need a number. It’s up to you how you treat it on each occasion.
var myresult = RO_Water_Meter.deltaSince(now.minusMinutes(5), "mysql") as Number
// variable is a number
logInfo("result1", myresult.toString)
// we get the string version for our text message
// but the variable is still a number
var otherresult = myresult / 5
// so we can do maths on that
logInfo("result2", otherresult.toString)