PS5-MQTT: Control PlayStation 5 devices using MQTT

I re-authandicate with URL and CODE from PS5 because I was thought that too. But it’s only AWAKE and CLOSE.

The web-ui will not display game state. Refer to the entities attributes in HA instead.

It’s not refer either to entities. I’m getting only awake…

  • Is the log showing any errors?
  • are your PSN accounts privacy settings “open” enough?
  • is your PSN account set to “online”?

Thanks for this great add-on, works perfectly fine. Have you any idea we can retrieve the Controller battery status and perhaps get controls working?

1 Like

Awesome add-on. A bit of work to set-up, but in the end it looks great:

PS5HA

I’m using media player template as custom component for this with the following in my configuration.yaml:

media_player:
  - platform: media_player_template
    media_players:
      playstation_5:
        device_class: tv
        unique_id: media_player.playstation_5
        friendly_name: "PS5"
        media_image_url_template: >
          {% if states('sensor.ps5_activity') == "playing" %}
            {{ state_attr('sensor.ps5_activity','title_image') }}
          {% endif %}
        turn_off:
          data_template:
            entity_id: switch.ps5_power
          service: switch.turn_off
        turn_on:
          data_template:
            entity_id: switch.ps5_power
          service: switch.turn_on
        volume_up:
          service: media_player.volume_up
          data_template:
            entity_id: media_player.onkyo
        volume_down:
          service: media_player.volume_down
          data_template:
            entity_id: media_player.onkyo                   
        current_source_template: "{{ state_attr('sensor.ps5_activity','title_name') }}"
        value_template: "{{ states('switch.ps5_power') }}"
        title_template: "{{ state_attr('sensor.ps5_activity','title_name') }}"
    
10 Likes
  • No
  • Yes
  • Yes

It works and just stopped…

Starting PS5-MQTT...
2023-05-14T23:39:39.454Z @ha:ps5:webserver Server listening on PORT: 62496
2023-05-14T23:39:39.481Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/5C9666253542
2023-05-14T23:46:20.860Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/5C9666253542
2023-05-14T23:47:50.888Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/5C9666253542
2023-05-14T23:54:42.520Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/5C9666253542

Am I right in thinking there’s no way to get media playing info from the PS5? I’d like to bring up my lights when I pause Netflix etc. TIA

Correct; non game activity information isn’t exposed by the Sony apis.

Thanks for the info

Hello!

I want to install it but, when I try to add repository, I get message that my setup is not good (I installed HA over with Python virtual environment).

Is there any way to setup this add-on?

Thanks a lot!
Claudio

Hi Guys!

I need help! I’m lost on how to get the NPSSO to a token… i was able to get my ssocookie by don’t know how to run does commands that the document talk about to get the token from the ssocookie! any help will be appreciated…

It’s all in the documentation

1 Like

I did read document, the part i don’t get its where i’m going to do the “function call” to convert my ssocookie

// This is the value you copied from the previous step.
const myNpsso = “<64 character token>”;

// We’ll exchange your NPSSO for a special access code.
const accessCode = await exchangeNpssoForCode(npsso);

// :rocket: We can use the access code to get your access token and refresh token.
const authorization = await exchangeCodeForAccessToken(accessCode);

You don’t need to convert it. The application does so for you.

ok this is what i got:

i added the NPSSO on my secret.yalm and on the ps5-mqtt configuration i added:

But i’m getting this error now:

Failed to save add-on configuration, Missing option ‘psn_accounts’ in root in PS5 MQTT (df2164f9_ps5_mqtt). Got {‘mqtt’: {}, ‘logger’: ‘@ha:ps5:*’, ‘device_check_interval’: 5000, ‘device_discovery_interval’: 60000, ‘account_check_interval’: 5000, ‘include_ps4_devices’: False}

Probably a formatting issue somewhere. Try restarting HA and retrying maybe. And double check all names. Also try it without secrets.

P.s. shouldn’t it be secrets.yaml?

yeap i restarted even rebooted my raspberry pi… and still the same error msgs… "I did fix the secrets (added the “s”)

1 Like

Most likely the formatting is incorrect. I’d advise to use the yaml editor for the configuration instead. Yaml is quite opinionated with regards to indentation and such. And the HA add-on configuration editor isn’t the best implementation for helping you get it right.

Hi @FunkeyFlo , first of all, thank you so much for this amazing add-on, works amazing.
I have a question that I am not sure if its even possible to make or not (tried to check the code and make it by myself, but seems that I am too dumb for things like this)

problem with PSN: a year ago PSN disabled all russian accounts (yeah, unfortunatelly I am russian and not proud of it to be honest). So you can check the info of a user (online, what this account is playing etc.) but when you try to login to playstation network it gives an error, therefore entering to your account is kind of impossible, but all your activity is available to other users

Solution: I saw that there is a way of searching for users from the API, so it might be possible to get this information from the npsso, also for people who want to check who is online that might be usefull. for example in the config we can input a list of users that we want to follow and the integration will create a sensor for each account, or 1 sensor with different attributes for all the info from the accounts that we input in the configuration. Also I saw that there is an option to check the trophies on the title that you are currently playing.

I tried replicating the work of the api by myself to get this info with a rest sensor, but it seems that sony thought about that and is impossible to get the information without requesting it from sony server, so there is no way of pulling this info on a “normal way”

I am not sure, maybe this is a feature that you were planning to implement

1 Like