Giter Club home page Giter Club logo

nodemcubuttonpusher's Introduction

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 }}'}"

nodemcubuttonpusher's People

Contributors

ogrady avatar

Stargazers

Greg Rauhöft avatar Noah Doersing avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.