I am attempting to add a custom background to some of my dashboards which will display any of several jpegs, based on the jpg name held in an input text sensor.
I have seen examples using custom background in the Raw Configuration editor and then using a custom button-card to reference this.
I know that sensors can be accessed in this editor and urls then returned with those details. However, the format looks different to code I have used in yaml scripts do I have been unable to get the syntax to work. My latest attempt is below and the screen errors when parsing ājpgā. I need to identify if the input_text contains the text ājpgā. If so, I need to build the return url statement concatenating the text with the folder names. If ājpgā i not found, use the default theme background.
this is nearly what i need. i just need to adapt the code that defines ābackground:ā to reflect my test for the text ājpgā and build the url. i have used jinja for templates before and realise this code in the linked discussion is a different language. if it is js, then i guess i am simply not understanding the code i need. I have since tried an ā.includes(ājpgā)ā line but still not working.
i do understand that āvalue templateā is not what this code is, I was just trying to use an equivalent template logic term to show it was not the editor yaml that was the issue for me but was the logic within the dynamic background definition.
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.
Thanks. That worked a treat! In my career as a programmer, I only brushed up against js a few times while using almost every other business systems language going. Harder to learn new languages at my age but I will give it a go.