Numeric Item with string Value

Hello,

I would like to have the label of the Numeric Items displayed in color depending on a status.

The heating can be controlled via the dashboard. For this I have created a numeric item. If the window in the room is open, the label should be displayed in red.

If I now send a string, the numeric item becomes "undefined" - until the current value is transmitted again.

Is it possible to rebuild this so that there is no "undefined" if the window sends open or closed?

Here is my flow:

[{"id":"2c3f9285.10fb0e","type":"tab","label":"Flow 3","disabled":false,"info":""},{"id":"dab8da1a.47c9c8","type":"change","z":"2c3f9285.10fb0e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"color","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":664.5,"y":272,"wires":[["3b88621e.236cde","85134bd7.110ea8"]]},{"id":"c42b4e65.94cfc","type":"switch","z":"2c3f9285.10fb0e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"closed","vt":"str"},{"t":"eq","v":"open","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":402.5,"y":283,"wires":[["dab8da1a.47c9c8"],["e28a4ff8.511fa"]]},{"id":"e28a4ff8.511fa","type":"change","z":"2c3f9285.10fb0e","name":"","rules":[{"t":"move","p":"payload","pt":"msg","to":"color","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":665,"y":314,"wires":[["3b88621e.236cde","85134bd7.110ea8"]]},{"id":"b36a0f2b.e2d1a","type":"inject","z":"2c3f9285.10fb0e","name":"","topic":"","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":233.5,"y":260,"wires":[["c42b4e65.94cfc"]]},{"id":"dd326319.c6e3c","type":"inject","z":"2c3f9285.10fb0e","name":"","topic":"","payload":"closed","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":231,"y":309,"wires":[["c42b4e65.94cfc"]]},{"id":"85134bd7.110ea8","type":"debug","z":"2c3f9285.10fb0e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":977.5,"y":367,"wires":[]},{"id":"3b88621e.236cde","type":"ui_numeric","z":"2c3f9285.10fb0e","name":"","label":"<font color= {{msg.color}} > Badezimmer oben </font>","tooltip":"","group":"995163c7.b641f","order":2,"width":"0","height":"0","wrap":false,"passthru":false,"topic":"payload.heat","format":"{{value}}","min":0,"max":"30","step":"0.5","x":550,"y":570,"wires":[["85134bd7.110ea8"]]},{"id":"81624baa.083f28","type":"inject","z":"2c3f9285.10fb0e","name":"","topic":"","payload":"18.5","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":249.5,"y":576,"wires":[["3b88621e.236cde"]]},{"id":"995163c7.b641f","type":"ui_group","z":"","name":"S1","tab":"dd7127ad.c3f3b8","disp":false,"width":"6","collapse":false},{"id":"dd7127ad.c3f3b8","type":"ui_tab","z":"","name":"Home","icon":"dashboard"}]

Thanks.
Regards
Hermann

I'm going to take a swing at this until the real experts show up. You are using html code in the label field and the read me states that html only works in the value field. If you change your label code to simply {{msg.color}} the flow works. I'm under the impression the only way to change color on this particular node would be to do it through the theme. Perhaps there is another node or another work around that would appeal to you. For instance the button has selectable label colors.
By the way, what do you mean when you say "the current wet is transmitted again'

I was a bit surprised that you managed to display colors for the labels using the strings "open" and "close" in the tag font color. There are no such color names. I had to find the hex code to figure out what is happening. Quite interesting. It seems to me there is an algorithm that tries to convert the color names to HEX. In this process invalid letters (that are not hexadecimal a,b,c,d,e,f) are replaced by the digit zero.

Your code needs to be rewritten to fix the color issue as well as the undefined issue.

"open" color

"closed" color

1 Like

Sorry...it should be "value"...:wink: