I use a global Variable in the riules:
var long Licht_Carport_start = now.millis
Variable ‘Licht_Carport_start’ on rule file ‘haus.rules’ cannot be initialized with value ‘.millis’: An error occured during the script execution: The name ‘now’ cannot be resolved to an item or type.
What do I have to include to make that working?
I allready have:
On another thread someone was noticing and having a problem with the fact that it takes a little bit before now becomes usable. At the time that the rules file is loaded and parsed now is not yet available for use so it can’t populate that var yet.
They initialized the val to null and then check for null in the rules and set it to now.millis at that point. However, it can’t be a long to do that, you will either have to store it as Long or just store the Joda DateTime.
O.K., so it’s the “now”.
I changed it like you said, and went on to use Number Items instead of global variables. But I now have a problem with casting/conversion of the Number item to do calculations with it.
please see: Need help Number conversion/casting