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

HC2 requesting data from web-API


Joohane
 Share

Question

Can't delete, so think that this thread doesen't exist.

Edited by Joohane
Link to comment
Share on other sites

12 answers to this question

Recommended Posts

  • 0
25 minutes ago, Joohane said:

I have a script which I wrote on Lua, that worked to get the prices and timestamps, but it won't work on Fibaro HC2.

The output I get in Lua: 

 

Please login or register to see this code.



The output I get in HC2:

 

Please login or register to see this code.


Is it possible to request an API using an URL to get prices and timestamps from web-API? If so then how can I request them? I am new to Fibaro and quite overwhelmed with all of this.

You can't use the 'require' function to include another Lua module (another file with code)

Link to comment
Share on other sites

  • 0
  • Inquirer
  • Posted (edited)
    5 minutes ago, jgab said:

    You can't use the 'require' function to include another Lua module (another file with code)


    Alright, Is there another way to get the timestamps and prices than requesting Lua modules then?

    Edited by Joohane
    Link to comment
    Share on other sites

    • 0
    29 minutes ago, Joohane said:


    Alright, Is there another way to get the timestamps and prices than requesting Lua modules then?

    Probably, do you have the URL's and http spec you need request the data?

    Can you post your code?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 6 minutes ago, jgab said:

    Probably, do you have the URL's and http spec you need request the data?

    Can you post your code?

    The URL yes, HTTP spec not sure.
    Code from Lua:

    Please login or register to see this code.


    This prints out the URL that I want to use to get prices and timestamps.

    Link to comment
    Share on other sites

    • 0

    Please login or register to see this code.

     

    So, the result will be something like below - what fields are you interested in?

    Secondly, what are you doing with the result? The 'success' handler in the code is asynchronous so it should contain the code that does something with the result  - ex displays it in  a label or store it in a global variable.

     

    Please login or register to see this spoiler.

     

     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Posted (edited)
    30 minutes ago, jgab said:

    Please login or register to see this code.

     

    So, the result will be something like below - what fields are you interested in?

    Secondly, what are you doing with the result? The 'success' handler in the code is asynchronous so it should contain the code that does something with the result  - ex displays it in  a label or store it in a global variable.

     

    Please login or register to see this spoiler.


    I am interested in getting only the prices and timestamps, and what I am trying to do is make a boiler and heater to start when the prices are low, and stop when the prices are high again. Thank you for helping me this far atleast.

    Edited by Joohane
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 59 minutes ago, jgab said:

    Please login or register to see this code.

     

    So, the result will be something like below - what fields are you interested in?

    Secondly, what are you doing with the result? The 'success' handler in the code is asynchronous so it should contain the code that does something with the result  - ex displays it in  a label or store it in a global variable.

     

    Please login or register to see this spoiler.

    Ok, I am not that good with Lua, so I am confused. Exactly what am I supposed to print to see all the JSON values? If I print the code you gave me, it returns nothing. If I print:

     

    Please login or register to see this code.


    I get 
     

    Please login or register to see this code.


    Am I missing something? Or am I not supposed to do it in Scenes?

    Link to comment
    Share on other sites

    • 0

    Well, the data returned is grouped into 4 categories. "ee", "fi", "lv","lt" and I don't know what they mean.

    Within each category there are timestamps and prices for the period requested.

     

    This code will call the priceHandler function with the lowest price and timestamp for the "ee" category. Here it just prints it out but it could do something else.

    The getPrices function could have additional parameters to accept other time intervals...

     

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Posted (edited)
    18 minutes ago, jgab said:

    Well, the data returned is grouped into 4 categories. "ee", "fi", "lv","lt" and I don't know what they mean.

    Within each category there are timestamps and prices for the period requested.

     

    This code will call the priceHandler function with the lowest price and timestamp for the "ee" category. Here it just prints it out but it could do something else.

    The getPrices function could have additional parameters to accept other time intervals...

     

    Please login or register to see this code.

     


    OK this is sort of what I want to get. Thank you for your help. I am bad with words so I badly explained what I wanted to do. Basically, what I want it to do is written in this

    Please login or register to see this link.

     post.

    Really sorry about making you keep wasting your time on me.

    Edited by Joohane
    Link to comment
    Share on other sites

    • 0
    18 minutes ago, Joohane said:


    OK this is sort of what I want to get. Thank you for your help. I am bad with words so I badly explained what I wanted to do. Basically, what I want it to do is written in this

    Please login or register to see this link.

     post.

    Really sorry about making you keep wasting your time on me.

    So you only want to print the values out?

    Not find the lowest price and start the washing machine at that time?

    Link to comment
    Share on other sites

    • 0
    On 4/11/2022 at 9:59 AM, Joohane said:

    I am interested in getting only the prices and timestamps, and what I am trying to do is make a boiler and heater to start when the prices are low, and stop when the prices are high again. Thank you for helping me this far atleast.

     

    Maybe you can also get some inspiration from post about the Tibber quickapp. Looks like somewhat the same principle, variable prices for energy and trying to use energy at the lowest price. In the Tibber quickapp we tried to get as much information to make those choices. 

     

     

     

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

     Share

    ×
    ×
    • Create New...