Define mapping values in switch item in sitemap

Hi,
I have a small problem…
I defined a switch item for cooling unit fan, which is a 3 speed fan (KNX device via knx binding)
to activate the fan in 1st speed, you have to send the command 26%, but he then sets the fan to 33%. to activate second speed, you need to send 53% but he then returns the value of 66%…
So when fan is in 1st speed, it is not visible on sitemap that this button is activated, since the value is not the same that was sent. the only buttons that do work correct are OFF and HI (0 and 100)
is there any workaround that I could tell openhab to mark that button as active?

this is the item:
Switch item=ACRooms1 label=“Fan Speed” icon=“fan” mappings=[0=“OFF”,26=“ON”,53=“MED”,100=“HI”]

There is no way around that. Either state matches mappings=[ ] , or it doesn’t match.

A dirty way is to display state alongside buttons.

Switch item=ACRooms1 label="Fan Speed [%s]" ...

That could enhanced with a MAP transform, to show OFF/MED/HI etc. instead of numerics.

Does anything bad happen if you do send say, 33 instead of 26?
You could have your mappings=[ ] send 33, and have a rule listen for command 33 and shortly afterward send the “correct” command 26.

If you need to avoid the “bad” commands altogether, then you could use a proxy Item on your sitemap with any values you like, and a simple rule to pass corrected commands to the real Item.

Hi,
Tried sending 33% but then it goes to 67% :slight_smile:
so I guess its configured that if it receives between 1-32 it sets itself to 33% and that is speed1, if it receives between 33-66 it sets to 67 and that is speed2, if it receives 66-100, something like that…

it already shows the real value next to the buttons, if I add [%s] as you suggested, it just removes %, so it shows 33, not 33%

If I use the rule, it might not trigger fast enough, so the real item will receive wrong command and then get throttled to lower speed, don’t want to do that to break the fan :slight_smile:
Proxy item might be good, but if I keep that fake item in sitemap, than those updates wont be based on real reading of item value, so if someone turns it on via wall controller, by sending command to the real item, the OH proxy item wont be updated.
I could have 2 items in sitemap, 1 for status, 1 for control but that is really dirty :slight_smile:

Why not? It’s easy enough to have a rule listening to “real” Item updates and posting them to proxy Item.
You’d probably want to have autoupdate disabled on both Items, so that commands don’t interfere with states.