Switch on/off hardware switch using pymavlink

Hello all,
I can trigger the safety switch using mavproxy using the commands “arm safetyoff”/“arm safetyon” as given here-
https://ardupilot.org/mavproxy/docs/uav_configuration/arming.html#safety-switch

I would like to control the hardware safety switch as on/off using pymavlink. I’m curious if there is a way to do this.

Thanks.

For safety on:
master.mav.set_mode_send(master.target_system, mavutil.mavlink.MAV_MODE_FLAG_DECODE_POSITION_SAFETY, 1)

For safety off:
master.mav.set_mode_send(master.target_system, mavutil.mavlink.MAV_MODE_FLAG_DECODE_POSITION_SAFETY, 0)