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

Change button entity based on state of another entity - Solved

$
0
0

@nellicus wrote:

TL;DR: What would be the best way to change an entity of a button based on the state of another entity?

I am automating my theater setup and integrating Harmony activities. When you visit the main control panel for the theater you are greeted with 2 buttons to select either “TV” or “Projector”. These buttons control an input_select

input_select:
  theater_media_mode:
    name: Media Mode
    options:
      - "None"
      - "TV"
      - "Projector"
    initial: None
    icon: mdi:target

Once a media mode is selected I have a conditional entity that displays a card with the source choices.

type: vertical-stack
cards:
  - type: 'custom:button-card'
    color_type: label-card
    color: 'rgb(44, 109, 214)'
    name: TV
  - type: horizontal-stack
    cards:
      - type: 'custom:button-card'
        entity: switch.tv_appletv
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Apple-TV.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false
      - type: 'custom:button-card'
        entity: switch.tv_shield
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Nvidia-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false
- type: 'custom:button-card'
        entity: switch.tv_raspberrypi
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Raspberry-PI-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false

Since you will be able to select the same sources for either TV or Projector, what would be the best way to make the entity dynamic?

If entity: input_select.theater_media_mode = projector

the button would be:

- type: 'custom:button-card'
        entity: switch.prj_raspberrypi
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Raspberry-PI-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false

If entity: input_select.theater_media_mode = tv

the button would be:

- type: 'custom:button-card'
        entity: switch.tv_raspberrypi
        color_type: card
        show_entity_picture: 'true'
        entity_picture: /local/Raspberry-PI-01.svg
        state:
          - value: 'on'
            color: 'rgb(20, 120, 220)'
        show_state: false
        show_name: false

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 95919

Trending Articles



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