Ping Range of IPs

Hi,

I love my thing “pingable network device” I have created twice (one for my handy and one for my girlfriend). → If both are not pingable over 2min All lights go off.
(want to extend avilability later with BLE, but lets stay in WLAN for now)

All my Wireless Network is seperated in VLANs, so I know for sure if a MQTT device, A Guest or a WellKnown device in logged in…

In this case I want to avoid that RULE above will shut of light, when guest are in my houes while I went to car;)

So how can I realise follwing:
Scan reguallry for new devices in 192.168.3.*
Set them on a list for regulary ping (2min same as well known devices) and remove from list, if ping unsucccesssfull.
→ rule from above only if that List ist empty.

Easiest would be if the binding I allready use would support a range of IPs instead of a single one.
For now I guess I need a alternative Script doint that. Does anyone have an example for me?

Greatings David

Unfortunately this feature isn’t available natively in openHAB or the network binding.

However, as you have VLANs it sounds like you’ve got some better-than-ISP network hardware. I have a simple Unifi WiFi access point, and with a guest SSID I can detect whether devices are connected to the G guest SSID or not, and can act accordingly in openHAB. But the detection runs outside of openHAB I’m afraid, using external scripts.

have a look at arpwatch, arpalert ( e.g. http://www.linux-magazine.com/content/download/63168/487297/version/1/file/Charly_Column.pdf&usg=AOvVaw1PXE_FhFZkRYX8PFkjiW-k ) resp their manual page .

Your also could run nmap -sP 192.168.3.0/24 -oG - the output will look similar to

|Host: 192.168.0.2 (WLAN.fritz.box)|Status: Up|
|Host: 192.168.0.15 (quark.fritz.box)|Status: Up|
|Host: 192.168.0.21 (sarek.fritz.box)|Status: Up|
|Host: 192.168.0.26 (janeway.fritz.box)|Status: Up|

As long as only guest are in that subnet you may count the number of lines returned:
nmap -sP 192.168.3.0/24 -oG - | wc -l

With grep command you can filter in case there are others connected as well.

1 Like

Good idea. I am familar with unix shell.
But how do I have to wrap it into OH-Rules | OH-Scripts?

I think there are different possibilities:

  • put the complete logic in a shell script which is scheduled to be executed by a linux cronjob and then turn a switch on/off via REST API call

or