Toggle Action Fan between Off and Preset Mode

I do not know if this is related specifically to the card I am using (bubble card) or more a generic setup question. But I am trying to control the tap action to control the on/off of a ceiling fan. I have the below that will turn the fan on correctly to the Low Speed. But how do you set this to toggle between On/Low Speed and Off?

- entity: fan.family_room_ceiling_fan
        tap_action:
          action: perform-action
          perform_action: fan.set_preset_mode
          target:
            entity_id: fan.family_room_ceiling_fan
          data:
            preset_mode: Low

I don’t know anything about bubble card, so take my response with that grain of salt.

If I understand you correctly, you want a ‘tap’ action on a UI item to toggle between a preset_mode (Low) and a state (off), as opposed to just toggling between on/off states (because setting the on state does something other than set the preset_mode to Low?).

If so, I suspect you could make this work with a script that handles this logic. The script would check the state of fan.family_room_ceiling_fan; if the fan entity’s state is on, the script would set the state to off; if the state is off, the script would set the preset_mode.

With that script written, you could set the tap_action to call script.[whatever_you_name_it], rather than fan.set_preset_mode.