Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

Need help with getting info from a string with live rain website


kooy

Question

Hope you guys can help me.

 

I found a website that can give you realtime rain info on a specific lat and long values.

 

It can predict rain in your area upto 2 hours upfront.

 

now my only trouble is how to get the right info from the website.

 

As it stand now im getting info like this

 

000|20:50 000|20:55 000|21:00 000|21:05 000|21:10 000|21:15 000|21:20 000|21:25 000|21:30 000|21:35 000|21:40 000|21:45 000|21:50 000|21:55 000|22:00 000|22:05 000|22:10 000|22:15 000|22:20 000|22:25 000|22:30 000|22:35 000|22:40 000|22:45 000|22:50

 

where 000 is the amount of rain and timestamp (lucky me no rain at least till 22:50)

 

What i would like is to get the info only for the next 15 minutes.

so if my local time 21:15 i would like to get the info for 21:30 which looks like 000|21:30

 

How to get the 000 part out of the string at 21:30?

 

i tried

str = string.match(response, "21:10")

fibaro:debug(str)
but that only get the me right time and i need the 3 chars before that.
 
 
 
 

 

 

 

Link to comment
Share on other sites

Recommended Posts

  • 0

strange... is your code

i will reboot and see what happens then, sometimes that helps

Link to comment
Share on other sites

  • 0

I just grabbed the original VD and changed the code and url. But still with the same result.
Found out that I had made an adjustment to the code

 

maybe stupid question but does https even work with this code ?

 

 BR = Net.FHttp("https://br-gpsgadget.azurewebsites.net",80);

  local response, status, err = BR:GET("/data/raintext?lat="..lattitude.."&lon="..longitude);

 

In a scene I get right response with this code ...

dont know how to intergrate it into this.

 

Please login or register to see this code.

 

Edited by D-Vine
Link to comment
Share on other sites

  • 0
10 hours ago, D-Vine said:

"https://br-gpsgadget.azurewebsites.net/data/raintext?lat=52.3&lon=5.27"


btw in my HC3 QuickApp I got an 404 response error, because I got in the latitude and longitue more than 2 figures after the   .


(I use the latitude and longitude initially from the HomeCenter location)

 

Using that same url in the browser, did not give an error

 

Just for your information

Link to comment
Share on other sites

  • 0
On 8/12/2020 at 5:07 PM, D-Vine said:

Please login or register to see this code.

 


So this code doesn’t work anymore?

 

 

Link to comment
Share on other sites

  • 0

It is already text, more text is not possible

 

Please login or register to see this code.


 

--

-- Buienradar Virtual Device (Lambik version 20161112)

--

-- Original code written by boerremk, all credits to him!

--

Please login or register to see this link.

-- 

-- 

-- Additional adjustments and extra code made by Lambik (20160621):

--  # added: option to change Telegram global variable

-- # added: option to change Buienradar global variable (max 15 characters, ID of this VD will be added at the end)

-- # added: symbols (table) instead of normal text to show in labels

-- # added: two report values in one label row

-- # changed: error report to top label

-- # removed: unnecessary labels deleted

-- # added: some additional headers and remarks

-- # added: Pre-text to show in message

-- Other adjustments:

-- # 20160903 changed: Buienradar URL

-- # 20160903 added: remark symbols to use

-- Bug fixes:

-- # 20161007 line near 179 changed (solved by boerremk):

-- if (response ~= nil ) then --> if (response ~= nil and response ~="") then

-- # 20161111 lines near 87 changed (solved by boerremk):

-- lattitude = jsonTable.latitude  -->  lattitude = round(jsonTable.latitude,2)

-- longitude = jsonTable.longitude -->  longitude = round(jsonTable.longitude,2) 

-- Remark:

-- # Pushover/E-mail options are not tested

 

--

-- ℹ Initialisation of user settings (change if necessary)

--

local debug = true; -- Enable (default, true) or disable (false) general debug output 

local beforeRain = 15; -- in minutes, time to send message before rain

local afterRain = 15; -- in minutes, time to set Buienradar to 0

