Try this with exec binding
https://github.com/ggeorgovassilis/linuxscripts/blob/master/tp-link-hs100-smartplug/switch-plug.sh