Hello everybody,
I have now dealt with the migration of the HTTP requests from OH2 to OH3. Unfortunately, a 1: 1 migration did not go as I had imagined. But not bad. I am now describing how I read out the XML website of a KOSTAL PIKO MP Plus inverter with the HTTP binding in OH3 and save the data points.
- Install The HTTP Binding
- Install the XPATH Trasformation Service
- Add A new Generic HTTP Thing
You can now name this new HTTP thing as usual and assign labels. Enter the website of the PIKO MP Plus as the URL.
Note: in order to act more dynamically with the queries later, I recommend only specifying the IP address of the MP Plus here!
After you have saved the settings, the thing should also “go online” directly. Next you can create the channels. I have prepared something here for the code definition. Since you should only enter the base URL at the beginning, you can now simply copy and paste the channel definition.
channels:
- id: Inverter_Values
channelTypeUID: http:string
label: Inverter_Values
description: ""
configuration:
stateExtension: /measurements.xml
- id: Inverter_Yields
channelTypeUID: http:string
label: Inverter_Yields
description: null
configuration:
stateExtension: /yields.xml
- id: Inverter_Events
channelTypeUID: http:string
label: Inverter_Events
description: null
configuration:
stateExtension: /events.xml
- id: Inverter_Version
channelTypeUID: http:string
label: Inverter_Version
description: null
configuration:
stateExtension: /versions.xml
Using this definition, 4 channels are created which each read out and save part of the XML string from the MP Plus. Now we can assign several items to each channel in which we filter out the individual values using XPATH.
To make it a little faster for you, I have created the items in a normal .items file. In the end you only have to adjust your channel UDID so that OH3 assigns it correctly.
Number PV1_AC_Voltage "PV1 AC Voltage [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='AC_Voltage']/@Value)"]}
Number PV1_AC_Power "PV1 AC Power [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='AC_Power']/@Value)"]}
Number PV1_AC_Current "PV1 AC_Current [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='AC_Current']/@Value)"]}
Number PV1_DC1_Power "PV1 DC1 Power [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='DC_Power1']/@Value)"]}
Number PV1_DC2_Power "PV1 DC2 Power [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='DC_Power2']/@Value)"]}
Number PV1_DC1_Voltage "PV1 DC1 Voltage [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='DC_Voltage1']/@Value)"]}
Number PV1_DC2_Voltage "PV1 DC2 Voltage [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='DC_Voltage2']/@Value)"]}
Number PV1_DC1_Current "PV1 DC1 Current [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='DC_Current1']/@Value)"]}
Number PV1_DC2_Current "PV1 DC2 Current [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='DC_Current2']/@Value)"]}
Number PV1_Inverter_Temp "Inverter 1 Temp [%s]" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Values" [profile="transform:XPATH", function="number(//Measurements/Measurement[@Type='Temp']/@Value)"]}
String PV1_WR_PU_APP "PV1 WR PU App Version" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Version"[profile="transform:XPATH", function="string(//Versions/Software[@Device='PU'][@Name='APP']/@Version)"]}
String PV1_WRHMI_APP "PV1 WR HMI App Version" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Version"[profile="transform:XPATH", function="string(//Versions/Software[@Device='HMI'][@Name='APP']/@Version)"]}
String PV1_Serialnumber "PV1 WR HMI Serialnumber" (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Version"[profile="transform:XPATH", function="string(//@Serial)"]}
Number PV1_Yield "PV1 [%s] " (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Yields" [profile="transform:XPATH", function="number(//Yields/Yield/YieldValue/@Value)"]}
String PV1_Errorcode "Errorcode PIKO MP Plus " (PV_Inverter) ["Point"] {channel="http:url:a8918fb671:Inverter_Events" [profile="transform:XPATH", function="string(//Events/Event[@Active='true']/@Message)"]}
replace every → http:url:a8918fb671 with your specific one!
You have to decide separately whether you want to create groups and co … …(PV_Inverter) [“Point”]
Otherwise, if you also want to create the items via the UI, you can do this as normal. A suitable number item would then have to be created for the AC power value and the transformation XPATH selected in the lower definition area. Then specify the actual PATH and whoosh OH diligently reads out the WR values.
I hope that this little guide will help some.