Hi,
I would like to be able to change the icon of a node based upon it's config node. I am currently using a config node for the 'device', which supports a number of device types; I would like the icon to dynamically change to show a picture of that device, dependent upon the device type selected. (eg. Door Sensor, Thermostat, PIR, Adaptor, etc).
I am currently setting a filename in the 'device' config node for the icon based upon the type of device discovered; which seems to be working OK.
I believe what I need to do is retrieve the 'icon' property from the device config node in the .html for the node, and use a function under RED.node.registerType to set the icon. I currently have this function defined as follows
icon: function () {
return (this.device.icon || "Thermostat.png")
},
This does not work, I suspect that this.device.icon
is wrong. Can anyone help with the correct way to do this?
There is an option to set the icon for a node in the 'Appearance' tab on the node properties, but I can't find the code for that in github, I ideally want it to work similarly to this and show the icon too.