Button card in button card + āentity.attribute.current_temperatureā reference
I am trying to make a header card to each room, which will hold multiple functions.
If you tap on the header itself (The kitchen text) it will toggle all the kitchen lights.
This button-card has a ācustom_fieldā called āclimateā.
In this climate custom_field, there is another button-card, with a label, showing the climate entityās attribute ācurrent_temperatureā (25Ā°C) and an icon based of the state of the climate component.
In the label, I use Java script reference to the entity.attribute (See code below).
The issue is; it is referring to the entity of the mother button card (light.kitchen) and not to the climate.kitchen, as defined in that Ā“custom_field card.
label: '[[[ return entity.attributes.current_temperature + '' Ā°C''; ]]]'
The current code for the complete header card I am trying to make:
type: custom:button-card
show_state: false
show_icon: false
show_label: false
show_name: true
name: Kitchen
entity: light.kitchen
tap_action:
action: toggle
hold_action:
action: more-info
color: yellow
styles:
card:
- padding: 1%
- background-color: rgba(43, 55, 78, 0.8)
- border-radius: 15px
grid:
- grid-template-areas: '"n climate"'
- grid-template-columns: 3fr 1fr
name:
- font-weight: 300
- font-size: 40px
- align-self: center
- justify-self: center
custom_fields:
climate:
card:
type: custom:button-card
entity: climate.kitchen
show_name: false
show_label: true
label: '[[[ return entity.attributes.current_temperature + '' Ā°C''; ]]]'
styles:
card:
- background-color: rgba(100, 100, 100, 0.5)
- box-shadow: 0px 0px
grid:
- grid-template-areas: '"l i"'
- grid-template-columns: 1fr min-content
I know I could hard code the entity.attribute directly in every label of each custom_field button-cards, but I want to make this button-card setup to a template, and therefore hopefully only have: Type, entity, template and name in the actual card code.
My goal for the code:
type: custom:button-card
entity: light.kitchen
template: header-card
name: Kitchen
custom_fields:
climate:
card:
type: custom:button-card
entity: climate.kitchen
template: climate-card
The goal for my templates:
templates:
header-card:
show_state: false
show_icon: false
show_label: false
show_name: true
tap_action:
action: toggle
hold_action:
action: more-info
color: yellow
styles:
card:
- padding: 1%
- background-color: rgba(43, 55, 78, 0.8)
- border-radius: 15px
grid:
- grid-template-areas: '"n climate"'
- grid-template-columns: 3fr 1fr
name:
- font-weight: 300
- font-size: 40px
- align-self: center
- justify-self: center
climate-card:
show_name: false
show_label: true
label: '[[[ return entity.attributes.current_temperature + '' Ā°C''; ]]]'
styles:
card:
- background-color: rgba(100, 100, 100, 0.5)
- box-shadow: 0px 0px
grid:
- grid-template-areas: '"l i"'
- grid-template-columns: 1fr min-content
On the top picture, it is trying to get the ācurrent_temperatureā attribute of the light.kitchen entity, which does not have that attribute.
On the second image, I have changed the entity of the mothercard to climate.kitchen, and then i get the correct reading - but now the toggle light function does not work
I hope someone can help me along here!