I have an esp8266 flashed with the Tasmota firmware working ok and is sending messages to openhab, i have a Contact item and when the ON or OFF message is sent from the MQTT it changes from OPEN and CLOSED, can i change this so it displays SET or UNSET as it will follow the state of my intruder alarm?
Sure. Use a MAP transform in the Item label. This doesn’t change the state of the Contact Item - it’ll still be OPEN/CLOSED so far as any rules are concerned, etc. - but you can display what text you want in the UI.
Nope. You cannot set a Contact type Item to state e.g “UNSET” by using a transform in the binding, or a profile.
What I suggested was not to do that, to leave the state alone, because it’s really the display you are interested in. The display is governed by the [format] part of the label in Item (or sitemap).
At the moment you’ve got [%s], meaning show state as string e.g. OPEN
To map OPEN into “SET”, you need to put your MAP in the [ ] part.
If you’ve not done this before you might need to install the MAP transformation service.
No, if the binding encounters a problem (a communication failure for example) it will set the state to UNDEF. That will then throw an error because it cannot look up UNDEF in your original map file.
So you might add a line like UNDEF = Unexpected problem
or whatever you want your string to be. You might be happy with UNDEF, so UNDEF = UNDEF
MAP in label [format] works just fine for many years.
Perhaps you’re viewing with PaperUI. Remember that is an administrator’s toolkit, allowing you inspect Items. It’s not intended as a user UI.
Yep, that’s the ticket browsers etc. can need a refresh to pick these things up, it can be a nuisance.
More fiddly bits … if you do use it in label display (as opposed to channel/binding side) then you may need to deal with NULL state too, where the system has been loaded but no update has yet taken place. Sometimes, the system seems to do a “pre-transform” I’ve never really understood and substitute “-” for NULL.
So in my own display maps I just put both NULL = uninitialized - = uninitialized
This isn’t needed for profile/binding side use.