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 got this far, you can try if you want.

Did not get into the notifications and I stripped the scene a bit so it won't keep running and will be triggered from the VD

What you have to do in the scene is the same as before so enter the VD number and location etc.

I changed the VD to get 1 hour forecast (and warning)
You can import the VD and in the VD enter the "buienradar" scene number in the TCP port field.. other changes ar not neccesary.

The scene will run each 5 mintues on 00, 05, 10 , 15 etc

apologies for being in dutch, i can translate if you want

please note you have to have global variabeles "Buienradar" and "Rain", if not you have to create them

 

 

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Please login or register to see this attachment.

Edited by Twannie
additional notes
  • Like 2
Link to comment
Share on other sites

  • 0

It would be nice to put all the times and mm into a global variabele (table)  but I am not good with tables so help would be apreciated

It should be a table with  2 columns (time and data)

f.e. global variabele "brData" with fields "tijd" en "neerslag"

so for example

for i = 1, nuOfFields do

   add "tijd 1" to first column of "brData"

   add "neerslag 1" to second column of "brData"

end

fields should be overwritten!

 

maybe @cag014 can give a quick example?

 

Edited by Twannie
Link to comment
Share on other sites

  • 0
12 minutes ago, SmartHomeEddy said:

You can use

Please login or register to see this code.

thanks Eddy, but is that overwrite?

 

Link to comment
Share on other sites

  • 0

@Twannie It will work like an add
 

@Lambik and @boerremk use it in their split function

 

Please login or register to see this code.


They use this split function to create the table

 

First create the table

Local table = {}

 

Then add every value

table.insert(table, tijd, brData)

 

 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0
10 hours ago, Twannie said:

I got this far, you can try if you want.

Did not get into the notifications and I stripped the scene a bit so it won't keep running and will be triggered from the VD

What you have to do in the scene is the same as before so enter the VD number and location etc.

I changed the VD to get 1 hour forecast (and warning)
You can import the VD and in the VD enter the "buienradar" scene number in the TCP port field.. other changes ar not neccesary.

The scene will run each 5 mintues on 00, 05, 10 , 15 etc

apologies for being in dutch, i can translate if you want

please note you have to have global variabeles "Buienradar" and "Rain", if not you have to create them

 

 

nice work @Twannie, and of course @Patrick for the initial solution.

Link to comment
Share on other sites

  • 0
3 minutes ago, WouterStegenga said:

I need the total amound of expected rain (sum of all 12 rows)

does anyone know how I can store it in a global that refreshes everytime the scene wil run?


I think @Twannie is working on it

Link to comment
Share on other sites

  • 0
4 hours ago, SmartHomeEddy said:

@Twannie It will work like an add
 

@Lambik and @boerremk use it in their split function

 

Please login or register to see this code.


They use this split function to create the table

 

First create the table

Local table = {}

 

Then add every value

table.insert(table, tijd, brData)

 

 

 

 

thanks for the info I meant a global variabele 

Link to comment
Share on other sites

  • 0
52 minutes ago, WouterStegenga said:

I need the total amound of expected rain (sum of all 12 rows)

does anyone know how I can store it in a global that refreshes everytime the scene wil run?

 

Hi

 

Do you want to overwrite this global value each 5 minute (so it shifts with the time and makes things much easier

Link to comment
Share on other sites

  • 0

To get from global variable

Please login or register to see this code.


and to store is

Please login or register to see this code.


On a HC3 (!)

You can find the HC2 variant to post (add a new global) or put (change an existing global) 
 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

In logic: 

 

if the global doesn’t exists: api.post

 

if it exists and you want to overwrite: api.put

 

if the table is already encoded, you don’t have to do that in the post or put

the debugs are only to check, not necessary    
 

and check the HC2 format, maybe different from HC3

Link to comment
Share on other sites

  • 0
19 hours ago, WouterStegenga said:

I need the total amound of expected rain (sum of all 12 rows)

does anyone know how I can store it in a global that refreshes everytime the scene wil run?

I have this now so far

 

Here is the scene with the hourly total rain added

Notes:

  • All the message data like Pushover, email etc is stripped and, to my opinion, would be easier to put in a seperate scene which has some advantages like could be triggered f.e. by hourlyRain (below) and could be easily be disabled or am I wrong?
  • create a new global variabele named "hourlyRain"
  • each 5 minute the total amount of rain for the next hour is entered into "hourlyRain" so shifts with time
  • if latitude and longtitude == 0 it wil use the location of the HC2
  • when within an hour rain is expected it wil show it on the VD like "Regen verwacht om XX:XX (1Hr=x.xmm)
  • Error messages will be shown in the same field on the VD as the above (lblError can be removed from the VD)
  • Date is changed into dutch format (also if interface is on English)
  • mm rounding digits on VD can eaasily be changed by changing roundNr in the scene
  • I noticed on the buienradar website explaining te text data, the mm shown in the table is in calculated mm/hr so i devided the numbers by 12 to get the sum of rain to fall in 5mm

 

 

 

 

Please login or register to see this attachment.

Edited by Twannie
  • Like 1
Link to comment
Share on other sites

  • 0

Latest version running

 

Please login or register to see this image.

/monthly_2020_08/image.png.2007b90758e35bfbfeceb103bf28fd92.png" />

Link to comment
Share on other sites

  • 0

I've updated my lua-script and vfib. Thanks! Don't have the 'Neerslag uur' but it works.

 

I'll try to create a push or telegram message.

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