Strange formatting problem

(Nigel Titley) #1

I’m running openhab2.4 on a raspberry PI and am gradually migrating from openhab1. I’ve just added the MQTT 2.4 binding and I’m getting a very strange formatting error.

I have an MQTT sensor that is reporting humidity as a floating point number. The MQTT messages are being sent correctly and are being received by the openhab2.4 MQTT binding. The event log indicates that the humidity item is being correctly updated and the chart of the item looks good.

The one niggling thing that is wrong is that in the classic UI, the basic UI and the android app the value is being multiplied by 100, so for example an RH value of 57.375 % is being reported on screen as 5737.5 %. I’m using a formatting string of [%.1f %%] in the item description. It’s exactly the same formatting string as I’m using for another (one-wire) sensor item, which is displaying correctly.

I emphasise that the value is correct, it’s just being displayed wrongly. The item is defined as a dimensionless number of type Humidity and has been set up using paperUI.

This is probably something really silly, but I can’t work out what.

(Vincent Regaud) #2

Use [%.1f %] instead

(Nigel Titley) #3

No that doesn’t work. You need to double the % in order to get a % sign in the output. A single % just gives you “Err” for the whole string.

(Nigel Titley) #4

Although, using [%.1f] results in the number being displayed properly, just without the “%”. Which is even more weird.

(Vincent Regaud) #5

That’s odd, it should work.
Have you tried removing the formatting in the item description and putting it in the sitemap instead?

(Nigel Titley) #6

Hmm, not sure how to do that. The item is being displayed as part of a group in the sitemap.

Frame {
Group item=Humidity label=“All humidity” icon=“climate”

(Vincent Regaud) #7

Add the items one by one

Text item=TempItem label="Temperature 1 [%.1f %%]"

(Nigel Titley) #8

Hmm, exactly the same… value times 100 and a following % sign.

(Vincent Regaud) #9

And the value of the item in the log?

(Nigel Titley) #10

The event log?

2019-01-11 11:22:22.713 [vent.ItemStateChangedEvent] - LoftHumidity changed from 63.3125 to 63.0
2019-01-11 11:22:53.309 [vent.ItemStateChangedEvent] - LoftHumidity changed from 63.0 to 63.3125
2019-01-11 11:23:54.345 [vent.ItemStateChangedEvent] - LoftHumidity changed from 63.3125 to 63.625

(Vincent Regaud) #11

Ok so there is no % there
Can I see a screen shot of your item definition in the paperUI, please?

(Nigel Titley) #12

(Vincent Regaud) #13

Are you willing to try a text based item instead of PaperUI?

(Nigel Titley) #14

This is after taking out the %%, the formatting string causing the trouble is [%.1f %%]

(Nigel Titley) #15

Yes, of course… but I’ll need to do that a bit later. This is eating into Real Job

(Vincent Regaud) #16

First delete the item from the paperUI (Remember the name and the groups)

Then create a file called temperatures.items in the items folder
With the following contents:

Number:Dimensionless LoftHumidity "Loft Humidity [%.1f %%]" <humidity> (g_Loft, Humidity, g_Chart, g_Chart_Humidity) { channel="thechanneltolinktofrompaperUI" }

Mine look like this:

Number:Dimensionless SmallBedroom_ThermostatHumidity       "Small Bedroom Humidity [%.1f %%]"             <humidity>    (SmallBedroom, Humidity, BedroomsHumidity, MQTTv2)                                                             { channel="mqtt:topic:MosquittoMqttBroker:SmallBedroomThermostat:Humidity" }



PaperUI Control:

(Nigel Titley) #17

Ah ha! That worked

So why didn’t it work with paperUI?

(Rossko57) #18

That’s a good question. It might be possible to fetch the Item via REST and compare details. It’s possible PaperUI is messing with % symbols or something.