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 🙏

© 2026 – Pkg Stats / Ryan Hefner

homebridge-cmd-tv-input

v1.0.0

Published

Homebridge plugin that creates a virtual Television accessory with shell-command-driven input selection

Readme

homebridge-cmd-tv-input

Homebridge plugin that creates a virtual Television accessory in HomeKit with shell-command-driven input selection.

Each "input" maps to a shell command. Selecting an input in HomeKit runs the corresponding command. Only one input can be active at a time — HomeKit enforces this natively via the Television service.

Use Cases

  • Route a doorbell/intercom call to different phones depending on who's home
  • Switch between audio zones or scenes
  • Select a mode or profile from a list
  • Any "one of N" selection that maps to shell commands

Installation

Via the Homebridge UI: search for homebridge-cmd-tv-input.

Or via npm:

npm install -g homebridge-cmd-tv-input

Configuration

{
  "platforms": [
    {
      "platform": "CmdTelevision",
      "televisions": [
        {
          "name": "My Selector",
          "state_cmd": "/usr/local/bin/mycommand.sh STATUS",
          "on_cmd":    "/usr/local/bin/mycommand.sh LAST",
          "off_cmd":   "/usr/local/bin/mycommand.sh OFF",
          "set_cmd":   "/usr/local/bin/mycommand.sh",
          "polling_interval": 10,
          "inputs": [
            { "name": "Option1", "label": "First Option" },
            { "name": "Option2", "label": "Second Option" },
            { "name": "Option3", "label": "Third Option",  "cmd": "/usr/local/bin/other.sh special" }
          ]
        }
      ]
    }
  ]
}

Configuration Reference

| Field | Required | Description | |-------|----------|-------------| | name | ✅ | Accessory name shown in HomeKit | | state_cmd | ✅ | Command that returns the internal name of the active input, or nothing if off | | set_cmd | | Base command for input selection — internal input name is appended automatically | | on_cmd | | Command executed when TV is switched on. Should return the internal name of the activated input | | off_cmd | | Command executed when TV is switched off | | polling_interval | | How often state_cmd is polled in seconds (default: 10) | | timeout | | Command timeout in ms (default: 3000) |

Input fields

| Field | Required | Description | |-------|----------|-------------| | name | ✅ | Internal key — no spaces. Passed as argument to set_cmd, matched against state_cmd output | | label | | Display name in HomeKit — may contain spaces. Defaults to name | | cmd | | Custom command for this input — overrides set_cmd + name |

How It Works

  • The plugin registers a HomeKit Television accessory with one InputSource per configured input.
  • When you select an input in the Home app, set_cmd <name> is executed (or the custom cmd if set).
  • state_cmd is polled periodically and should output the internal name of the currently active input, or nothing if off.
  • HomeKit automatically ensures only one input is active at a time.
  • Switching the TV on runs on_cmd (e.g. restore last state). Switching off runs off_cmd.

Example Backend Script

#!/bin/bash
# /usr/local/bin/mycommand.sh

FLAGFILE=/etc/mycommand-active
LASTFILE=/etc/mycommand-last
DEFAULT="Option1"

case "$1" in
    STATUS)
        [ -f "$FLAGFILE" ] && [ -f "$LASTFILE" ] && cat "$LASTFILE"
        ;;
    OFF)
        rm -f "$FLAGFILE"
        ;;
    LAST)
        NAME=$([ -f "$LASTFILE" ] && cat "$LASTFILE" || echo "$DEFAULT")
        echo "$NAME" > "$FLAGFILE"
        echo "$NAME" > "$LASTFILE"
        echo "$NAME"
        ;;
    *)
        echo "$1" > "$FLAGFILE"
        echo "$1" > "$LASTFILE"
        ;;
esac

Notes

  • The Television accessory is published as an external accessory and must be paired manually in the Home app the first time: tap +I Don't Have a Code → enter your Homebridge PIN.
  • Multiple televisions can be configured in one platform instance.
  • The virtual TV is shown as "off" when no input is active.

License

MIT