Disable switch item toggle change in GUI

I have item as below
Switch node04_dev16 “Exhaust Fan” {mqtt=">[rshmosquitto:…/com:command:*:default]"}

From the GUI, when I click on the button, it will toggle the status from ON to OFF / OFF to ON and accordingly the end device is turned ON or OFF.

What I want is the end device to turn ON or OFF but in GUI it should remain on its current statue.

It is not clear what you are trying to accomplish.

You turn the device ON some other way but you want the UI element to say it’s still OFF?

You turn on the device using the GUI but you don’t want the UI to change state?

Why would you not want the UI to reflect the actual state of your device?

Are you really looking for a push button type UI where instead of a toggle you have a button to press?

Sorry for not being clear.

The device will turn ON/OFF from the GUI only and not from some other way.

I am having issue, sometime my end device will not turn on instantly or will not turn on at all. But once it turn ON/OFF it will send the reply back about the status. Base on the reply back status I want to show that in the GUI.

Currently I and doing it with rules, may be its not the write way.

.items

Number node14_dev41 “Water Heater” {mqtt=“<[rshmosquitto:…/dev41:state:default]”}
Switch node14_dev17 “Water Heater [%s]” {mqtt=“>[rshmosquitto:…/dev17/com:command:*:default]”}

.rules

rule "node14 Water Heater State"
        when
                Item node14_dev41 received update
        then
                if(node14_dev41.state == 0 ) {
                        postUpdate(node14_dev17, OFF);
                }
                if(node14_dev41.state == 1 ) {
                        postUpdate(node14_dev17, ON);
                }
end
rule "node14 WH Response Chk"
        when
                Item node14_dev17 received command
        then
                if(receivedCommand == ON) {
                        postUpdate(node14_dev17, OFF);
                }
                if(receivedCommand == OFF) {
                        postUpdate(node14_dev17, ON);
                }
end

This is a tricky one because in order to have a good UI experience you need feedback on the UI that you have successfully triggered the action. On the other hand you want to represent the actual state of the heater.

So I see a few different approaches:

  • Forget about the feedback on the UI and use a mapping to turn the toggle into a button and the visibility flag to change the icon and text of the button depending on the real state.

For example:

                Switch item=T_D_Garage1 label="Garage Door 1" icon="garagedoor-closed" mappings=[ON=Open] visibility=[N_D_GarageDoor1!="OPEN"]
                Switch item=T_D_Garage1 label="Garage Door 1" icon="garagedoor-open" mappings=[ON=Close] visibility=[N_D_GarageDoor1=="OPEN"]

When N_D_GarageDoor1 says the door is OPEN, the button says “Close” and the icon is an opened garage door. When N_D_GarageDoor1 says the door is CLOSED, the button says “Open” and the icon is a closed garage door.

The command to open or close the door goes to one Item (T_D_Garage1) but the way the line looks on the sitemap depends on the status of a second Item. So if you split your setup into two Items, one for controlling and one for status this should work.