Jump to content
Guides for the Forum Read more... ×
Poradniki na Forum Read more... ×
FIBARO Home Center App 1.0.0 - release Read more... ×
FIBARO Home Center App 1.0.0 - wydanie Read more... ×
  • 0
kooy

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

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.
 
 
 
 

 

 

 

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

Maybe this can help you.

Please login or register to see this attachment.

 

 

 

 

Please login or register to see this attachment.

Edited by boerremk
New url

Share this post


Link to post
Share on other sites
  • 0
  • Inquirer
  • awesum ty very much:)

    Share this post


    Link to post
    Share on other sites
    • 0
  • Inquirer
  • and thats the exact website i was talking about:) ty both

    Share this post


    Link to post
    Share on other sites
    • 0

    One thing: you need a global variable Buienradar to let it work, the lon/lat the scripts graps from the HC2.

    Share this post


    Link to post
    Share on other sites
    • 0

    Please login or register to see this image.

    /emoticons/default_biggrin.png" alt=":D" srcset="https://forum.fibaro.com/uploads/emoticons/biggrin@2x.png 2x" width="20" height="20" /> fun tipped boerremk about this api, he did a awesome job to make this..

     

    boerremk maybe start a official virtual device topic with the buienradar VD ?

    we already did a few weeks of testing. Stil looking good with the latest version... 

    Share this post


    Link to post
    Share on other sites
    • 0

    One thing: you need a global variable Buienradar to let it work, the lon/lat the scripts graps from the HC2.

    Hi boerremk,

    tried your VD - it would be very helpful, if I would get it to work. However, all values stay at "0", although it's raining here (at the moment, at least). Global var is set and location is properly picked up, but still values stay at "0". Does it only work in the Netherlands? Thanks!

     

    Cheers

     

    Alfons

     

    BTW: Debug:

    [DEBUG] 16:36:52: buienradar: 0

     

    [DEBUG] 16:36:52:

    Please login or register to see this link.

     

    [DEBUG] 16:36:52: Gegevens opgehaald

     

    [DEBUG] 16:36:52: 16:40:000

     

    [DEBUG] 16:36:52: 16:45:000

     

    [DEBUG] 16:36:52: 16:50:000

     

    [DEBUG] 16:36:52: 16:55:000

     

    [DEBUG] 16:36:52: 17:00:000

     

    [DEBUG] 16:36:52: 17:05:000

     

    [DEBUG] 16:36:52: 17:10:000

     

    [DEBUG] 16:36:52: 17:15:000

     

    [DEBUG] 16:36:52: 17:20:000

     

    [DEBUG] 16:36:52: 17:25:000

     

    [DEBUG] 16:36:52: 17:30:000

     

    [DEBUG] 16:36:52: 17:35:000

     

    [DEBUG] 16:36:52: 17:40:000

     

    [DEBUG] 16:36:52: false

     

    [DEBUG] 16:36:52: not rain and 0

    Share this post


    Link to post
    Share on other sites
    • 0

    As far I know it only work in the netherlands.

     

    You can check this api of yours (like in the debug)

    Please login or register to see this link.

    If it's raining and there are values in it, maybe it work..  If the value's are 000 like I see with yours it won't work

     

    Buienradar is a dutch site with rainfall detection for the Netherlands

    Share this post


    Link to post
    Share on other sites
    • 0

    As far I know it only work in the netherlands.

     

    You can check this api of yours (like in the debug)

    Please login or register to see this link.

    If it's raining and there are values in it, maybe it work..  If the value's are 000 like I see with yours it won't work

     

    Buienradar is a dutch site with rainfall detection for the Netherlands

    Hi D-Vine,

     

    thansk - I already did this ... and only 0 values. Strangely, on their website you can select Netherlands/Belgium or Europe - but obviously this doesn't work via the api.

     

    Cheers

    Alfons

    Share this post


    Link to post
    Share on other sites
    • 0

    Yes the website of buienradar gives more but al alert possibilities are for the Netherlands..   

    Share this post


    Link to post
    Share on other sites
    • 0

    Ahh, too bad - just what I would have needed to retract my shutters in case of rain

    Please login or register to see this image.

    /emoticons/default_icon_sad.gif" alt=":-(" /> NetAtmo has too much of a delay.

    Cheers

    Alfons

    Share this post


    Link to post
    Share on other sites
    • 0

    Yes the website of buienradar gives more but al alert possibilities are for the Netherlands..   

    Other open similar sites?

    Share this post


    Link to post
    Share on other sites
    • 0

    Hi there,

     

    I'm using the 'VD buienradar' which was posted by boerremk. This is working great (in the Netherlands)!

    Please login or register to see this image.

    /emoticons/default_icon_rolleyes.gif" alt=":roll:" /> 

    But, now I want to use it in a Scene, where 5 minutes before it starts raining my sunscreen closes. Does anyone know, how I can extract these times from 'VD buienradar'?

    Share this post


    Link to post
    Share on other sites
    • 0

    Hi there,

     

    I'm using the 'VD buienradar' which was posted by boerremk. This is working great (in the Netherlands)!

    Please login or register to see this image.

    /emoticons/default_icon_rolleyes.gif" alt=":roll:" /> 

    But, now I want to use it in a Scene, where 5 minutes before it starts raining my sunscreen closes. Does anyone know, how I can extract these times from 'VD buienradar'?

     

    Hi,

     

    You can use the following:

    Please login or register to see this code.

    You can tune the time before it will be set to 1 in the mainloop with the variable beforeRain.

    Share this post


    Link to post
    Share on other sites
    • 0

    Remko,

     

    thank you for your suggestion. However, if I adapt the variable 'beforerain' to 5, the variable 'Buienradar' is put on '1' much earlier then 5 minutes. I think the error is in the next line of the script :

       

    while counter < math.floor(beforeRain/runTime) and rain do
            log("rain and counter: "..counter)

     

    beforeRain = 5

    afterRain = 5

    runTime = 5

     

     

    How can I solve this?

     

    Greetz John

    Share this post


    Link to post
    Share on other sites
    • 0

    Yes a bug!

     

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

     

    need an = after the < (smaller and equal)

     

    Can you test this, to see if it is ok now, I will then upload a new version.

    Share this post


    Link to post
    Share on other sites
    • 0

    Hello Remko ,

    It does not work as I want; the variable 'Buienradar' jumps to early to "1".

    Maybe there is a possibility to work with the variable 'Timet', you used in the 'function raincheck()'. I see here that the raintime is requested. Can I work with os.difftime(t2,t1)  (t2 = timeT, t1 = currentTime)? The result put into a variable ' Time2rain'?

    If the variable 'Time2rain' is less than 300 seconds then starts a scene?

     

    I hope you can help me.

     

    Greetz John

    Share this post


    Link to post
    Share on other sites
    • 0

    Hello Remko ,

    It does not work as I want; the variable 'Buienradar' jumps to early to "1".

    Maybe there is a possibility to work with the variable 'Timet', you used in the 'function raincheck()'. I see here that the raintime is requested. Can I work with os.difftime(t2,t1)  (t2 = timeT, t1 = currentTime)? The result put into a variable ' Time2rain'?

    If the variable 'Time2rain' is less than 300 seconds then starts a scene?

     

    I hope you can help me.

     

    Greetz John

     

     

    Hi John,

     

    Try the new VD (attached) and the following scene:

    Please login or register to see this code.

    Please login or register to see this link.

    Share this post


    Link to post
    Share on other sites
    • 0

    Hi Remko,
    beautiful script. And it seems to work! At least if I use a dummy time. Tomorrow expect rain and I can properly test the script.
    I have another question. I've written a scrip where I put the awning in a different position depending on the wind speed, to avoid damaging. Is it possible to combine these two scripts into one ?

    Please login or register to see this code.

    Thank for you're support,

     

    Greetz John

    Share this post


    Link to post
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    ×