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

Question

Posted

How can I get the following to change value ONLY once if errorCode does not change rather than all the time?

I have it display a message on TV saying "Wife is Home" but it CONSTANTLY does it rather than just once... HELP!

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

tcpSocket = Net.FTcpSocket("192.168.0.11", 5555)

bytes, errorCode = tcpSocket:write("test")

if errorCode == 0 then

fibaro:setGlobal("Dean", "1");

fibaro:log("S3 - Ping Successful");

fibaro:call(1304, "setProperty", "ui.Label1.value", "Ping Successful");

else

fibaro:setGlobal("Dean", "0");

fibaro:log("S3 - Ping Failed");

fibaro:call(1304, "setProperty", "ui.Label1.value", "Ping Failed");

end

tcpSocket:disconnect();

fibaro:sleep(10000);

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

3 answers to this question

Recommended Posts

  • 0
Posted

try

Please login or register to see this code.

  • 0
  • Inquirer
  • Posted

    almost perfect just needed to add a space after the id 1304, but works a treat thank you so much i ALMOST had it aswell! i will learn!

    [ Added: 2013-09-26, 11:19 ]

    very odd it has stopped working... not sure how reliable this pinging is... if i remove the additional if then it starts to work again... not sure if i can use the global variable instead? is that possible?

    if Dean == 0 then

    [ Added: 2013-09-27, 11:48 ]

    Robmac sorry to bother you but i assumed

    if fibaro:getGlobal("Dean") == 1 then

    end

    would work but it seems not to? does that look right? i feel it is!?

    [ Added: 2013-09-27, 22:13 ]

    --[[

    %% properties

    %% globals

    Dean

    --]]

    tcpSocket = Net.FTcpSocket("192.168.0.11", 5555);

    bytes, errorCode = tcpSocket:write("test");

    if errorCode == 0 then

    if tonumber(fibaro:getGlobalValue("Dean")) == 0 then

    fibaro:setGlobal("Dean", "1");

    fibaro:log("Ping Successful");

    fibaro:call(1304, "setProperty", "ui.Label1.value", "Ping Successful");

    end

    else

    if tonumber(fibaro:getGlobalValue("Dean")) == 1 then

    fibaro:setGlobal("Dean", "0");

    fibaro:log("Ping Failed");

    fibaro:call(1304, "setProperty", "ui.Label1.value", "Ping Failed");

    end

    end

    tcpSocket:disconnect();

    fibaro:sleep(10000);

    this works for about a minute then seems to fall asleep and not work anymore any reason why?

    • 0
    Posted

    tcpSocket = Net.FTcpSocket("192.168.0.11", 5555);

    bytes, errorCode = tcpSocket:write("test");

    .......=ping>

    this works for about a minute then seems to fall asleep and not work anymore any reason why?=ping>

     

    Maybe you can try to add between the first and second line:

    Please login or register to see this code.

    As far as I know, the errorcodes returned are:

    2 = offline

    1 = timeout

    0 = data received

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