Author Topic: Ping Sensor  (Read 199573 times)

Offline additude

  • Full Member
  • ***
  • Posts: 241
  • Karma: +24/-17
Re: Ping Sensor
« Reply #615 on: October 16, 2017, 12:43:17 pm »
I've installed Ping Sensor on one Vera Plus with firmware 1.7.3232 and I've combined all the updated files to include Ping Count, Inverse, etc. and I feel that I have a stable install.

I installed the app from the Install Apps interface and I've uploaded the updated files thru Develop Apps / Upload.

I made a few minor text cleanup changes to formatting for the Settings table but that's it.

Then I've downloaded each of the files used for Ping Sensor in my UI7 Vera Plus and I've put them all into a zip file.

It will also have the pre UI7 files as well.

I think this will provide a single repository at this point for all of the updated files that others here have graciously updated.

I hope this helps.

* Updated Zip File 10-20-17
« Last Edit: October 20, 2017, 12:24:19 pm by additude »
If you want something that you have never had before, then you are going to have to do something that you have never done before.

Offline additude

  • Full Member
  • ***
  • Posts: 241
  • Karma: +24/-17
Re: Ping Sensor
« Reply #616 on: November 11, 2017, 12:01:35 pm »
I've made a few "Cosmetic" display changes to the UI7 files.
If you want something that you have never had before, then you are going to have to do something that you have never done before.

Offline Majimus

  • Full Member
  • ***
  • Posts: 106
  • Karma: +24/-0
Re: Ping Sensor
« Reply #617 on: September 05, 2018, 02:09:58 am »
I've been using the ping sensor with various devices and some scripting to replace the non working geolocation feature of the vera.  Some devices do not respond to ping reliably (android), these devices will however respond to an "arping".

I've modified the ping sensor to send an arping if the regular ping fails, this works great for me. Maybe plugin dev could consider making that small addition.

Here is my addition.

Code: [Select]
if( returnCode ~= 0) then
  returnCode = os.execute("arping -f -w 3 -I br-wan " .. address)
end

YMMV

edit: do check the interface though...
« Last Edit: September 07, 2018, 11:10:34 pm by Majimus »

Offline ElYoM29200

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
Re: Ping Sensor
« Reply #618 on: January 11, 2019, 11:40:32 am »
I've been using the ping sensor with various devices and some scripting to replace the non working geolocation feature of the vera.  Some devices do not respond to ping reliably (android), these devices will however respond to an "arping".

I've modified the ping sensor to send an arping if the regular ping fails, this works great for me. Maybe plugin dev could consider making that small addition.

Here is my addition.

Code: [Select]
if( returnCode ~= 0) then
  returnCode = os.execute("arping -f -w 3 -I br-wan " .. address)
end

YMMV

edit: do check the interface though...

Hello, I'm interested in your modification of the plugin. Can you tell me in which file and where exactly to insert this piece of code? Thank you.  :)

Offline col8eral

  • Sr. Member
  • ****
  • Posts: 356
  • Karma: +3/-2
Re: Ping Sensor
« Reply #619 on: January 11, 2019, 11:58:11 am »
Thi could b what I am looking for.  Could you kindly explain what each of the extensions to the arping code mean and do?
Thank you

Offline Octoplayer

  • Jr. Member
  • **
  • Posts: 81
  • Karma: +3/-0
Re: Ping Sensor
« Reply #620 on: January 11, 2019, 12:35:12 pm »
Hi Col8eral,
Best place is to look at the MANual page for arping,  https://linux.die.net/man/8/arping
From this the command:
  Finishes when / if a reply is received
  Waits for a max of 3 secs
  uses the br-WAN Interface device

The extra code goes in the i_Pingsensor.xml file, in the ExecutePing function (about halfway down).

ARPing works with a very similar format to Ping, but at a lower network level, so it sometimes succeeds where the Ping fails, e.g. due to firewall settings.
Other than a tiny bit of extra network traffic, this code is harmless and can be used anyway...

HTH
Octo



Offline col8eral

  • Sr. Member
  • ****
  • Posts: 356
  • Karma: +3/-2
Re: Ping Sensor
« Reply #621 on: January 11, 2019, 12:42:53 pm »
Many thanks for the explanation I'll certainly give it a go thank you

Offline ElYoM29200

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
Re: Ping Sensor
« Reply #622 on: January 11, 2019, 01:57:19 pm »
Hello Octoplayer,

Thank you for the explanations.

Is this how the code should be inserted?

Code: [Select]
local function executePing(address)
      local returnCode = os.execute("ping -c 1 -w 2 " .. address) --Octo 2/1/16 - count of 1 ping, wait 2s before timeout
      if( returnCode ~= 0) then
       returnCode = os.execute("arping -f -w 3 -I br-wan " .. address)
      end
      if (returnCode == 0) then
        -- we did not reach the host
        return "1"
      else
        -- we reached the host
        log("Ping Failed. ErrorCode: " .. tostring(returnCode)) -- (negative logic)
        return "0"
      end
    end

Offline ElYoM29200

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
Re: Ping Sensor
« Reply #623 on: January 11, 2019, 03:15:30 pm »
OK, thank you very much. ;)

PS : Your attachment is empty, no file in the zip.

Offline Octoplayer

  • Jr. Member
  • **
  • Posts: 81
  • Karma: +3/-0
Re: Ping Sensor
« Reply #624 on: January 12, 2019, 09:06:25 am »
Yep, That is what I have got...

I have added that with a comment and Additudes' changes to a new repository (attached).
I have uploaded it to my vera with no ill effect, but my Ping gets a response anyway, so it has not a full test cycle.

Octo

(re-posting... hopefully with the files included in the zip this time).

Offline ElYoM29200

  • Newbie
  • *
  • Posts: 13
  • Karma: +1/-0
Re: Ping Sensor
« Reply #625 on: January 12, 2019, 08:49:30 pm »
This time is the right one. All files are present in the zip archive. Thanks for sharing Octoplayer. ;)