If shell command fails to turn off the button, want to stay turn on in the command_line switch

Hello Home assistant community,

I have some simple command_line switches as follows;

 - platform: command_line
       command_on: 'python2 /home/homeassistant/share/switchbot-cmd.py XX:XX:XX:XX:XX press'
       command_off: 'python2 /home/homeassistant/share/switchbot-cmd.py XX:XX:XX:XX:XX press'
       friendly_name: unlock

but sometimes it fails to turn on/off.

Logger: homeassistant.components.command_line.switch
Source: components/command_line/switch.py:133
Integration: command_line (documentation, issues)
First occurred: 06:04:08 (6 occurrences)
Last logged: 06:20:56

Command failed: python2 /home/homeassistant/share/switchbot-cmd.py XX:XX:XX:XX:XX:XX press

my wish is that if command failed, the status of this button remains as previous. for example, if failed to turn on, the status remains as turn off.

the idea is building the script with grabbing the log, but do you have any method to realize this one?

Is there a reason you aren’t using the switchbot integration?