Proxy item will not update

I tried to create an proxy item. But it will not update.
The rule is fired and i can see the output in the logs.
But the update of the proxy item will not be shown.

I want to add the the power values L1, L2 L3 to calculate the balance.
Then i want to store the values to create an chart.
But i can not update the item with the display name “Saldo”. Where is my mistake?

My item is shown in the sitemap but without any display:

Items:

/* PV */
Number:Power Netzbezug_1 "Bezug L1 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l1", expire="5s"}
Number:Power Netzbezug_2 "Bezug L2 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l2", expire="5s"}
Number:Power Netzbezug_3 "Bezug L3 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l3", expire="5s"}
Number:Power Proxy_Netzbezug_Saldo "Test Netzbezug Saldo" <power>
	Frame label="PV" {
		Text item=Proxy_Netzbezug_Saldo label="Saldo" icon="qualityofservice"
		Text item=Netzbezug_1 label="L1" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_2 label="L2" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_3 label="L3" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
	}

rule "Saldiere Leistung"
  when
    Item Netzbezug_1 received update
  then
	  Proxy_Netzbezug_Saldo.postUpdate(234)
    //postUpdate(Proxy_Netzbezug_Saldo", 123)
    //logInfo("myHome Leistungs Saldo", Netzbezug_1.state.toString )
    logInfo("myHome Leistungs Saldo", "Saldo.postUpdate 234123")
end

Text item=Proxy_Netzbezug_Saldo label="Saldo [%.1f %unit%]"

@JimT has the solution to your specific problem.

I’d like to mention that a rule isn’t required to do this though. Assuming all you are doing is adding, or even if you are taking the average, you could put these three Items into a Group:Number:Power:SUM or a Group:Number:Power:AVG (I think that syntax is correct) then the aggregation function will take over from the rule.

The only gotcha is you will have to list this Group Item explicitly in the persistence config for it’s values to be saved.

Thanks. that solved my first problem…
I will check the aggregation function later…

But now i stuck at the JSONPATH Transform. And can not find a solution.
I suppose there is a syntax problem. In the log i can not see any error.

How can i get a more detailed log? openHAB 2.5 is installed on my Synology Diskstation and i checked the openhab.log (tail -f openhab.log)

Here my actual try:

Items:

/* PV */
Number:Power Netzbezug_1 "Bezug L1 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l1", expire="5s"}
Number:Power Netzbezug_2 "Bezug L2 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l2", expire="5s"}
Number:Power Netzbezug_3 "Bezug L3 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l3", expire="5s"}
Number:Power Proxy_Netzbezug_Saldo "PV Saldo [%.2f kW]" <power> {expire="5s"}
Number:Power Netz_180 "Netz 1.8.0 [%.0f]" <power> { channel="mqtt:topic:westnetz/SENSOR", expire="10s"}
Number:Power Netz_280 "Netz 2.8.0 [JSONPATH($.MT631.leistung_einspeisung):%.0f]" <power> { channel="mqtt:topic:westnetz/SENSOR", expire="10s"}
Number:Power Netz_Saldo "Netz Saldo [JSONPATH($.MT631.leistung_saldo):%.4f]" <power> { channel="mqtt:topic:westnetz/SENSOR", expire="10s"}

