RaspberryPi poweroff with Sonoff

Is there a smart way to use a Sonoff switch to powerdown a Raspberry Pi ? So: when the Pi is in a “halt” state, switch the Sonoff off.

Use a regulated power supply connect it through the Sonoff to the GPIOs of your Raspberry Pi should work.