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

Updated with working standby

Using a pi because I already use that for bluetooth → switchbot and, besides containers, I don’t want to install stuff on my NAS, where I run hass.

If your always-on computer is running hass os this probably will not work.

Install npm

sudo apt install nodejs npm

Install https://github.com/dhleong/playactor

sudo npm install -g playactor

Search for PS5

playactor browse

Outputs

{
  "address": {
    "address": "192.168.1.95",
    "family": "IPv4",
    "port": 9302,
    "size": 170
  },
  "hostRequestPort": 997,
  "extras": {
    "statusLine": "620 Server Standby",
    "statusCode": "620",
    "statusMessage": "Server",
    "status": "STANDBY"
  },
  "discoveryVersion": "0003...",
  "systemVersion": "08540...",
  "id": "78C88...",
  "name": "PS5-635",
  "status": "STANDBY",
  "type": "PS5"
}

Copy JSON "name":

playactor login --host-name PS5-635 --no-open-urls

Follow on screen steps

Open the following URL in a web browser to login to your PSN account.
When the page shows "redirect", copy the URL from your browser's address bar and paste it here.
  https://auth.api.sonyentertainmentnetwork.com/...

Checking PS5 state

playactor check outputs json but for some reason refuses to play nice with command line sensor so I also installed jq

sudo apt install jq

Home Assistant

These can be combined with a template switch

sensor:
  - platform: command_line
    name: Playstation
    scan_interval: 300
    command: ssh -o StrictHostKeyChecking=no -i /config/.ssh/id_rsa [email protected] 'playactor check --host-name PS5-635 | jq -r ".status"'
    value_template: >
      {% if value == 'AWAKE' %}
        ON
      {% elif value == 'STANDBY' %}
        OFF
      {% else %}
        Okänd
      {% endif %}
shell_command:
  playstation_5_wake: ssh -o StrictHostKeyChecking=no -i /config/.ssh/id_rsa [email protected] 'playactor wake --host-name PS5-635'
  playstation_5_sleep: ssh -o StrictHostKeyChecking=no -i /config/.ssh/id_rsa [email protected] 'playactor standby --host-name PS5-635'
3 Likes