Creating a fake switch for Sonoff S20 power plug

I have two Sonoff S20 power plugs that I do not want to flash with Tasmota, as the eWe Link app and Google Home integration works perfectly.

One of the plugs is connect to the coffee maker. I currently turn on and off the coffee maker by asking Google Home to turn it on or off.

However, I want to make a switch in Home Assistant that will use IFTTT to trigger a turn on signal to the switch, and the same goes when I turn it off.

I also want to use Node-RED to automatically turn the switch off after 30 minutes when it has been turned off.

As far as I see, I need to have a two way communication. I currently have set up two IFTTT triggers that uses Home Assistant API to send a webhook every time they turn on and off, but I need some guidance to set up Home Assistant switches that will be in sync with IFTTT/eWe Link app/Google Home.

There may be a better, more direct way to do this, but here’s one possibility…

First, use an HTTP Binary Sensor that will be driven by the “incoming” IFTTT events. This will store the current state of the power plug.

Next, use a Template Switch to tie the incoming and outgoing IFTTT events together. The value_template should simply use the state of the HTTP Binary Sensor. Note that the sensor won’t exist after a HA restart until the first incoming IFTTT event occurs. So take this into account. E.g., {{ is_state('', 'on') }} should work, because when (the HTTP Binary Sensor) doesn’t exist, the is_state function will return False (as opposed to causing an error.) Then use the turn_on and turn_off actions to send the corresponding outgoing IFTTT events.

Thanks for your reply! I did what you said, and it seems to be working great! Thanks :slight_smile:

1 Like