Choice between 2 images

I'm creating a Weather Station using sensors and I would like it to be interactive.
I mean than if it's raining then below the value there will be an image of rain and if it's not raining then an image of the sun on the Dashboard.
I've tried different solutions but I'm stuck.
For the moment, I can send a picture using <img src=/pluie1.gif> but when I try <img src=msg.payload> with msg.payload defined as "/pluie1.gif" with function node the image doesn't appear.

I've also tried to define msg.payload as <img src=/pluie1.gif> but an error appears.

Can someone help me please?
Best regards,

Why not use @Paul-Reed's great weather icons?


Thank you,I'm going to see what I can do with that but I will soon have the same issue because for an another project I need to choose between images !

That is not how you concatenate strings in javascript.... you'll need some " and + in there, but I can't guess where as you haven't shared the whole line where you set that up

I just put msg.payload= "/pluie1.gif"; return msg; In the function node and <img src=msg.payload> in the template

Well either you can just do it in the function node itself...
msg.payload= '<img src="/pluie1.gif">'; return msg;
or in the template (normal template node not ui_template node)
<img src="{{payload}}">

Thank you, it works perfectly ! :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.