[SOLVED] ESP-Easy Tempsensor - Syntax Error?

Hi Community,

I´m new here and now I try to set up a few sensors and devices. Some SonOff devices with Tasmota are working.
And now I have a ESPEasy device running with a switch, a motion detector and a Temp/Hum Sensor. The switch is working in Openhab, but I can´t get the temp/hum sensor to work in OpenHab.

Here my item code:

String ESP_Easy1_Temp "Temperature [%.1f °C]" <temperature>
        { mqtt="<[broker:/ESP_Easy-Sensoren-hinten/TempHum/Temperature:state:default]"}


String ESP_Easy1_Hum "Luftfeuchtigkeit [%.1f]%" <humidity>
        { mqtt="<[broker:/ESP_Easy-Sensoren-hinten/TempHum/Humidity:state:default]"}

And here the sitemap code:

Frame label="Temperatur hinten"

        {
           Text item=ESP_Easy1_Temp
        }


        Frame label="Luftfeuchtigkeit hinten"

        {
           Text item=ESP_Easy1_Hum
        }

And here´s the error code:

21:06:22.143 [INFO ] [smarthome.event.ItemStateChangedEvent] - ESP_Easy1_Temp changed from 21.7 to 23.1
21:06:22.054 [WARN ] [.ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '23.1' of item ESP_Easy1_Temp with format '%.1f °C': f != java.lang.String
21:06:22.416 [INFO ] [smarthome.event.ItemStateChangedEvent] - ESP_Easy1_Hum changed from 58.4 to 59.5
21:06:22.109 [WARN ] [.ui.internal.items.ItemUIRegistryImpl] - Exception while formatting value '59.5' of item ESP_Easy1_Hum with format '%.1f': f != java.lang.String

I think OpenHab does receive the mqtt message, but can´t understand what the messages means.

Where´s the fault, is something wrong in the syntax?

Thanks
Homer

  • Platform information:
    • Hardware: RasPi 2
    • OS: Raspian 9 Stretch
    • Java Runtime Environment: oracle-java8-jdk
    • openHAB version: 2.3

Did you try to use a Number Item type to see if it works for both?

Number ESP_Easy1_Temp "Temperature [%.1f °C]" <temperature> { mqtt="<[broker:/ESP_Easy-Sensoren-hinten/TempHum/Temperature:state:default]"}
Number ESP_Easy1_Hum "Luftfeuchtigkeit [%.1f]%" <humidity>  { mqtt="<[broker:/ESP_Easy-Sensoren-hinten/TempHum/Humidity:state:default]"}

I believe the error is due to the formatting that you are applying (for display purposes).
Since the value is being stored as a String (aka text) in the Item state you cannot format it with [%.1f °C]. (this works with Numbers)

Yes that´s the solution.
I don´t know where this string comes from.

Thank you for the quick help.

1 Like