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


Question

Posted

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.
 
 
 
 

 

 

 

Recommended Posts

  • 0
Posted (edited)

@Patrick made a HC2 solution @Twannie

 

17 hours ago, Patrick said:

All, (draft note)

 

I think I got it working again (very beta code) , it is a combination of old buienradar (thanks to 

Please login or register to see this link.

!) and the code from 

Please login or register to see this link.

  
(thanks guys !)

 

Working progress / tot do:

- generalise the the scene as I have added soms "persona extensions" / modifications.

- rebuild the -> function latlon() -> (for now hard coded in scene)

- restore error messages -> disabled most of them

- cleane code _> code is still a mess, was not the first priority

- implement the self-run so it will refresh's every e.a 5 min -> for me not a prio as I use Sankotronic FTBE v 1.3.0 to schedule a refresh run every 5 min.

 

If people are interested or if we can find a way to work on this as a group I can share my (bata) work :)

Edited by SmartHomeEddy
  • Like 1
  • 1
Posted

does he have it running now?

If so, do you want to share it patrick?

 

  • 1
Posted (edited)

All,

 

Did manage to spend some time to update the code, it still needs some work but it looks likes it works again :)

-- added my Buienradar VD

 

2020-08-23  *** UPDATE BETA 0.3 ***

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by Patrick
  • Thanks 1
  • 0
Posted

Is this a seperate scene Patrick or the loop in the VD

Thanks for sharing!!!

  • 0
Posted
6 hours ago, Twannie said:

Is this a seperate scene Patrick or the loop in the VD

Thanks for sharing!!!

Hi Twannie, this is a separate scene, and you need to "delete or disable" the code in the VD and I added the following code to the "refresh button" in the VD -> fibaro:startScene(442); -- start: Buienradar (refresh) Scene and replace 442 with the right scene number, 

  • 0
Posted

Thanks Patrick for sharing.

 

I copied your code into a new scene and adapted the VD number. The data is correctly fetched from the web-site after I added the global variable "Rain".

 

At this moment I got a fatal error at:

[DEBUG] 21:59:18: 000|23:55
[DEBUG] 21:59:18: nil
[DEBUG] 21:59:18: Check 01
[DEBUG] 21:59:18: 2020-08-18 21:59:18.018986 [ fatal] LUA error: /opt/fibaro/scenes/31.lua:164: attempt to call method 'sub' (a nil value)

 

Line 164:  rainT = responseTable:sub(1,3)

 

Any idea why the code at my side is not working?

 

Thanks, Quino

 

BTW which VD did you use?

  • 0
Posted
1 hour ago, Quimobiel2 said:

Thanks Patrick for sharing.

 

I copied your code into a new scene and adapted the VD number. The data is correctly fetched from the web-site after I added the global variable "Rain".

 

At this moment I got a fatal error at:

[DEBUG] 21:59:18: 000|23:55
[DEBUG] 21:59:18: nil
[DEBUG] 21:59:18: Check 01
[DEBUG] 21:59:18: 2020-08-18 21:59:18.018986 [ fatal] LUA error: /opt/fibaro/scenes/31.lua:164: attempt to call method 'sub' (a nil value)

 

Line 164:  rainT = responseTable:sub(1,3)

 

Any idea why the code at my side is not working?

 

Thanks, Quino

 

BTW which VD did you use?

same with me

  • 0
Posted

Hi all,

 

Apologise for my delayed response, but was very busy this week, please see my update above.

  • 0
Posted
5 minutes ago, Patrick said:

Hi all,

 

Apologise for my delayed response, but was very busy this week, please see my update above.

I will try later but others have tried and came up with errors

  • 0
Posted
6 minutes ago, Twannie said:

I will try later but others have tried and came up with errors

Think I have solved most of them ..and everything is working fine (since this morning) 

  • 0
Posted

can you share the right code with vd at once to avoid mistakes?

  • 0
Posted

done, I have updated my code in earlier post (see above)

  • 0
Posted
29 minutes ago, Patrick said:

done, I have updated my code in earlier post (see above)

Thanks for the update Patrick,

I still get an error message in the scene

Please login or register to see this image.

/monthly_2020_08/afbeelding.png.58b39cb4998e6ef188ccf99133efb881.png" />

 

 

 

  • 0
Posted

Hi Thanks and very interesting as I do not have this error myself 

  • 0
Posted (edited)

My mistake

 

I get this

23-Aug 13:08:13 : Selfrun activated (1212)
23-Aug 13:08:13 : update: latlon()
23-Aug 13:08:13 : 2020-08-23 13:08:13.913450 [ fatal] Unknown exception: /opt/fibaro/scenes/830.lua:99: attempt to concatenate a nil value

Edited by Twannie
  • 0
Posted (edited)

I noticed it is this line:

logbug("grey", "Rain: " ..fibaro:getGlobal("Rain")) 

I noticed the global variabele "Rain" is not created by the scene

So I created "Rain"

Edited by Twannie
  • 0
Posted (edited)

So now I get:

 

23-Aug 13:21:06 : 20200823 vBeta 0.2
23-Aug 13:21:06 : Status buienradar: 0
23-Aug 13:21:06 : Status Rain: 0
23-Aug 13:22:06 : Selfrun activated (1212)
23-Aug 13:22:06 : update: latlon()
23-Aug 13:22:06 : Rain: No
23-Aug 13:22:06 : End

 

But the VD stays empty so now updatetime or anything

 

Please login or register to see this image.

/monthly_2020_08/image.png.5503086a5995c02be7ab8aa7eccb8248.png" />

Edited by Twannie
  • 0
Posted
9 minutes ago, Twannie said:

So now I get:

23-Aug 13:21:06 : 20200823 vBeta 0.2
23-Aug 13:21:06 : Status buienradar: 0
23-Aug 13:21:06 : Status Rain: 0
23-Aug 13:22:06 : Selfrun activated (1212)
23-Aug 13:22:06 : update: latlon()
23-Aug 13:22:06 : Rain: No
23-Aug 13:22:06 : End

 

But the VD stays empty so now updatetime or anything

 

 

Same for me

(I did edit the # of Buienradar VD)

  • 0
Posted
4 minutes ago, WouterStegenga said:

Same for me

(I did edit the # of Buienradar VD)

You did create "Rain" too?

  • 0
Posted

Think I found the problem as some of the code gets disrupted when I copy this to this forum .. l have added a txt file with the full code  :)

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