npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

garage-js

v0.1.5

Published

Garage Door Opener Tester using Node JS

Downloads

8

Readme

garagejs

A simple Node.js CLI example application using GPIO on a Raspberry Pi to control a device (in this case a garage door), and receive input on attached sensors (existing reed switches that monitor the limits of the door movement).

GaragePi

Usage

  • You can run node cli.js, and follow the instructions to trigger the relay connected to your garage door, assuming you've followed instructions on setting up the door (see HomeForARest Garage Setup Part 1)
  • You could include this package in your Node project with npm install garage-js.

Options

  • Recently I've added NodeMailer for email notifications, and the ability to take pictures for your notification, if you have the Pi Camera.
  • To enable and include pictures, update the config.json with the camera.enable option set to 1 (true).
  • To enable mail notifications, in the config.json set the mail.enable option to 1 (true). You will also need to rename config-example.mail.json to config.mail.json, and update the account information appropriately.

Dependencies

This example uses the helpful Node package onoff, and NodeMailer for the optional email notification.

Notes

One advantage of using Node.js over the Python example, is the non-blocking event driven nature of Node. This becomes important when interacting with the physical world as instructions are not always immediate, and are naturally more asynchronous. Additionally, if you are monitoring and initiating with several different interfaces at once (sensors, motors, etc) you may miss critical events in a blocking regime.

  • You will notice the use of the "onoff" optional parameter "debounceTimeout" (which in turn just uses Node.js setTimeout callback). This is important as you may experience "noise" from the switch that would otherwise indicate a false-positive change in state.
  • For the sensors: a value of 0 implies a falling edge and 1 implies a rising edge. When the magnet passes the sensor it will cause a falling edge.
  • The actual switch, utilizing a relay, should be initialized "high"; If not specified it's possible on an unexpected restart of the Pi (eg power outage) that on startup of the app it may trigger the relay and you come home to find the door open!
  • I found a higher tolerance was required from the sensor closest to the motor and Pi (the "Top" sensor), likely due to a slightly faster electrical change in state.

Other Considerations

  • With this example, we could leverage existing projects like Homebridge and the underlying HAPNode-JS to enable Siri control and feedback (Done, example coming soon)
  • If you own a Wink Hub, you could extend this example to interact with their API: http://docs.wink.apiary.io/
  • Run this as a server instead of a CLI and initiate a text or Whatsapp message to indicate the door opening or closing