Issue of the topic: please be detailed explaining your issue
Please post configurations (if applicable):
Items configuration related to the issue Number Stromzaehler_Verbrauch_Tag "Verbrauch heute [%.2f kWh]" (Strom) Number Stromzaehler_kWh "Zählerstand [%.2f kWh]" (Strom)
Sitemap configuration related to the issue
Rules code related to the issue
rule "Stromzaehler Verbrauch Tag"
when
Item Stromzaehler_kWh received update
then
Stromzaehler_Verbrauch_Tag.postUpdate(Stromzaehler_kWh.deltaSince(now.withTimeAtStartOfDay))
end
and in the rrd4j.persist database I added
Stromzaehler_kWh : strategy = everyMinute, restoreOnStartup
Stromzaehler_Verbrauch_Aktuell : strategy = everyMinute, restoreOnStartup
Stromzaehler_Speicher_Tag : strategy = everyMinute, restoreOnStartup
I tried to implement the rule over the GUI “Rules” and I tried to add the rule above in “DSL Rule”
Nothing worked.
The best way to get help for UI generated rules is to post the entire rule structure. Without that we’re only guessing. Click on the Code tab in the upper right of the window when looking at the rule and copy paste the whole text you find there.
In this case, without seeing the full rule structure, the best guess is that you pasted the entire text of the rule into the script window. This isn’t how the UI rules work, because much of the rule structure is already accounted for in the other parts of the rules window. So when converting a DSL rule to a UI rule with a DSL script action you just paste the code of the then section into the action script. The when section of the rule should already be accounted for by the trigger section that you have set.
Hi Rich,
I get the following error in the console
16:58:31.888 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘910dc4bd36’ failed: Stromzaehler_Verbrauch_Tag. ___ postUpdate(Stromzaehler_kWh.deltaSince(now. ___ withTimeAtStartOfDay))
The method or field withTimeAtStartOfDay is undefined for the type ZonedDateTime; line 1, column 70, length 20
Ambiguous feature call.
The extension methods
postUpdate(Item, State) in BusEvent and
postUpdate(Item, Number) in BusEvent
both match.; line 1, column 27, length 10
17:00:43.809 [ERROR] [.internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘910dc4bd36’ failed: Stromzaehler_Verbrauch_Tag.postUpdate( ___ Stromzaehler_kWh)
Type mismatch: cannot convert from NumberItem to State; line 1, column 38, length 16
Because now.withTimeAtStartOfDay doesn’t exist, the call to deltaSince fails and Rules DSL can’t figure out what you mean in the postUpdate.
Well, that doesn’t make much sense. Stromzaehler_kWh is an Item. You can’t update an Item to another Item. You need to update Items with a State. Maybe try Stromzaehler_kWh.state?
No, as the errors make clear, neither are numbers.