#Custom: Button card
1 messages ยท Page 1 of 1 (latest)
local is spelled wrong in this version of the code...
Gimmie a sec. Lemme see what I can come up with. I'm still guessing a path issue maybe pertaining to the variable.
ok, thank you! i have also checked the "state" vs the name of the SVG file, and it matches perfectly
Let's take the variable out of the equation for the moment. This is what I just used. yaml custom_fields: icon: | [[[ var weather = states['weather.home'].state; return '<img src = "/local/icons8-sunny-48.png" width="50" height="50" />' ]]] Change the /local/icons8-sunny-48.png to one of your icons. Hard-code it for right now. Let's get it to show first.
I'm going to grab an SVG and see it that might be an issue.
still dont work, i will try to upload a png file hold on
An SVG worked for me. return '<img src = "/local/sunny-svgrepo-com.svg" width="50" height="50" />'
i will try to move them out of the local file and keep it in the www file for fun
That's what I was saying earlier. They're not supposed to be in a "local" folder.
I've match my path more to your's.
i tried with a images folder now in the www folder. but no joy
Show me the full path that you're trying to use.
i might have setup the www folder wrongly? does it need reed/write rights as in a FTP server?
what do you mean you set up the www folder? The www folder is already made.
[[[
var weather = states['weather.home'].state;
return '<img src = "/images/sunny.svg" />'
]]]
path in the file editor is /config/www/images
blah. I haven't used File Editor in years. Lemme install it right quick so I can try to see what you're seeing.
Just took a screenshot, and when i click the image, it workes fine. but just not in that button-card
Try local/images/sunny.svg
same thing
but if i add a / before local, that "brokan image" icon goes away, but still no icon
my bad. There is supposed to be a / at the beginning.
yeah, but the image still not showing. this makes me go crazy! ๐
Try the image that I downloaded. https://www.svgrepo.com/svg/67725/sunny Maybe there's something going on with the SVG file. Your path looks correct and the file looks like it is in the folder of the path you're using. ๐
Off-topic: I use the Samba share add-on to expose folders on the network and the Studio Code Server add-on which is way better than the File Editor.
So you're able to see that SVG now?
yes ๐ for some wierd reason
i tested the SVG file within home assistant, and it did work.. i just dont understand why its not willing to work with mine
I think SVG files can be weird sometimes. If they're not written just right they can cause issues. Perhaps HA could understand its code but not your browser. (Because SVGs are technically code and not a graphic.)
now the challange is to get that code to work with state hehe.
I would suggest at this point, set up your files and folders the way you want. Next, let's test each of your weather conditions.
That will be next.
it might actually be the file manager when i re-name files
Yeah.. its the file manager thats the problem.
I re-named it to cloudy.svg for a test. It bugged out again, but when i change the code back to "/local/images/sunny-svgrepo-com.svg" and keep the name cloudy.svg from file manager.. it works hehe
thank you for the help! sleep time ๐
okay. I might play with the variable part because I'm not sure if it is going to work with the current syntax. I'll let you know what I figure out.