Wake on LAN does not work from OpenHab2

Hi,
I have an openmediavault server running and want to make it switch on/off via wake-on-lan and the OpenHab2 iphone app.

Therefore I installed the wake-on-lan binding in OpenHab2 and configured the following item:

Switch House_Server_Lan “Server Wake-On LAN” <it_server> (Status, Network) { wol=“192.168.0.2#12:34:56:ab:cd:ef”, exec=">[OFF:systemctl suspend \\192.168.0.2]" }

Wakeing up the server from my windows 10 installation using wol.exe with the command

wol.exe 123456abcdef

But when I use the switch in the app, the log viewer shows the following:

2019-12-14 07:24:54.512 [INFO ] [nhab.binding.wol.internal.WolBinding] - Wake-on-LAN packet sent [broadcastIp=myserver.lan, macaddress=123456abcdef]

==> /var/log/openhab2/events.log <==

2019-12-14 07:24:54.521 [vent.ItemStateChangedEvent] - House_Server_Lan changed from OFF to ON

For me this looks not so wrong, but the server just doesn’t wake up…

Can you help me, what I’m doing wrong? Also when I try to suspend it again, the command doesn’t seem to work. But systemctl suspend is the command I use on debian based openmediavault to send it to hibernate.

Thanks and kind regards,

Dirk

Please use the broadcast ip instead of the ip of the device (if using a class C network (or /24), this is

Switch House_Server_Lan "Server Wake-On LAN" <it_server> (Status, Network) { wol="192.168.0.255#12:34:56:ab:cd:ef", exec=">[OFF:systemctl suspend \\192.168.0.2]" }

I’m pretty sure that the OFF-command won’t work either, as the backslashes seem wrong to me :wink:

3 Likes

Hello Udo,
thanks a lot. Now it works and after your post and re-reading the official documentation (https://www.openhab.org/addons/bindings/wol1/) it is clear now, what they meant. I thought they were talking about not to use the OpenHab2 ip… Sorry for that.

Thanks also for your hint regarding the exec. This didn’t and doesn’t work, too. The official documentation uses the \\ and I thought this masking would be necessary.

Nevertheless, also with \ it doesn’t work. Is there a possibility to find out, why it doesn’t work? What exactly is executed? The logging only tells me

2019-12-14 16:21:11.508 [ome.event.ItemCommandEvent] - Item 'House_Server_Lan' received command OFF

2019-12-14 16:21:11.520 [vent.ItemStateChangedEvent] - House_Server_Lan changed from ON to OFF

But that doesn’t help me that much.

THanks and kind regards,

Dirk

Your Item has an Exec binding version 1 configuration. Have you installed exec1?

You can type your command on the karaf console to see if it works.

You can use a temporary rule to call your exec action and inspect results.

rule "try exec"
when
   Item House_Server_Lan received command OFF
then
   val String results = executeCommandLine("systemctl suspend \\192.168.0.2", 5000)
   logInfo("Exec", results)
end

I’m not aware of this command. Can’t find anything about remote execution via \\ip Where did you find this command?

Good morning Rossko and Udo,

thanks for your responses.

@rossko57: I installed the exec binding right now and will try to make it run with the new syntax.

@Udo_Hartmann: Not exactly this command. I thought it was part of the exec to execute it against the given ip. Just as the shutdown command with ip parameter.

As far as I saw on the wiki page of the exec binding, it could be possible to connect to the server via ssh and then run the systemctl suspend command on the server directly.

Thanks and kind regards,

Dirk

In fact, you can use systemctl to remotely suspend a computer, but afaik the command is like that:

systemctl suspend -H user@remotepc

where ‘user’ is a user with sufficient permission at the remote system to use systemctl suspend.
‘remotepc’ is either the ip or the fqdn, by the way.

Hello Udo,

thanks a lot, that’s awesome and I’ll try this out.

Kind regards,

Dirk