Hello Everyone,
I’m looking for help. I’m using custom:button to create a button/status widget for my Home Theater remote running on an iPad.
The button uses the name field to display status information:
- -
My issue is that when the volume ends in a 0, it’s truncated and only displays a single digit. For example, if the volume is at 20%, it’s displayed as 2. If I increase it to 19 or 21, it’s displayed as 19 or 21.
Here is the button code:
- type: custom:button-card
template: large_status
icon: mdi:theater
name: "[[[\n var av_state = states['media_player.anthem_av'].state;\n
if (av_state == \"on\") {\n
var str = av_state.charAt(0).toUpperCase() + av_state.slice(1);\n
var vol_state = entity.attributes.volume_level.toString();\n \n
var src_state = entity.attributes.source.toString();\n
str = str + \" - \" + vol_state.slice(2) + \"%\" + \" - \" + src_state;\n }\n
else {\n var str = av_state.charAt(0).toUpperCase() + av_state.slice(1);\n }\n
return str;\t\t\t\n]]]\n"
entity: media_player.anthem_av
variables:
label_var: Home Theater