piitaya / lovelace-mushroom

Build a beautiful Home Assistant dashboard easily
Apache License 2.0
3.75k stars 341 forks source link

[Feature]: Allow custom secondary_info #1447

Closed ceinmart closed 1 month ago

ceinmart commented 5 months ago

Requirements

Is your feature request related to a problem?

Trying to custom my mushroom-entity card , to show the time left on the timer of my switch.

Describe the solution you'd like

Something like:

type: custom:mushroom-entity-card
entity: switch.toalheiro
name: Toalheiro
tap_action:
  action: none
double_tap_action:
  action: call-service
  service: script.toalheiro_2h
  target: {}
icon_color: red
fill_container: false
primary_info: name
secondary_info: {{states("number.toalheiro_timer")}}

Describe alternatives you've considered

found nothing until now...

Additional context

Better dashboard customization and optimization where I can put the necessary info grouped.

sgofferj commented 4 months ago

Another use case would be to show the current power consumption of a device. Power consumption usually is a separate entity. The card would then use the switch.xyz entity for coloring the icon and action but the secondary info would be the sensor.xyz_power

Johanneke commented 3 months ago

Can't you just use the mushroom-template-card for that?

ceinmart commented 2 months ago

Can't you just use the mushroom-template-card for that?

Yes! I just learn about it now and works perfect! It's much more powerful and more visual resources...

Thank you!

bakerkj commented 1 month ago

Can't you just use the mushroom-template-card for that? Yes! I just learn about it now and works perfect! It's much more powerful and more visual resources... Thank you!

@ceinmart / @Johanneke would you be able to provide a sample of your configuration here?

ceinmart commented 1 month ago

Can't you just use the mushroom-template-card for that? Yes! I just learn about it now and works perfect! It's much more powerful and more visual resources... Thank you!

@ceinmart / @Johanneke would you be able to provide a sample of your configuration here?

This one is to monitor and activate my boiler automation.

type: custom:mushroom-template-card
primary: Boiler
secondary: >-
  {% if states('number.boiler_timer_2') | int(0) > 0 %}

  {{timedelta(seconds=states('number.boiler_timer_2')|int) |
  regex_replace(':[0-9]{1,2}$','')}} para desligar

  {%- elif states('script.boiler_automatico_v2_script') == 'on' %} 

  Auto até 

  {{ states('input_datetime.boiler_desligar_as') |as_timestamp
  |timestamp_custom('%H:%M',True)}}

  {%- endif -%}
icon: mdi:water-boiler
entity: script.boiler_automatico_v2_script
badge_icon: mdi:home-automation
badge_color: |-
  {% if states('script.boiler_automatico_v2_script') == 'on' %} 
  blue
  {% endif %} 
icon_color: |-
  {% if states('switch.boiler_switch_2') == 'on' %} 
  red
  {% endif %} 
double_tap_action:
  action: perform-action
  perform_action: script.boiler_automatico_2_script
  data:
    add_mais_1_hora: 1
  target: {}
hold_action:
  action: perform-action
  perform_action: script.boiler_automatico_2_script
  target: {}
  data:
    desligar_as: "2020-01-01 00:00:00"
fill_container: true
tap_action:
  action: navigate
  navigation_path: /dashboard-dash/boiler
multiline_secondary: true

This is to monitor the automation for a HAVAC

type: custom:mushroom-template-card
primary: Ar Augusto
secondary: >-
  {{-states('sensor.sensor_temperatura_xiaomi_62_temperature')|float(0)}}ºC

  {%- if states('script.ar_quente_augusto_script') == 'on' %} 

  Desligar as 

  {{
  states('input_datetime.ar_augusto_automacao_quente_desligar_as')|as_timestamp
  |timestamp_custom('%H:%M',True) }}

  {%- endif -%}
icon: mdi:air-conditioner
entity: script.ar_quente_augusto_script
badge_icon: mdi:home-automation
badge_color: |-
  {% if states('script.ar_quente_augusto_script') == 'on' %} 
  blue
  {% endif %} 
icon_color: |-
  {% if states('climate.ar_condicionado_augusto') == 'heat' %} 
  red
  {% elif states('climate.ar_condicionado_augusto') == 'cool' %} 
  blue
  {% elif states('climate.ar_condicionado_augusto') == 'fan_only' %} 
  green
  {% elif states('climate.ar_condicionado_augusto') != 'off' %} 
  purple
  {% endif %} 
double_tap_action:
  action: perform-action
  perform_action: script.ar_quente_augusto_script
  target: {}
  data:

This one is only a multi status viewer, where I show few status from my washmachine or external temperature...

type: custom:mushroom-template-card
primary: |-
  {% if states('sensor.lg_13kg') == 'on'  %}
  {{ states('sensor.lg_13kg_run_state') }}
  {% else %}
  {{ states('sensor.sensor_temperatura_xiaomi_51_temperature') }} ºC
  {% endif %}
secondary: >
  {% if states('sensor.lg_13kg') == 'on'  %}

  {{ states('sensor.lg_13kg_remaining_time')| regex_replace(':[0-9]{1,2}$','')
  }}

  {% else %}

  Temp externa 

  {% endif %}
icon: |-
  {% if states('sensor.lg_13kg') == 'on'  %}
  mdi:washing-machine
  {% else %}
  mdi:thermometer
  {% endif %}
entity: sensor.lg_13kg
icon_color: |-
  {% if states('sensor.lg_13kg') == 'on'  %}
    {% if states('sensor.lg_13kg_run_state') | regex_search('enxa|lava') %}
    blue
    {% elif states('sensor.lg_13kg_run_state') | regex_search('centr') %}
    yellow
    {% elif states('sensor.lg_13kg_run_state') | regex_search('seca') %}
    red
    {%endif%}
  {%else%}
    {% set vTemp= states('sensor.sensor_temperatura_xiaomi_51_temperature')|float %}
   {% if vTemp < 15 %} #e3f2fd
   {% elif vTemp < 18 %} #90caf9
   {% elif vTemp < 21 %} #64b5f6
   {% elif vTemp < 25 %} blue
   {% elif vTemp < 27 %} orange
   {% else %} red
   {% endif %}  
  {% endif %}
fill_container: true
multiline_secondary: true
tap_action:
  action: more-info
hold_action:
  action: more-info
double_tap_action:
  action: more-info

Screenshot_20241014_165628_Home Assistant

bakerkj commented 1 month ago

@ceinmart thanks. My aim is to have a light card, with secondary information that includes the power that light is consuming. I'll see if I can put something together that does that with your examples. Thanks!