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

@Twannie Sorry, I don’t use a HC2, so I don’t have and know the VD. Yes changing the code. 
 

In the VD you have, somewhere the URL will be. And not the whole URL 

Please login or register to see this link.

 but probably only this part 

Please login or register to see this link.

 (I think) 
 

That has to be replaced with the new URL. 
 

I have got my QuickApp working, so there is hope for the VD. 
 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0
1 minute ago, Twannie said:

The URL only states "gpsgadget.buienradar.nl"


try to replace it with 

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0

I changed the URL (see the response data, still getting an error

12-Aug 16:22:19 : buienradar: 0
12-Aug 16:22:19 : http://https://br-gpsgadget.azurewebsites.net/data/raintext?lat=51.57&lon=5.45
12-Aug 16:22:19 : error: 2
12-Aug 16:22:19 : status:

Link to comment
Share on other sites

  • 0
1 minute ago, Twannie said:

http://https://br-gpsgadget.azurewebsites.net/data/raintext?lat=51.57&lon=5.45


Did you put an extra http in front of it?

Link to comment
Share on other sites

  • 0

I made the URL correction, now another error:

12-Aug 16:28:39 : buienradar: 0
12-Aug 16:28:39 :

Please login or register to see this link.


12-Aug 16:28:39 : error: 0
12-Aug 16:28:39 : status: 301

 

Just now, SmartHomeEddy said:


Did you put an extra http in front of it?

 

No, the code does but 

The URL is working now but still the error

status:301

Link to comment
Share on other sites

  • 0

Still   HTTP 301 Moved Permanently

 

It has to be https. Somewhere in the code http is put in front of it. Can you find it?

 

Almost there ?


 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

yes, changed it, no change

12-Aug 16:39:02 : buienradar: 0
12-Aug 16:39:02 :

Please login or register to see this link.


12-Aug 16:39:02 : error: 0
12-Aug 16:39:02 : status: 301

that was only the log... this is the code important... there is noh http put in front

 

local url = "br-gpsgadget.azurewebsites.net" --"gpsgadget.buienradar.nl";

BR = Net.FHttp(url,80);
log("https://"..url.."/data/raintext?lat="..lattitude.."&lon="..longitude)

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

Link to comment
Share on other sites

  • 0

It should be something like this.

no error but it doesnt seems running right.

But every 5 min. same rule comes without error

 

[DEBUG] 16:41:44: buienradar: 0
[DEBUG] 16:41:44:

Please login or register to see this link.


[DEBUG] 16:46:47: buienradar: 0
[DEBUG] 16:46:47:

Please login or register to see this link.

 

Please login or register to see this code.

 

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

  • 0
2 minutes ago, SmartHomeEddy said:


@Twannie  So that should be the code to change

 

don't forget

Please login or register to see this code.

Link to comment
Share on other sites

  • 0

There must be someting else wrong in the code... m made the changes and nog getting another error:

12-Aug 17:02:38 : buienradar: 0
12-Aug 17:02:38 :

Please login or register to see this link.


12-Aug 17:02:38 : error: 2
12-Aug 17:02:38 : status:

Shall I send you the whole code?

I find it strange this working with others

Link to comment
Share on other sites

  • 0

Please login or register to see this code.

 

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

  • 0

I can copy and paste this into the loop?

Do I need to make global variabeles?

 

With your code I get this but the VD still shows "error getting data"

12-Aug 17:09:57 : Global variable VD_Buienrad_1198 created
12-Aug 17:09:57 : buienradar: 0
12-Aug 17:09:57 :

Please login or register to see this link.

and the last field is showing "âš "

Link to comment
Share on other sites

  • 0

I don’t know what source you are using now. I would save the current source code in a text somewhere and paste the new one and see what is does. 
 

But I like to live dangerously ?

 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0
7 minutes ago, Twannie said:

I can copy and paste this into the loop?

Do I need to make global variabeles?

 

With your code I get this but the VD still shows "error getting data"

12-Aug 17:09:57 : Global variable VD_Buienrad_1198 created
12-Aug 17:09:57 : buienradar: 0
12-Aug 17:09:57 :

Please login or register to see this link.

and the last field is showing "âš "

 

 

I thought this version makes the global himself

I got VD_Buienrad_557 in my globals.

 

But it's a long time ago so you have to test is and check it out.

 

But i have to go pick up my kids now. Think you on the right track now :D

Link to comment
Share on other sites

  • 0

the last reply is from your code pasted

I noticed it did create a variabele but no predefined variabele... a normal variabele cannot contain a table right?

Link to comment
Share on other sites

  • 0

Yes, I will see what will happen, but the VD still shows "error getting data"

If the prediction is right we will get rain tonight.

thanks for now @SmartHomeEddy

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