OpenUrl question

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
ressof
Posts: 60
Joined: Thursday 20 April 2017 7:20
Target OS: Linux
Domoticz version: Latest
Contact:

OpenUrl question

Post by ressof »

Hi

I writing a script to check electical prices from Nord Pool that uses this URL:

Code: Select all

https://dataportal-api.nordpoolgroup.com/api/DayAheadPrices?date=2024-10-19&market=DayAhead&deliveryArea=SE3&currency=SEK
You can use tomorrow date in the url but the url is only valid sometime after 13:00. Is there a way to check if the URL is valid before I'm trying to open it? If I try to open url from 13:00 and its not valid I get an error message in the log that I don't want.
User avatar
habahabahaba
Posts: 190
Joined: Saturday 18 March 2023 14:44
Target OS: Windows
Domoticz version: 2024.4
Contact:

Re: OpenUrl question

Post by habahabahaba »

You can try smth like this (curl is needed):

Code: Select all

 	local handler1 = io.popen('curl -s -o /dev/null -w "%{http_code}" "URL_to_check" ')
        local response1 = handler1:read('*a')
            
            
            if (response1 == "200") then  -- if OK
            
            
            end
ressof
Posts: 60
Joined: Thursday 20 April 2017 7:20
Target OS: Linux
Domoticz version: Latest
Contact:

Re: OpenUrl question

Post by ressof »

Thank you for your help
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest