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
AutoFrank

lua script to ping ip address and store result in variable

Question

Hi,

I was wondering if anybody had tried this before.

I am looking to ping a device on my home network to see if it is 'online' and then store something like an online/offline in a variable that I can display.

I use static IP's for all the devices I am looking to monitor

 

I was thinking about using the arp approach and see if the device is returned as part of the list

 

Has anybody tried this before .. or do people think it may be possible or is there another route ?

 

Thoughts appreciated

 

Thanks

Frank

Edited by autofrank

Share this post


Link to post
Share on other sites

2 answers to this question

Recommended Posts

  • 0

I don't think there is a 'ping' command available. However, you can try a http or tcp connect. Even if the device at the other end does not have a http or tcp sever. Just let it time out. To try that connection, the system has to 'arp' the IP address. If the device's tcp/ip stack is up and running, it'll answer the arp request and appear in the HC2 arp table. The only downside I immediately see is the fact that arp entries are cached (probably for 10 minutes) so it isn't very precise... If the device has any open TCP connection, you can try to use TCP in a virtual device:

Please login or register to see this code.

Not tested, but I've used this kind of code for other stuff.

Share this post


Link to post
Share on other sites
  • 0
  • Inquirer
  • I don't think there is a 'ping' command available. However, you can try a http or tcp connect. Even if the device at the other end does not have a http or tcp sever. Just let it time out. To try that connection, the system has to 'arp' the IP address. If the device's tcp/ip stack is up and running, it'll answer the arp request and appear in the HC2 arp table. The only downside I immediately see is the fact that arp entries are cached (probably for 10 minutes) so it isn't very precise... If the device has any open TCP connection, you can try to use TCP in a virtual device:

    Please login or register to see this code.

    Not tested, but I've used this kind of code for other stuff.

     

     

    Hi Peter,

     

    That's interesting approach and sounds like it would work.

    Perhaps I can get over the arp cache by executing the scene every minute and storing a result (or table of results) in a global variable 

     

    I'll give it a shot and report back in case somebody else finds use in what I find out.

     

    Thanks for taking the time to reply

     

    -Frank

    Share this post


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