I am using the updateState method to values for my channels but the state changes from the format I specified in the thing.xml file and in the sitemap. How do I solve this

A function keeps overriding the format the state I assigned to a channel. eg [%.2f W]. It only comes at the first time and changes without including the W

Yes, this is a known issue (work in progress) you could circumvent this in using a proxy item, and cutting of the unneeded decimals with a rule.

Proxy item ??

Proxy Item -> an Item with no Binding at all, i.e. the item will only be updated from rules, UI, or through osgi console.

I am new to openhab, please how do I do that, I am getting the data from a webservice I have created


Number getPower {...} //bound to webservice
Number showPower "Current Power [%.2f W]" <icon> //no binding here


import java.lang.Math

rule "update current power"
    Item getPower received update
    val myPower = Math::round((getPower.state as DecimalType) * 100.0) / 100.0

I didn’t test this code, so maybe there are some lapses, but I think you get an idea…

ok, please what goes into the getPower “bound to webservice”

getPower is the item what you used since now (the one with many decimal places)

ok thanks
something like getpower {item=Outside_Light_Switch}

I don’t know about your existing item definitions :slight_smile:

I am just giving an example lol