Controling sonoff switch directly from computer with Python

Last year I released an open source solution on Github which showed how to flash a Sonoff S31 power plug on esphome such that the plug when turned off would automatically turn back on after a short delay.

The purpose of such a solution is to recycle the power to a device that needed to be hard rebooted (power off power on) remotely.

Recently, however I came across an issue that I couldn’t turn off the switch via Home Assistant (as was my normal use case) as the network connection to Home Assistant wasn’t available.

Accordingly, I’ve now added a python script that allows me to directly turn off the plug remotely from my computer (Windows machine but could be Linux as well) without needing access to Home Assistant.

If this sounds as if it could be helpful to you, here’s the Github page for it:

I dont understand why you wouldn’t just activate the web-server and toggle it that way if the primary goal was to find a backup that didn’t rely on using HA. Another simple option would be to just setup mqtt and that would allow you to do the same thing as well as use one of the dozens of downloadable phone or pc apps that allow you to communicate to IOT devices through mqtt.

There’s nothing wrong with what you’ve come up with and it’s a very cool method you’ve made. It just seems like one of the many other built-in options would have sufficed without coming up with IMO overkill option…

Either way it’s cool and i definitely appreciate the effort and you sharing it, im more just curious of your thought process if you dont mind.