Items shown as "Err" in sitemap

Hi,
i am reading temperature and humidity with a DHT11 sensor at the openhab raspberry.
I am runing a command using the exec binding.

This is my python script:

#!/usr/bin/env python

import Adafruit_DHT

sensor = Adafruit_DHT.DHT11
pin = 4
humidity, temperature = Adafruit_DHT.read_retry(sensor, pin)
print(humidity)

This is my thing:

Thing exec:command:buero_humidity “Buero - Luftfeuchtigkeit” @ “Buero” [command=“/home/openhabian/Adafruit_Python_DHT/examples/AdafruitDHT_hum.py”, transform=“REGEX((.*?))”, interval=15, timeout=10, autorun=true]

This is my item:

Group Klima_Buero_Diagramm “Raumklima Buero” (FF_Office)

String Buero_Humidity “Luftfeuchtigkeit [%.1f %%]” (Klima_Buero_Diagramm) { channel=“exec:command:buero_humidity:output” }

In the paper ui control the value is displayed correct. However in the sitemap frame FF_Office it is written “Err”.

This is the log info:

[WARN ] [ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value ‘47.0’ of item Buero_Humidity with format ‘%.1f %%’: f != java.lang.String

Can i read the value as a Number or display a String correct in the sitemap?

Strings cannot be displayed with a format instruction for floating point numbers.
%s would do instead.

The exec binding returns strings. You could have a second Number Item, and a rule to parse string into number and update that.

A third option is to write a little javascript that parse the string into a float, and formats how you wish. Use that as a JS transformation in your label [format] section.

1 Like

Hello rossko57,
Thank you. The %s worked!
Ome additional question: is it possible to plot the data over time in the sitemap? Even if the data is in string format?
BR

No.
You will need a Number Item.

Ok, thank you. So you suggest a rule to convert the string into a number?