Sitemap:

	Frame label="PV" {
		Text item=Netz_180 label="Netz 1.8.0 [JSONPATH($.MT631.leistung_bezug):%.0f]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netz_280 label="Netz 2.8.0 [JSONPATH($.MT631.leistung_einspeisung):%.0f]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netz_Saldo label="Netz Saldo [JSONPATH($.MT631.leistung_saldo):%.4f]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Proxy_Netzbezug_Saldo label="PV-Saldo [%.3f kW]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_1 label="PV-L1  [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_2 label="PV-L2  [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_3 label="PV-L3  [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
	}

Do you have JSONPATH installed? Why are you not applying the transform at the Channel or Profile level? It’s unusual to use this transform in the Item’s label.

Note, because the result of any transformation is a String, %.0f is almost certainly going to fail. You must use %d or you need to apply the transform before the value gets sent to a Number Item.

THNX

seems my problems are nearly solved.
The JSONPATH is installed. I first set up them in the GUI and want to move them in my config files. Sorry for confusing :wink:

Only the inverting in the items won’t work.

Items:

/* PV */
Number:Power Netzbezug_1           "Bezug L1 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l1", expire="5s"}
Number:Power Netzbezug_2           "Bezug L2 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l2", expire="5s"}
Number:Power Netzbezug_3           "Bezug L3 [%.0f]" <power>  { channel="mqtt:topic:pv_anlage:netzbezug_l3", expire="5s"}
Number:Power Proxy_Netzbezug_Saldo "PV Saldo [%.0f W]" <power> {expire="5s"}
Number:Energy Netz_180             "Netz 1.8.0 [%.4f]" <power> { channel="mqtt:topic:Netzleistung:netzbezug_180",       expire="10s" [ profile="transform:JS", toItemScript="| Quantity(input).multiply(-1)" ]}
Number:Energy Netz_280             "Netz 2.8.0 [%.4f]" <power> { channel="mqtt:topic:Netzleistung:Netzeinspeisung_280", expire="10s" [ profile="transform:JS", toItemScript="| Quantity(input).multiply(-1)" ] }
Number:Power Netz_Saldo            "Netz Saldo [%.0f]" <power> { channel="mqtt:topic:Netzleistung:netzbezug_leistung",  expire="10s" [ profile="transform:JS", toItemScript="| Quantity(input).multiply(-1)" ] }

Sitemap:

	Frame label="PV" {
		Text item=Netz_180 label="Netz 1.8.0 [%.4f kWh]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netz_280 label="Netz 2.8.0 [%.4f kWh]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netz_Saldo label="Netz Saldo [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]

		Text item=Proxy_Netzbezug_Saldo label="PV-Saldo [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_1 label="PV-L1  [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_2 label="PV-L2  [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
		Text item=Netzbezug_3 label="PV-L3  [%.0f W]" icon="qualityofservice" valuecolor=[>0="green",<=0="red"]
	}

Things:

{
Thing mqtt:topic:Netzleistung {
    Channels:
      Type Number : netzbezug_leistung  [ stateTopic="westnetz/SENSOR" , transformationPattern="JSONPATH:$.MT631.leistung_saldo"]
      Type Number : netzbezug_180       [ stateTopic="westnetz/SENSOR" , transformationPattern="JSONPATH:$.MT631.leistung_saldo"]
      Type Number : Netzeinspeisung_280 [ stateTopic="westnetz/SENSOR" , transformationPattern="JSONPATH:$.MT631.leistung_saldo"]
}
}

I don’t know what you mean by “inverting in the items”. And I’ll not be much help from me if you are facing syntax errors in your text based configs. I haven’t looked at 2.5 in years, I never had my Things in .things files even when I used 2.5, and when OH 3 came out I moved all my configs to the UI.

The best I can say is make sure you have the right property names for each parameter.

The only thing I can think of based on a quick scan is [ profile="transform:JS", toItemScript="| Quantity(input).multiply(-1)" ] is almost certainly wrong. toItemScript isn’t something that existed until OH 4. It definitely wasn’t supported by OH 2. When looking at the docs, in the upper left there is a option to choose the version of OH you want the docs for.

Sorry, wrong word. I mean negating. Multiplyin by -1.

I want to backup my config. If i make all te config in the UI Ido not know how to make a backup.of it.

I switched to 2.5 maybe i used the back Button and it switched back to 4.

You’ll need a JS Transform or a rule for that.

Use openhab-cli backup or just make sure you include the userdata (/var/lib/openHAB) folder in your backup, which you should be doing anyway to have a complete backup.

Thanks for the hint.

Now I installed openHAB 4 (Docker on Synology) and trying the UI.
I created some mqtt things, created channels and linked them to new created items.

In the link i select “SCRIPT ECMAScript (ECMAScript 262 Edition 11)” in the type and set “Thing To Item Transformation” in the profile section to “| Quantity(input).multiply(-1).toString();”

and i created a link with “standard” for the original values

In the things tab i can see now that the links/ponint showing the original valu and the inverted value.

But if i create an graph in the pages section one value generates a floating average of two values. Sometimes there is a on single error.

her another try:

Strange is if i create a new link and item with a new name there ist no problem in the chart.
netz_l1 is the original value netz_l1_inv the new negated value with the error.
and a new item/link withe the name netz_l1_inv2 has no error.

I can not find where i made the mistake.