Basic UI: Text color depending of item string content

  • Platform information:
    • Hardware: Proxmox Virtual Environment 8.2.2 on Futro S920
    • OS: Debian 12
    • Java Runtime Environment: 17
    • openHAB version: 4.3.2
  • Issue of the topic:

Helloy Guys. Why doensn’t work this sidemap code for mobile app:

Text item=Status_Licht label="Status Beleuchtung" valuecolor=[=="Büroschalter AUS"="red", =="Licht AUS"="green", ="Licht AN"="yellow"]

I would like to expect the following behaviour:

Status_Licht == “Licht AUS” shows green text
Status_Licht == “Licht AN” shows yellow text
Status_Licht == “Licht AUS” shows green text

Thank you very much

Check in logs what is the exact state value of your item.
How is defined your item ?

A screenshot

In this case, the item Status_Licht=“Licht AN”. I expect a yellow text, but it is in black

The item is defined as follows:

Is your problem in Basic UI or Android app or iOS app ?

A = seems to be missing at the beginning of your last condition (yellow).

1 Like

In case your problem is solved, please mark it as resolved and post a small message.

I have to check it. I mean the Basic UI. Nevertheless I don’t unterstand what you mean.

Th fixed syntax
Text item=Status_Licht label=“Status Beleuchtung” valuecolor=[==“Büroschalter AUS”=“red”, ==“Licht AUS”=“green”, ==“Licht AN”=“yellow”]
Instead of
Text item=Status_Licht label=“Status Beleuchtung” valuecolor=[==“Büroschalter AUS”=“red”, ==“Licht AUS”=“green”, =“Licht AN”=“yellow”]

Okay thank you :smile: I’ll check it later and marked this thread as solved.

It doesn’t work. The code is not even saved. If I save it and refresh, the line is removed…

Neither work the code directly nor in the GUI:

In the meantime, I notice in the code editor a general issue but I can’t find the mistake.

Here the message:

But it seems be good. That is the code line 2 until line 9.

    Selection icon=presence item=FritzBoxStatus label="Betriebszustand"
    Group icon=sun item=Astronomische_Berechnungen label="aktuelle Sonnendaten" {
        Text icon=iconify:material-symbols:height item=Sonnenhoehe label="Höhe"
        Text icon=sun item=Sonnenrichtung label="Azimut"
        Selection icon=sun_clouds item=Tag label="Es ist gerade "
        Selection icon=sunrise item=Sunrise label="Sonnenaufgang"
        Selection icon=sunset item=Sunset label="Sonnenuntergang"
        Chart icon=line item=Sonnenhoehe label="Sonnenstand" period=12h refresh="1000000"
    }

In the previous version of OH (like 3.4.2) the code was without failures.
I hope the one has nothing to do with the other

It looks like there is a bug in the UI parser when the icon contains a combination of : and -.
I will have a look when I have time.

Make sure to use the proper quotes. If you copy/paste, the quotes will be wrong. This line does work for me when I put it in the sitemap code window.

PR for fix created: Sitemap editor: fix icon parsing error by mherwege · Pull Request #3048 · openhab/openhab-webui · GitHub

2 Likes

As I mention, I can’t save the code. I save it witch Ctrl+S, refresh the browser and the saved code is gone.

Look at the quotation marks:

“ vs "

You will need the latter:

Text item=Status_Licht label="Status Beleuchtung" valuecolor=[=="Büroschalter AUS"="red", =="Licht AUS"="green", =="Licht AN"="yellow"]

This happens because of the forum software when text configs are quoted without the proper code tag:

grafik

Edit: removed one wrong quotation mark

I know, but sorry, it doesn’t work. I can’t save it with Ctrl-S if I change the code.

I added the following line:

Save it with Ctrl-S

and now

nothing happend!

Which editor are you using?
Are you able to save other files?

You copied a typo which I corrected in my edit, see above.

You have double quotes (“”) before yellow in your screenshot.

The Openhab one.

Maybe it’s connected with the bug: Pull Request #3048

I fixed yout code with one quote, but I can’t save anyway.

So, I’ve tried an another way. I add this in the Design GUI the following:

If I save, follow error message is showing:

I check the code:

and that is the proposed code line but … It doesn’t work :upside_down_face: