* Platform information:
* Hardware: Raspberry Pi 4 Model B Rev 1.1, 4 GB RAM, 256 GB SSD
* OS: Linux/4.19.118-v7l+ (arm)
* Java Runtime Environment: Azul Systems 11.0.8 (Zulu11.41+75-CA)
* openHAB version: 3.0.0 Build #1958
Hi all,
i have a Homematic HM-ES-PMSw1-Pl Wireless Switch Actuator 1-channel with power metering and i want to collect the power usage per day, month and year based on a “energy rule” in which i use the deltaSince extension of the rrd4j persistence service.
Unfortunately the rule ends with an error “Could not invoke method … on instance null”.
log snippet
Summary
This text will be hidden
2020-10-07 12:14:55.399 [INFO ] [enhab.core.model.script.HM_FSD.rules] - HM_FSD ENERGY_COUNTER Änderung - Anfang
2020-10-07 12:14:55.411 [INFO ] [enhab.core.model.script.HM_FSD.rules] - HM_FSD ENERGY_COUNTER Änderung - Funk_Steckdose_EnergyCounter: 48785.40 Wh
2020-10-07 12:14:55.416 [INFO ] [enhab.core.model.script.HM_FSD.rules] - HM_FSD ENERGY_COUNTER Änderung - strom_verbrauch_tag: 0
2020-10-07 12:14:55.419 [INFO ] [enhab.core.model.script.HM_FSD.rules] - HM_FSD ENERGY_COUNTER Änderung - tagesanfang: 2020-10-07T00:00
2020-10-07 12:14:55.422 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.persistence.extensions.PersistenceExtensions.deltaSince(org.openhab.core.items.Item,java.time.ZonedDateTime) on instance: null in HM_FSD
Funk_Steckdose_EnergyCounter is of type Number:Energy
The rrd4j persistence service of the item Funk_Steckdose_EnergyCounter also have values for the required time frame from start of day.
I dont understand the error “Could not invoke method … on instance null” because the variable tagesanfang is not null and the item Funk_Steckdose_EnergyCounter is also not null.
Have you any reason to think that deltaSince uses rrd4j? (That’s a hint about default persistence)
rrd4j is the default persistence service but for sure i insert the string “rrd4j” into the command.
I’ve not seen people use LocalDateTime in connection with persistence before, I wonder if that is a suitable datetime type.
The usage of now.withTimeAtStartOfDay() instead of LocalDate.now().atStartOfDay() results in an error message
2020-10-07 15:01:47.475 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: 'withTimeAtStartOfDay' is not a member of 'java.time.ZonedDateTime'; line 37, column 17, length 26 in HM_FSD
so i decided to use LocalDate.now().atStartOfDay() .
Add a line to fetch and display historicState to see if that works.
To fetch a value with historicState also results in the error message
2020-10-07 15:21:37.997 [INFO ] [enhab.core.model.script.HM_FSD.rules] - HM_FSD ENERGY_COUNTER Änderung - Anfang
2020-10-07 15:21:38.011 [ERROR] [internal.handler.ScriptActionHandler] - Script execution failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.persistence.extensions.PersistenceExtensions.historicState(org.openhab.core.items.Item,java.time.ZonedDateTime,java.lang.String) on instance: null in HM_FSD
Joda-Time was removed in OH3. Use ZonedDateTime instead. This is one of the more impacting breaking changes that will affect people still trying to use legacy rules DSL. With scripted automation, you can just add it back in.
Joda-Time was removed in OH3. Use ZonedDateTime instead. This is one of the more impacting breaking changes that will affect people still trying to use legacy rules DSL. With scripted automation, you can just add it back in.
This is the solution. After using ZonedDateTime the extension deltaSince of the persistence service rrd4j delivered a value and the rule ended without an error.