Page 1 of 1

System Alive Checker and WOL

Posted: Monday 18 November 2019 16:54
by tarmacalastair
Hi,

I've created some switches to wake up devices and some to check if devices are pingable on the network. So that's 2 Domoticz switches per device.

Then I thought I could save space on the dashboard by just having a single switch (System Alive Checker) and assigning a script to it in the On Action: box. I've added a script: script:///home/bob/domoticz/scripts/wakeupPC.sh but when I click the button in Domoticz I get Error sending switch command, check device/hardware ! and the log says Error: Pinger: This is a read-only sensor!

Is there something I've missed or could this be added as a request please?

Many thanks.

Re: System Alive Checker and WOL

Posted: Monday 18 November 2019 21:17
by FireWizard
Hi,

What is your goal?

I assume, that you want to create a switch, that, if you press it, your PC (or any other device, that supports Wake on Lan) is booting and that the same "switch" indicates that the device in online (you are able to ping it)

If so, that is quite easy, without any script or whatever.

Do it as follows:
1. Create in hardware a hardware component of the type: Wake-on-Lan
2. Fill in the Remote Address => Use the network broadcast address (So if your network has the address 192.168.1.0 and netmask 255.255.255.0, you fill in here: 192.168.1.255)
3. Fill in as port: 9
4. Click Setup and fill in your Device Name and its corresponding MAC address
NEXT
5. Create a hardware component of the type: System Alive Checker (Ping)
6. Click Setup and fill in the required fields, such as Name, IP address and Timeout

Now you created two devices (WoL and Equipment Alive)
Under Setup => Devices, set the Equipment Alive to "Set Unused" (Green arrow), while the WoL device has to be set to used (blue arrow)
Under Switches, go to your (WoL) device, which is visible and click "Edit". Switch type is "On/Off and under Sub/Slave Devices add the "Equipment Alive(ping) device, which you set previously to "Unused".

You can change the icon, if you like. If you press the button the WoL command will be sent, while availability (ping status) is indicated by "On".

Regards

Re: System Alive Checker and WOL

Posted: Tuesday 19 November 2019 15:47
by tarmacalastair
Thanks for the suggestion - it sort of works! I am indeed aiming to do what you suggest - I'd like a single button which shows if a PC is up or not and which can be clicked to wake it up. (Even better would be if I could also click on it when on to turn the PC off via a script. But to do that I'd like to be able to prompt for confirmation which I haven't worked out how to do yet.)

Using your method does work in a sense. However, in testing on a PC there are a few snags:
  • If I shut down the PC then the icon does not change and the button still says "On", even after a couple of hours. If I refresh Domoticz then the status does change to "Off". But with a normal System Alive icon, it changes without refreshing.
  • Thus, with the icon still showing as "On" then I would not know that it had gone down (without refreshing). If I do realise and click the button then Domoticz says "Switching Off" and does not issue the WOL call - I have to press it a further time to wake up the PC.
  • Similarly, if the PC is on and the icon says "On" then Domoticz says "Switching Off" again when you click on it but nothing happens.
Thanks again.

Re: System Alive Checker and WOL

Posted: Wednesday 20 November 2019 16:08
by FireWizard
Hi,

You said:
If I shut down the PC then the icon does not change and the button still says "On", even after a couple of hours. If I refresh Domoticz then the status does change to "Off". But with a normal System Alive icon, it changes without refreshing.
Thus, with the icon still showing as "On" then I would not know that it had gone down (without refreshing). If I do realise and click the button then Domoticz says "Switching Off" and does not issue the WOL call - I have to press it a further time to wake up the PC.
Similarly, if the PC is on and the icon says "On" then Domoticz says "Switching Off" again when you click on it but nothing happens.
This is obviously a browser issue. I always do a refresh, if I know, that the situation might have been changed since I looked for the last time, in order to avoid that I get "cached data". Pressing F5 refreshes the screen.The behavior you described, I also have noticed, while testing, but I do not have any solution for it, except refreshing the screen.

If the PC is "On" and the icon says "On" is correct in, my opinion. If you press the button then Domoticz will say "Switching Off", but because you have no action defined, if you press the button, nothing will happen. Unfortunately the icon will indicate off, until you refresh the screen (F5).

You said also:
Even better would be if I could also click on it when on to turn the PC off via a script. But to do that I'd like to be able to prompt for confirmation which I haven't worked out how to do yet.
The intention is that, if you push a button, that the action is carried out, in this case to send a WoL command. Probably you don't want to confirm that WoL command, but only if you switch off. If it is acceptable that both on and off have to be confirmed, you can tick the "Protected" box and select a very simple "Yes" as password in the Settings for Light/Switch Protection. It is a work around, I know.

For remote switching off a PC, various solutions are available, both Windows and Linux.

E.g.
For Windows: https://www.online-tech-tips.com/comput ... n-command/
For Linux: https://linuxcommando.blogspot.com/2013 ... -host.html

Regards

Re: System Alive Checker and WOL

Posted: Wednesday 20 November 2019 18:32
by tarmacalastair
OK many thanks for your suggestions.

I've added a hibernate script to the Off action for the WOL switch and that does work nicely. As you suggest I could add a simple password to prevent accidentally powering things off.

Unfortunately for me at least, the whole point of a system alive checker is that it does the checking for me without me having to refresh. And this is what the system alive checker switches do on their own (when not attached as a slave device). Otherwise I have to keep refreshing to find out if devices are up or down in the building.

So I think for now I'll use your suggestion for waking and powering off but keep the System Alive switches for checking their status. Unless you or anyone else have any other thoughts?

Thanks.

Re: System Alive Checker and WOL

Posted: Wednesday 20 November 2019 19:00
by FireWizard
Hi,

No other ideas for the moment but I' m open for suggestions.

Regards

Re: System Alive Checker and WOL

Posted: Thursday 21 November 2019 17:07
by Thorgal789
I had same problem > https://www.domoticz.com/forum/viewtopi ... 95#p219795
So much problems with that, so I have used my router/modem API.
Check for your model, but on mine
- with 1 request you can have a JSON list with all devices connected or not connected
- buildin WOL command that work with REST request
- More information like link quality for wifi.
- works perfectly with wireless devices

Need more work, but I have finaly make a python plugin script for that, all is automatic, and no more problem with slave/master.

Re: System Alive Checker and WOL

Posted: Friday 22 November 2019 12:29
by tarmacalastair
Thanks everyone