stateDescription works only when value changed

Dear all,

I have several items using the stateDescription to transfer to human readable values. This works in principle but only when something has changed. Is this normal behavior or some wrong configuration / usage on my side.

On example:

Number                      BadezimmerThermostat1ProfileDefault                                   "Profil Standard"                                               <calendar>       (gBadezimmerThermostat)                                                                                                                              ["Point","None"]                 {channel="homematic:GATEWAY-EXTRAS-CCU3:ccu3:GWE00000000:1#Thermostat_Badezimmer_Profile_Default", stateDescription=""[options="1=Normal,2=Baden,6=Absenken"],listWidget="oh-label-item"}

This initially shows e.g. “1.00” and later when something has changed e.g. “Baden”.

That’s normal. The state description is only applied once the state will change or receives an update.

Any other option how to get this working?

You can manually post an update to the item sending the current state as an update to trigger a refresh.

However the issue you are describing is in most cases only a one-time issue when newly creating an item.
As in most cases the state description will not change frequently you only have a missing / wrong state description for the time between creating/updating state description and updating the item.
Any time later once your OH installation is running and your item received at least once update you will never see this issue again.

The following does not work. Sending a command is not appreciated as this will cause rules tu fire.

BadezimmerThermostat1ProfileDefault.postUpdate(BadezimmerThermostat1ProfileDefault.state)

I see this behavior in case of items file new loaded or openhab restarted even though I have persistence activated.

Not sure if that’s maybe a type issue and 1.00 is different to 1

Have you tried both options in your state description (and send an update afterwards)?

Interesting idea, tried it but I actually do not see the item BadezimmerThermostat1ProfileDefault showing up in the log. Does openhab do anything for postUpdate in case of no state change at all?

I have done a quick test and sending the same state as current state is obviously not updating the state description. The stateDescription is only refreshed if the state of the item is changing.

However I have also tested if there is a difference between 1.0 and 1:
If the state description only provides a mapping for state = 1, then state = 1.0 is not having a description.

You can test it with the following expression:

=items.BadezimmerThermostat1ProfileDefault

where the expression will return:

{ "state": "1", "displayState": "Normal" }

and

{ "state": "1.00" }

Unfortunately for postUpdate state=1 and state=1.00 is the same (as you have a numeric item and 1 is the same as 1.00), therefor this will not issue a change in the item state, but for state description 1 & 1.00 are two different states.

Therefor I would recommend to adjust your state description and also include a 1.00 state or test with a string type item (maybe the 1 from the channel is converted to a 1.00 as your item is numeric?)

Hi, I tried string and this works. Thanks for the hint, does not change anything for me in the logic.