Skip to content

ogrady/NodeMCUButtonPusher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node MCU Button Pusher

Purpose

Sets up a REST interface on a Node MCU to control a servo motor. Used as a low-cost button pusher to smart up appliances and light switches. This project is based on a tutorial by Antonio Mancuso.

Setup

Create a file called wlan.config with the following contents:

SSID=your_ssid
PASS=your_password

Then run bake.sh to create the .ino file from the template and bake the values into the appropriate variables (this is mostly me freaking out about accidentally pushing my password to the repo...).

I use a bunch of inexpensive servo motors which can easily be fixated to most appliances using neodymium magnets (I do recommend using more than one magnet to avoid the servo pushing itself up instead of pushing the button).

The D4 pin is being used as data line.

Usage

The RESTful interface offers two endpoints:

GET /servo

Retrieves the current state of the servo. Not really used.

POST /servo

Causes the servo to perform a button push. A JSON payload is expected to specify angle (in degree) and duration (in milliseconds).

curl -d '{"angle":"50", "duration":"500"}' -H "Content-Type: application/json" -X POST http://MYNODEMCU/servo

Performs a 50 degree pushdown for 500 milliseconds before going back to neutral position.

Integrating into Home Assistant

I use this tool to heat up my coffee maker in the morning using a Home Assistant script. For that I use the following entry in my configuration.yaml to use it as a script:

rest_command:
  get_servo_state:
    url: "http://MYNODEMCU/servo"
    method: "get"
  push_servo_button:
    url: "http://MYNODEMCU/servo"
    method: "post"
    content_type: "application/json; charset=utf-8"
    payload: "{'angle': '{{ angle }}', 'duration': '{{ duration }}'}"

About

RESTful Button Pusher Utilising NodeMCU

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published