Why do you want to change this?
Hi I copied your code and it looks like this, the PS5 is in sleep mode rn so is that why?
Here is my code:
type: custom:mushroom-template-card
primary: PlayStation 5
secondary: |-
{% if is_state(âswitch.ps5_544_powerâ, âonâ) %}
{{ state_attr(âsensor.ps5_544_activityâ, âtitle_nameâ)
or states(âsensor.ps5_544_activityâ)
}}
{%- else -%}
{{ states(âswitch.ps5_544_powerâ) }}
{%- endif -%}
icon: mdi:sony-playstation
entity: switch.ps5_power
picture: â{{state_attr(ââsensor.ps5_544_activityââ, ââtitle_imageââ)}}â
badge_icon: |-
{% if is_state(âsensor.ps5_544_activityâ, âplayingâ) %}
mdi:controller
{%- elif is_state(âsensor.ps5_544_activityâ, âidleâ) -%}
mdi:sleep
Because iâm from germany and i just had like german commands
Iâm lost, is your question about the actual entity or a card?
I created a manual map and inserted various things. This also works perfectly, I see when the PS5 is on, it can turn it off and on and see what Iâm playing. Everything is perfect ⌠Only I would like to see something else instead of âidleâ and if the PS5 from us should be something else instead of âunvailableâ. Now I would like to know where I can customise these commands.
Okay, Iâm still not 100% sure what you mean so Iâm going to guessâŚ
There is no option to change the behaviour of the entities.
You can however use template entities to âchangeâ the composition of the entities in HA itself. As demonstrated here.
Do you mean something like this?
type: custom:mushroom-template-card
primary: PlayStation 5
secondary: |-
{% if is_state('switch.ps5_808_power', 'on') %}
{{ state_attr('sensor.ps5_808_activity', 'title_name') or states('sensor.ps5_808_activity') }}
{%- elif is_state('switch.ps5_808_power', 'unavailable') -%}
Powered off
{%- else -%}
{{ states('switch.ps5_808_power') }}
{%- endif -%}
icon: mdi:sony-playstation
entity: switch.ps5_808_power
picture: '{{state_attr(''sensor.ps5_808_activity'', ''title_image'')}}'
badge_icon: |-
{% if is_state('sensor.ps5_808_activity', 'playing') %}
mdi:controller
{%- elif is_state('sensor.ps5_808_activity', 'idle') -%}
mdi:sleep
{%- elif is_state('sensor.ps5_808_activity', 'unavailable') -%}
mdi:power-plug-off
{%- endif -%}
I would look something like this
Your hyphens were the wrong ones use '
insted of â
â You type the correct ones on a german keyboard with Shift + #
Correct code here
type: custom:mushroom-template-card
primary: PlayStation 5
secondary: |-
{% if is_state('switch.ps5_544_power', 'on') %}
{{ state_attr('sensor.ps5_544_activity', 'title_name') or states('sensor.ps5_544_activity')}}
{%- else -%}
{{ states('switch.ps5_544_power') }}
{%- endif -%}
icon: mdi:sony-playstation
entity: switch.ps5_power
picture: '{{state_attr(''sensor.ps5_544_activity'', ''title_image'')}}'
badge_icon: |-
{% if is_state('sensor.ps5_544_activity', 'playing') %}
mdi:controller
{%- elif is_state('sensor.ps5_544_activity', 'idle') -%}
mdi:sleep
type: custom:mushroom-template-card
primary: PlayStation 5
secondary: |2-
{% if is_state(âswitch.playstation_5_powerâ, âonâ) %}
{{ state_attr(âsensor.playstation_5_activityâ, âtitle_nameâ)
or states(âsensor.playstation_5_activityâ) }}
{%- elif is_state(âswitch.playstation_5_powerâ, âunavailableâ)-%}
ausgeschaltet
{%- else -%}
{{ states(âswitch.playstation_5_powerâ) }}
{%- endif -%}
icon: mdi:sony-playstation
entity: cover.playstation_5_power
picture: â{{state_attr(ââsensor.playstation_5_activityââ, ââtitle_imageââ)}}â
badge_icon: |-
{% if is_state(âsensor.playstation_5_activityâ, âplayingâ) %}
mdi:controller
{%- elif is_state(âsensor.playstation_5_activityâ, âidleâ) -%}
mdi:sleep
{%- elif is_state(âsensor.playstation_5_activityâ, âunavailableâ) -%}
mdi:power-plug-off
{%- endif -%}
tap_action:
action: toggle
hold_action:
action: more-info
fill_container: false
multiline_secondary: false
icon_color: |-
{% if is_state(âswitch.playstation_5_powerâ, âonâ) %}
cyan
{% endif %}
badge_color: red
This is my current code. I have now managed to replace âunvailableâ, now I want to replace âidleâ and everything is perfect. Somewhere I have a mistake in thinking and canât do it, can someone help me here?
Iâve modified the mushroom template a little bit:
Before:
After:
Iâve added a âcheckâ in the picture part to see if the PS5âs activity is âplayingâ.
Only if both PS5s are online, the image wonât be correct due to the API.
type: vertical-stack
cards:
- type: custom:mushroom-template-card
primary: PlayStation 5 Sammy
secondary: |-
{% if is_state('switch.ps5_sammy_power', 'on') %}
{{ state_attr('sensor.ps5_sammy_activity', 'title_name')
or states('sensor.ps5_sammy_activity')
}}
{%- else -%}
{{ states('switch.ps5_sammy_power') }}
{%- endif -%}
icon: mdi:sony-playstation
entity: switch.ps5_sammy_power
picture: |-
{% if state_attr('sensor.ps5_sammy_activity', 'activity') == "playing" %}
{{state_attr('sensor.ps5_sammy_activity', 'title_image')}}
{% else %}
{% endif %}
badge_icon: |-
{% if is_state('sensor.ps5_sammy_activity', 'playing') %}
mdi:controller
{%- elif is_state('sensor.ps5_sammy_activity', 'idle') -%}
mdi:sleep
{%- endif -%}
tap_action:
action: more-info
hold_action:
action: toggle
- type: custom:mushroom-template-card
primary: PlayStation 5 Vic
secondary: |-
{% if is_state('switch.ps5_vic_power', 'on') %}
{{ state_attr('sensor.ps5_vic_activity', 'title_name')
or states('sensor.ps5_vic_activity')
}}
{%- else -%}
{{ states('switch.ps5_vic_power') }}
{%- endif -%}
icon: mdi:sony-playstation
entity: switch.ps5_vic_power
picture: |-
{% if state_attr('sensor.ps5_vic_activity', 'activity') == "playing" %}
{{state_attr('sensor.ps5_vic_activity', 'title_image')}}
{% else %}
{% endif %}
badge_icon: |-
{% if is_state('sensor.ps5_vic_activity', 'playing') %}
mdi:controller
{%- elif is_state('sensor.ps5_vic_activity', 'idle') -%}
mdi:sleep
{%- endif -%}
tap_action:
action: more-info
hold_action:
action: toggle
code:
Change the complete secondary
part to
secondary: |-
{% if is_state('sensor.ps5_808_activity', 'playing') %}
{{ state_attr('sensor.ps5_808_activity', 'title_name') }}
{%- elif is_state('sensor.ps5_808_activity', 'idle') -%}
An tut aber nix
{%- elif is_state('sensor.ps5_808_activity', 'none') -%}
Schläft
{%- elif is_state('sensor.ps5_808_activity', 'unavailable') -%}
Ausgeschaltet
{%- endif -%}
This should give you the possbility to change every possible state of the sensor and rename it however you seem fit
Obviously you need to change the sensor to the correct name âŚ
Thatâs it, thank you very much. Somewhere I probably had a mistake in thinking and when I look at the code now, I also know where ⌠Thanks
Thanks it worked!
@FunkeyFlo, thanks for the great addon!
Iâve got a suggestion and a question.
Suggestion: maybe make it clearer that activity info is dependent on PSN account configuration in the addon. I say this because since the Activity sensor is there by default, I was initially confused why all I got was âIdleâ as a state instead of all the rest of the info (game name, picture, etc).
Question: although everything seems to be working OK (sensor, switch) I regularly get this message in the addon logs:
2022-09-26T12:00:59.896Z @ha:ps5:error SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at /app/server/dist/redux/sagas/check-devices-state.js:75: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)
Is something amiss?
Thanks,
Ricardo
suggestion
What would you suggest to make it less confusing?
error
Has been asked and answered multiple times.
TL;DR: Not a problem
suggestion
Maybe an explicit callout, something like âfor information on usage status (idle/playing), game title, cover, etc, PSN account configuration is strictly requiredâ.
error
Understood. Itâs basically my whole log file, hence me asking.
I donât use HASSOS, I run my service on Docker. Are you able to port this to a HACS Addon? That way anyone can add it to the instance of HA however they run it.
There is no such thing as a HACS addon. And if you mean a HACS integration the answer is noâŚ
Also there is an option to run this add-on within docker and the repo includes documentation on this. If you are unfamiliar with docker and docker compose I suggest to first read up on them before continuing.
Anyone got a link to the discord?
Do you need the psn stuff to be in the config to see if the PS5 is on or off? I donât use my PS5 super often so I donât want to have to be inputting the api code basically every time I use it.