Chacsam
(Frédéric)
January 8, 2022, 9:35am
1
Hello,
I am creating a dynamic audio player where the user can select various media and devices.
I have 3 media (spotify, radio, plex) and 3 possible speaker groups and would like to show a dynamic media card without creating 9 set of conditional cards.
I thought the following would work, but no luck:
type: media-control
entity: '{{ states(''sensor.selected_speaker_group'') }}'
Using the entity: '{{ states(''sensor.selected_speaker_group'') }}'
line in the model tool displays perfectly the media_player.xxx entity, but the card in lovelace uses the raw code.
Is there a subtle option I have missed?
nedievas
(Nedievas)
November 16, 2022, 8:35am
2
I’m also trying to make a input button, which dynamically changes on a sensor state:
type: horizontal-stack
cards:
- type: custom:numberbox-card
name: Setpoint
border: true
entity: input_number.komfovent_set_setpoint_temperature
initial: '{{ sensor.komfovent_setpoint_temperature_c }}'
- type: custom:numberbox-card
name: Set Fan
border: true
entity: >-
{% if states("sensor.komfovent_ventilation_level_current") == "1" -%}
input_number.komfovent_set_away_supply_flow
{%- elif states("sensor.komfovent_ventilation_level_current") == "2" -%}
input_number.komfovent_set_normal_supply_flow
{%- elif states("sensor.komfovent_ventilation_level_current") == "3" -%}
input_number.komfovent_set_intensive_supply_flow
{%- elif states("sensor.komfovent_ventilation_level_current") == "4" -%}
input_number.komfovent_set_boost_supply_flow
{%- endif %}
initial: '{{sensor.komfovent_fan_intensity}}'
But I get this error (Please define a number entity.):
eggman
(bertie basset)
November 16, 2022, 9:05am
3
Most cards, especially the built-in ones don’t support templating in their configuration.
iantrich/config-template-card: Templatable Lovelace Configurations (github.com)
or
gadgetchnnel/lovelace-card-templater: Custom Lovelace card which allows Jinja2 templates to be applied to other cards (github.com)
can help
Alternatively, use the template code to create a template sensor that you can then use in the card configuration.
1 Like