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

weather forecast query and set variable


Question

Guest Kuuno
Posted

How is it possible over LUA to query for a specific value from web. lets say temperature and then set variable value according to that.

the idea would be to query tomorrows weather forecast and then control heating accordingly.

if temp forecast outside = more than 10 degrees higher than now then stop heating the house

this would help to prevent overheating when there are big temperature drops or rises

sample link to get the info:

Please login or register to see this link.

thanks!

12 answers to this question

Recommended Posts

  • 0
Guest PJ
  • Inquirer
  • Posted

    Something like this was posted recently on polish forum by sztywniak.

    You have to create virtual device with button like this. It has polish comments, but you should be able to find out what you have to do without them:

    Please login or register to see this code.

    It gets information about temperature from this website -

    Please login or register to see this link.

    and write it to global variable "Temp_zew"

    You need to use debugger in firefox to find out where are numbers related with temperature you want. Traxelektronik is very simple in construction, so it isn't a problem. Would be more difficult with your sample link.

    • 0
    Guest Kuuno
  • Inquirer
  • Posted

    can someone help to extract today and tomorrow temp forecast from this link

    Please login or register to see this link.

    thanks!

    [ Added: 2013-07-15, 12:50 ]

    found little bettary way

    here is a sample, i should extract celsius from period 1

    "epoch":"1373911200",

    "pretty":"9:00 PM EEST on July 15, 2013",

    "day":15,

    "month":7,

    "year":2013,

    "yday":195,

    "hour":21,

    "min":"00",

    "sec":0,

    "isdst":"1",

    "monthname":"July",

    "weekday_short":"Mon",

    "weekday":"Monday",

    "ampm":"PM",

    "tz_short":"EEST",

    "tz_long":"Europe/Tallinn"

    },

    "period":1,

    "high": {

    "fahrenheit":"72",

    "celsius":"22"

    • 0
    Posted

    You must have an API on this site web.

    So with a small script in php you can extract all and put it in global variable.

    • 0
    Posted

    Here is an example:

    you need to create an free account to fetch this data from wunderground

    Please login or register to see this link.

    Create a virtual device

    Please login or register to see this code.

    • 0
    Posted

    Good, didn't know how to parse json with HC2

    • 0
    Guest Kuuno
  • Inquirer
  • Posted

    thanks!

    i already had the key and could get some data but used http response

    your way is much better!

    thanks

    • 0
    Posted

    can someone help out with this json? want to get the forecast part...

    Please login or register to see this code.

    i can do to date part but not any longer then that, becase next part do not have any name (i think)

    Please login or register to see this code.

    [ Added: 2013-07-15, 17:13 ]

    From json parser i see this:

    and i test this:

    Please login or register to see this code.

    But log do not show anything. What am i doing wrong?

    Please login or register to see this attachment.

    • 0
    Posted

    forecastday is an array. You should try the statement below

    Please login or register to see this code.

    • 0
    Posted

    That did not work....still nothing in log

    [ Added: 2013-07-15, 18:46 ]

    OH! found the problem..json error?

    first in array is 1 not 0...strange, can someone explain that?

    [ Added: 2013-07-15, 19:04 ]

    Final solution

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    Please login or register to see this code.

    • 0
    Posted
    Here is an example:

    you need to create an free account to fetch this data from wunderground

    Please login or register to see this link.

    Create a virtual device

    Please login or register to see this code.

    Jompa,

    I copied your LUA-code in a virtual device and filled in my own API-key. When I run the scene I get a error: [ERROR] 20:20:22: line 8: attempt to index global 'Net' (a nil value)

    It is pointing to this line: FHEM = Net.FHttp("api.wunderground.com")

    What am I doing wrong or forgetting ??

    Never mind, forget it. I did not read everything, it's working right now.

    Please login or register to see this link.

    • 0
    Posted

    Just wanna say thank you, this post really help me figure out json for my HC

     

    Please login or register to see this image.

    /emoticons/default_icon_biggrin.gif" alt=":-D" />

    • 0
    Posted

    i wanted to implement this, but noticed that weather underground no longer provides a free API service. has anyone found a suitable replacement?

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