local push = {false,"fibaro",{1073,1103}}; -- false (off) or true (on), use pushover or fibaro, ID of phone(s) (seperated by comma, only used for Fibaro push)

local email = {false,{2}}; -- false (off) or true (on), ID of account(s) (seperated by comma)

local telegram = {true}; -- Enable (true) or disable (default, true) sending logs to Telegram

local telegramGlobalVarName = 'Telegram'; -- Name of Telegram global variable to send messages to

local prio = "0"; -- priority of pushmessage, only used for Pushover

local startTime = "07:00" -- time to start messages

local stopTime = "23:00"; -- time to stop messages

local runTime = 5; -- in minutes

local globVarName = 'VD_Buienrad_'; --  Name of global variable to store status (max 15 characters, 3 characters ID of this VD will be added at the end)

local symbolTextTable = { -- Symbols to show in this VD

  timeActual = '?',  -- Symbol/Text for the actual time

  timeExpected = '', -- Symbol/Text for predicted time

  rainExpected = '⛆', -- Symbol/Text (top label) when rain is expected

  rainNotExpected = '', -- Symbol/Text (top label) when rain is not expected

  rainPredicted = '', -- Symbol/Text (update-labels) to show when rain is predicted

  rainNotPredicted = '', -- Symbol/Text (update-labels) to show when no rain is predicted

  errorGetData = '⚠', -- Symbol/Text (error label) to show if error occurs getting data

  rainExpectedMsg = 'Rain expected' -- Pre-text to send in message

  };

-- Other symbols you could use: 

-- Sun (bright): ☉ 

-- Sun (dark): ☀

-- Cloud (with sun): 

-- Cloud (light): ☁

-- Cloud (raining): ⛈

-- Rain: ⛆

-- Umbrella: ☂

-- Umbrella (rain):  

--

-- Initialisation (do not change)

--

local selfId = fibaro:getSelfId();

local currentTime = os.date("%H:%M");

local currentDate = os.date("*t");

local label = "";

local msg = "";

local raintime = "";

local globVarName = globVarName..selfId; -- add ID of this VD to the used global variable name

local reportLabelText = '';

 

--

-- Funtions (do not change)

--

local function log(str) if debug then fibaro:debug(tostring(str)); end; end

local function errorlog(str) fibaro:debug("<font color='red'>"..tostring(str).."</font>"); end

 

function latlon()

  if HC2 == nil then

    HC2 = Net.FHttp("127.0.0.1",11111);

  end

  local response ,status, err = HC2:GET("/api/settings/location");

  if (tonumber(status) == 200 and tonumber(err)==0) then

    if (response ~= nil) then

      jsonTable = json.decode(response)

      lattitude = round(jsonTable.latitude,2) -- Bugfix 20161111 by boerremk

      longitude= round(jsonTable.longitude,2) -- Bugfix 20161111 by boerremk

    end

  end

end

 

function globalVar(var)

  if fibaro:getGlobalValue(var) ~= nil and fibaro:getGlobalValue(var) ~= "" then

    return fibaro:getGlobalValue(var)

  else

    if HC2 == nil then

      HC2 = Net.FHttp("127.0.0.1",11111);

    end

    local response ,status, err = HC2:POST('/api/globalVariables','{"name":"'..var..'","value":"0"}');

    if (tonumber(err)==0) then

      log("Global variable "..var.." created");

    end

    return "0"

  end

end

 

function trim(s)

  return (s:gsub("^%s*(.-)%s*$", "%1"))

end

 

function split(s, pattern, maxsplit)

  local pattern = pattern or ' '

  local maxsplit = maxsplit or -1

  local s = s

  local t = {}

  local patsz = #pattern

  while maxsplit ~= 0 do

    local curpos = 1

    local found = string.find(s, pattern)

    if found ~= nil then

      table.insert(t, string.sub(s, curpos, found - 1))

      curpos = found + patsz

      s = string.sub(s, curpos)

    else

      table.insert(t, string.sub(s, curpos))

      break

    end

    maxsplit = maxsplit - 1

    if maxsplit == 0 then

      table.insert(t, string.sub(s, curpos - patsz - 1))

    end

  end

  return t

