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

I think a lot are interested, great work! Is it a VD and script combination?


 


 

 

 

For those who own or want to buy ? a HC3, the new QuickApp is over here:

 

 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

I would be but i am running a HC2..

don't want to switch as i have a big system with lots of lua scenes

Link to comment
Share on other sites

  • 0

@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
Link to comment
Share on other sites

  • 0
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, 

Link to comment
Share on other sites

  • 0

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?

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0

Hi all,

 

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

Link to comment
Share on other sites

  • 0
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

Link to comment
Share on other sites

  • 0
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) 

Link to comment
Share on other sites

  • 0
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" />

 

 

 

Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0

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
Link to comment
Share on other sites

  • 0
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)

Link to comment
Share on other sites

  • 0
4 minutes ago, WouterStegenga said:

Same for me

(I did edit the # of Buienradar VD)

You did create "Rain" too?

Link to comment
Share on other sites

  • 0

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  :)

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