Network:pingdevice, change colors if is OK or NOT OK

  • Platform information:
    • Hardware: Raspberry Pi 3 Model B Rev 1.2
    • OS: Raspbian GNU/Linux 10 (buster)
    • Java Runtime Environment: which java platform is used and what version
    • openHAB version: 2.5.12 (Build)

Hi all
I have the following item for ping device

Switch espSala { channel="network:pingdevice:espSala:online" }
Number:Time espSalaResponseTime { channel="network:pingdevice:espSala:latency" }

sitemap section

Text item=espSalaResponseTime label="Zona Giorno [%s]" icon="chip"

thing section

Thing network:pingdevice:espSala [ hostname="" ]

This is the result on BasicUI from mobile phone when IP is OK


I would like if the ip was KO, the color was red, for example

How I can do this?

In the official documentation is an example to set colors. Have you seen this?

Have I to create a rule?


Text item=espSalaResponseTime label="Zona Giorno [%s]" icon="chip" valuecolor=["ON"="green", "OFF"="red"]

Thanks a lot!!!
I works fine!!!

Hi everyone
I have another question and I don’t know how to solve it
I have this item to take the temperature value

String          GY21    "Value: [%S C/U]"       <temperature>   ["CurrentTemperature"]  {http="<[*?))]"}

and the output format is “18.79|60.41” (temperature|humidity)

Now I want that if ONLY temperature value is more or less than specific value, the text must be of specific color.

How can I do this?

You will have to parse out the temperature-only part into a separate Number type Item, either from another HTTP channel or by rule.

Then you can use something like

Have you looked at the docs at all?

thank you very much, but I don’t want to use another HTTP channel just for temperature, because the value is taken from an esp8266 with all values
Can I parse the value with HTTP channel?

It doesn’t cost anything. The HTTP Thing fetches the data; as “children” of that Thing you can have a whole bunch of channels, each interpreting and selecting from the same data into different openHAB Items.

Hi rossko57
thanks for your explanation.
If I have understood well, I have to use REGEX into HTTP, in order to parsing “|” value, right?

That’s a good way to do it, yes.

Hi rossko57
I tried to parse “|” value for HTTP, but it doesn’t work. I checked my REGEX online and it works.
But I would prefer to parse with item object, so I don’t call more times HTTP (sometimes ESP8266 loses the wifi connection)

Could you help me in this way?

Thanks a lot

What with? i.e. what have you done so far?

I tried to parse my temperature value with HTTP item

String          ExtGY21    "Value: [%S C/U]"       <temperature>   ["CurrentTemperature"]  {http="<[*?))]"}

but it didn’t work

I would parse my value after HTTP call, so I’ll have only one call to take all values and after take specific value (temperature or humidity)

There’s nothing there to select the temperature part. Would you not want to select until | character?

Because you are using v1 binding, you will have to set that up as a cache in your HTTP.cfg

Hi rossko57
thanks a lot for your support

I created for test in my http.cfg


and in my item file I tried a few solutions, but nothing work fine

String          testHTTP     "Value: [%S]"              <temperature>   { http="<[test:10000:REGEX((%7C.*?))]" }
//String                testHTTP     "Value: [%S]"              <temperature>   { http=">[*:POST:test&type=%7C]" }

Output of http is “19.25|58.20”, and I want only “19.25”


Okay. There is no % or 7 or C in there, so this is not going to work.
When a REGEX transformation fails, you get the whole original string.

Experimenting in rules is good for transform testing.

val rawtext = "19.25|58.20"
var results = transform("REGEX", "(\\d+.\\d+)\\|.*", rawtext)
logInfo("test", "from " + rawtext + " extract " + results)

This REGEX captures digits from the start, then a decimal point, then more digits until it encounters the | character, then to the end without capture.
Note that d and | need to be escaped with double \

2022-02-26 00:00:44.188 [INFO ] [.eclipse.smarthome.model.script.test] - from 19.25|58.20 extract 19.25

Hi rossko75
great!!thanks for your help
It’s working fine!!

Now in my sietmap I write this to change valuecolor

Text item=testHTTP
Default item=GY21 label="GY21" valuecolor=[testHTTP<=23="blue"]

Two issue for me:

  1. I don’t want to see testHTTP item
  2. GY21 item doesn’t change valuecolor by checking testHTTP item

How can I resolve it?

Then you would remove the widget that you put there to show testHTTP item.
Text item=testHTTP

No, it wouldn’t.
is an arithmetic comparison, but your Item is a String type. If you want to do maths you will need a Number.

Yes, I want use value item testHTTP only for comparison to change valecolour of other item (item=GY21), but I don’t want show it on basicUI

I changed to number for the item testHTTP and now it works fine :wink: