If you need to get some data from the Internet into a program running on a PLC. Typically spot energy prices or weather forecast. You can use the new Text Parser function. This function requires a PLC with .NET driver support, from the current offer these are the markMXL, mark520, w751-9301 and windows runtime models. We will show it with the windows runtime, it is installed automatically with Domat IDE, it is an unlicensed free version that runs for 20 minutes. So let's start the runtime and the IDE. We assign the plc and download the configuration. We will add a channel with the Text Parser protocol and two devices to it. The first will be on the weather and the second on the spot price of electricity.
I found a weather resource on the server api.met.no, it is filled in as the address of the device, and the parameter with a specific location is filled in the path field, in my case /weatherapi/locationforecast/2.0/compact?lat=50.01&lon=15.68.
For a test, I can put the entire address in the browser and I should get to the page where all the data is, here I have to find the necessary value, for example, we are interested in the current temperature, we can find it embedded in properties.timeseries[0].data.instant. details.air_temperature so we copy it as group parameter, http method is GET and type is Jpath, other supported ones are Xpath and regex.
We will add a data point to this group and call it temperature, the data type is real.
For spot prices, I found an api at the address spotovaelektrina.cz, when we click on the api at the bottom, we get to the path for the json api, so, similar to the temperature, we put the address spotovaelektrina.cz from the device field and into the path /api/v1/price/get-actual -price-json,
we create a group again and the jpath is now simply $.priceCZK,
we add a data point and done, we can upload to the plc, turn on debug and we should see the correct values.
Please keep in mind that you are using third-party services, so if the provider changes something or cancels it completely, it will stop working in the PLC program as well.