Its an old solved question, but it is the first result for my question and i found a more simple solution.
I write a script (with the UI, named ui_script_1), no trigger only a IF ELSE, there i ask IF value = A THEN value = B ELSE value = A. On UI i use the Mushroom entitiy card, showing me the state of my entity and set as click event “call service ui_script_1” so i toggle between these two states (there are 5 possible states, but i want only these 2 states as my toggle).
Reply if you are interessted and need more input.