cant you just trigger another script when action is detected
powerplug.sh
and it contains
something like this

sudo bash smart_fritz_terminal.sh 1 on

maybe that works