LIFX Developer Zone

Creating HomeKit switches for Morph and Flame effects

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-employee 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-employee 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!

Post removed because @delfick-employee is a legend.

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.

1 Like

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

awesome :slight_smile:

Hello, I have everything running… But I can’t seem to work out what is the “SELECTOR” ? Is it the name of the light ? Thank you

The selector refers to these https://api.developer.lifx.com/docs/selectors

1 Like

good afternoon and happy Sunday everyone, I’m trying to stop my sister form swapping from Lifx to Nanoleaf since apparently there scenes can also include effects. so I have 2 questions - I have managed to keep her happy by setting up home bridge and switches to get things like bias lighting and multi color light strips - but she wants a “candy cane effect” for Christmas and within the lifx app I she can get what she wants with the move effect and I think I’ve sandboxed it at my house as 2 separate switches so what I’m wondering is:

  1. can a json be written so that it triggers both the multi zone strip triggers the white and red color and then apply the 2nd attribute of the effect (in one switch)
  2. can I control the speed of the effect - as it is now set up as 2 separate switches the speed of the move is quite fast.

any help would be great!

on a side note any chance Lifx would entertain the same functionality as nanoleaf in the “near” future so that this can all be more seamless and allow HomeKit users a much easier experience. I for one love your lights over all the others they truly have some of the best color and saturation but with all the competition on the market and just now learning that there an option that makes this way easier I have to admit it is a little tempting to try them out too.

Yes: Creating HomeKit Switches for LIFX Morph and Flame Effects. See also: Triggering LIFX firmware effects with Photons Interactor.