[SOLVED] Last rule I need to make this fully autonomus

If your Item never went ON, you won’t see it go OFF either when you unplug the router.

Also with retry=4 it will take four minutes to notice a failed connection.

I’ve created a panel on habpanel with the MyDevice information and it’s saying it’s returning a value of NULL

I unplugged the router to see if that changed to OFF but it stayed the same.

Does this help?

{"link":"http://192.168.0.100:8080/rest/items/MyDevice","state":"NULL","editable":false,"type":"Switch","name":"MyDevice","tags":[],"groupNames":[]}

Try something simple to verify your install
Add a new thing -
Thing network:pingdevice:mememe [ hostname="localhost" ]
Add a new Item -
Switch Myself "Local [%s]"{channel="network:pingdevice:mememe:online"}

You should probably check the Network binding configuration options in PaperUI. Tell us what your host system is -Windows anf nix environments differ greatly for this.

I’ve added those two lines of code and I now get this when I run the Rest API:

{"link":"http://192.168.0.100:8080/rest/items/Myself","state":"NULL","stateDescription":{"pattern":"%s","readOnly":false,"options":[]},"editable":false,"type":"Switch","name":"Myself","label":"Local","tags":[],"groupNames":[]}

I’ve looked at Network Binding and this is the configuration:

cacheDeviceStateTimeInMS = 2000
allowSystemPings = true
arpPingToolPath = arping
allowDHCPlisten = false

I’m using a Raspberry Pi with the most uptodate OpenHab version (I updated it yesterday morning)

Okeydoke, that means the binding is unable to ping its own host. We’ve ruled out external firewalls etc. or internal Item issues.

It’s likely some permissions thing accessing system ping, I’m not a Pi person.

Can you ping from the command line?

What happens if you set allowSystemPings to false?

@rossko57 Yep it’s like it isn’t running. Nothing is coming up in the log file. I would expect to see it return a sucessful ping every 4 minutes. Even when I unplug the phone socket from the router, nothing appears in the log file. Very strange.

@rlkoshak I have connected to the Pi and was able to ping sucesfully, so the device sems fine and can connect to the outsidfe world.

I have now changed the setting to false for the SystemPing.

I’ll give the Pi a restart to see if that get’s it up and running.

The extra Thing and Item I suggested was for localhost i.e. the ping there never leaves the Pi box. So yes, nothing to do with external net, box, or service. Which was what the exercise was meant to demonstrate.

Thanks for all your help, I thought it would be a simple line switch but it’s proving to be a bit more complicated than that :persevere:

I’ve got it working.

I started to have a play with the Paper UI and searched for all network devices. Strangely it didn’t find any but I thought I’d add Google to my network device list.

After that I started seeing [vent.ItemStateChangedEvent] - network_pingdevice_2bf21589_latency appear in my log viewer.

I simply copied network_pingdevice_2bf21589 and added it to my rule. Then I ran the test by unplugging the phone line from my router and sure enough the plug switched itself off.

Thanks for all your help. Not sure why it was so difficult but hopefully this may help users who are faced with the same issue.

Ben

Please tell me how you added Google to your network device list.

Also please post your rule.

Thx!

Hi Chris

I just used the rules section within paperui.

Here is the rule I use to switch the plug off:

//Internet Is Down. Don't Panic
rule "Internet Is Down"
when
	Item network_pingdevice_2bf21599_online changed
then
	if (network_pingdevice_2bf21599_online.state == OFF){
	FF_Router_Power.sendCommand(OFF)
	InternetIsDown.sendCommand(ON)
	}
	end
	
	
//Switch The Router Back On
rule "Turn The Internet Back On"
when 
	Item InternetIsDown changed to OFF
then
	{
    FF_Router_Power.sendCommand(ON)
	}
  end

Hope that helps

It does. Thanks. But how did you add Google?