ButtonBot - A DIY solution to automate any switch with Home Assistant

I created a device that can automate any switch with Home Assistant without touching the mains electricity!
Sep 15, 2023 — 3 mins read — Home Assistant

ButtonBot - A DIY solution to automate any switch with Home Assistant

A common problem with Home automation is the fact that you will need to update or modify all of your existing switches in order to properly automate your home.

Since these operate on mains electricity, and that electricity can easily kill you, not many people dare to touch them and this is OK.

To try and tackle this, I've created a device that can be attached to the exterior of the switch and can be connected to Home Assistant to automate any switch without even touching the wires or removing the switch from the wall.

Let me introduce you to the ButtonBot!

As you've seen from the video above, the device can be glued to the outside of the switch and it can then push it in any direction to either turn it on or turn it off. Both the distance and the time of the press duration can be easily adjusted so it can be easily adjusted to work with any switch or button that needs to be held pressed.

To make one for yourself, you'll need the following components:

The configuration code that I used on my device is below.

output:
  - platform: esp8266_pwm
    id: pwm_output
    pin: D5
    frequency: 50 Hz

button:
  - platform: template
    name: Turn On
    id: my_btn_on
    icon: "mdi:light-switch"
    on_press:
      - number.set:
          id: servo_value
          value: !lambda "return id(press_distance).state;"
      - delay: !lambda "return id(press_duration).state;"
      - number.set:
          id: servo_value
          value: 0

  - platform: template
    name: Turn Off
    id: my_btn_off
    icon: "mdi:light-switch-off"
    on_press:
      - number.set:
          id: servo_value
          value: !lambda "return id(press_distance).state * -1;"
      - delay: !lambda "return id(press_duration).state;"
      - number.set:
          id: servo_value
          value: 0

servo:
  - id: my_servo
    output: pwm_output

number:
  - platform: template
    id: servo_value
    name: Servo Position
    min_value: -100
    initial_value: 0
    max_value: 100
    step: 1
    optimistic: true
    set_action:
      then:
        - servo.write:
            id: my_servo
            level: !lambda 'return x / 100.0;'

  - platform: template
    id: press_duration
    name: Press Duration
    min_value: 200
    initial_value: 500
    max_value: 5000
    step: 100
    mode: box
    optimistic: true
  
  - platform: template
    id: press_distance
    name: Press Distance
    min_value: 0
    initial_value: 60
    max_value: 100
    step: 1
    mode: box
    optimistic: true    

By buying through the links below, you support the channel at no extra cost!


esphome nodemcu home assistant servo
Read next

MQ7 Carbon Monoxide Sensor done the right way!

There are a ton of tutorials on how to use the MQ7 Carbon Monoxide sensor with Arduino, Raspberry Pis, and other microcontrollers but they a...

You might also enojy this

SDS011 based Air Quality Monitor

Unfortunately, where I live, the air quality in winter is really bad and the air is very polluted. There are many reasons why it is like tha...