end

 

function round(val, decimal)

  if (decimal) then

    return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)

  else

    return math.floor(val+0.5)

  end

end

 

function message(msg)

  local requestBody = '&priority=' ..prio ..'&title=Buienradar&message=' ..msg;

  if email[1] then

    for i=1, #email[2] do

      fibaro:call(email[2], "sendEmail", "Buienradar", msg);

    end

  end

  if telegram[1] then

    fibaro:setGlobal(telegramGlobalVarName, msg)

  end

  if push[1] then

    if string.lower(push[2]) == "pushover" then

      fibaro:setGlobal("Pushover", requestBody)

    elseif string.lower(push[2]) == "fibaro" then

      for i=1, #push[3] do

        fibaro:call(push[3], "sendPush", msg);

      end

    end

  end

end

 

function checkRain()

  rain = false;

  raintime = "";

  reponseTable={};

  values = 0;

  if BR == nil then

    -- Changed 20160903: BR = Net.FHttp("gps.buienradar.nl",80);

    --BR = Net.FHttp("gadgets.buienradar.nl",80);

    BR = Net.FHttp("https://br-gpsgadget.azurewebsites.net",80); 

  end

  -- Changed 20160903: log("http://gps.buienradar.nl/getrr.php?lat="..lattitude.."&lon="..longitude)

  log("https://https://br-gpsgadget.azurewebsites.net/data/raintext?lat="..lattitude.."&lon="..longitude)

  -- Changed 20160309: local response, status, err = BR:GET("/getrr.php?lat="..lattitude.."&lon="..longitude);

  local response, status, err = BR:GET("/data/raintext?lat="..lattitude.."&lon="..longitude);

  if (tonumber(status) == 200 and tonumber(err)==0) then

    if (response ~= nil and response ~="") then -- Bugfix 20161007 by boerremk

      log("Gegevens opgehaald");

      fibaro:log("Getting data...")

      response = trim(response)

      --log(response)

      responseTable = split(response, "\n")

      local values = 0;

      for i=1, (#responseTable) do

        rainT = responseTable:sub(1,3)

        timeT = responseTable:sub(5,9)

        rainSymbol = false

        --log("take1: "..timeT..":"..rainT)

        if tonumber(timeT:sub(1,2)) <= 2 then

          timeTN = tostring(tonumber(timeT:sub(1,2)) + 24) .. timeT:sub(3) or symbolTextTable.errorGetData

        else

          timeTN = timeT

        end

        if (currentTime <= timeT or currentTime <= timeTN) and values < 14 then

          log(timeT..":"..rainT)

          values = values + 1

          rainfall = round(10^((tonumber(rainT)-109)/32),1)

          if rainfall > 0 and tonumber(rainT) > 77 then

            if rainfall >= 1 or tonumber(responseTable[i+1]:sub(1, 3)) > 77 then

              rain = true

              rainSymbol = true

              if raintime == "" then

                raintime = timeT;

                log(raintime)

              end

            end

          end

          -- Determine rain prediction symbol to show in label

          if rainSymbol then

            reportText = symbolTextTable.timeExpected..' '..timeT..' '..symbolTextTable.rainPredicted..' '..string.format("%.1f", rainfall);

            else

            reportText = symbolTextTable.timeExpected..' '..timeT..' '..symbolTextTable.rainNotPredicted..' '..string.format("%.1f", rainfall);

            end

          -- Report two values in one label

          if (values %2 == 0) or values == 14 then

            labelRow = round(values/2);

            fibaro:debug('i = '..i..' number of tablevalues = '..#responseTable..' valuecounter: '..values..' labelRow: '..labelRow );

            reportLabelText = reportLabelText..' - '..reportText;

            fibaro:call(selfId, "setProperty", "ui.lblBuienradar"..labelRow..".value", reportLabelText);

            else

            reportLabelText = reportText;

            end

          label = label .. timeT .. ": " .. rainfall .. "%0A"

        end

      end

      fibaro:call(selfId, "setProperty", "ui.lbllastUpdate.value", os.date("%c"));

      return true

    else

      fibaro:call(selfId, "setProperty", "ui.lbllastUpdate.value", symbolTextTable.errorGetData);

      return false

    end

  else

    fibaro:call(selfId, "setProperty", "ui.lbllastUpdate.value", symbolTextTable.errorGetData);

    return false

  end

end

--

-- Code (do not change)

--

latlon()

buienradar = globalVar(globVarName)

log("buienradar: "..buienradar)

 

if checkRain() then

  log(rain)

  if rain and buienradar == "0" then

    log("rain and 0")

    counter = 1

    while counter <= math.floor(beforeRain/runTime) and rain do

      log("rain and counter: "..counter)

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainExpected..' '..symbolTextTable.timeExpected..' '..raintime);

      counter = counter + 1

      fibaro:sleep(runTime*60*1000)

      tmp = checkRain()

      log(rain)

    end

    if rain then

      log("rain")

      fibaro:setGlobal(globVarName, raintime)

      if currentTime >= startTime and currentTime <= stopTime then

        msg = symbolTextTable.rainExpectedMsg.." "..symbolTextTable.rainExpected.." "..raintime

        message(msg)

        log(msg)

      end

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainExpected..' '..symbolTextTable.timeExpected..' '..raintime);

    end

  elseif not rain and buienradar == "0" then

    log("not rain and 0")

    fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainNotExpected);

  elseif rain and buienradar ~= "0" then

    log("rain and 1")

    fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainExpected..' '..symbolTextTable.timeExpected..' '..raintime);

  elseif not rain and buienradar ~= "0" then

    log("no rain and 1")

    counter = 1

    while counter < math.floor(afterRain/runTime) and not rain do

      log("no rain and counter: "..counter)

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainNotExpected);

      counter = counter + 1

      fibaro:sleep(runTime*60*1000)

      tmp = checkRain()

      log(rain)

    end

    if not rain then

      log("not rain")

      fibaro:setGlobal(globVarName, "0")     

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainNotExpected);

    end

  end

  fibaro:log("transfer ok")

