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

lifx-halloween

v2.2.1

Published

Flash a random light in a Group of LIFX bulbs during Halloween.

Downloads

3

Readme

LIFX Halloween

Flash a random light in a Group of LIFX bulbs during Halloween.

Configuration

There are two options for configuration your project to work with lifx-halloween. The first option is a local config file, the other is environment variables.

Passing Config Vars

Local Config File

Create a localConfig.js file in your project's root directory with these contents:

module.exports = {
	apiToken: 'c180e4553d9b3d61a0536055555a7d96dba3cea4154b171b5522b915a572b86f',
	lifxSelector: 'group:Front Porch',

	// Optional
	halloweenStartTime: '10-31 16:00',
	halloweenEndTime: '10-31 22:30',
}

Required

  • apiToken
  • lifxSelector

Optional

  • halloweenStartTime
  • halloweenEndTime

Environment Variables

Instead of creating a local config file, you might be hosting this project online. If you do that, you'll want to use environment variables instead.

Required

  • API_TOKEN
  • LIFX_SELECTOR

Optional

  • HALLOWEEN_START_TIME
  • HALLOWEEN_END_TIME

Config Vars

API Token

  • Local Config File: apiToken
  • Environment Variable: API_TOKEN

Your LIFX API token from https://cloud.lifx.com/settings. It should look something like this:

c180e4553d9b3d61a0536055555a7d96dba3cea4154b171b5522b915a572b86f

LIFX Selector

  • Local Config File: lifxSelector
  • Environment Variable: LIFX_SELECTOR

Whatever you change this to will be the light or group of lights to randomly flash.

The value is a LIFX HTTP API selector.

For simplicity, you can simply follow these guidelines:

  • For group, use group:Group Name.
  • For light, use label:Light Name.
  • For all lights, use all.

Start and End Times

  • Local Config File: halloweenStartTime
  • Local Config File: halloweenEndTime
  • Environment Variable: HALLOWEEN_START_TIME
  • Environment Variable: HALLOWEEN_END_TIME

The format is MM-DD hh:mm such as 10-31 16:00. The month, date, then the time in 24h military format.

These values include the start and end times for when random light flickering occurs. Currently, this package does not support executing daily during a set time period. You can always create a PR or write your own code to handle this use case in your own project.

Example Usage

Simple Version

This example checks every 10 seconds to see if it's currently Halloween night between 4:00p and 10:30p on October 31st. If it is, it randomly flashes a light in those 10 second intervals.

const { filter, map, startWith } = require('rxjs/operators')
const { interval } = require('rxjs')

const { config, flashRandomLight, isDuringHalloweenNight } = require('./')

interval(10000)
.pipe(
	startWith(0),
	map(isDuringHalloweenNight),
	filter(Boolean),
	flashRandomLight(
		config
		.getLifxSelector()
	),
)
.subscribe(
	console.log,
	console.error,
)

Advanced Version

See app.js for what I'm using on my home.

This version is set to run indefinitely. It will set a timeout from now until Halloween at 4:00p, then it will run, flashing a random light at a random time interval until 10:30p. Afterward, it sets a new timer to wait until next Halloween.

API

Functions

flashRandomLight

Flashes a random light in the provided LIFX selector.

getTimeUntilHalloweenEnds

Get the time remaining in milliseconds until Halloweens ends from the optionally given date.

getTimeUntilHalloweenStarts

Get the time remaining in milliseconds until Halloweens starts from the optionally given date.

isDuringHalloweenNight

Returns a boolean if it's Halloween night.

This Project

When developing this package locally, use:

yarn start

For testing, use:

yarn test:watch