Wake on Lan and Hibernate your pc or mediacenter

To Wake your pc over Lan just have to add the following code to a Virtual device button:

The only thing you have to do is change the XX:XX:XX:XX:XX:XX into the MAC address of your network card. Which can be found by launching cmd and typing “ipconfig /all” and look up the Physical Address

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

-- convert MAC adress, every 2 Chars (7-bit ASCII), to one Byte Char (8-bits)
function convertMacAddress(address)
local s = string.gsub(address, ":", "");
local x = ""; -- will contain converted MAC
for i=1, 12, 2 do
x = x .. string.char(tonumber(string.sub(s, i, i+1), 16));
end
return x;
end

fibaro:log("Start process");

-- MAC adress
local _macAddress = convertMacAddress("XX:XX:XX:XX:XX:XX");
-- Create Magic Packet 6 x FF
local _magicPacket = string.char(0xff, 0xff, 0xff, 0xff, 0xff, 0xff);
-- Broadcast Address
local _broadcastAddress = "255.255.255.255";
-- Default port used
local _wakeOnLanPort = 9;

fibaro:sleep(750);

for i = 1, 16 do
_magicPacket = _magicPacket .. _macAddress;
end

fibaro:log("Magic packet successfully created");

fibaro:sleep(1000);

socket = Net.FUdpSocket();
socket:setBroadcast(true);

local bytes, errorCode = socket:write(_magicPacket, _broadcastAddress, _wakeOnLanPort);
--check for error
if errorCode == 0 then
fibaro:log("Successfully sent");
else
fibaro:log("Transfer failed");
end

-- clean up memory
socket = nil;

fibaro:sleep(1000);
fibaro:log("Please wait for the computer to startup.");

Put your pc in Hibernate or shut it down

You can install an application where you can send a command to to shutdown.

For instance use: http://www.airytec.com/en/switch-off/default.aspx

Make sure you portforward in your firewall otherwise the Home Center has no access to the application.

Then add the following code to a Virtual Device button and your done:

httpSession = Net.FHttp("192.168.1.11", 8000);
httpSession:setBasicAuthentication("USERNAME", "PASSWORD");
response = httpSession:GET("/?action=System.Hibernate");

Replace System.Hibernate by any of the following codes to change the behaviour:

  • System.Hibernate
  • System.Shutdown
  • System.Restart
  • System.Sleep

De waardering van www.controlliving.nl bij Webwinkel Keurmerk Klantbeoordelingen is 9.4/10 gebaseerd op 22 reviews.