I’d like to set an item’s color depending on its value. Since it’s not a straight number but contains text (e.g. 930 ppm) I need the split function, which usually works fine. In the developer sidebar =items.NetatmoEsszimmer_CO2Gehalt.state.split(’ ')[0] gets a number, too.
For some strange reason, I get error messages in the context of ‘color’. Do you have any explanation for this?
Hello Jan,
I’ve tried both versions without success; no errors in the code-window, but the results get ignored. And when I test it in the dev. sidebar, I get errors:
color: ‘=(Math.round(((items.NetatmoEsszimmer_CO2Gehalt.state.split(’ ‘)[0])) < “900”) ? “green” : (Math.round((items.NetatmoEsszimmer_CO2Gehalt.state.split(’ ‘)[0])) > “1200”) ? “red” : “green”’
→ Run-Mode: result igrnored, standard color - Developer Sidebar: Error: Expected comma at character 59
color: “=(Math.round(((items.NetatmoEsszimmer_CO2Gehalt.state.split(’ ‘)[0])) < ‘900’) ? ‘green’ : (Math.round((items.NetatmoEsszimmer_CO2Gehalt.state.split(’ ')[0])) > ‘1200’) ? ‘red’ : ‘green’”
→ Run-Mode: result ignored, standard color - Developer Sidebar: Error: Unclosed ( at character 185
I’ll look deeper in the post by Rainer and check back here in case I’m succuessful. Might be interesting for others since I’d expect this to be a rather common question/problem …