OH3 need help with network binding and wake on lan

Hi,

I am on my Raspi 3B+ and OH3. Now I want to use the network binding of OH3 to wake up my PC. Therefore I tried to get some information from following thread:

Switch state from network binding combined with wake-on-lan action.

  1. I installed the network binding in OH3 using the UI
  2. I created a thing called ‘MiniPC_thing’ also using the UI:

  1. I created an item called ‘MiniPC_item’ using Visual Studio Code:

Switch MiniPC_item "MiniPC_item" {wol="192.168.178.255#B4:2E:99:27:13:77", channel="network:pingdevice:MiniPC_thing:online"}

I set Auto-update to false using metadata, but now I stuck.
I thought if I create an item of type ‘Switch’ I get some switch-icon in the UI what I can use set to on and off for testing - but it just shows ‘OFF’ - no icon that I can really use.
Now I stuck - I don’t know how to get further.

My final goal is to wake up my PC every day at 02:00 AM to do a data backup to external storage.

What I am missing please?

This is old syntax, for the V1 wake-on-LAN binding. It will not work in openHAB 3.

Wake-on-LAN can now be effected through the Network binding. See this section of the documentation on how to achieve this via a rule.

The tutorial that you are using will not work without modification, as it was written for the old v1 binding. See the latter posts in that thread for more information.

OK thanks,

does that mean I have to create a rule like mentioned in the docu?:
And what about the item? Do I still need it in OH3?

And then? - How to get further?
How to get a simple switch (or better a timer) to wake my PC?

Yes

Probably.

Like this one, for example.

Hi,

now I have a simple Switch item and created a rule using OH3 UI:

In the Then section I added a script:

But if I run this script using the 'Run Now (Ctrl-R) inside the OH3 script editor I get following log in frontail:

What I am missing here?

I think it’s trying to interpret your DSL script as javascript.

I found it by myself now, I chose the wrong script type, one must use ‘Rule DSL’:

Now it is working

1 Like

In Javascript / ECMAScript it would be:

var wolAction = actions.get("network","network:pingdevice:devicename");
wolAction.sendWakeOnLanPacket();

:wink:

1 Like

How can I link the script? I want to have a switcher to control my tv

I have following configuration, but it won´t work.

item:

Switch TV {wol="192.168.188.52#00-c3-f4-14-41-83", channel="network:servicedevice:258a024dad:online"}

Rule:

Script:

val deviceaction = getActions("network", "network:servicedevice:258a024dad")
deviceaction.sendWakeOnLanPacket()

This is openHAB 1 syntax for the outdated WOL binding and is not going to work with openHAB 4!
As commented in your other topic, first check if your TV supports WOL wakeup.

yes my tv supports wol. How should it be done in openhab 4 syntax?

Sometimes it works for my tv to turn it on (via OH1 Setup), sometimes it won´t work. Immediadly after turning off, it won´t work.

First, read the network binding documentation carefully snd setup a network thing for your TV with the given MAC Address.
Then take the rule from the docs and modify it to your needs


val actions = getActions("network", "network:pingdevice:devicename")
if (actions === null) {
    logInfo("actions", "Actions not found, check thing ID")
    return
} else {
    // Send via MAC address
    actions.sendWakeOnLanPacketViaMac()
}

1 Like