PlayStation 5 Command Line Sensor Help - Command Failed/Empty JSON

Good point!! Silly me - corrected it now :slight_smile:

I’ll keep hoping :slight_smile:

playactor is also having problems now to set it to standby, sometimes it works and sometimes it doesn’t, there’s an open issue on github for that: playactor standby doesn't work correctly · Issue #37 · dhleong/playactor · GitHub

Hi guys, im pretty new to HA and have just started to automate my TV and audio receiver to turn on and off and switch to the correct inputs, without having to rely on the awful CEC integration of my devices.

What is the best way to get a (fast) trigger from my PS5 when i turn it on and off?

Ive read the whole thread (and others) but im quite overwhelmed right now…

—A bit off-topic –
I use Ping (ICMP) - Home Assistant (home-assistant.io) integration to ping to the PS5. In my situation I can see on/off states. PS5 needs to be really OFF for this (standby is reported as ON). Still hoping for a HA integration as available for PS4 though… For discussion on this please open a new topic (and mention me if you need help, I can give it a try). We should not hijack this topic

1 Like

I’m biased ofc, but if you want support for standby I’d say my python script is the easiest way to go right now as it doesn’t have any dependencies that HA doesn’t have - meaning you can just drop it in and configure it with a command line sensor (binary or otherwise). Examples just above :+1:

1 Like

Thank @wicol for this script, would be very nice if you get the sleep function integrated also!
Since I use a synology with docker HA, I had to change the command format to

- platform: command_line
  unique_id: 1644163974631
  name: ps5_wired
  device_class: connectivity
  command: 'python ./custom_sensors/ps5.py -b DEV_PS5'
  scan_interval: 30

BTW, for now I don’t really care for waking it up with HA since I cannot turn it off again, so I didn’t even try to use that, but it looks like you need some additional sniffing and credentials and stuff before getting.
It would be nice if you’re able to get the sleep functionality working as well, and would you then also be so kind to post a bit more about the steps how to get the right credentials/settings/etc.?

The sleep/standby function is supported in playactor https://github.com/dhleong/playactor

There are posts above that show how to make a command_line switch… you can also then make that a “universal media player” so you have a media player entity like the PS4 integration did. I believe the instructions for that came from above also.

where can i find my user credential?

You’ll have to use tcpdump at this point. Unless someone’s got a better idea? playactor has implemented the login flow so you might be able to get it through that as well. Here’s an old instruction from ps4-waker:

</s> <s># tcpdump -s0 -X -n -i <interface> udp and port 987</s> <s>
> You’ll be looking for a packet that looks like HTTP and contains the string ‘user-credential:NNNNNNN’. Remember the “user credential” number.

That won’t work here. Here’s a working example:

tcpdump -An udp and dst PS5_IP_GOES_HERE | grep user-credential

Then wake the PS5 from your phone app, and a line should appear with the credential:

$ tcpdump -An udp and dst 192.168.0.37 | grep user-credential
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
user-credential:-XXXXXXXXXX

Hello,

I have installed HA in Docker on my Raspberry.

I have managed that the commands e.g. playactor wake --host-name PS5-639 are executed correctly on the Raspberry.

I think I need to somehow still allow the SSH connection from HA but how?

I mean this function:

switch:
- platform: command_line
  switches:
      playstation:
        value_template: >
          {% if value == 'AWAKE' %}
            true
          {% elif value == 'STANDBY' %}
            false
          {% else %}
            Unknown
          {% endif %}
        command_state: ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'playactor check --host-name PS5-639 | jq -r ".status"'
        command_on: ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'playactor wake --host-name PS5-639'
        command_off: ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'playactor standby --host-name PS5-639'
        friendly_name: Playstation 5

Great job,

I create repository docker image in Docker Hub

Hi, Trying to get this to work with very limited coding / yaml skills. attempting to use your code as a template for mine.

From what i can work out i have successfully installed Playactor on my Pi and connected to the PS5 remote play.

