PS5-MQTT: Control PlayStation 5 devices using MQTT

Yes thanks. I made a few more adjustments and now it looks perfect.

type: custom:mushroom-template-card
primary: PlayStation 5
secondary: |-
  {% if is_state('switch.ps5_id_power', 'on') %}
    {% if is_state('sensor.ps5_id_activity', 'idle') %}
      Ligado
    {% elif is_state('sensor.ps5_id_activity', 'playing') %}
      {{ state_attr('sensor.ps5_id_activity', 'title_name') or states('sensor.ps5_id_activity') }}
    {%- else -%}
      {{ state_attr('sensor.ps5_id_activity', 'title_name') or states('sensor.ps5_id_activity') }}
    {%- endif -%}
  {%- elif is_state('switch.ps5_id_power', 'unavailable') -%}
   IndisponĂ­vel
  {%- elif is_state('switch.ps5_id_power', 'off') -%}
    Desligado
  {%- else -%}
    {{ states('switch.ps5_id_power') }}
  {%- endif -%}
icon: mdi:sony-playstation
entity: switch.ps5_id_power
picture: '{{state_attr(''sensor.ps5_id_activity'', ''title_image'')}}'
badge_icon: |-
  {% if is_state('sensor.ps5_id_activity', 'playing') %}
    mdi:controller
  {%- elif is_state('sensor.ps5_id_activity', 'idle') -%}
    mdi:sleep
  {%- elif is_state('sensor.ps5_id_activity', 'unavailable') -%}
    mdi:power-plug-off
  {%- endif -%}
fill_container: true
multiline_secondary: true
icon_color: |-
  {% if is_state('sensor.ps5_id_activity', 'playing') %}
    #1986e6
  {%- elif is_state('sensor.ps5_id_activity', 'idle') -%}
    #ffe057
  {%- elif is_state('sensor.ps5_id_activity', 'unavailable') -%}
    #737373
  {%- endif -%}
badge_color: |-
  {% if is_state('sensor.ps5_id_activity', 'playing') %}
    #1986e6
  {%- elif is_state('sensor.ps5_id_activity', 'idle') -%}
    #ffe057
  {%- elif is_state('sensor.ps5_id_activity', 'unavailable') -%}
    #737373
  {%- endif -%}
layout: horizontal
card_mod:
  layout: horizontal
  style:
    mushroom-state-item$: |
      .container {
        {% if is_state('sensor.ps5_id_activity', 'playing') %}
        width: 100%;
        gap: 1rem;
        {% else %}
        {% endif %}  
      }
      .icon {
        {% if is_state('sensor.ps5_id_activity', 'playing') %}
        margin-right: 0 !important;
        {% else %}
        margin-right: 1 !important;
        {% endif %} 
        display: flex;
        justify-content: flex-end;
      }
      .info {
        {% if is_state('sensor.ps5_id_activity', 'playing') %}
        width: 100%;
        {% else %}
        {% endif %}  
      } 
    .: |
      ha-card {
        padding:0 !important;
      }
      mushroom-shape-icon {
       display: flex;
       {% if is_state('sensor.ps5_id_activity', 'playing') %}
        padding-top: var(--spacing);
       {% else %}
       {% endif %}  
      }
      mushroom-shape-avatar {
        --icon-size: 100%;
        --icon-height: 100%;
        display: flex;
        {% if is_state('sensor.ps5_id_activity', 'playing') %}
         width: 150px;
         position:relative;
         margin: .6rem;
         box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
         --icon-border-radius: 8px;
         overflow: hidden;
         border-radius: 8px;
        {% else %}
        {% endif %}
      }
      mushroom-state-item {
       display: flex;
       {% if is_state('sensor.ps5_id_activity', 'playing') %}
       padding: 0;
       {% else %}
       padding: 1rem 2rem 1rem 1rem;
       {% endif %}  
      }
      mushroom-state-info {
        {% if is_state('sensor.ps5_id_activity', 'playing') %}
        padding: 4rem 1rem 1rem 0;
        {% else %}
        {% endif %}
      }
      mushroom-badge-icon  {
        {% if is_state('sensor.ps5_id_activity', 'playing') %}
        top: 3rem;
        right: unset;
        left: calc(100% + 1rem);
        --badge-size: 32px;
        --badge-border-radius: .4rem;
        {% else %}
        {% endif %}  
      }
7 Likes

Love this design! Now hopefully to get it running on docker eventually… still haven’t figured out the whole run.sh file.

Turns out the PS5 didn’t have remote enabled. I’ve now enabled it, MQTT sees the device and sees idle and has an on/off switch but does nothing else. Is this normal?

PS5 MQTT always gives a blank page for the UI

Hi,

The status is always Awake.
No playing or Game title :frowning:

Is there a way to fix it?

THX

Added an npsso? If not; please read the docs.

1 Like
Starting PS5-MQTT...
2023-10-09T20:42:24.601Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/00E42124CFBD
2023-10-09T20:42:24.625Z @ha:ps5:webserver Server listening on PORT: 62082
2023-10-09T20:42:27.625Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/00E42124CFBD
2023-10-10T09:46:48.521Z @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-10-10T09:46:48.523Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/00E42124CFBD
2023-10-10T09:46:53.890Z @ha:ps5:checkDevicesState Update HA
2023-10-10T09:46:53.897Z @ha:ps5:mqtt MQTT Message received ps5-mqtt/00E42124CFBD

Still nothing from the webpage ui

image

Game activity does not show up in the UI. Only in the mqtt entities in HA.

Thanks for the response. MQTT shows no game activity, only status (working) and on/off switch (not working); this webpage screenshot was to show what happens when I open the web ui; it has never asked to be associated with my system nor has it shown anything other than 502 bad gateway. Is it normal and I’m misunderstanding?

on/off switch (not working)

That’s because you’ve never authenticated (using the web-ui) with the remote play feature.

502 bad gateway

Are you using a proxy service? Maybe something’s up with the config. Can you access the web-ui of other add-ons? Have you tried accessing it using your local network address? Etc.

I am not using a proxy service. Are there any external ports that should be opened? Tried accessing the PS5 or PS5 MQTT using my local address?

Also, this is constantly happening as well, having to change my npsso.

2023-10-11T20:32:30.111Z @ha:ps5:psn-api Unable to retrieve PSN information. API response: "401:Unauthorized"

buongiorno , io non riesco a configurare l’addon ,
cosa devo mettere in psn_account ?

Hi, is there any way to bypass the rest mode and turn off the PS completely? Mine is connected to an UPS and I’d like to turn it off in case of a power blackout, so the battery doesn’t die in the middle of an update, for example.

Since 2 October I only get the status activity “idle” or “awake”. It no longer provides the state “playing” nor the game title and game image.
Reconnecting did not solve the issue.
Other people the same issue or know a solution?
Many thanks

Maybe your npsso expired (Note 2). Have you tried refreshing it?

Many thanks for the quick response. The NPSSO token was indeed changed. Will try again this evening to see if it now works normal again

1 Like

The only details in my entities are as follows:

How can I add the other details such as the running title, image etc.?