Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 95483

Custom Button Card templating

$
0
0

@lukman wrote:

Hi Community, it is my first post, so if something wrong let me know.
I try to call service with custom button card based on actual Status. On Click the Sonos should play or pause. I tried so many versions of my templated code so maybe someone of you have a working version.
Here is what im trying:

#
#
#   Sonos Test
#
#

                      - type: "custom:button-card"
                        color_type: card
                        entity: media_player.wohnzimmer
                        show_state: false
                        tap_action:
                          action: call-service
                          service: [[[
                                        if (states.media_player.wohnzimmer == "paused"){
                                            return media_player.media_play;
                                        }else{
                                            return media_player.media_pause;
                                        }
                                    ]]]
                          service_data:
                            entity_id: media_player.wohnzimmer
                        color: rgb(30,144,255)
                        name: Wohnzimmer
                        icon: mdi:speaker
                        styles:
                             card:
                                - animation: none
                                - height: 150px
                                - width: 150px
                                - border-radius: 5%
                                - font-size: 20px
                                - font-weight: bold
                                - opacity: 0.7 
                        state:
                         - value: play
                           operator: '>'
                           color: rgb(255,127,80)
                           icon: mdi:play
                           styles:
                             card:
                                - animation: none
                                - height: 150px
                                - width: 150px
                                - border-radius: 5%
                                - font-size: 20px
                                - font-weight: bold
                                - opacity: 0.7

                         - value: pause
                           operator: '>'
                           color: rgb(255,191,0)
                           icon: mdi:pause
                           styles:
                             card:
                                - animation: none
                                - height: 150px
                                - width: 150px
                                - border-radius: 5%
                                - font-size: 20px
                                - font-weight: bold
                                - opacity: 0.7

Thanks for your help.

Posts: 5

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95483

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>