[solved] Wake on Lan in OH3 not working - not a member of 'org.openhab.core.thing.binding.ThingActions'

Hello
I’m getting a little desperate.
I am trying to set up Wake on Lan with the network binding according to the documentation. When triggering the rule, however, I always get the error

2022-01-27 11:37:58.111 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID 'strom-2' failed: 'sendWakeOnLanPacketViaMac' is not a member of 'org.openhab.core.thing.binding.ThingActions'; line 43, column 17, length 34 in strom

rule snippet

val aktion = getActions("network", "network:pingdevice:computer")
                if (aktion === null) {
                     logInfo("actions", "Actions not found, check thing ID")
                     return
                } else {
                Thread::sleep(8000)
                aktion.sendWakeOnLanPacketViaMac()
                }

I have also tried it with the original variable names via copy paste but that did not help either.
Binding an OH version 3.2

I think I had the same problems that you have but finally found a post in the community that works for me. Here is the example code that I am using:

var wolAction = actions.get("network","network:pingdevice:b16bfbfc7c");
wolAction.sendWakeOnLanPacketViaIp();

This is a JavaScript action in a rule, I think I created this via the JavaScripting addon, I’m not sure if I can see this somewhere in MainUI. It might also work in the built-in Nashorn Engine though, you can just try for yourself.

Unfortunately, no luck. I always write my rules as a file and not in the user interface. With the Javascript part, the whole rule doesn’t work anymore either.

 Script execution of rule with UID 'strom-2' failed: An error occurred during the script execution: index=0, size=0 in strom

Ok i solved the problem or not…
An DSL rule need a static function. [SOLVED] Actions - #4 by hilbrand?
The only static function is the deprecated function “sendWakeOnLanPacket”
sendWakeOnLanPacketViaMac and sendWakeOnLanPacketViaIp are not static… so the DSL rule can not use them.
openhab-addons/NetworkActions.java at main · openhab/openhab-addons · GitHub

1 Like

Good find! Would you log a Githib issue to get a fix?

any fix for that ?

The code I posted works for me. I think the fix is only required for DSL rules

II don’t think so. The only way would be to adapt the functions of the binding. sendWakeOnLanPacketViaIp(); should work without problems in ECMAScript for rules. For DSL rules only sendWakeOnLanPacket