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

Restart HC2 by an VD ?


samuel
 Share

Question

How to make a button in a VD what will restart your HC2 ?

 

Thanks for your help

-sbo

Link to comment
Share on other sites

15 answers to this question

Recommended Posts

  • 1
On 2/4/2017 at 11:15 AM, Sankotronic said:

@samuel,

Please login or register to see this code.

works from scenes because I use it in my scene that monitors house power supply. I didn't try with VD but I expect that this functions should also work in VD.

 

 

just FYI 

 

Please login or register to see this image.

 

Please login or register to see this code.

Link to comment
Share on other sites

  • 0

nevermind my post just do as Jompa writes - he knows what hes talking about i just stole my solution .P

Edited by Kuba13
beter way avalible
Link to comment
Share on other sites

  • 0
  • Inquirer
  • would that be the plain username / password or do i have to convert my username / password by a method?

    Link to comment
    Share on other sites

    • 0
    11 minutes ago, samuel said:

    would that be the plain username / password or do i have to convert my username / password by a method?

    Plain username and password

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • It doesn't work: it returns in the log under the VD in the main page with "501"

    [DEBUG] 21:45:00: 501

     

    Does it need to be:

    HC2 = Net.FHttp("127.0.0.1", 11111) OR  HC2 = Net.FHttp("127.0.0.1")  ?? or with another tcp port number, or none ??

     

    My user name is a plain email adrdress, will that work?

     

    on top of the page, under general or advanced I filled in the following 

    Name: Restart HC2

    Room: Service

    IP = ""

    TCP port = 80

     

    in a buttom of a VD i fill in the following:

    -----------------------------------------------------------------------------------------------------

    fibaro:call(259, "sendDefinedPushNotification", "186");    
    fibaro:log("Re-starting HC2...")
    fibaro:sleep(20*1000);
     
        HC2 = Net.FHttp("127.0.0.1", 11111)
        HC2:setBasicAuthentication("user","password")
        response, status, errorCode = HC2:POST("/api/settings/reboot", "data=reset")
            if errorCode == 0 then
                fibaro:log(status)
            else
                fibaro:log("error")
            end

     

    What I am doing wrong?

    Edited by samuel
    Link to comment
    Share on other sites

    • 0

    @samuel, @jompa68

     

    To reboot HC is it really necessary to use http? Can this be done with LUA function:

    Please login or register to see this code.

    I know that this function:

    Please login or register to see this code.

    works from scenes because I use it in my scene that monitors house power supply. I didn't try with VD but I expect that this functions should also work in VD.

    Edited by Sankotronic
    Link to comment
    Share on other sites

    • 0

    Hi Everyone - since the new login method came out my VD stoped working? I ve change my login for email using %40 instead @ but still no luck :(

    Any idea how to do it now??

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • That was the same for me, it didnt work wiith the %40 from the @ (email)

     

    Make a VD add in the button  
    fibaro:log("Re-starting HC2...")
    fibaro:sleep(20*1000);
    fibaro:startScene(SCENE_ID);

     

    SCENE_ID from scene put the SCENE_ID in the fibaro:startScene(SCENE_ID); fro the VD

    Make a lua scene and add this in your scene:

     

    --[[
    %% properties
    %% events
    %% globals
    --]]

    fibaro:debug("HC2 will reboor in 3 seconds")
    fibaro:sleep(3000)

    HomeCenter.SystemService.reboot()

     

    This worked for me. 
     

     

    • Thanks 1
    Link to comment
    Share on other sites

    • 0

    Thanx samuel i get u + for quick answer and it is working for me :) 

    Any Idea how to do it for HClite?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Apparently not because i don't own a hclite, but a HC2.. uhmm.. hclite aren't able to do lua coding, understand

    Link to comment
    Share on other sites

    • 0
    On 2/5/2017 at 2:32 AM, samuel said:

    That was the same for me, it didnt work wiith the %40 from the @ (email)

     

    Make a VD add in the button  
    fibaro:log("Re-starting HC2...")
    fibaro:sleep(20*1000);
    fibaro:startScene(SCENE_ID);

     

    SCENE_ID from scene put the SCENE_ID in the fibaro:startScene(SCENE_ID); fro the VD

    Make a lua scene and add this in your scene:

     

    --[[
    %% properties
    %% events
    %% globals
    --]]

    fibaro:debug("HC2 will reboor in 3 seconds")
    fibaro:sleep(3000)

    HomeCenter.SystemService.reboot()

     

    This worked for me. 
     

     

    hi,

    can you pls export this VD and send.

    I made the lua code as told but cant understand SCENE part?

    Can you pls tell me step wise or by photos how to do this.

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Add a scene called: "Reboot HC2". Copy / paste the following code in the scene:

    Save the scene and set it as manual.

     

    --[[
    %% properties
    %% events
    %% globals
    --]]

    fibaro:debug("HC2 will reboot in 3 seconds");
    fibaro:setGlobal("HC2", "RESTARTED"); 
    fibaro:sleep(3000);

    HomeCenter.SystemService.reboot();

     

    Add a virtual device (VD) and add a button called "Restart"

    copy / paste this in the button:

     

    local selfId         = fibaro:getSelfId();

    fibaro:log("Re-starting HC2...")

    fibaro:sleep(20*1000);
    fibaro:startScene(308); -- start restart scene

     

    Change "308"to your Scene ID

     

    And when your press the button in your VD then after 20 seconds the HC2 will reboot

     

    Let me know how it goes :-) 

     

    • Like 1
    Link to comment
    Share on other sites

    • 0

    Thanks for the helpful answers above folks. Is there a way this can monitor an active network connection and if not it runs a scene to restart? I find when a data connection drops, often the hc2 will not pick it back up once the router is back in action. 

     

     

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