LIFX Developer Zone

Home Assistant: LIFX Switch

Hi Everyone!
I use Home Assistant for my automation.
I have two LIFX Switches but they don’t show up in Home Assistant as a device/entity.
Actually, I use Node-RED currently which I think must use a LAN API?


Is there some way I can control the LIFX Switch using Home Assistant/Node-RED?
Thanks!

I have this working with Home Assistant and Node-RED using node-red-contrib-lifx-api The commands are all via https but I can track state and setup switches in HA to control each switch. Its not lan control so I am reliant on LIFX cloud control

Hey Lebowski9000!
Thanks so much for this, I don’t know how I missed that.
I can now see the switch in Node-RED and can control the whole switch quite easily, however, I haven’t been able to figure out how to control each relay.
Are you able to show me how you have been able to control each relay? I have used the labels of each relay, however, that didn’t work (I tested using a label from a light which worked fine so I know that the token etc works)

This should help

label:Front Switch|0
label:Front Switch|1
label:Front Switch|2
label:Front Switch|3

I found toggle is buggy so use on and off commands

I also use a timestamp to poll the states to make a sensor in Home Assistant so I can see the state.

I use this on the switch to read the on or off
image

I also use the custom Node RED component to make a switch inside node red with the trigger command automation for on and off to make Home Assistant control them.

1 Like

I have discovered something around the LIFX Switch and the LIFX integration in HA. HA (for me) stalls on start up for 4-5 mins trying to (from what I can guess) discover the switches. When I move LIFX to complete manual config. Home Assistant starts up instantly. I can replicate the issue by putting in the IP address of the Switch into the manual config and it will stall HA on start up.

Thanks for the inspiration @Lebowski9000 ! FYI - This is how I’ve solved it similarly in HA with node-red.

In my setup I’ve got 80+ LIFX lights, but I only have 1 “dumb” set of smart festoons wired into a switch that I want to control, so I only care about controlling 1 relay of 1 switch (I have 13 :slight_smile: )

  • Rather than a separate switch & sensor entity in HASS, I’ve got one switch entity I create in node-red.
  • I query the state of the physical relay every second in case someone changes the power state physically on the switch, and if there is a change I pass this as a msg.enable true/false boolean to the HA switch entity. This will update the state in HASS, but the node will not output and fire a state change on physical switch :+1:
  • When you change the switch state within HASS this triggers a LIFX set-state to change power of the physical relay

Works great thus far and I’ve then got a Light entity using the switch platform in HASS which I surface to Google Assistant and my dashboard so I’m controlling a Light entity which subsequently uses the switch entity.

Thanks for the inspo…this was the final thing in my setup I couldn’t control with GA!

Wondering now about taking it a step further. As my festoon lights are smart, but on FLUX platform, I might be able to leave that circuit powered on and then connect the relay button to something in LIFX for node-red to monitor and control soft power state on FLUX platform. I think I’ll need to have a LIFX light that doesn’t actually do anything to act as a “ghost” device though, possible could use a Z-strip/beam controller that’s not connected to an actual light.

Is there any chance you could post the JSON for the node flow? Trying to replicate this for a switch in my shed and it is not playing the game at all :joy: