ESP 01 remote to toggle a sonoff switch

Hello fellow domoticians (is that what we’re called)

I discovered home assistant a few weeks back and I’m loving it. I managed to set a few Led lightstrips (with the help of Bruh automation) and a few sonoff’s switches ( thanks to DR. ZZZZ). All is running fine and on different schedule with the mqtt broker.

I would like to build a small bedside remote to toggle one of the sonoff’s switches I built.

I’ve seen many tutorial with the DASH button from amazon and that’s pretty much what I want to do but I don’t want to use IFTTT if possible. The little box I want to build should be on my son’s night stand so he can toggle the light from his bed. His bed room is wired weirdly; it doesn’t have a ceiling light nor switch.

I have a bunch of ESP01 and ESP12 to use.

Has anyone seen a good tutorial for this? and maybe one that would have one or multiple button?

Thanks a lot everyone for all the knowledge!

JD

P.S. I started with arduinos last summer so I’m a hell of a newb in electronics!

Are the sonoff switches equipped with RF? Sonoff provides battery powered remotes:

https://sonoff.itead.cc/en/products/sonoff/sonoff-rf

Hi, you may have a look at existing firmwares for ESP8266 like Tasmota or esphomeyaml.

If you want to dig deep into the interesting stuff you may have a look e.g. at my project.

It’s a thermostat but I also have a button attached to one GPIO, realized debouncing and use MQTT including HA discovery.

Thanks!

I’ll look into it! The thermostat add on is a nice feature too.

JD

My sonoffs basics don’t have RF embedded in them.

It was hard enough to get them to work, I’m a bit reluctant to touch them again.

JD

Forgot to mention that the sonoffs already have the tasmota firmware in them already. If that makes a difference.

JD

Maybe one additional thing, some people would not want to place a continuously powered wifi device next to their childrens bed. In this case you could look for devices that do only transmit radio waves when you actually push the button.

For this purpose I use the RPi RF HassIO Addon with a 433 MHz Remote and a 433 MHz receiver attached to my RPi hosting HA.
The received codes then trigger automations to control devices attached to HA.

Some info here: https://pypi.org/project/rpi-rf/

My HA config is also uploaded to GitHub if you want to have a look.

1 Like

I did not think about that! that makes sense!

Thanks for your insight.

JD

i just added a IR receiver to a sonoff running tasmota, then in automation i tell it what to do on wich ir code and use a old obsolete tv remote. i can control several lights, mpd, fan, whatever wich just one remote.

1 Like

7 Months later and you probably found you solution. So did make something that works for you? Else, I could share my setup. I have made a little remote control with a ESP-01 but only because, why not. Not using it daily or something, just wanted to see if it worked.

Please let me know.

It is always good to share :slight_smile:

I have been using ESPHome since a couple of months and this is what I came up with.

Attached a tactile push button to GPIO 02 paste the code in the YAML of your ESP-01 and thats about it. You can check this section on the ESPHome website

Unfortunatly I didn’t spend more time with it to enable deep sleep and just “stand-by” and wait for a button press. I just hooked it up to a slider switch, so in my case I have to power the switch on, and then I can press the button.

esphome:
  name: esp_portable
  platform: ESP8266
  board: esp01_1m

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_pass
  manual_ip:
    static_ip: 192.168.178.170
    gateway: 192.168.178.1
    subnet: 255.255.255.0

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO02
      mode: INPUT_PULLUP
      inverted: True
    name: "ESP Portable"
    on_press:
      - homeassistant.service:
          service: light.toggle
          data:
            entity_id: light.light.desk
    filters:
      - delayed_on: 10ms

#SYNC TIME BETWEEN HA AND ESPHOME
time:
  - platform: homeassistant
    id: homeassistant_time

Yeah esphome is great.

Is there a reason you are using the time component? It seems unnecessary in this usage, unless it is needed for the delayed_on:

It’s not needed, I just copied and paste most of my configs and I just left it there haha. I have some time based stuff