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

IP Device Local Network Detector & Scene


fingusio

Question

I have below script VD in LUA which detect my phone IP in network - works good :]

 

Cytuj

 


fibaro:call(45,"setProperty","ui.Label111.value","start");

local _deviceIp = "192.168.0.4";
local _devicePort = 53516;
local _maxRetryProcess = 5;

-- recursive function to ping device
local function _ping(retry)
  retry = retry or 0;
  --open the socket
  local tcpSocket = Net.FTcpSocket(_deviceIp, _devicePort);
  --set the read timeout
  tcpSocket:setReadTimeout(250);
  --notify user
  fibaro:call(45,"setProperty","ui.Label111.value","szukam");
  fibaro:sleep(250);    
  --send packet
  local bytes, errorCode = tcpSocket:write("ping");
  --check for error      
  if errorCode == 0 then
      return true;
  else
      if retry < _maxRetryProcess then
        fibaro:call(45,"setProperty","ui.Label111.value","powtarzam szukanie");
        fibaro:sleep(1000);
      return _ping(retry + 1);
    end
    return false;
  end
end

--ping device, secure with pcall to catch errors.
local f, result = pcall(_ping);

if (f) then
  if (result == true) then
    fibaro:call(45,"setProperty","ui.Label111.value","W zasiegu");
    fibaro:setGlobal("remo", "1");
    
  else
    fibaro:log("Server was not found!");
    fibaro:call(45,"setProperty","ui.Label111.value","Poza zasiegiem");
    fibaro:setGlobal("remo", "-1");
  end
else
  fibaro:call(45,"setProperty","ui.Label111.value","błąd");
end

 

 

 

Now question - how can i must create scene with blocks ? after detect my phone in local network switch lights or etc...... Must first make variable or how?

 

Please help really dont know, try since few hours :/

  • Like 1
Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

There are many ways to detect your phone or make auto lights go on it. And yes you must make global variables.

I have 3 phones to detect with 3 globals with 0 and 1 for example. all 3 with the precense detector on 0 and home status goes on Away... > lights of ;)

1 motion sensor in hall or 1 of the 3 phones on 1 home status goes on Home > lights On :D and you can go on like that...

See my signature for some solutions I use from great people that are around here

 

 

 

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.

×
×
  • Create New...