[SOLVED] PS4-waker - Ubuntu - Bash/Sudo - Not working

A long story short, I cannot get PS4-waker to work from within OpenHAB. I can only find the 1 article on here, where someone said they were having problems getting it to work, but switched from Windows to Debian and they got it to work.

For reference, Im on Armbian (Ubuntu) on an ARM install.

Because the website here thinks Im posting links, when Im not, my pson.sh file will be called pson.shELL in this forum post.

I have:

  • Created a pson.shELL in /etc/openhab2/scripts

  • Set execute permission on that (when logged in as myself) - chmod +x pson.shELL

  • Logged in as myself and confirmed the script works - sudo bash /etc/openhab2/scripts/pson.sh also bash /etc/openhab2/scripts/pson.sh

  • Ensured the openhab user has sudo permissions - sudo adduser openhab sudo

  • Edited the passwd file to ensure openhab user is true on bash

    openhab:x:116:125:openhab2 runtime user,:/var/lib/openhab2:/bin/false
    openhab:x:116:125:openhab2 runtime user,:/var/lib/openhab2:/bin/bash

  • Run the script as the openhab user (when logged in as myself) - sudo --user=openhab bash pson.shELL (which works fine)

  • Tried multiple variations within my rules to get this thing to work or log results (Note the creation of a directory at the bottom of the rule, which that directory DOES get created, so the rule is working)

rule “PlaystationOn”
Item PLAYSTATION received command ON
val String results = executeCommandLine=(“sudo bash $OPENHAB_CONF/scripts/pson.sh”)
logInfo(“PlaystationOn”, results)
val String results1 = executeCommandLine=(“bash $OPENHAB_CONF/scripts/pson.sh”)
logInfo(“PlaystationOn”, results1)
val String results2 = executeCommandLine=(“bash@@$OPENHAB_CONF/scripts/pson.sh”)
logInfo(“PlaystationOn”, results2)
val String results3 = executeCommandLine=(“sudo --user=openhab /usr/local/bin/ps4-waker”)
logInfo(“PlaystationOn”, results3)
val String results4 = executeCommandLine=(“sudo /usr/local/bin/ps4-waker”)
logInfo(“PlaystationOn”, results4)
val String results5 = executeCommandLine=("/usr/local/bin/ps4-waker")
logInfo(“PlaystationOn”, results5)
val String results6 = executeCommandLine=(“mkdir /etc/openhab2/NEWDIR1”)
logInfo(“PlaystationOn”, results6)

As you can see, Ive tried calling the script pson.shELL multiple ways from the rule, as well as directly calling ps4-waker directly (and created a directory to prove that openhab is executing my commands). Ive added the val String result bits, which seems to be the correct way to output any errors etc back into the openhab logs?

Of which the openhab.log shows the following when I flip the switch on the Basic UI:

2018-01-15 14:07:02.246 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘sudo bash $OPENHAB_CONF/scripts/pson.sh’
2018-01-15 14:07:02.262 [INFO ] [smarthome.model.script.PlaystationOn] - null
2018-01-15 14:07:02.269 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘bash $OPENHAB_CONF/scripts/pson.sh’
2018-01-15 14:07:02.274 [INFO ] [smarthome.model.script.PlaystationOn] - null
2018-01-15 14:07:02.286 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘[bash, $OPENHAB_CONF/scripts/pson.sh]’
2018-01-15 14:07:02.296 [INFO ] [smarthome.model.script.PlaystationOn] - null
2018-01-15 14:07:02.304 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘sudo --user=openhab /usr/local/bin/ps4-waker’
2018-01-15 14:07:02.309 [INFO ] [smarthome.model.script.PlaystationOn] - null
2018-01-15 14:07:02.316 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘sudo /usr/local/bin/ps4-waker’
2018-01-15 14:07:02.321 [INFO ] [smarthome.model.script.PlaystationOn] - null
2018-01-15 14:07:02.336 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘/usr/local/bin/ps4-waker’
2018-01-15 14:07:02.346 [INFO ] [smarthome.model.script.PlaystationOn] - null
2018-01-15 14:07:02.353 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine ‘mkdir /etc/openhab2/NEWDIR1’
2018-01-15 14:07:02.363 [INFO ] [smarthome.model.script.PlaystationOn] - null

Im not exactly what you would call an expert with Ubuntu… so if anyone has any ideas, Im all ears and the help would be really appreciated!

i run some shell scripts like that without any issues:


edit: you don’t get an answer from a script without timeout, so if you want so see the result you have to add something like:

var String text= executeCommandLine(“sh@@/etc/openhab2/scripts/script.sh”, 30000)

Thanks for the quick reply. I cut down my rules file and did as you said. OpenHAB still says its executing the script and still has a null output. Ive cut the rules down to this (two different attempts):

rule “PlaystationOn”
** when **
** Item PLAYSTATION received command ON**
** then**
** val String results7 = executeCommandLine=(“sh@@/etc/openhab2/scripts/pson.sh”)**
** logInfo(“PlaystationOn”, results7, 100000)**
** val String results8 = executeCommandLine=(“ps4-waker”)**
** logInfo(“PlaystationOn”, results8, 100000)**

