Playstation 4/PS4 custom component

maybe a screenshot of what you currently have? i’m sorry, i’m not quite wrapping my head around it …

The games you’ve launched are stored in your config directory in an invisible fille titled .ps4-games.json - For example here is an entry from mine for Sonic Mania.

    "CUSA07023": {
        "locked": false,
        "media_content_type": "game",
        "media_image_url": "https://store.playstation.com/store/api/chihiro/00_09_000/container/US/en/19/UP0177-CUSA07023_00-SONICMANIA000000/1563901994000/image",
        "media_title": "Sonic Mania"
    }

You can see the image url and the title. The hard part would be figuring out how to read that json file and create the buttons with cover art and name automatically. If you figure this out let me know, it sounds like a very interesting idea.

1 Like

If we could make a custom integration that reads the file and creates an entity for each app/game the we coud use something like a monster card to create the buttons

/fredrik

Why not use the custom button card to create the buttons, and then use the conditional card to have a different card show for different games/apps with the buttons you want to show?

I havn’t done this exactly, but had (in the past) a conditional card with a few buttons on it that shows up when my PS4 was powered on (same for my Xbox). If it was off, the card with the buttons was hidden.

It’s easy to create all the buttons manually, but that would require constant upkeep. You would have to do that for each game/app you play and then comment out, delete, or re-arrange things that you are no longer playing.

I believe the desired goal was to have it be fully dynamic (kinda like the PS4 dashboard itself works). So when you play a new game it would get added to your UI automatically, and you could have a horizontal stack of four buttons that would be arranged by the order you played them - all with no user interaction.

1 Like

That would make sense. I didn’t realize that you wanted it to be dynamic.

1 Like

I’m not sure if anyone was looking for something like this but since I didn’t see it posted elsewhere, I thought I would share the PS4 remote I created in Lovelace.
I tried to mimic the PS4 Remote App as closely as I could. The diagonal arrows are the same as the left/right buttons and are only there to make the layout look better. I’m open to any suggestions for improvement.

PS4 Remote App:

My PS4 remote card:

Code:

cards:
  - entity: media_player.playstation_4
    secondary_info: last-changed
    type: media-control
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-top-left-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: left
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-up-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: up
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-top-right-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: right
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-left-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: left
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        name: ENTER
        show_icon: false
        show_name: true
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: enter
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-right-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: right
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-bottom-left-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: left
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-down-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: down
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:arrow-bottom-right-bold-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: right
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: ps
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        name: BACK
        show_icon: false
        show_name: true
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: back
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        name: OPTIONS
        show_icon: false
        show_name: true
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: option
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
title: Playstation 4 Pro
type: vertical-stack
7 Likes

where do you store the cards: yaml?
I am running HACs and other things and dont have cards: in my configuration.yaml file

Given this is lovelace, I imagine it’s set up through the lovelace interface?

what I meant is where do I write that bit of code you provided?

NM - sorry I simply pasted the above example into a custom card added to a tab… viola!

1 Like

This is what i would like to have any tips. maybe by using node-red.
are trying to make a sensor that were evry game is an atribute with sub values or if it is åossible to make one sensor per game.

I’m not sure if this is necro bumping, but I have to ask: Is there solution to set height of type: entity-button

I pasted your code and I’m very thankful, this is exactly what I looked for, but it would be more eye candy if we could have “ENTER”, " OPTIONS" and “BACK” buttons, same height as “arrow” buttons.

EDIT: Or i would make workaround - would make “ENTER”, " BACK" and “OPTIONS” icons, same dimensions as arrow icons and place them on buttons instead of text :slight_smile:

I’m no expert but when I tried to fix it, I found custom sizing wasn’t supported, probably due to the fact that Lovelace re-arranged to fit different screens and aspect ratios.

I like your idea. As yet another alternative, why not select existing icons that can represent those functions? Thumbs up, X, a cog/gear, etc.

Hi, thanks for info.
First of all, I am very new to HA and later I figured out that out of box, we are not able to put local icons, but only icons from https://cdn.materialdesignicons.com/4.5.95/ (let someone correct me if I’m wrong).

No matter, below is my modded configuration, but all credits goes to @aslongasbassstrings :slight_smile:

cards:
  - entity: media_player.playstation_4
    secondary_info: last-changed
    type: media-control
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: ps
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        style:
          height: 40px
        hold_action:
          action: more-info
        icon: 'mdi:gamepad-up'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: up
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:cogs'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: option
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:gamepad-left'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: left
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:gamepad-right'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: right
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
  - cards:
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:backburger'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: back
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:gamepad-down'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: down
            entity_id: media_player.playstation_4
        type: entity-button
      - entity: media_player.playstation_4
        hold_action:
          action: more-info
        icon: 'mdi:thumb-up-outline'
        show_icon: true
        show_name: false
        tap_action:
          action: call-service
          service: ps4.send_command
          service_data:
            command: enter
            entity_id: media_player.playstation_4
        type: entity-button
    type: horizontal-stack
