I just noticed while converting my rules from DSL to JSR that the return value from a persistence action is not directy usable for comparison (ie. higher/less than) without converting it to string and then float.
myVal = pe.averageSince(ir.getItem("myItem"), DateTime.now().minusMinutes(10), "jdbc")
if (myVal > 50): <- This doesn't work correctly, the comparison is not "numerical"
This however works: if (float(str(myVal) > 50):
I don’t know if this is as designed or if I’m doing something wrong, could it be worth adding to the Wiki in the persistence action section as a note? Could save some users some time
items is included in the default scope for scripted automation and is not part of the helper libraries. But, the Jython HLs allow you to save a couple key strokes (I still don’t use this myself) and get an Item’s state from items as an attribute rather than treating it as a dict…
Not at all. It’s a learning activity. It also shows that even if something is in the docs doesn’t mean we know to look there. I’ve seen items[“MyItem”] in lots of examples. It never occurred to me to look at the docs to see if there is another way.
This kind of stuff can help us with the docs. We should settle on one way and stick to it where possible.