The name 'lastCount' cannot be resolved to an item or type

Hi,
i´m on OH 1.8.3. Can i use lastCount inside a rule?

In my rule i get the error from the title.

Here you can see my rule, items file, error message and so on…
https://community.openhab.org/t/s0-counter-from-power-meter-how-to-get-kwh/20335/10

Please can anybody help me?

var lastCount = 0

var newCommand = (receivedCommand as DecimalType).intValue

lastCount = newCommand

lastCount is I think a ‘primitive’, so things will go wrong when you try to fit a DecimalType object into it. Maybe cast lastCount as a DecimalType too.

Starting a new thread because your original one has not been answered within a few hours is usually considered “poor form”.

1 Like

Sorry, i thought, that with this special thread title of the initial thread only people look inside it, which want to get information about this.

Bit lastCount has nothing to do with power meters - it is a general thing.

I will wait some time longer next time.

Can you tell me, how i can make a decimalType out of lasCall?

Maybe this way:

var lastCount = 0 as DecimalType

Please use the other thread: