[SOLVED] Previousstate in notification rule

Do you have persistence set up?

yes, i am using mysql as default persistence service and also influxdb as a second service to play a bit around with grafana.

Are these items persisted?
And what does the error log show?

Try changing it to :

TankstelleHoyerDodenhof_E10.previousState.state

thanks! its working with previousState.state!

now i get a number (just with a lot of digits after “,” - can you also tell me how to cut it to 3 digits?)

Based on a previous post , try replacing this:

(" +TankstelleHoyerDodenhof_E10.previousState+ "€)

with this:

(" + String::format("%1$3d", TankstelleHoyerDodenhof_E10.previousState.state) + "€)
1 Like

thanks for your fast reply, but this doesnt seem to work, i get the following entry in the log:

==> /var/log/openhab2/openhab.log <==

2018-05-09 21:42:54.102 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Spritpreise': d != org.eclipse.smarthome.core.library.types.DecimalType

==> /var/log/openhab2/events.log <==

Try changing the d for an f
d is for integers
f for floats

(" + String::format("%1$3f", TankstelleHoyerDodenhof_E10.previousState.state) + "€)

tried it out, almost same result:

2018-05-09 21:47:18.310 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Spritpreise': f != org.eclipse.smarthome.core.library.types.DecimalType

"%1$03f"

2018-05-09 21:55:01.195 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Spritpreise': f != org.eclipse.smarthome.core.library.types.DecimalType

"%.3f"

sorry for getting on your nervs, but:

2018-05-09 22:11:48.005 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Spritpreise': f != org.eclipse.smarthome.core.library.types.DecimalType

I was reading the docs but I ran out of ideas now…

ok, but thank you very much for trying to help me!

is it possible that its not working because the item is a number and no string?

No, one of these will work, we just have to find the right one…

...(" + String::format("%1$03f", (TankstelleHoyerDodenhof_E10.previousState.state as DecimalType).floatValue) + "€)...

almost :slight_smile: we are getting closer!

dont mint the UNDEF - this gas station is already closed.

Back to:
"%.3f"

great! thank you for beeing so patient! thank you very much!