Closed danielbrunt57 closed 9 months ago
This variation in my code also works but is NOT the same as the README example:
- type: custom:config-template-card
variables:
- '"cover.kitchen_blind_2"'
- '"sensor.kitchen_blind_2_battery_level"'
entities:
- '${vars[0]}'
card:
type: entities
entities:
- entity: '${vars[0]}'
type: custom:multiple-entity-row
name: Kitchen 2
show_state: false
icon: "${states[vars[0]].state === 'closed' ? 'phu:blind-tilt-open' : 'phu:blind-tilt-closed'}"
entities:
- entity: '${vars[1]}'
name: Battery
- entity: '${vars[1]}'
name: false
icon: true
Typo in readme. Should be
type: 'custom:config-template-card'
variables:
- states['sensor.light']
entities:
- '${vars[0].entity_id}'
card:
type: light
entity: '${vars[0].entity_id}'
name: "${vars[0].state === 'on' ? 'Light On' : 'Light Off'}"
Revise your code based on that & close the issue if resolved. ~The wrong code in Readme will be fixed.~ Done
This is not correct:
variables:
- '"cover.kitchen_blind_2"'
- '"sensor.kitchen_blind_2_battery_level"'
entities:
- '${vars[0]}'
You got vars depending on TWO entities & going to monitor only one of them. No - you should monitor both of them, otherwise the card will not be updated if the missed entity is changed.
Thank you! This is working:
type: custom:config-template-card
variables:
- states['cover.kitchen_blind_1']
- states['sensor.kitchen_blind_1_battery_level']
entities:
- ${vars[0].entity_id}
- ${vars[1].entity_id}
card:
type: entities
entities:
- entity: ${vars[0].entity_id}
type: custom:multiple-entity-row
name: Kitchen 1
show_state: false
icon: >-
${vars[0].state === 'open' ? 'phu:blind-tilt-open' :
'phu:blind-tilt-closed'}
entities:
- entity: ${vars[1].entity_id}
name: Battery
- entity: ${vars[1].entity_id}
name: false
icon: true
show_header_toggle: false
state_color: false
Good.
But: CTC (config-tamplate-card) here is only used to make an icon dynamically set. In this particular case using CTC is a waste of resources. Consider other ways, like:
I first tried setting '--card-mod-icon' with card-mod but the code I came up with changed the state badge for all entities within the multiple-entity-row whereas I only want to change the primary entity icon.
After quite a bit of digging, I came up with a solution:
type: entities
entities:
- entity: cover.kitchen_blind_1
type: custom:multiple-entity-row
name: ' '
show_state: false
card_mod:
style:
hui-generic-entity-row:
$: |
state-badge {
--card-mod-icon: {{ iif(states("cover.kitchen_blind_1") == "open", "phu:blind-tilt-open", "phu:blind-tilt-closed") }}
}
entities:
- entity: sensor.kitchen_blind_1_battery_level
name: Battery
- entity: sensor.kitchen_blind_1_battery_level
name: false
icon: true
show_header_toggle: false
state_color: false
The card-mod code seems to be OK.
Yes, once I figured out how to target just the main entity! With just:
card_mod:
style:
--card-mod-icon: {{ iif(states("cover.kitchen_blind_1") == "open", "phu:blind-tilt-open", "phu:blind-tilt-closed") }}
the icon for the battery entity was changed as well!
I also implemented the decluttering card so now I only have one template I use for all 6 blinds.
The last code you posted is absolutely wrong.
Checklist:
Release with the issue: 1.3.6
Last working release (if known): unknown
Browser and Operating System: Current versions of Windows 11 & Microsoft Edge
Description of problem: Example in README is not working:
Additional information: I find I need to define a string variable to pass as the entity to the entities card. If I use the example as stated, the entities card complains that it can't find the entity 'closed':
The following variation of the example works but I would like to only have to specify the entity once for the entire code segment.
The above is part of a vertical stack of cards: