#Sending variables
1 messages · Page 1 of 1 (latest)
An example passing variables from a custom button- card. ```yaml
type: custom:stack-in-card
mode: horizontal
card_mod:
style: |
ha-card {
--ha-card-background: none;
}
cards:
- type: entities
entities:- entity: input_select.navigation_test_variable
name: Room
tap_action:
action: none
card_mod:
style: |
ha-card {
--ha-card-background: none;
border: none;
}
- entity: input_select.navigation_test_variable
- type: custom:button-card
entity: null
show_icon: false
show_name: true
name: Test
show_state: false
styles:
card:
- height: 100px
- width: 100px
variables:
var_entity: |-
[[[
var e = states["input_select.navigation_test_variable"].state;
if (e == "living-room" ) return 'light.living_room_lights';
else if (e == "kitchen" ) return 'light.kitchen_lights';
else if (e == "bedroom" ) return 'light.bedroom_lights';
else return;
]]]
tap_action:
action: more-info
entity: '[[[ return variables.var_entity; ]]]'
double_tap_action:
action: toggle
entity: '[[[ return variables.var_entity; ]]]'
hold_action:
action: none
card_mod:
style: |
ha-card {
--ha-card-background: none;
border: none;
}
@terse mirage Thanks for this, still not positive or understanding how I can pass something coming from response_variable automation and use it within the card. I have not tried it but am wondering if that variable is globally available or only exists within the automation/script that is using it.
I think your variable has to be in a state or attribute for the card to use/see it. The example above is using the helper input_select.navigation_test_variable and its different states living-room, kitchen and bedroom. You would use your automation action to set the different states in the helper. And the card then uses that for whatever you are trying to do
Yeah. I meant to add that part but I forgot. Cards can see stuff in memory and have to rely on an entity. The automation can set the entity and then the card can use that information.