LIFX Developer Zone

Creating HomeKit switches for Morph and Flame effects


#1

Hey folks,

I know a bunch of us are HomeKit enthusiasts and many use Homebridge even with LIFX’s native HomeKit support in their newer bulbs. After @delfick and the LIFX team implemented firmware effect calls in the HTTP API, I knew it would be possible to create a HomeKit switch that would turn an effect on and off and here it is.

Edited because @delfick is a legend.

Requirements

  1. Install homebridge-http-switch.
  2. Get a LIFX Cloud Personal Access API token from https://cloud.lifx.com/settings

Configuration Notes

  1. Replace :selector in the configuration with the actual selector of your multizone bulbs.
  2. Replace <api_token> with your Personal Access Token API
  3. If you want to trigger the Flame effect, just change morph to flame (or FLAME in the statusPattern value).

Configuration

{
	"accessory": "HTTP-SWITCH",
	"name": "Tile Morph Switch",

	"switchType": "stateful",

	"onUrl": {
		"url": "https://api.lifx.com/v1/lights/:selector/effects/morph",
		"method": "POST",
		"strictSSL": true,
		"body": "{\"power_on\": true}",
		"headers": {
			"Authorization": "Bearer <api_token>",
			"Content-Type": "application/json"
		}

	},

	"offUrl": {
		"url": "https://api.lifx.com/v1/lights/:selector/effects/off",
		"method": "POST",
		"strictSSL": true,
		"body": "{\"power_off\": true}",
		"headers": {
			"Authorization": "Bearer <api_token>",
			"Content-Type": "application/json"
		}
	},
	"statusUrl": {
		"url": "https://api.lifx.com/v1/lights/:selector",
		"method": "GET",
		"strictSSL": true,
		"headers": {
			"Authorization": "Bearer <api_token>"
		}


	},
	"statusPattern": "\"effect\": \"MORPH\"",
	"debug": true

}

Enjoy!


#2

Post removed because @delfick is a legend.


#3

I’ve added an /effects/off endpoint that can be used to turn off effects. It also has a power_off parameter that will turn off the light at the same time

This works for all effects endpoints, so any breathe or pulse will also be stopped.


#4

You’re a legend! :slight_smile: I’ve updated the sample code to reflect the API change.


#5

awesome :slight_smile: