Yes, you can enable processing.computedAttributes.lastAttributes
. You need to prefix attributes with last
. For example, fuelLast
.
did not understood if it is with capital L or not as you wrote both ways :) But will try with capital:
Attribute: Fuel
io48 ? (io48 - io48Last) == 1 ? io48Last * 0.7 : io48 * 0.70 : null
io48 fuel percentage, if it increases by 1% then keep the previous value in fuel (0.7 - 70 litres fuel tank). Hope the expression is correct.
Sorry, it's actually a prefix. It should be lastFuel
.
I added the configuration:
<entry key='processing.computedAttributes.lastAttributes'>true</entry>
but the following still gives undefined lastio48 on the test message
io48 ? (io48 - lastio48) == 1 ? lastio48 * 0.7 : io48 * 0.70 : null
ignore the undefined on the test message or is there an issue with lastio48 that I am missing ?
It should be lastIo48
.
It worked perfectly. Thanks Anton. So after the prefix, the attribute must be with capital first letter.
Correct.
I realized that comparing with the previous io48 will not work if there will be 2 consecutive io48 with wrong values (slightly increased).
I tried using lastFuel but apparently it is not working :
Attribute: Fuel ```
``` Expr: (lastFuel && io48) ? ((io48- lastFuel) > 0 && (io48 - lastFuel) < 3 ) ? lastFuel : io48 * 0.70 : null ```
Does it not work to take previous computed attribute and only works to take previous attributes reported by the device ?
Previous computed attribute should work.
I would like to compare an attribute (or computed attribute) with the previous value and I dont know if it is possible.
I am getting from time to time a small increase in fuel from the device which corrects itself and dont want to see those fluctuations in the graph.
Would processing.computedAttributes.lastAttributes help in this case ? And if so, what would be the configuration and how to use the previous value in the computed attributes expression ?