end

 

fibaro:sleep(runTime*60*1000)

Link to comment
Share on other sites

  • 0

Hi guys. I didn't check the Virtual Device (I don't use it for years...) but I noticed something, reading the last of several post.

 

I checked, without using the VD, and noted the data needed still can be pulled in by using the original URL but only using  https instead of http.

for example, 

Please login or register to see this link.

, is getting data (using a webbrowser).

 

Maybe the http/https can be the bottom line problem?

Edited by Lambik
Link to comment
Share on other sites

  • 0
1 minute ago, SmartHomeEddy said:

I think someone has to actually change and use the VD

I downloaded your original version but that didn't work

The URL does work but I am getting an error on the VD

The loop does show:

15-Aug 11:54:03 : buienradar: 0
15-Aug 11:54:03 :

Please login or register to see this link.

 

But the VD shows 

Error getting data

 

Why don't you share the code for the Loop in a text file?

Link to comment
Share on other sites

  • 0
2 minutes ago, Twannie said:

Why don't you share the code for the Loop in a text file?


Which loop? 

It is not my code, I don’t use the VD, I use a HC3 with a (perfect) working QuickApp

  • Like 1
Link to comment
Share on other sites

  • 0

With a working QuickApp I am convinced that the Buienradar rain predictions should work. 

 

Yesterday we had good weather conditions to see it working, with pop-up clouds everywhere. 

Link to comment
Share on other sites

  • 0
1 hour ago, SmartHomeEddy said:

It is already text, more text is not possible

 

Please login or register to see this code.


 

--

-- Buienradar Virtual Device (Lambik version 20161112)

--

-- Original code written by boerremk, all credits to him!

--

Please login or register to see this link.

-- 

-- 

-- Additional adjustments and extra code made by Lambik (20160621):

--  # added: option to change Telegram global variable

-- # added: option to change Buienradar global variable (max 15 characters, ID of this VD will be added at the end)

-- # added: symbols (table) instead of normal text to show in labels

-- # added: two report values in one label row

-- # changed: error report to top label

