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


  • 1

HC2 AutoReboot/Restart Scene 4.520


Stiven
 Share

Question

Hello guys,

 

before the 4.520 update I used to have a scene which used to restart the HC2 but with the new update it doesn't work anymore and I cant figure this out. I could use some help from you guys. Thank you! Below is the code of the script.

 

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

-- specify user and passwort in clear text
local user = ''
local password = ''

function encbase64(data) 
  local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; 
  return ((data:gsub('.', function(x) 
          local r,b='',x:byte() 
          for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end 
        return r; 
        end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x) 
          if (#x < 6) then return '' end 
          local c=0 
          for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end 
        return b:sub(c+1,c+1) 
   end)..({ '', '==', '=' })[#data%3+1]) 
end

local http = net.HTTPClient();
http:request('http://127.0.0.1/services/system/reboot.php',{
    options = {
      method = 'GET',
      headers = {
        ["Authorization"] = 'Basic '.. encbase64(user .. ':' .. password)
      }
    },
    success = function(response) end,
    error = function(err) fibaro:debug("Error: " .. err) end
})

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0
  • Inquirer
  • Sorry to disappoint you because this wasn't my code so I don't know where to implement it in the code. Im bad at coding.

     

    Edit: Thank you it works!

    Edited by Stiven
    Link to comment
    Share on other sites

    • 0
    On 12/18/2018 at 3:06 PM, Stiven said:

    Edit: Thank you it works!

    So... can you paste the correct code?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 2/1/2019 at 7:35 PM, adyboss said:

    So... can you paste the correct code?

     HomeCenter.SystemService.reboot();

    Edited by Stiven
    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...