I see, Dev tools cannot help to debug a JS code.
Need to learn JS basics…
Suggest to ask all button-card related questions in the main thread - there is a chance users may help you.
Try this:
type: vertical-stack
cards:
- type: entities
entities:
- input_text.test_text
- type: custom:button-card
entity: sun.sun
styles:
card:
- background: >-
[[[
var strState = states['input_text.test_text'].state;
if(strState.includes('jpg'))
{
var strPath = '/local/images/test/' + strState;
return 'url(' + strPath + ')';
}
else
return 'var(--red-color)'
]]]
