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

This is the result in my HC3 quickapp:

 

before:

Please login or register to see this code.

 

 

after:

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0
31 minutes ago, SmartHomeEddy said:

Now we need to put a zero in front of all two digits and not in front of all three digits

str:gsub("%s(%d%d)|", function(s) return " 0"..s.."|" end )

  • Thanks 1
Link to comment
Share on other sites

  • 0
25 minutes ago, jgab said:

str:gsub("%s(%d%d)|", function(s) return " 0"..s.."|" end )

 

Thanks jgab !!!!

 

If the first value (doesn't have a leading space) also didn't had the leading zero, I put one there also.

 

 

My variable in the HC3 quickapp is "apiResult".

So to get the response in "the old" format:

 

Please login or register to see this code.

 

 

 

Link to comment
Share on other sites

  • 0

@Twannie

 

I changed the HC2 version. This is the code, I think it works:

 

Please login or register to see this code.

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

I need to check the data

Look at the last time, that is the last time of the whole lost, not the next in line timewise

 

Please login or register to see this image.

/monthly_2022_01/image.png.a0337fc2ce7d19267ea49ee8a9ccec42.png" />

 

and the next 5 mins, last 2 lines

 

image.png.a1e26f7dbe87455612abca9b7b5c09fc.png

 

 

Edited by Twannie
Link to comment
Share on other sites

  • 0
1 hour ago, Twannie said:

Look at the last time, that is the last time of the whole lost, not the next in line timewise

I don’t understand it yet, what do you mean?

Link to comment
Share on other sites

  • 0

Now the times seem to run fine but I have to wait until regen has the comma inside the value

Link to comment
Share on other sites

  • 0

Ah, I see it now ?

 

Maybe put some extra debug lines inside. Or put simulation values in the code. It ain’t gonna rain in NL for some time. 

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...