Hello. I’m trying and retrieve information from a JSON file. I manage to pick up the json string. But I can’t sort the data with WagoAppJSON.FbWrite_ToIEC_ByRule.
The data I try and retrieve is electricity prices in Norway during 24 hours.
VAR
FbWrite_ToIEC_ByRuleStrom : WagoAppJSON.FbWrite_ToIEC_ByRule; // Function block to sort the info from the JSON file
stringPath : STRING(20):='/'; // Path the JSON file uses
My1 : FbWrite_ToIEC_ByRule;
xHttpsGetTrigger2 : BOOL;
xWriteToIEC_Error : BOOL;
iWriteToIEC_ActualArrayRow : INT;
MyJsonData : ARRAY[0..23] OF typEnergyPrice; // JSON data to sort the data inn
bTestRule : ARRAY[0..MAX_ARRAY_ELEMENTS_CUSTOM] OF typRuleBase:=[
(sPath:='NOK_per_kWh',iConvertType:=eReal), // 1
(sPath:='EUR_per_kWh',iConvertType:=eReal), // 2
(sPath:='EXR',iConvertType:=eReal), // 3
(sPath:='time_start',iConvertType:=eString), // 4 Tride to use eTime but got error
(sPath:='time_end',iConvertType:=eString) // 5
];
END_VAR
FbWrite_ToIEC_ByRuleStrom( // Function block to sort the info from the JSON file
sPathBase:= stringPath,
pDataIn:= ADR(unHttpsGetRxBuffer.sVar),
udiSizeDataIn:= SIZEOF(unHttpsGetRxBuffer.abVar),
aRule:= bTestRule,
pIecVariable:= ADR(MyJsonData),
iArraySizeIecVariable:= 24,
udiSizeIecVariable:= SIZEOF(MyJsonData),
xError=> xWriteToIEC_Error,
iActualArrayRow=> iWriteToIEC_ActualArrayRow,
xTrigger:= xHttpsGetTrigger2 ); // xHttpsGetTrigger2 = TRUE to run
Hi @espenbo ,
For this purpose, the SAX parser of the WagoAppJSON is perfect.
You just need to define the token, and the associated rule to process the string data.
You’ll find attached the way to implement it in your example. eCockpit_Json.txt (139.7 KB)
(This is an export file change the extension file to .export)
Set xTriggerJSONParser to start the parsing process.
I see that you created some big function for formatting time, take a look at WagoAppString.TimeComponents_To_String where you can easy format time/date:
I am continuing to work on this project and have added HMI tables. I also added extra information in typEnergyPrice.
There I added iArrayPlace to have an overview of where in the array the info is located when I sort from cheap to most expensive. But when I added iArrayPlace then I get weird values in HMI tables
I’am working in a project similar to you. I have to decode a LoraWan Signal to the wago parcel. For that i’am using IoT Sensors. Those sensors will send the information into the LoraWan.
Hello,
Yes this library will suit your requirement.
We also have a LoRaWAN solution based on Multitech gateways in France
We have already decoded Watteco, Adeunis, and Nexelec sensors.
I know this is an old thread, but have to try anyway.
I’m using FbHTTPs_Get, where the receive buffer is dword, how do I convert it to string or json-format? From your posts it seems like you display stringformat on the functionblock.
I’ve recently started looking at this, and used “https://www.hvakosterstrommen.no/api/v1/prices/2022/10-30_NO5.json” as example, as interfacing my router was obviously too hard due to certificate issues, but need to resolve the basics before I take the next step. There are no errors in the status of the function block.
I wasn’t interested in hvakosterstrommen in particular, so I’m sorry if it feels like I’m kidnapping your thread.
I was looking for help on how to handle the incoming data from a httpsget-request and how to use the WagoAppJSON.FbWrite_ToIEC_ByRule. I couldnt figure out why my project only had numbers in the receive buffer, while I noticed you had text.
My project is about my PLC communicating with a 5G-routers API (Rutx50) in order to send SMS. For that I need to send a login request to the router and single out the authorization token to use in my following request to send the SMS. Not sure how it will work yet.
Looks like you got the solution, grate:) I have used the RUTx09 with Tailscale to get a mesh VPN. But it looks like grate fun to use it to send SMS messages to. Don’t worry about kidnapping the tread, I just want to read about more projects and solutions, so anything you can share is grate.