My shell script is now as simple as this:


Ive tried it without #!/bin/bash at the top. Ive tried multiple methods for executing ps4-waker in the shell script:

sudo --user=openhab /usr/local/bin/ps4-waker
sudo /usr/local/bin/ps4-waker

The above 3 examples say “Command not found” when I run from the command line as either bash or sh (but do work from command line), which is why I simply went for ps4-waker. Ive tried to sudo from within the shell script, outside of it… all work, if I run in from the command line… but not if I run it from within OpenHAB.

The only thing I note that my limited knowledge of Ubuntu has, is that…I installed ps4-waker as my own user account, it is in /usr/local/bin and the file is a symbolic link, pulling in files from around other places (I assume).

So I dont think this is an OpenHAB specific problem as such? Perhaps Ive messed up my permissions somehow? Perhaps I need to setup some other environment permissions?

Any other thoughts? Has anyone who has gotten this working any thoughts/information on how they got it working?


You have to put the timeout parameter inside the executeCommandLine call, not inside the logInfo call.

Like this:

val String results = executeCommandLine("sh /etc/openhab2/scripts/pson.sh", 5000)
logInfo("PlaystationOn", results)
1 Like

See my post again, you put the timeout in the wrong command.

EDIT - Ive logged into the console as the OpenHAB user account and re-run the setup for ps4-waker… and it now works!! :slight_smile: I began to suspect that ps4-waker stores information on a user account specific basis, hence if scripts run as OpenHAB user… then OpenHAB user needs to have run the basic setup for ps4-waker.

However, Im still curious as to why my timeout settings didnt work, if anyone can tell me?

That is what I thought, however I had problems and seen someone do it differently. I didnt notice the change you guys specified about being on the execute line… but Im now back at my previous problem. The log file states:

2018-01-15 16:34:35.640 [INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model 'home.rules’
2018-01-15 16:34:35.649 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘home.rules’ is either empty or cannot be parsed correctly!
2018-01-15 16:34:35.712 [WARN ] [el.core.internal.ModelRepositoryImpl] - Configuration model ‘home.rules’ has errors, therefore ignoring it: [5,81]: mismatched input ‘,’ expecting ‘)’
[5,87]: mismatched input ‘)’ expecting ‘end’

This is my rules file:

rule "PlaystationOn"
Item PLAYSTATION received command ON
val String results7 = executeCommandLine=(“sh@@/etc/openhab2/scripts/pson.sh”,30000)
logInfo(“PlaystationOn”, results7)
val String results8 = executeCommandLine=(“sudo ps4-waker”,30000)
logInfo(“PlaystationOn”, results8)

Those should be correct… right?

It will run as the user that started OpenHab. In my setup that is the openhab user

1 Like

Thanks to everyone for your help!!

If anyone can explain why my timeout settings above didnt work (2 posts above), id really like to know as it looks useful for debugging. EDIT - Double = in the command line!! :roll_eyes:

For anyone in the future trying to get ps4-waker working, here is my simple switch to turn on your ps4.

To make sure it works, you need to log into the openhab user account at the console and run ps4-waker to set it up AS the openhab account. There may be another way of doing this, but this is the only way I got it to work.

The contents of all my files are as below:

FILE “pson.sh” in the scripts folder

String PLAYSTATION “Playstation On/Off”

rule "PlaystationOn"
Item PLAYSTATION received command ON


How to run ps4-waker with openhab user?

See above:

I know, but when i conneted whit openhab account the shell is a openhad program.


EDIT: I modified / etc / passwd and now it works


Ive only just picked up on this and seen the re-opening of the post.

EDIT: I see youve solved it, but for anyone else, hope this helps

Im having to think back as to what I did, however, you have to log into the server as the Openhab user account, at the desktop. Im not sure if this is what you are doing or not, however, my best guess is that if you are logged in as another user account, and run a shell as the openhab account, some environment variables arent created correctly/used. So please confirm you have logged in as the openhab user.

Additionally, I cannot remember now if I set any other permissions… I dont think so, however, I did write a full post on everything I did to get my whole openhab setup working, including any strange permissions I set. You can find that here

Finally, heres a selection of the way I got the rules working eventually. As you can see, I am not calling a separate script in the end. Eventually, openhab would call the ps4-waker directly without the need for a script. so examples below.

// *************************
// *************************

// Update switch status to On/Off if device manually switched on

rule "Update Playstation state"
    Item PSResult changed
	if (PSResult.state == 0) PLAYSTATION.postUpdate("ON") else PLAYSTATION.postUpdate("OFF")


rule "PlaystationOn"
		Item PLAYSTATION received command ON

rule "PlaystationOff"
		Item PLAYSTATION received command OFF
		executeCommandLine=("ps4-waker standby")

// PLAYSTATION - Activities

rule "Playstation-Amazon"
		Item PLAYSTATIONACT received command 0
		executeCommandLine=("ps4-waker start CUSA00126")

rule "Playstation-Netflix"
		Item PLAYSTATIONACT received command 1
		executeCommandLine=("ps4-waker start CUSA00127")

To see how the PSResult for On/Off works, check this post: