PS5-MQTT: Control PlayStation 5 devices using MQTT

Strange, not behaviour I’ve seen before.

Just to verify:

  • MQTT broker is installing and running
  • PS5 MQTT is installed and running
  • The add-on log shows no errors
  • MQTT auto discovery is enabled
  • You’ve tried power cycling all involved devices.
  • You’ve been able to connect other MQTT devices/services

Correct, everything seems to be set up properly.I have not set up another MQTT device/service. All logs seem fine and like everything is running without errors…

Thanks so much for the amazing addon!

My activity is stuck on idle. I read some earlier comments about making sure I’m set to online, and I’ve gone through all the PS5 settings and made it as open as possible, so not sure where my problem might be.

I also wondered, is there a list or way of viewing all of the content I can get over MQTT from the PS5? I looked in the documentation but didn’t see it, and I’m new to HA and this kind of thing in general. I’ve seen in this chat people getting info on the cover art for the game currently playing etc, but don’t know how anyone knows where to find it :slight_smile:

1 Like

Could you try adding another Mqtt based service? Otherwise you could use mqtt explorer to check the mqtt traffic.

You could ask a friend if they can see your online activity, to check whether the problem is on Sony’s end or on yours. Otherwise make sure to check the logs. Just to verify; you did add an npsso to your config, right?

The information like cover art is exposed through attributes, not entity state. You can use the developer tools in HA to easily find out which attributes are being exposed by which entities. :slight_smile:

I finally figured it out. MQTT wasn’t configured properly and even though I couldn’t see any errors in the logs, it wasn’t communicating with the PS5 add-on. Got it now, thank you for your help/contributions!

2 Likes

Thank you for creating this.

I got it configured as part of my 1 button sequence to turn on the PlayStation, turn on the TV, turn on the receiver, set the receiver input, set the receiver volume for the PlayStation, pause the whole house music, and adjust the lights.

Cheer!

1 Like

Hi all.

I am missing some simple step I guess… I have the Mosquitto Broker installed and running (with default settings, was I supposed to tweak them?), I got the PS5 MQTT installed and running. I can find my PS5 with the web UI. But I don’t see any sensors in Developer Tools - states, except the update.ps5_mqtt_update. What have I missed?

Thanks,
-k

Is the add-on log showing any errors?

1 Like

PS5 MQTT:

Starting PS5-MQTT…
2023-02-27T12:06:04.625Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00ACxxxx
2023-02-27T12:06:04.701Z @ha:ps5:webserver Server listening on PORT: 63470
2023-02-27T12:06:07.679Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00ACxxxx

Mosquitto broker:

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service legacy-cont-init: starting
cont-init: info: running /etc/cont-init.d/mosquitto.sh
[13:13:40] INFO: SSL is not enabled
cont-init: info: /etc/cont-init.d/mosquitto.sh exited 0
cont-init: info: running /etc/cont-init.d/nginx.sh
cont-init: info: /etc/cont-init.d/nginx.sh exited 0
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service legacy-services: starting
services-up: info: copying legacy longrun mosquitto (no readiness notification)
services-up: info: copying legacy longrun nginx (no readiness notification)
s6-rc: info: service legacy-services successfully started
[13:13:40] INFO: Starting NGINX for authentication handling…
[13:13:40] INFO: Starting mosquitto MQTT broker…
2023-02-27 13:13:41: Warning: Mosquitto should not be run as root/administrator.
[13:13:41] INFO: Successfully send discovery information to Home Assistant.
[13:13:42] INFO: Successfully send service information to the Supervisor.

Okay, no problems in the log. Is MQTT auto-discovery enabled?

After several reboots I now got 3 sensors (don’t really know what was the real issue):

So I got at least a step forward! :slight_smile: Still unclear to me how to control the PS5:;if I hit the power switch nothing happens.
image

Have you authenticated the ps5 using the web-ui?

To be honest I had actually previously missed that part (small icon in the web UI to make the authentication). Now when I click the link, get an error. Tried in incognito mode as well :frowning:

image

Edit: With another device I was able to follow it through. Now seems to work, I’ll give it a try. Thanks!

Hello FunkeyFlo,

Again thanks for your amazing Add-On !

Is there a way to determine how long the Npsso Tokens are valid?
I have set up a reminder every two months but it would be cool to actually know how long the Tolkens are valid.

I have a bit of a weird problem since I’ve been using this. Everything works, but powering the PS5 off seems to be very unreliable. Turning it on always works though.

I just had it happen again, see the log below. In this case (because LG’s TV software sucks) the PS5 turned on automatically when I don’t want it to and I have an automation running to switch off the PS5 if it shouldn’t be on. Note that this is not the only case the switch off is unreliable, it can also happen after a lengthy play session, so this is just an example.
Sometimes it will just work and sometimes I have to retry many times. For this reason I have an automation at the moment that just keeps trying until it works with a delay between the retry…

