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

[SOLVED][SOLVED]Setting vacation temperature of multiple zones in VD freezes HC2


Question

Posted

I made a VD for turning on and off heating in my home by setting vacation temperature. 

Here is my code. 

 

Please login or register to see this code.

I've tested this code today through remote connection. It freezes my HC2 every time I run it. 

Could someone figure out whats wrong with this code? 

Thanks in advance.

8 answers to this question

Recommended Posts

  • 0
Posted

What does fibaro:getGlobalValue("tempWakacje") contain? Is it a number? What happens if you change to tonumber(fibaro:getGlobalValue('tempWakacje'))

 

Where does it freeze? Directly at HC2:PUT row? 

 

Does it hang if you write the same json object back again without changing stuff in it?

 

Print the json object after you have read it and after you have modified it (i.e before the PUT). post it here... Make sure the json object to write is looking good. Also remove the for loop and write only one value directly. Also you could change code to....

response, status, errorCode = HC2:PUT("/api/panels/heating/"..strefa, json);
fibaro:debug("REQEST [" .. status .. "][" .. errorCode .. "][" .. string.len(response) .. "]")

  

 

I can mention that if you modify json objects and do it wrong, like for example add a comma in the wrong place it will totally freeze the HC2.  I have done this a few times during tricky code pieces when expanding variables with json inside json. An advice is to write the code in such way you wont have it autorun at HC2 boot if you are not 100% sure it will work as expected. Otherwise it is probably a HC2 restore instead of just a reboot...

 

Peo

  • Thanks 1
  • 0
  • Inquirer
  • Posted

    Thank you for your help Peo. Your great questions helped me find a solution. 

     

    1. You were right about trying to use tonumber(fibaro:getGlobalValue('tempWakacje')).

    tempWakacje is a global variable that always contains a number but every global variable in HC2 is of type string. This line causes the HC2 to hang. 

     

    2. json = json.encode(jsonTable);

    This line caused error too - attempt to call field 'decode' (a nil value)

    I just changed a variable name to Json and the error is gone. 

     

    3. I've refactored my code a little. I thought it would be more efficient to send GET and PUT request only once. 

    Please login or register to see this code.

    However, it seems that HC2 API allows only to send PUT request with "id" parameter. 

    This is what I get in response.

    [DEBUG] 00:53:40: REQEST [400][0][{"type":"ERROR","reason":"id","message":"no id"}]

    So back to previous solution... 

    Please login or register to see this code.

    ... and now it works like a charm! 

     

    Thanks again for help and have a nice day! 

    • 0
    Posted

    Glad to help

    • 0
    Posted
    On 29/09/2017 at 1:26 AM, Jacławiciel said:

    Thank you for your help Peo. Your great questions helped me find a solution. 

     

    1. You were right about trying to use tonumber(fibaro:getGlobalValue('tempWakacje')).

    tempWakacje is a global variable that always contains a number but every global variable in HC2 is of type string. This line causes the HC2 to hang. 

     

    2. json = json.encode(jsonTable);

    This line caused error too - attempt to call field 'decode' (a nil value)

    I just changed a variable name to Json and the error is gone. 

     

    3. I've refactored my code a little. I thought it would be more efficient to send GET and PUT request only once. 

    Please login or register to see this code.

    However, it seems that HC2 API allows only to send PUT request with "id" parameter. 

    This is what I get in response.

    [DEBUG] 00:53:40: REQEST [400][0][{"type":"ERROR","reason":"id","message":"no id"}]

    So back to previous solution... 

    Please login or register to see this code.

    ... and now it works like a charm! 

     

    Thanks again for help and have a nice day! 

    Wow, great.

    I am trying to find a way how to deactivate vacation temperature and with no luck. How do you deactivate holiday mode from this VD?

    • 0
    Posted

    Hi

     

    I currently do not use the heating panels. I only have one thermostat (Popp) connected to the HC2. The rest are today connected through a separate Danfoss Link z-wave system. I will probably leave the Danfoss link though, and write my own VD to handle all heating so I can have all functionality I want. Will work on that later this year...

     

    But I would start by  going to http://YOUR_HC2_IP/docs and check the heating panels json object. Then change vacation status in the heating panel and read those json objects again. When I find what is changed, I it probably easy to change that data from your VD.

     

    Regards

    Peo

    • 0
  • Inquirer
  • Posted

    You can just simply set vacationTemperature to 0 to deactivate holiday mode like this.

    Please login or register to see this code.

    I am using vacationTemperature to set lower temperature when nobody is at home. Then when my presence check return 'true' I set 0 to vacationTemperature to disabled it and then heating panel set scheduled temperature. 

    • 0
    Posted (edited)

    Actually, I found the easiest way I think :D 

     

    I changed this : 

    local antiFreezeTemp = 10 -- activate the holiday temp to 10 degrees, that is always the same for me

     

    and then in another button I used this:

     

    local antiFreezeTemp = 0 -- it basically deactivate the holiday mode.

     

    Easy :D

     

    Edit:

    or as 

    Please login or register to see this link.

     said just a second ago :D:D

    Edited by HomeSystem.sk
    • 0
    Posted

    @Jacławiciel thank you very much you helped me a lot :!:

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