If we want to convert UnixTime to local time, we can use an external service, e.g.: https://unixtime.co.za/.
According to the example on: https://unixtime.co.za/,
the API query looks like as following:
API call: https://showcase.api.linx.twenty57.net/UnixTime/fromunix?timestamp=1549892280.
Below is presented how we can easily perform this conversion. In the example, we will use data on sunrise from the OpenWeatherMap website - an example of receiving data is available at the link:
https://support.grenton.pl/en/support/solutions/articles/35000164999-gate-http-receiving-information-from-the-openweathermap-website.
- Create the HttpRequest periphery object:
- The following parameters should be set in the HttpRequest object:
Where:
Host: https://showcase.api.linx.twenty57.net
Path: /UnixTime/fromunix
QueryStringParams: \z
Warning! The QueryStringParams feature will be set using a script based on data received from the OpenWeatherMap website. - The next step is to create user features of the string type:
- Then prepare the script:
Assign the script to the OnResponse event in the HttpRequest periphery object:
Additionally, a script that will set the value of the QueryStringParams feature should be created:
Then, the configuration should be sent to the CLU.
After the configuration has been successfully sent, read information from OpenWeatherMap website.
In the next step, call the script responsible for setting the QueryStringParams feature and sending the request.
After calling the script, the StatusCode feature should receive the value 200.
User feature value should receive appropriate value.
- The obtained data can be displayed in the mobile application and Smart Panel or use to create logic in the system (e.g. setting rules in the Calendar virtual object).