For the Switch, and more specifically the 3 command lines (state / on / off)
Can you clarify:
in the example pi: is this the Raspberry pi user name?
the IP address; Assume of the Pi not the PS5
Host name: The name of the PS5 discovered as part of the browse command during setup?

[email protected] 'playactor check --host-name PS5-639

Many thanks in advance

Regards

Pretty much yes to all your questions.

  • pi is the pi’s username
  • ip the pi’s ip. You are basically creating a remote connection to your pi, running a command and whatever the output is feeding it back to home assistant.
  • host name is what was discovered by the playactor in previous steps

The strictHostkey thing is there to make sure Pi doesn’t ask you for pass (logs in automatically using your id_rsa key) when you try to do the remote connection to your pi.

To test you you should be able to run this command from your HA docker instance and it should return a status of your playstation.

ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] 'playactor check --host-name PS5-639 | jq -r ".status"'

I think I’ve found the the problem but im too much of an beginner to know the solution.

With the retirement of the default pi (no password) default account on newbuilt Raspbian systems Im having to put in my chosen username substituting pi before the IP address.

When I try and run the command from the Terminal Im being asked to enter my account password in advance on getting the status response (Standby / Awake).

Is there a way to modify the commands (State / On / Off) to incorporate the pi account password?

Sorry for being such a trouble

@davy932
You guys are correct you need to login first to your Pi without the password. Here is how to set it up

  • First install the “ssh & web terminal” add-on in home assistant (settings > addons > add on store)
  • Turn it on and open it up. Once you are logged in you will need to generate an SSH key.
  • Run ssh-keygen when asked for a password just press enter, everything else you can enter whatever you want
  • Now that we have the key made, you need to add it to your Pi (or wherever you are running your playactor), it will then use this key to authorize you without asking for a password. To do that run ssh-copy-id followed by your PI. For example: ssh-copy-id [email protected]. (pi is the username to use for my Pi)
  • It should ask you for a password this one time to add it.
  • Now that its done, try logging in into your pi by just using ssh [email protected] you should be logged in without being asked for a password
  • And the final step, see if your playactor command works.
    Run

ssh [email protected] ‘playactor check --host-name PS5-639 | jq -r “.status”’

(update the above to match your username, pi hostname and ps5 host name)
If everything went correctly you should get ps5 status in your terminal.

If it doesn’t you can try to copy the ssh key to a HA config folder by using this command:
cp .ssh/id_rsa /config/ssh/id_rsa
… I don’t remember if cp actually makes the folder if it doesn’t exist so you might have to run mkdir /config/ssh first before you can run the above
you can now try to connect using the key in that specific folder using this command:

ssh -i /config/ssh/id_rsa -o StrictHostKeyChecking=no [email protected] ‘playactor check --host-name PS5-639 | jq -r “.status”’

Hopefully it now works and you get the status of your ps5 in the console.
You can now add the command (the one that worked into your HA sensor config).
You should be all set now.

If you are still having trouble google how to generate ssh key and copy it to a different host, since that’s what we are doing here.

1 Like

AND…
IT WORKS!!! Woohoo!!

Many thanks!!

Thanks! All I needed was the binary sensory to run a automation…

Hey guys, I created an add-on to make it easier to integrate Playactor with Home assistant using MQTT. You can find and install it through this repository!

4 Likes

Has anyone successfully install this on a original Raspberry Pi B

Im getting this error:

pi@raspberrypi:~ $ playactor browse
/usr/local/lib/node_modules/playactor/node_modules/ix/asynciterable/asyncsink.js :7
_ended;
^

SyntaxError: Unexpected token ;
at Module._compile (internal/modules/cjs/loader.js:760:23)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)
at Function.Module._load (internal/modules/cjs/loader.js:620:12)
at Module.require (internal/modules/cjs/loader.js:723:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object. (/usr/local/lib/node_modules/playactor/dist/util/async .js:13:21)
at Module._compile (internal/modules/cjs/loader.js:816:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:827:10)
at Module.load (internal/modules/cjs/loader.js:685:32)

Many thanks