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
Just now, SmartHomeEddy said:

Replace all of the code with this minimal code

Then I get

Please login or register to see this code.

Link to comment
Share on other sites

  • 0

I don’t know the syntax for a VD. Trial and error. Maybe @D-Vine can help.
 

Try this 

 

Please login or register to see this code.

in stead of 

Please login or register to see this code.

Edited by SmartHomeEddy
Link to comment
Share on other sites

  • 0

one bracket?
Maybe someone with a working version on the HC2 can help.

I believe there is something else wrong in the code.

Link to comment
Share on other sites

  • 0

Please login or register to see this code.

5 minutes ago, Twannie said:

Maybe someone with a working version on the HC2 can help


That would absolutely help. There are members out there with a working version of the Buienradar VD. 

Link to comment
Share on other sites

  • 0

For the HC2, Scenes are able to get https requests, Virtual Devices are not, as far as I know of (but I'm bit rusty with lua, didn't have to use quite a time).

 

There is a difference in lua commands used (in usage) by Virtual Devices and Scenes. As far as I can tell the only way to get around is to get the https-data by a scene --> store it in a variable --> use it in a VD, when needed.

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

  • 0
5 minutes ago, Lambik said:

Scenes are able to get https requests, Virtual Devices are not, as far as I know of (but I'm bit rusty with lua, didn't have to use quite a time).

 

There is a difference in lua commands used (in usage) by Virtual Devices and Scenes. As far as I can tell the only way to get around is to get the https-data by a scene --> store it in a variable --> use it in a VD, when needed.

 

I just was checking this and you are right.

So we can not change the http simple to https in only the VD. So anyone with only a VD buienradar will not work.

I have only a time problem because we are busy with expanding our house so little time to dive into this and also I'm not that good with VD and LUA...

Side story is after our house expansion is complete I am thinking of changing from fibaro to Home Assistant.

So maybe somebody else can make a simple scene - store it in a variable and read it with the VD.

 

  • Like 2
Link to comment
Share on other sites

  • 0
8 minutes ago, D-Vine said:

 

Side story is after our house expansion is complete I am thinking of changing from fibaro to Home Assistant.

That's what I did a long time ago ?. Nice to see you are still active @D-Vine !! Greetings to you!

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

  • 0
2 minutes ago, Lambik said:

That what I did a long time ago ?. Nice to see you are still active @D-Vine !! Greetings to you!

Thank you Lambik, Nice to hear from you also.

Did some test with OpenHAB but HA looks better for me.

had little sleep with our 2nd little girl last year and don't feel like converting my fibaro to HA.
Fortunately, everything has now been settled, we have the nights back, but a renovation will cost enough energy for the next 2 months.

2021 will be the year to moving to HA, will see you there then also ;)

 

  • Thanks 1
Link to comment
Share on other sites

  • 0
10 minutes ago, D-Vine said:

Thank you Lambik, Nice to hear from you also.

Did some test with OpenHAB but HA looks better for me.

had little sleep with our 2nd little girl last year and don't feel like converting my fibaro to HA.
Fortunately, everything has now been settled, we have the nights back, but a renovation will cost enough energy for the next 2 months.

2021 will be the year to moving to HA, will see you there then also ;)

 

Maybe a little suggestion from my side, use the HC2 as a z-Wave controller ONLY (although I'm still using the Presence Detector also!!) and use the Home Assistant Fibaro integration to communicate with the HC2. This way you can convert in steps without the need to do it all over again....

 

I have a different username on the HA forum, but when you use the same on the HA forum I will send you a PM, or if you want it, I could send it on this (Fibaro) forum by PM.

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

  • 0
42 minutes ago, Lambik said:

Maybe a little suggestion from my side, use the HC2 as a z-Wave controller ONLY (although I'm still using the Presence Detector also!!) and use the Home Assistant Fibaro integration to communicate with the HC2. This way you can convert in steps without the need to do it all over again....

 

I have a different username on the HA forum, but when you use the same on the HA forum I will send you a PM, or if you want it, I could send it on this (Fibaro) forum by PM.

 

You can send PM here that is ok for now, when I'm ready with the renovation and expansion of the house I will dive into HA..

  • Thanks 1
Link to comment
Share on other sites

  • 0
20 hours ago, Lambik said:

For the HC2, Scenes are able to get https requests, Virtual Devices are not, as far as I know of (but I'm bit rusty with lua, didn't have to use quite a time)


well, that explanes. Searching on the forum, here is an example with a script for https lookup and global variables and a VD 

 


That looks doable, but I don’t use a HC2. Otherwise, just buy a HC3 ?

 

Link to comment
Share on other sites

  • 0

whet in try the link in a browser without the "s" it automatically ads the "s" in https

Can I check the link without the s in another way?

Please login or register to see this link.

Link to comment
Share on other sites

  • 0
1 minute ago, SmartHomeEddy said:

In the browser, the link gets forwarded to the https link. That won’t work in the VD. 

 

Okay, I have to convert it to a scene had then use 

Please login or register to see this link.

?

Link to comment
Share on other sites

  • 0

Yes, there is still hope. Like suggested, a script which retrieves the Buienradar data and stores it in a global variable. And a VD that reads the global variable instead of retrieving it from the site. 

Link to comment
Share on other sites

  • 0

I can do some lua programming (made vd's for energy and water and more) but that is not really 100% error-proof when getting http data

so that's why I want to convert instead wring new code

Link to comment
Share on other sites

  • 0

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

  • Like 3
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...