Swiches with mapping: error in WEB-UIs (Basic+Classic)

I think the complaint is that the single button version does not “light up” as anticipated.

Does it change if refresh the browser? How about if you click the button?

clear browser cache? Chrome is really bad about that. Try a different browser?

It’s the same for all browsers… Refreshing also doesn’t change anything.
I can switch on the switch by clicking on “ON”, but “ON” will never get highlighted.

I would expect a Switch by definition would need more than one state. In fact, OpenHAB documentation describes it like this:

Switch Item, used for anything that needs to be switched ON and OFF

This is a Switch widget in a UI. It need not be associated with a Switch type Item, and is commonly used with Number or String types. When mappings are used, it may take into account one or ten different recognizable states.

1 Like

Can confirm this behaviour with OH2.4

I have some one-button switches in my sitemap - never noticed this (lack of) effect because I use visibility= as well to alter text

Switch item=test_motion_U1gate mappings=[ON="Detect"] visibility=[motion_U1gate!=ON]
Switch item=test_motion_U1gate mappings=[ON="Motion!"] visibility=[motion_U1gate==ON]

but even in that case the button should really “light up” red, and it doesn’t.

I would log a github issue for BasicUI & ClassicUI

No, you can just use one Mapping and, in this case, when you press the button it will send the ON command to the Item. I use this for my garage door openers as the control mimics a momentary push button.

@andreas_furrer68, honestly, I’ve noticed this behavior for about as long as I’ve been using OH. I never gave it much attention as it never was a problem for me. But an Issue should probably be filed.

1 Like

It used to work like you expected in the old version of the Ios App. You could use a switch item and show it as a single mapped button that would be shown as on if the switch had the mapped state. But one of the app developers told me that that actually was the bug.

Johannes

1 Like

You are right… I just updated my iOS version and now it changed the behaviour…
I can‘t understand why…

Yep I also used the supposed ‘bug’ as a feature in my sitemap :see_no_evil:

I also think it is more clearly for informing about an active state of some things…

It has nothing to do with autoupdate

1 Like

I think the misunderstanding is that weren’t expecting the button to turn off when we pressed it again. So not like a momentary push button. Instead we were expecting the button the to behave just the same with one mapping as with 2 or 10 mappings. Meaning it is highlighted when the corresponding item is in the state that the button in the sitemap is mapped to. I don’t understand why it should behave differently when there is one mapping versus 2 or more. Which is how the Ios App used to behave. Now it’s kind of counter intuitive when a mapping gets highlighted to the corresponding item state but only for 2 or more mappings but the behavior with a single mapping is inconsistenct.
Johannes

1 Like

Yes, this is also my oppinion.

The use a switch without mapping, simple as that.

We had the discussion before. There is several use cases were one has a switch item that only ever gets switched to one state in the ui by the user and there is no point in switching it off as it either switches itself off or gets switched when another item gets switched through a rule or nothing happens at all. So there is a point in having the possibility to have a button In a ui that is kind of one way and only gives the possibility to switch something to one state but not manually to another. But the user might want to know if it is still switched to the mapped state or if it changed state. So yes there is use cases where you don’t want to show a two way switch although the underlying item has multiple states. I would have thought that use cases like this ard what mappings are for. And I come back to my consistency argument as it just isn’t the expected highlight behavior if you use mappings otherwise.
Johannes

1 Like

I understand your intention, but the underlying UI element does not work that way.

To achieve what you want, you will have to use the visibility attribute. Just make two switches with one mapping, switch visibility depending on item state and ignore interaction for one of them.

But this will still not show me a single button that is off/not highlighted when the item is not in the mapped state and than as long as the item is in the mapped state show me a button that is on/highlighted.
Independently of where the state change came from, eg rule or ui, and when you press it triggers a change to the mapped state. Because that’s exactly how it behaved before.
Can you please post an example Sitemap code for your two switch visibility solution that achieves this, because I don’t quite understand it?
If you look at the first post in this thread you see that android app too behaved in our expected way.

1 Like

Anybody knows, how a number item with one mapping is behaving?