[SOLVED] Update Virtual Item with value of Group Item multiplied by Fixed Value

Hi Guys,
Need some help with a rule to estimate cost of energy used

Idea is to get Group KwH multiplied by cost per KwH (22 cents) to then update a virtual item.

I realise I have to change the Group:Number:AVG to Group:Number:SUM for accuracy, but at the moment just trying to work out the rule to get a value

Rule:

rule "Kw into $"
when
    Group gkWh changed 
then
    val production = triggeringItem.state as Number
    VI_Energy_Cost_Month_So_Far.postUpdate(production * 0.22)
end

Items

Group:Number:AVG	gkWh	"kWh"	<energy>	 (Home)	["Energy"]

Number	VI_Energy_Cost_Month_So_Far	"Energy Cost So Far this Month"	

Any help would be much appreciated

EDIT: Log File Output from rule

2019-12-23 10:21:31.682 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model 'energy_cost.rules' has errors, therefore ignoring it: [3,5]: no viable alternative at input 'Group'

Shouldn’t that be

VI_Energy_Cost_Month_So_Far.value.postUpdate(production * 0.22)

I will try that, but per my edit above, I seem to be getting stuck on line 3

Group gkWh changed

I’ve learned this stuff by copying, pasting from the community and then editting to suit my needs, so not too sure where i’m going wrong

It appears adding the When statement to look for the Group is the issue. Changing it to an Item cleared the output faults in VS Code and updated the Virtual Item:

rule "Kw into $"
when
    Item gkWh changed 
then
    val production = triggeringItem.state as Number
    VI_Energy_Cost_Month_So_Far.postUpdate(production * 0.22)
end
2019-12-23 12:49:22.510 [GroupItemStateChangedEvent] - gkWh changed from 772.422 to 772.438 through GF_Lounge_Rear_SS_kWh
2019-12-23 12:49:23.028 [vent.ItemStateChangedEvent] - VI_Energy_Cost_Month_So_Far changed from NULL to 169.93636

@Bruce_Osborne FYI when using

VI_Energy_Cost_Month_So_Far.value.postUpdate(production * 0.22)

I got the error below

2019-12-23 12:38:22.816 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Kw into $': 'value' is not a member of 'org.eclipse.smarthome.core.library.items.NumberItem'; line 6, column 5, length 33