-- # removed: unnecessary labels deleted

-- # added: some additional headers and remarks

-- # added: Pre-text to show in message

-- Other adjustments:

-- # 20160903 changed: Buienradar URL

-- # 20160903 added: remark symbols to use

-- Bug fixes:

-- # 20161007 line near 179 changed (solved by boerremk):

-- if (response ~= nil ) then --> if (response ~= nil and response ~="") then

-- # 20161111 lines near 87 changed (solved by boerremk):

-- lattitude = jsonTable.latitude  -->  lattitude = round(jsonTable.latitude,2)

-- longitude = jsonTable.longitude -->  longitude = round(jsonTable.longitude,2) 

-- Remark:

-- # Pushover/E-mail options are not tested

 

--

-- ℹ Initialisation of user settings (change if necessary)

--

local debug = true; -- Enable (default, true) or disable (false) general debug output 

local beforeRain = 15; -- in minutes, time to send message before rain

local afterRain = 15; -- in minutes, time to set Buienradar to 0

local push = {false,"fibaro",{1073,1103}}; -- false (off) or true (on), use pushover or fibaro, ID of phone(s) (seperated by comma, only used for Fibaro push)

local email = {false,{2}}; -- false (off) or true (on), ID of account(s) (seperated by comma)

local telegram = {true}; -- Enable (true) or disable (default, true) sending logs to Telegram

local telegramGlobalVarName = 'Telegram'; -- Name of Telegram global variable to send messages to

local prio = "0"; -- priority of pushmessage, only used for Pushover

local startTime = "07:00" -- time to start messages

local stopTime = "23:00"; -- time to stop messages

local runTime = 5; -- in minutes

local globVarName = 'VD_Buienrad_'; --  Name of global variable to store status (max 15 characters, 3 characters ID of this VD will be added at the end)

local symbolTextTable = { -- Symbols to show in this VD

  timeActual = '?',  -- Symbol/Text for the actual time

  timeExpected = '', -- Symbol/Text for predicted time

  rainExpected = '⛆', -- Symbol/Text (top label) when rain is expected

  rainNotExpected = '', -- Symbol/Text (top label) when rain is not expected

  rainPredicted = '', -- Symbol/Text (update-labels) to show when rain is predicted

  rainNotPredicted = '', -- Symbol/Text (update-labels) to show when no rain is predicted

  errorGetData = '⚠', -- Symbol/Text (error label) to show if error occurs getting data

  rainExpectedMsg = 'Rain expected' -- Pre-text to send in message

  };

-- Other symbols you could use: 

-- Sun (bright): ☉ 

-- Sun (dark): ☀

-- Cloud (with sun): 

-- Cloud (light): ☁

-- Cloud (raining): ⛈

-- Rain: ⛆

-- Umbrella: ☂

-- Umbrella (rain):  

--

-- Initialisation (do not change)

--

local selfId = fibaro:getSelfId();

local currentTime = os.date("%H:%M");

local currentDate = os.date("*t");

local label = "";

local msg = "";

local raintime = "";

local globVarName = globVarName..selfId; -- add ID of this VD to the used global variable name

local reportLabelText = '';

 

--

-- Funtions (do not change)

--

local function log(str) if debug then fibaro:debug(tostring(str)); end; end

local function errorlog(str) fibaro:debug("<font color='red'>"..tostring(str).."</font>"); end

 

function latlon()

  if HC2 == nil then

    HC2 = Net.FHttp("127.0.0.1",11111);

  end

  local response ,status, err = HC2:GET("/api/settings/location");

  if (tonumber(status) == 200 and tonumber(err)==0) then

    if (response ~= nil) then

      jsonTable = json.decode(response)

      lattitude = round(jsonTable.latitude,2) -- Bugfix 20161111 by boerremk

      longitude= round(jsonTable.longitude,2) -- Bugfix 20161111 by boerremk

    end

  end

end

 

