Simple switch pointing to URL

Hi all,

I’m new here and new to Home Assistant. I had Domoticz for years and want to try HA.

I’m trying to find an easy way to get a switch in HA that “executes” this URL: http://192.168.1.2/cm?cmnd=Power%20On for powering on and http://192.168.1.2/cm?cmnd=Power%20Off for powering off. State would be very nice but not a must. These commands will trigger a flashed Sonoff WIFI switch.

I’ve been reading a lot but have absolutely no clue how to start and set this up.

Please some help in easy steps?

Sorry, I can’t help with this specific question.

However…

You may want to simply investigate using ESPHome on the Sonoff WiFi switch. This would then provide proper two way communications between the WiFi Switch and Home Assistant.

I flashed a Sonoff S31 smart outlet with ESPHome and it works very well. Hopefully there is a online guide/tutorial to help flash ESPHome on to your Sonoff Switch device.

Use a template switch

1 Like

Thanks for the replies, still have no clue how to do that. I’m new to this and looking at this template switch page is like seeing water burn. For such an easy task it looks like a very difficult proces. Although really appreciated I need more help then just pointing me to a page.

@ogiewon I will look into the ESPHome thing you suggested but it should be possible with my current hardware setup? It’s just setting up a virtual switch with 2 commands :sweat_smile:

It is really simple, but I’m on my phone right now, so difficult to write it for you.

No hurry, glad you want help! It can wait till you are on a pc/laptop.

Maybe someone else can help me? Also trying to add Mi-Ligth wifi box, is that also possible?

Flashing ESPHome ot the Sonoff switch (if possible) is by far the best way to solve your real problem (control of the switch).

That said, you can add the template switch configuration to your HA configuration.yaml by having it call one of two different REST commands (which you should also add to configuration.yaml).

Thank you, I will look into it! Much appreciated!

1 Like