title: Playstation 4
type: vertical-stack

Of course, cover is also there, when PS is playing, currently is in rest mode.

I just found this: https://github.com/custom-cards/button-card and will try to playing later, after my job :slight_smile:

Btw, I don’t know if this is off topic, I also made Tasker - AutoVoice profiles, to run games with voice from my phone, via Tasker and Home Assistant plugin, and if someone is interested in that let me know on PM, I can create topic.

1 Like

Custom button in the custom components section will let you use any image as a icon. That button will change your life and consume your free time for sure. I use it for 99% of my UI!

1 Like

This is how i did my PS4 Controls.
Two PS icons for ps and ps_hold buttons.
In general it’s 3 horizontal stacks of button entity:

Here is the code (i use pre baked scripts for every ps service action):

      - type: vertical-stack
        cards:
          - type: markdown
            content: >
                **Play Station 4**
          - type: horizontal-stack
            cards:    
              - entity: script.ps4_button_ps
                type: button
                icon: mdi:playstation
                show_name: false 
                tap_action:
                    action: toggle
              - entity: script.ps4_button_up
                type: button
                icon: mdi:arrow-up-drop-circle
                show_name: false
                tap_action:
                    action: toggle
              - entity: script.ps4_button_ps_hold
                type: button
                icon: mdi:playstation
                show_name: false
                tap_action:
                    action: toggle
          
          - type: horizontal-stack
            cards: 
              - entity: script.ps4_button_left
                type: button
                icon: mdi:arrow-left-drop-circle
                show_name: false
                tap_action:
                    action: toggle            
              - entity: script.ps4_button_enter
                type: button
                icon: mdi:location-enter
                show_name: false
                tap_action:
                    action: toggle
              - entity: script.ps4_button_right
                type: button
                icon: mdi:arrow-right-drop-circle
                show_name: false
                tap_action:
                    action: toggle
                    
          - type: horizontal-stack
            cards:
              - entity: script.ps4_button_back
                type: button
                icon: mdi:backspace
                show_name: false
                tap_action:
                    action: toggle
              - entity: script.ps4_button_down
                type: button
                icon: mdi:arrow-down-drop-circle
                show_name: false
                tap_action:
                    action: toggle
              - entity: script.ps4_button_option
                type: button
                icon: mdi:cogs
                show_name: false
                tap_action:
                    action: toggle

And the scripts are here:

'ps4_button_ps':
  alias: PS4 PS
  sequence:
  - data:
      command: ps
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_ps_hold':
  alias: PS4 PS Hold
  sequence:
  - data:
      command: ps_hold
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_down':
  alias: PS4 Down
  sequence:
  - data:
      command: down
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_up':
  alias: PS4 Up
  sequence:
  - data:
      command: up
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_option':
  alias: PS4 Option
  sequence:
  - data:
      command: option
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_left':
  alias: PS4 Left
  sequence:
  - data:
      command: left
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_right':
  alias: PS4 Right
  sequence:
  - data:
      command: right
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_enter':
  alias: PS4 Enter
  sequence:
  - data:
      command: enter
      entity_id: media_player.playstation_4
    service: ps4.send_command
'ps4_button_back':
  alias: PS4 Back
  sequence:
  - data:
      command: back
      entity_id: media_player.playstation_4
    service: ps4.send_command
1 Like

Hello every one,
I am trying to create a card for my harmony remote.
I followed petro’s setup Harmony Activities, Volume Slider, and Lovelace.
I am now trying to put the cover from my playstation as a state picture.
I managed to find the link for the cover which the entity_picture of the PS4.
I was wondering if there was a way to use entity_picture attribute to generate a link for the state picture.
Here is the code for the card:

aspect_ratio: 0%
entities:
  - entity: switch.ps4
  - entity: switch.fire_tv
  - entity: switch.watch_tv
  - entity: switch.listen_to_music
entity: sensor.harmony_activity
hold_action:
  action: none
state_image:
  Listen to Music: local/music.jpg
  Play PS4: #something using media_player.playstation4.entity_picture 
  PowerOff: local/Poweroff.png
  Watch Fire TV: local/fire_tv.jpg
  Watch TV: local/tv.jpg
tap_action:
  action: more-info
theme: Google Dark Theme
title: harmony
type: picture-glance

Thank you for your help

It’s possible but it takes alot to setup. You need to create a camera and cycle your images sent to the camera. Otherwise, if the URL set on Play PS4 changes, the picture will not update. Now you could also use a template card to get the same behavoir and it will update. I can help with it if you let me know what the entity and attribute is. You’d need to install HACS for custom cards and then get the 100% template card made by iantrich.

1 Like

Hi petro,
thank you very much for your response.
the PS4 entity is media_player.playstation_4 and the attribute for the cover is entity_picture

Did you get the 100% template card?