function globalVar(var)

  if fibaro:getGlobalValue(var) ~= nil and fibaro:getGlobalValue(var) ~= "" then

    return fibaro:getGlobalValue(var)

  else

    if HC2 == nil then

      HC2 = Net.FHttp("127.0.0.1",11111);

    end

    local response ,status, err = HC2:POST('/api/globalVariables','{"name":"'..var..'","value":"0"}');

    if (tonumber(err)==0) then

      log("Global variable "..var.." created");

    end

    return "0"

  end

end

 

function trim(s)

  return (s:gsub("^%s*(.-)%s*$", "%1"))

end

 

function split(s, pattern, maxsplit)

  local pattern = pattern or ' '

  local maxsplit = maxsplit or -1

  local s = s

  local t = {}

  local patsz = #pattern

  while maxsplit ~= 0 do

    local curpos = 1

    local found = string.find(s, pattern)

    if found ~= nil then

      table.insert(t, string.sub(s, curpos, found - 1))

      curpos = found + patsz

      s = string.sub(s, curpos)

    else

      table.insert(t, string.sub(s, curpos))

      break

    end

    maxsplit = maxsplit - 1

    if maxsplit == 0 then

      table.insert(t, string.sub(s, curpos - patsz - 1))

    end

  end

  return t

end

 

function round(val, decimal)

  if (decimal) then

    return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)

  else

    return math.floor(val+0.5)

  end

end

 

function message(msg)

  local requestBody = '&priority=' ..prio ..'&title=Buienradar&message=' ..msg;

  if email[1] then

    for i=1, #email[2] do

      fibaro:call(email[2], "sendEmail", "Buienradar", msg);

    end

  end

  if telegram[1] then

    fibaro:setGlobal(telegramGlobalVarName, msg)

  end

  if push[1] then

    if string.lower(push[2]) == "pushover" then

      fibaro:setGlobal("Pushover", requestBody)

    elseif string.lower(push[2]) == "fibaro" then

      for i=1, #push[3] do

        fibaro:call(push[3], "sendPush", msg);

      end

    end

  end

end

 