2023-02-28T23:40:04.807Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-02-28T23:40:10.562Z @ha:ps5:checkDevicesState Update HA
2023-02-28T23:40:10.563Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:45:51.195Z @ha:ps5:checkDevicesState Update HA
2023-03-01T10:45:51.215Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:45:51.662Z @ha:ps5:psn-api Unable to retrieve PSN information. API response: "401:Unauthorized"
2023-03-01T10:46:21.228Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:46:23.065Z @ha:ps5:error Error: Error[2] UNKNOWN_ERROR
    at Object.<anonymous> (/usr/local/lib/node_modules/playactor/dist/socket/helpers.js:76:19)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/playactor/dist/socket/helpers.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

2023-03-01T10:46:36.238Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:46:51.237Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:46:56.257Z @ha:ps5:turnOffDevice 
2023-03-01T10:46:56.260Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:47:06.242Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:47:06.801Z @ha:ps5:checkDevicesState Update HA
2023-03-01T10:47:06.806Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:47:21.252Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:47:26.272Z @ha:ps5:turnOffDevice 
2023-03-01T10:47:26.287Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:47:36.258Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:47:36.793Z @ha:ps5:checkDevicesState Update HA
2023-03-01T10:47:36.794Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:47:51.268Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:47:51.878Z @ha:ps5:error Error: Registration error: 403: Forbidden: Remote is already in use
    at Object.<anonymous> (/usr/local/lib/node_modules/playactor/dist/remoteplay/protocol.js:88:19)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/playactor/dist/remoteplay/protocol.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

2023-03-01T10:48:06.278Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:48:21.281Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:48:26.298Z @ha:ps5:turnOffDevice 
2023-03-01T10:48:26.300Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:48:36.290Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:48:36.891Z @ha:ps5:checkDevicesState Update HA
2023-03-01T10:48:36.895Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:48:51.290Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:48:51.842Z @ha:ps5:error Error: Registration error: 403: Forbidden: Remote is already in use
    at Object.<anonymous> (/usr/local/lib/node_modules/playactor/dist/remoteplay/protocol.js:88:19)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/playactor/dist/remoteplay/protocol.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

2023-03-01T10:49:06.294Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:49:21.304Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:49:26.326Z @ha:ps5:turnOffDevice 
2023-03-01T10:49:26.330Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:49:36.310Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:49:36.887Z @ha:ps5:checkDevicesState Update HA
2023-03-01T10:49:36.888Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:49:51.317Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:49:51.913Z @ha:ps5:error Error: Registration error: 403: Forbidden: Remote is already in use
    at Object.<anonymous> (/usr/local/lib/node_modules/playactor/dist/remoteplay/protocol.js:88:19)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/playactor/dist/remoteplay/protocol.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

2023-03-01T10:50:06.322Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:50:21.334Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:50:23.110Z @ha:ps5:error Error: Error[2] UNKNOWN_ERROR
    at Object.<anonymous> (/usr/local/lib/node_modules/playactor/dist/socket/helpers.js:76:19)
    at Generator.next (<anonymous>)
    at fulfilled (/usr/local/lib/node_modules/playactor/dist/socket/helpers.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

2023-03-01T10:50:36.342Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:50:51.346Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972/set/power
2023-03-01T10:50:56.366Z @ha:ps5:turnOffDevice 
2023-03-01T10:50:56.368Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:51:06.354Z @ha:ps5:checkDevicesState Resume polling
2023-03-01T10:51:37.589Z @ha:ps5:error SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /app/server/dist/redux/sagas/check-devices-state.js:78:38
    at step (/app/server/dist/redux/sagas/check-devices-state.js:35:23)
    at Object.next (/app/server/dist/redux/sagas/check-devices-state.js:16:53)
    at next (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1161:27)
    at currCb (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1255:7)
    at runSelectEffect (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:735:5)
    at runEffect (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1208:7)
    at digestEffect (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1275:5)
    at next (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1165:9)
2023-03-01T10:51:37.590Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:51:57.617Z @ha:ps5:error SyntaxError: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at /app/server/dist/redux/sagas/check-devices-state.js:78:38
    at step (/app/server/dist/redux/sagas/check-devices-state.js:35:23)
    at Object.next (/app/server/dist/redux/sagas/check-devices-state.js:16:53)
    at next (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1161:27)
    at currCb (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1255:7)
    at runSelectEffect (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:735:5)
    at runEffect (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1208:7)
    at digestEffect (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1275:5)
    at next (/app/node_modules/@redux-saga/core/dist/redux-saga-core.dev.cjs.js:1165:9)
2023-03-01T10:51:57.619Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972
2023-03-01T10:52:08.276Z @ha:ps5:checkDevicesState Update HA
2023-03-01T10:52:08.278Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/2C9E00FB6972

No, unfortunately not AFAIK.

I’ve noticed the same behaviour. My guess is that the remote play protocol does not allow power control over the device when it is in the sign in screen. From a functional perspective this makes sense, since another user might be using the device.

I haven’t noticed other scenario’s where it’s unreliable. It might be worth checking out the playactor GitHub, which is the underlying library being used, for similar reports.

Hmm, you are correct that in this case it was in the sign in screen. It did turn off when I turned off my TV, but it is possible that was done by CEC?

As said, I also have it when I’m signed in at times, but this then at least would be part of the ‘solution’ (in that it can’t be fixed…)?

Very likely, as PS devices support turning off through libCEC.

Did you check the info mentioned below?