Rule error for minusHours()

I calculate electricity consumption. Every hour there is a record of the energy meter status to the influxdb. With the ud rule of the current meter reading, it subtracts the meter reading from 1 hour ago. But instead of using energy in the last hour, I get the result in two hours. Where is the mistake?

rule "Energy by hour"

when
        Time cron "0 0 * * * ?"
then
        var hour = Licznik_Import.state as DecimalType - Licznik_Import.historicState(now.minusHours(1), "influxdb").state as DecimalType
        postUpdate(LicznikLastH, hour)
end


Strategies {
everyMinute : "0 * * * * ?"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
everyWeek : "0 0 0 ? * MON "
everyMonth : "0 0 0 1 * ? "
default = everyChange
}

Items {
Licznik_Import, Licznik_Export, LicznikLastH : strategy = everyHour, restoreOnStartup
LicznikLastDay : strategy = everyDay, restoreOnStartup
LicznikLastWeek : strategy = everyWeek, restoreOnStartup
LicznikLastMonth : strategy = everyMonth, restoreOnStartup
}

well if this meant to be an hour should look like 0 0 * * * ? *

I explained it wrong. The rule calculates wrong - subtracts data from 2 hours back despite writing

Licznik_Import.historicState(now.minusHours(1), "influxdb")

No problem with starting every 1 hour.
I used the strategies from the official tutorial and there is a record for the action every 1 hour like this:
0 0 * * * ?
What does the additional sign “*” change?

If there is no record at exactly now-1 hours, (and there will not be), then by design historicState goes back in time to the next valid state. Each recorded state is assumed to stay valid until the next record in time.

You need to have a think about what you really want here - just the most recent record, perhaps?

If, say, you are recording data each hour, then historicState for (now - 1 minute) will return a record from between 1 minute and an hour ago. That record might be 2 minutes old, or 59 minutes old, etc.

Please use brackets:

rule "Energy by hour"

when
    Time cron "0 0 * * * ?"
then
    var hour = (Licznik_Import.state as DecimalType) - (Licznik_Import.historicState(now.minusHours(1), "influxdb").state as DecimalType)
    postUpdate(LicznikLastH, hour)
end

Please consider to use the method instead of the action:

    LicznikLastH.postUpdate(hour)