function checkRain()

  rain = false;

  raintime = "";

  reponseTable={};

  values = 0;

  if BR == nil then

    -- Changed 20160903: BR = Net.FHttp("gps.buienradar.nl",80);

    --BR = Net.FHttp("gadgets.buienradar.nl",80);

    BR = Net.FHttp("https://br-gpsgadget.azurewebsites.net",80); 

  end

  -- Changed 20160903: log("http://gps.buienradar.nl/getrr.php?lat="..lattitude.."&lon="..longitude)

  log("https://https://br-gpsgadget.azurewebsites.net/data/raintext?lat="..lattitude.."&lon="..longitude)

  -- Changed 20160309: local response, status, err = BR:GET("/getrr.php?lat="..lattitude.."&lon="..longitude);

  local response, status, err = BR:GET("/data/raintext?lat="..lattitude.."&lon="..longitude);

  if (tonumber(status) == 200 and tonumber(err)==0) then

    if (response ~= nil and response ~="") then -- Bugfix 20161007 by boerremk

      log("Gegevens opgehaald");

      fibaro:log("Getting data...")

      response = trim(response)

      --log(response)

      responseTable = split(response, "\n")

      local values = 0;

      for i=1, (#responseTable) do

        rainT = responseTable:sub(1,3)

        timeT = responseTable:sub(5,9)

        rainSymbol = false

        --log("take1: "..timeT..":"..rainT)

        if tonumber(timeT:sub(1,2)) <= 2 then

          timeTN = tostring(tonumber(timeT:sub(1,2)) + 24) .. timeT:sub(3) or symbolTextTable.errorGetData

        else

          timeTN = timeT

        end

        if (currentTime <= timeT or currentTime <= timeTN) and values < 14 then

          log(timeT..":"..rainT)

          values = values + 1

          rainfall = round(10^((tonumber(rainT)-109)/32),1)

          if rainfall > 0 and tonumber(rainT) > 77 then

            if rainfall >= 1 or tonumber(responseTable[i+1]:sub(1, 3)) > 77 then

              rain = true

              rainSymbol = true

              if raintime == "" then

                raintime = timeT;

                log(raintime)

              end

            end

          end

          -- Determine rain prediction symbol to show in label

          if rainSymbol then

            reportText = symbolTextTable.timeExpected..' '..timeT..' '..symbolTextTable.rainPredicted..' '..string.format("%.1f", rainfall);

            else

            reportText = symbolTextTable.timeExpected..' '..timeT..' '..symbolTextTable.rainNotPredicted..' '..string.format("%.1f", rainfall);

            end

          -- Report two values in one label

          if (values %2 == 0) or values == 14 then

            labelRow = round(values/2);

            fibaro:debug('i = '..i..' number of tablevalues = '..#responseTable..' valuecounter: '..values..' labelRow: '..labelRow );

            reportLabelText = reportLabelText..' - '..reportText;

            fibaro:call(selfId, "setProperty", "ui.lblBuienradar"..labelRow..".value", reportLabelText);

            else

            reportLabelText = reportText;

            end

          label = label .. timeT .. ": " .. rainfall .. "%0A"

        end

      end

      fibaro:call(selfId, "setProperty", "ui.lbllastUpdate.value", os.date("%c"));

      return true

    else

      fibaro:call(selfId, "setProperty", "ui.lbllastUpdate.value", symbolTextTable.errorGetData);

      return false

    end

  else

    fibaro:call(selfId, "setProperty", "ui.lbllastUpdate.value", symbolTextTable.errorGetData);

    return false

  end

end

--

-- Code (do not change)

--

latlon()

buienradar = globalVar(globVarName)

log("buienradar: "..buienradar)

 

if checkRain() then

  log(rain)

  if rain and buienradar == "0" then

    log("rain and 0")

    counter = 1

    while counter <= math.floor(beforeRain/runTime) and rain do

      log("rain and counter: "..counter)

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainExpected..' '..symbolTextTable.timeExpected..' '..raintime);

      counter = counter + 1

      fibaro:sleep(runTime*60*1000)

      tmp = checkRain()

      log(rain)

    end

    if rain then

      log("rain")

      fibaro:setGlobal(globVarName, raintime)

      if currentTime >= startTime and currentTime <= stopTime then

        msg = symbolTextTable.rainExpectedMsg.." "..symbolTextTable.rainExpected.." "..raintime

        message(msg)

        log(msg)

      end

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainExpected..' '..symbolTextTable.timeExpected..' '..raintime);

    end

  elseif not rain and buienradar == "0" then

    log("not rain and 0")

    fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainNotExpected);

  elseif rain and buienradar ~= "0" then

    log("rain and 1")

    fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainExpected..' '..symbolTextTable.timeExpected..' '..raintime);

  elseif not rain and buienradar ~= "0" then

    log("no rain and 1")

    counter = 1

    while counter < math.floor(afterRain/runTime) and not rain do

      log("no rain and counter: "..counter)

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainNotExpected);

      counter = counter + 1

      fibaro:sleep(runTime*60*1000)

      tmp = checkRain()

      log(rain)

    end

    if not rain then

      log("not rain")

      fibaro:setGlobal(globVarName, "0")     

      fibaro:call(selfId, "setProperty", "ui.lblOverview.value", symbolTextTable.rainNotExpected);

    end

  end

  fibaro:log("transfer ok")

end

 

fibaro:sleep(runTime*60*1000)

 

Still the same, loop shows:

15-Aug 13:05:45 : buienradar: 0
15-Aug 13:05:45 : https://https://br-gpsgadget.azurewebsites.net/data/raintext?lat=51.57&lon=5.45

THis URL does not work this time

 

Label VD shows:

"Error geting data"

Do you have a working VD?

Link to comment
Share on other sites

  • 0

@D-Vine made a minimal version, just to get the data and debug messages:

 

Please login or register to see this code.

Replace the code of your VD with this one, let’s see

 

 

Link to comment
Share on other sites

  • 0
2 minutes ago, SmartHomeEddy said:

@D-Vine made a minimal version, just to get the data and debug messages:

 

Please login or register to see this code.

Replace the code of your VD with this one, let’s see

 

 

The whole loop code?

 

If I replace the whole loop code by the above i get

Please login or register to see this code.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...