[SOLVED] Creating a single push button with two different actions (ON/OFF)

Hello!

I am trying to create a single push button (not with a classical switch appearance) for Mute TV. When button is tapped, it will activate “TV_Mute_ON” and sitemap item will be highligted (eg : change color) and while TV_Mute_ON state, if the button is tapped again , it will change back to ''Mute_OFF" state, indication will go back to initial state.
I tried something like this :

Switch item=TV_Mute label="MUTE" mappings=[ON="MUTE"] icon="soundvolume"
//and a rule like : 

 rule "  Single Mute Switch"
when
  Item TV_Mute received command
then
   if (TV_Mute.state != ON) TV_Mute.sendCommand(ON)
    else TV_Mute.sendCommand(OFF)

end

I tried to make it with a switch of a single mapping. My output is nothing but a TV_Mute state eternally changing its state from ON-OFF-ON-OFF… I also realized that with a single mapping option , tapping to that mapping button doesn’t change its own visual appearance although that command is changing the state of TV_Mute to ON.

Would appreciate it if someone could help.

Regards,
Erdal.

Sitemap for single “dynamic button”

Switch item=TV_Mute label="MUTE" mappings=[ON="MUTE"] icon="soundvolume" visibility=[TV_Mute!=ON]
Switch item=TV_Mute label="MUTE" mappings=[OFF="UNMUTE"] icon="soundvolume" visibility=[TV_Mute==ON]
4 Likes

Wow! Never thought it would be solved with visibility. Thanks for the response rossko57!

Erdal

I expect there’s other ways as well, but it works. You can also fiddle with icons and text colours in the alternate versions.