Jump to content
  • 0

Restart HC2 by an VD ?


Question

15 answers to this question

Recommended Posts

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

@samuel,

HomeCenter.SystemService.shutdown()

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 

 

olpLg6y9BH.png

 

HomeCenter.SystemService.reboot()
Link to post
Share on other sites
  • 0
HC2 = Net.FHttp("127.0.0.1") 
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

 

Link to post
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 post
Share on other sites
  • 0

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

Link to post
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 post
Share on other sites
  • 0

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 post
Share on other sites
  • 0

@samuel, @jompa68

 

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

HomeCenter.SystemService.reboot()

I know that this function:

HomeCenter.SystemService.shutdown()

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 post
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 post
Share on other sites
  • 0

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 post
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 post
Share on other sites
  • 0

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

Link to post
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 post
Share on other sites
  • 0

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

 

Link to post
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 post
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...