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

whistle-switch

v1.1.7

Published

Control Homekit by whistling 🎶

Downloads

16

Readme

The Whistle Switch

Control Homekit by whistling 🎶

I built this during my batch at the Recurse Center in 2021. I whistle a lot, and I wanted to put it to some constructive use!

Setup

The easiest way to install the switch is with yarn or npm.

$ yarn global add whistle-switch

If you install it globally, then you can run it from wherever.

$ whistle-switch

Raspberry PI

If you want to run whistle-switch on a Raspberry PI you need to tell it where to find Chromium, because the version from NPM doesn't work the PI's ARM processor.

WHISTLE_SWITCH_CHROME_EXECUTABLE_PATH=$(which chromium-browser) whistle-switch

For more info, check out my post on running headless chrome on a PI.

Connect with Homekit

Once the switch is running on your local network, you should be able to add it to Homekit on your iOS device.

| | | | :--: | :--: | | 1-add-accessory | Select "More Options.." from the Add Accessory card. | | 2-select-whistle-switch | Tap the accessort called "Whistle Switch ..." | | 3-uncertified-accessory | Tap "Add Anyway" when you're prompted about an "uncertified" accessory. | | 4-setup-code | The default setup code is "123-45-678", but you can change it to anything you want using the WHISTLE_SWITCH_SETUP_CODE environment variable. |

Whistle "Buttons"

The switch has three built-in "buttons" that recognize different musical patterns. It'll try to match patterns regardless of key or rhythm.

| Homekit Button | Pattern | Example | | :--------------: | :-----------------: | :-------: | | Button 1 | One Three Five | C E G | | Button 2 | Five Three One | G E C | | Button 3 | One Two One Two One | C D C D C |

Homekit "Button" Map

Note: Right now, whistle-switch only triggers the "Single Press" action.

Advanced Configuration

You'll find the default configs in controller.js. The switch should work just fine with the defaults but you can override them by setting local environment variables.

| Environment Variable | Default | | :-----------------------------------: | :----------------------: | | WHISTLE_SWITCH_CHROME_EXECUTABLE_PATH | | | WHISTLE_SWITCH_DEBUG | false | | WHISTLE_SWITCH_ID | colbyr.whistle-switch.v1 | | WHISTLE_SWITCH_LISTENER_PORT | 47130 | | WHISTLE_SWITCH_PORT | 47130 | | WHISTLE_SWITCH_SETUP_CODE | 123-45-678 | | WHISTLE_SWITCH_USERNAME | 27:52:11:F5:BC:05 |

Resetting the switch

If your whistle-switch gets into a bad state with your homekit setup, you can reset your install.

First off, change WHISTLE_SWITCH_USERNAME in your .env file to a new value.

Then remove the persist directory if it exists.

rm -rf persist

Start the switch again, and you should be able to connect to Homekit as a completely new accessory.