Closed cyr123 closed 1 year ago
don't know if my problem is totally related, but I guess there's something wrong going on with variables. I am trying to utilize variables just to save a lot of typing and use them in different templates, buttons etc., but variables are always "undefined".
I tried with the simplest code possible:
- type: custom:button-card
entity: update.0_sts_zamel
variables:
test_var: "this-is-test"
name: "[[[ return variables.test_var; ]]]"
and still - instead of default button with "this-is-test" as name, I can see the entity's name anyway..
button card: 3.5.0, homeassistant: 2023.04.4, browser: latest chrome
OK, update: I'm a massive idiot and/or was too tired when I wrote this code. It works perfectly as long as I actually type the correct values (hint: "." and ":" are not the same thing).
OK, update: I'm a massive idiot and/or was too tired when I wrote this code. It works perfectly as long as I actually type the correct values (hint: "." and ":" are not the same thing).
can you provide a fragment of corrected code for reference? as far as I am understanding your case - I guess that it will not resolve my problem :( so I want to investigate more to be sure if I need to step up my template game or to post a new issue with my scenario exactly ;)
My code as posted is actually working correctly, my only issue was that the values I had typed in for the variable ("1:78.1" etc) didn't match the values defined for the input_select I was targeting. It should have been "1.78:1" etc.
```yaml - type: custom:button-card entity: update.0_sts_zamel variables: test_var: "this-is-test" name: "[[[ return variables.test_var; ]]]"
this exact card config is working fine:
- type: custom:button-card
entity: sensor.alarm_button_hall_battery
variables:
test_var: "this-is-test"
name: "[[[ return variables.test_var; ]]]"
if you still experience configuration challenges (these are not 'issues', as in: bugs) then please create a post in the community, and lets keep this repo clean as possible
this exact card config is working fine
thanks for testing!
if you still experience configuration challenges (these are not 'issues', as in: bugs) then please create a post in the community, and lets keep this repo clean as possible
sure! after few hours of searching for typos and other errors in my templates I almost gave up and then suddenly found this issue, looked similar to my problem, but now I know it is not button-card related. thans again :)
Checklist
Describe the bug I'm trying to use a number of button cards to display and select the options in an input_select helper. I managed to get it working, but I want to use a template to avoid a lot of code duplication. I'm trying to use a variable to map each button to a specific value as shown below, but neither the state indication (color) or tap_action works.
I tried a number of things that do work:
Disclaimer: Although I am a software developer, I have next to zero JS or web development experience and YAML makes me go cross-eyed so I may be missing something obvious...
Version of the card Version: 3.5.0
To Reproduce This is the configuration I used:
(the input_select helper does exist, and includes these values as valid options)
Expected behavior
Desktop (please complete the following information):