Author Topic: Ping Sensor  (Read 193987 times)

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Ping Sensor
« on: September 12, 2009, 11:08:06 am »
Hello all together,

After upgrading to the current version of Vera yesterday and having a look at Guesseds weather plugin, I had to create a plugin on my own.
I never had used Lua before and only after one day and night I have a working PingSensor plugin. Thanks go out to Guessed for his weather plugin. It teached me a lot, how plugins work.

However, I made a plugin which pings defined addresses (IP and domain names) a keeps the result of the ping in a variable.

My intention is, that it can trigger scenes when a IP-based device appears or disappears in the network.
So you can turn on your TV when your network-enabled HD-Recorder is turned on, or you can turn on a printer if your PC turns on, without the need of having another Z-Wave switch put between your network-device and the powerline.

Nevertheless I struggle with a few features I finally need to have it work the way I want it to. Probably someone of you can give me some hints: Here are the things to still be implemented.

1. Update the UI on state-change (device becomes visible or unvisible to the plugin)
    Currently you have to reload the Vera UI to display changes.
2. Display a red / green circle (similar to motion sensors) to indicate the presence of a device
3. Active / Inactive Buttons (even this should work similar to the motion sensors "Armed" and "Bypass")
4. Show up as a sensor in the scene-events.
5. A custom icon should be displayed instead of the na.gif

Have a look on the wikipage -> http://wiki.micasaverde.com/index.php/Ping_Sensor_Plugin

Ideas, hints and questions are welcome.
« Last Edit: September 18, 2009, 11:38:02 am by TedStriker »

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #1 on: September 13, 2009, 03:40:47 pm »

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #2 on: September 18, 2009, 11:37:40 am »
The Ping Sensor is now working as it was inteded.
Use it as a regular sensor in scenes, to trigger them.

Feel free to ask, if something's unclear or you have an idea for improvements.

Ted

Offline Boyo

  • Full Member
  • ***
  • Posts: 180
  • Karma: +0/-0
Re: Ping Sensor
« Reply #3 on: September 18, 2009, 02:25:01 pm »
What impact does the sensor have on the stability and responsiveness of vera?
Vera UI4 1.1.1183; Schalge Link Door Handle; HA18WD 3-Way/Single-Pole Switch x2; WDHA-12R - Wireless Gateway Module; Trane Thermostat; Retired: WDTC-20 - Z-Wave Enabled Thermostat

Offline cbarker

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Ping Sensor
« Reply #4 on: September 22, 2009, 10:50:38 pm »
Shouldn't the Tripped indicator be reversed - IE, 0 for 'not tripped' and 1 for 'tripped' - IE, if the site is unavailable, the sensor is tripped.  This would make a 'working' sensor green.

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #5 on: September 23, 2009, 02:08:58 am »
What impact does the sensor have on the stability and responsiveness of vera?

I recognized no impact running three sensors parallel for a short time. Actually I need only one sensor. So I guess a ping every 15th second is not too hard to handle for Vera ;)

Have you made different experiences?

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #6 on: September 23, 2009, 02:15:35 am »
Shouldn't the Tripped indicator be reversed - IE, 0 for 'not tripped' and 1 for 'tripped' - IE, if the site is unavailable, the sensor is tripped.  This would make a 'working' sensor green.

I thought about it, too. But the I decided to let it be at the moment to have a clear UI. e.g.
When you have a motion sensor, it displays you a red cirle when it found something. And when the ping sensor found something it turns red, too. So if you have a look on the dashboard, red means: something is going on.

BUT, it's planned to create a field in the UI to give you the possibility to invert red/green circle by setting it to "0" or "1".

Offline cbarker

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
Re: Ping Sensor
« Reply #7 on: September 23, 2009, 10:04:14 pm »
Ok. . . got that.
What I'm trying to do is exactly the opposite of what the plugin was created for; I'm checking for Internet connectivity and trying to have Vera reset the DSL router if it loses connectivity (which happens once a day).  I'm trying to reverse the operation with Scene 'event type: An armed sensor has pinged  a device' and 'Got response: No', but it is still triggering when the Internet is reachable.

