#Need to run an automation from button in Mini Media Player Card

1 messages · Page 1 of 1 (latest)

hasty sorrel
#

I created automation to send several IR blaster codes that are stored in scripts to my TV with delays in between. I can trigger automation manually and it works. From Developer tools/Actions I can also select Animation.trigger and if will run. I searched for way to do this from a card and found a way that seems that should work, but its not: https://community.home-assistant.io/t/mini-media-player-shortcut-buttons-start-automation/486157
Here is yaml for player card and when pressed nothing happens:

type: custom:mini-media-player
entity: media_player.tv_1
source: icon
volume_stateless: true
sound_mode: full
hide:
  icon: true
  prev: true
  next: true
  play_pause: true
  play_stop: true
  source: true
  power_state: false
hide_when_off:
  buttons: true
shortcuts:
  hide: null
  power_state: false
  hide_when_off: true
  columns: 3
  buttons:
    - icon: mdi:hdmi-port
      type: service
      service: automation.trigger
      service_data:
        entity_id: automation.tv_av_hdmi_2
      show_name: true
      name: HDMI 2

Dot I put there to prevent auto bulletining that I don't know how to avoid
Thanks for any guidance

hasty sorrel
#

Need to run an automation from button in Mini Media Player Card

idle trellis
#

First of all, please have a look about posting code. See #best-posting-practices message

Next, I think running an automation via an action is very confusing. Scripts are made to do that so would be more logical to move it to a script.

And looking at you yaml I see multiple things that are weird. I see a . before the button. Or is that a copy past error? And hide and power_state don't seem valid keys for a Shortcuts object. Same for service as key under the Shortcuts item. And hide_when_off is not a valid root key. Aka, you made up quite a bit.

Think it should look like:

type: custom:mini-media-player
entity: media_player.tv_1
source: icon
volume_stateless: true
hide:
  icon: true
  prev: true
  next: true
  play_pause: true
  play_stop: true
  source: true
  power_state: false
shortcuts:
  hide_when_off: true
  columns: 3
  buttons:
    - icon: mdi:hdmi-port
      type: service
      id: script.tv_av_hdmi_2
      show_name: true
      name: HDMI 2
hasty sorrel
#

Thanks @idle trellis I did not made up those keys, custom mini media player supports those. Actually they were made through UI and copied it from code editor and they are working.
I edited my first post so code is OK now, thanks for that.
I added manually in code editor part for buttons: and by directive for mini media player that should work: https://github.com/kalkih/mini-media-player?tab=readme-ov-file#shortcut-item-object
Anyway after many trials I finished it with a script that will call an automation, similar to what you suggested. Thanks again

GitHub

Minimalistic media card for Home Assistant Lovelace UI - kalkih/mini-media-player

idle trellis
#

When I look in the UI the number of settings is very limited. And some of the keys you had are valid keys, only not in the location you used them 😄 They don't give you an error but they also don't do anything 😄 Can you share what you have now?

Any my tip, just get rid of the automation! You're making it a Rube Goldberg machine 😉

hasty sorrel
#
type: custom:mini-media-player
entity: media_player.tv_prestigio
source: icon
volume_stateless: true
sound_mode: full
hide:
  icon: true
  prev: true
  next: true
  play_pause: true
  play_stop: true
  source: true
  power_state: false
hide_when_off:
  buttons: true
shortcuts:
  hide: null
  power_state: false
  hide_when_off: true
  columns: 3
  buttons:
    - icon: mdi:arrow-up-bold
      type: script
      id: script.tv_ekran_source_up
      show_name: true
      name: Source UP
    - icon: mdi:arrow-down-bold
      type: script
      id: script.tv_ekran_source_down
      show_name: true
      name: Source DOWN

This is what I end up and its working, ditched automation as you suggested