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

Hi @Twannie ,

 

Great work! I have tested version 0.4 you posted and its working like a charm.

Can you upload your latest version please? The screenshot above is really looking good :-)

 

Thanks,

Remi

Link to comment
Share on other sites

  • 0

Thanks @Remi

 

Here is the latest version I am running myself (Beta 1.3)

 

 

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
  • Like 2
  • Thanks 1
Link to comment
Share on other sites

  • 0

In de VD staat:

 

Please login or register to see this code.

 

Moet dat zijn?

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0

Both can be done, depends on what info you want to show on the VD

"0.0mm" or "geen regen verwacht"

Here is the latest version

 

 

Please login or register to see this attachment.

Please login or register to see this attachment.

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

  • 0

Not in the fibaro.log() But there was no code to fill the ui.lblHourly.value. Now I see the code ?

 

But I don't see anything happening in de fibaro.log() yet. 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

Yes, installed new VD, remove the old one and changed the VD id in the script. 

 

Just did a reboot (after the backup) and now it is showing. 

 

Thanks!

 

 

 

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

  • 0

If you want the icons i use...

 

Please login or register to see this attachment.

Please login or register to see this attachment.

  • Thanks 1
Link to comment
Share on other sites

  • 0

The icons look great

 

Please login or register to see this image.

/monthly_2021_01/image.png.8b7deda91c8cb2c2f5a63dcbe0c45069.png" />

 

Works like a charm ?

 

 

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

  • 0

Hi @SmartHomeEddy

I think the buienradar data has changed some time ago

I get error because number have a "," (comma) when more rain falls

did you get around this?

  • Thanks 1
Link to comment
Share on other sites

  • 0

Thanks @Twannie

 

I had a look at the response:

 

Please login or register to see this image.

/monthly_2022_01/7E1BE208-AA25-42C3-937C-9BFBC0EDA2DA.jpeg.1efb5f7d136e2f3b4c6840546bfdef66.jpeg" />
 


 

 

I found some older response:

 

 "000|23:45 077|23:50 099|23:55 110|00:00 130|00:05 087|00:10 012|00:15 000|00:20 077|00:25 077|00:30 087|00:35 099|00:40 110|00:45 254|00:50 130|00:55 125|01:00 110|01:05 087|01:10 077|01:15 000|01:20 000|01:25 000|01:30 000|01:35 077|01:40"

 

So they added decimals to the response?

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

I am not sure but the split function or the trim function does cut of when the comma is reached

edit: so yes

so i get a 92, in some part of the code which is (edit: NOT) numeric

so the code stops

does your code still work or did you stop using the HC2?

 

Edited by Twannie
Link to comment
Share on other sites

  • 0

On the HC2 I get a nil value error

 

On the HC3 I get no error, but have to check if the logics are still ok

 

Please login or register to see this image.

/monthly_2022_01/560883BC-2E7D-49A2-97C7-3B6E087F858C.jpeg.68249e32b050da8db92beb792c036854.jpeg" />

 

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

nil value error here too, "92," is not numeric (mind the comma)

I am not deep into programming enough to see what happens in these 2 functions:

I think the code stops somewhere in here at the comma while it might has to stop when "|" is reached 

 

Please login or register to see this code.

 

Link to comment
Share on other sites

  • 0

Need to figure out how to replace all digits between , and | with nothing

 

,2659197224948|

should be:

,|

 

with string.gsub() function

 

 

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

No just delete all numbers between the komma (,) and the pipeline character (|)

 

Like:  

apiResult = apiResult:gsub(",(.-)|" ,"|")

 

(if apiResult is the variable which has the Buienradar Rain response)

 

 

 

The only thing the handle is the response now also can have only two characters in stead of three. There is no zero in front. That is also a problem. 

 

 

 

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