Very new to code red so bit of a steep learning curve for me. Iv'e got a bit of time on my hands so I am trying to make a smart thermostat following Peter Scargill's excellent information. Problem is I'm stuck at how to code png images as buttons in the template node which will then show up in dashboard.
All I get is is a grey square with an icon that looks like a broken page (pretty sure this means that the file cant be found or isnt in the right place or something really stupid that i'm doing wrong). I've tried putting the png image in various locations with no luck. To try to make it easier my flow consists of just one template node and nothing else.
Hope one of you chaps can help me with this simple issue.
Have a look at the network tab in the developer tools of your browser. Usually F12 will open the tools (depends on your OS and browser though), select the networks tab, you will have to reload the browser.
Then scan down the list of loaded resources to find the red ones - see what url it is trying to load.
Now you need to think about the difference between accessing a file on the server vs how the browser will get a file. You have provided local file paths but the browser needs URL's.
Assuming that you set up your static folder correctly as /home/pi/node-red/public in settings.js and assuming that you have not changed the httpRoot setting, the url will be /myicons/png/48x48/actions/arrow-down-2.png or /myicons/png/48x48/actions/arrow-left-2.png.
If you have changed the root, you will probably be able to prefix the URL with a single dot which should, I think work.
I've deleted all of my flows and dashboard items and have placed one template node in one flow to keep everything simple. I have the following code in the template node:
Right, I might be on to something. I opened the setting file in a text editor on the pi. Here is the httpstatic line:
`
//httpStatic: '/home/nol/node-red-static/',
I think I need to change it to something like this:
httpStatic: '/home/pi/node-red/images/',
When I remove the comments (//) at the beginning and change the path and try to re-save the file I get a permission denied error. How can I edit this file and re-save it.
OK, I have figured out how to change the file permissions and have re-saved the text file setting.js to include the following:
// When httpAdminRoot is used to move the UI to a different root path, the
// following property can be used to identify a directory of static content
// that should be served at http://localhost:1880/.
httpStatic: '/home/pi/.node-red/images/',
I have set placed my png image in the images folder above (i called mine test1.png)
and have this code in a template node:
That shouldn't happen!
I'm assuming that you have a Raspberry pi?
If so, did you install node-RED using the recommended script for Raspberries and ran the script exactly as it says in the docs?
If you had a permissions error trying to save the settings file as user Pi, I'm wondering if you installed it using sudo.
To be sure, I would run the installation script again, it will not wipe out your flows, but it will make sure that your permissions are correct.