Mappings break switches in BasicUI and Android App

I’m not sure if the following is a bug or the intended behaviour; I was struggling with this issue since I began to use Openhab, however, and I want to hereby share it:

When you map the states of switches like this:

Switch Notmodus "Notmodus [MAP(]"	<error> (Heizungsstatus)

and a map like this:


Basic UI & the Android App won’t update the state of switches neither their associated icons.
If you define the switch as text, it will work (hence show the defined/mapped strings), if you define it as switch, it won’t (hence not “flipping” the switch nor changing the icon e.g. from lit to unlit) . Maybe that’s because the switch state is being handled as a string and this string is wrongly interpreted after transforming?


Text item=Notmodus

Doesn’t work:

Switch item=Notmodus

As soon as you remove the mapping, everything works fine with both Basic UI and the Android App.

I can confirm that behavior with the iOS app and openHAB 2. As soon as there is a map for a switch like that

Switch	Ruhemodus	"Ruhemodus [MAP(]"	<sound>	(Status)

the Switch item can’t be used via the app. When you switch it on, openHAB receives the update, but the switch changes back in the app ui to OFF.

I tested the contents of the map-file, but it doesn’t seem to be a problem of it.

This is a problem regarding openHAB 2. Nothing wrong with version 1.x.

There seem to be further problems, which also could be caused by this bug (?).

Removing the mapping in the item definition helps with using the item as a switch in the app just as stated above. But when using the item as a text item like this

Text item=Ruhemodus

there is no state output at all. If I’m not mistaken there should be “OFF” or “ON” as a text item in the app, but the only thing you see is the icon and the label.

Also the on- and off-versions of the icons don’t work anymore in this case. Only the standard fallback icon is shown.

So there seem to be a general issue with switches as text items at least in the iOS app.

I push this, because it really seems like a bug. And maybe this thread should be moved to another board more regarding possible bugs.

Does nobody else face this issue? Is this the intended behaviour or should I open an issue for that?

I doubt that this is intended. It worked fine with openHAB 1.x. But it seems that nobody cares…

There is a detailed exploration here

Thank you, but this is not the problem we described above. There is no problem with icons or the naming of them.

I recently proposed a fix that is now merged but not yet in the nightly snapshots. It should fix this issue.

1 Like

FTR, this is the fix from @Lolodomo:

I have done a new ESH stable build and a new openHAB distro - so the latest build should have the fix included.

1 Like

Should this work now? I’m at the latest build and it doesn’t work as intended. I think that it worked with some of the last few builds.

It looks ok for me with build 937 and my contact items with mapping.

This is kind of a hop on - hop off thing. It always works in the Android App and Edge, it only sometimes works with firefox. That’s strange, but at least it works sometimes :slight_smile:

I narrowed the problem down to the following:
if I update any item file Basic UI won’t react as usual anymore. Variables won’t get updated, visibility won’t get toggled and so on. Changes are only visible after reloading the page. This was mentioned before:

It starts working again without any problems after restarting Openhab.

Edit: Changing sitemaps also seems to break the stream.

You have apparently identified a clear bug with Basic UI when refreshing files. Can you open an issue in Git ?