How can I reverse the operation so the scene triggers when an IP address is not reachable?
« Last Edit: September 23, 2009, 10:06:31 pm by cbarker »

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #8 on: September 24, 2009, 01:50:04 am »
How can I reverse the operation so the scene triggers when an IP address is not reachable?
What IP did you ping? I guess it was an external one, wasn't it?

I would have expected it to work exactly the way you tried it.... Well, I'll have a look on it, but you have to get it back to work.
But this weekend I have got to work for my job, because I have to finance my hobby somehow;)
So the fix will take a little time.
Meanwhile you can try the attached version 1.2 of the plugin, which might fix your problem. It's not tested very much, but maybe you'll give it a try.

The only difference is, that event states are not enforced while a device has been found / not found. It only triggers an event if a transition occurs between "not found -> found" and "found -> not found".

e.g. let's have a light which is turned on when your router has been pinged successfully.
In V 1.1 you could turn off the light and max. 15 seconds (default value) later the light would be turned on again, and again and again...

In V1.2 this trigger should only be fired on changes like the ones mentioned above.

(Wiki will be updated later, when I have time!  ;))

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Ping Sensor
« Reply #9 on: September 30, 2009, 11:50:26 am »
I too want to cycle power on my DSL modem for the same reason. I was starting to look at doing it with an 'ash' script, but this is much more elegant.
Thanks for posting the plug-in in the Wiki.
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #10 on: September 30, 2009, 05:19:18 pm »
Thanks for the flowers ;)

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Ping Sensor
« Reply #11 on: September 30, 2009, 07:45:50 pm »
This is probably a dumb question, but where do I find the place to install LUUP plugins? I got the files onto the hard drive, but there is NO place under "Devices" to add LUUP plugins. I'm running v1.0.616. I can only add regular devices, or controllers.
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline Ap15e

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1998
  • Karma: +12/-0
Re: Ping Sensor
« Reply #12 on: September 30, 2009, 08:05:53 pm »
Luup plugins require a Luup firmware (http://wiki.micasaverde.com/index.php/Vera_Luup_Releases).
The latest Luup firmware is 1.0.939 (http://forum.micasaverde.com/index.php?topic=2100.0). Your firmware is pre-Luup, so you have to upgrade your firmware.

Offline mpenda

  • Jr. Member
  • **
  • Posts: 99
  • Karma: +1/-0
Re: Ping Sensor
« Reply #13 on: September 30, 2009, 09:13:58 pm »
Thanks, that did the trick for the luup plugins.
The ping plugin does not look like it will do the reverse yet. It looks like it will only fire on the not-found to found transition, and not the reverse (the two actions in the event pull-down).
So we'll wait until you make enough money to support your (and our) hobbies!!  :)
v1.0.980, HA09C, HA07C, WDTC-20, HRDS1, BLC131A, SM103, ZIR000, HA-18WD, ZRW103, HA02C, HA03C

Offline TedStriker

  • Jr. Member
  • **
  • Posts: 65
  • Karma: +2/-0
Re: Ping Sensor
« Reply #14 on: October 05, 2009, 04:43:08 pm »
Ping Sensor 1.3 has been finished. Now you can invert the red/green circle by configuration.
And I did some renaming of scene events and response field.
Have a look at the wiki for details http://wiki.micasaverde.com/index.php/Ping_Sensor_Plugin

Invert = 1 -> red = no response, green = response
Invert = 0 -> red = response, green = no response

To make the scene handling congurent you have to choose between D_PingSensor.xml (if Invert = 0) and D_PingSensor_Invert.xml (if Invert = 1). It's not possible at the moment to handle this by the script itself, because it's static text within the device description.

If you have questions or experience issues, please let me know. I will answer as fast as it is possible.

P.S. New version files are attached
« Last Edit: October 05, 2009, 04:46:04 pm by TedStriker »