More responsive control of LIFX?

I have a Scene whereby a PIR being triggered makes a LIFX bulb turn on with a random colour for a short while. I have the PIR and LIFX bulb in my porch, so I get that area lit up as someone approaches.

Everything works, I copied the Python from the LIFX API webpage and converted it to Lua. But it’s quite unresponsive because it has a lot of “hops” before the light lights up.

The main delay, I reckon, is with the LIFX Cloud angle.

Has anyone had any success controlling a LIFX bulb locally via Lua… that is, without having to GET, PUT or POST over HTTPS out to the LIFX Cloud?

There’s no need for it in my situation. The PIR is local to Vera, it talks to Vera, I’d like Vera to just talk to the LIFX bulb if poss…

I can see the LIFX Bulb on my network; so is it possible to just “blat” something directly to it and get it to do what I want it to do?

The answer is “yes”… I’ve done this via Python using a socket and I just need to translate it, if possible, to Lua, I hope. This will power the bulb on - 240000145aaea562d073d5004f8900000000000000000200000000000000000075000000ffff00000000. It’s so much more responsive than going via the LIFX Cloud… like it’s instant, rather than a second or two (unnerving seconds when you’re wondering - “will it work this time?”). ;D

This will turn a specific LIFX light off…

[code]function string.fromhex (str)
return (str:gsub (‘…’, function (cc)
return string.char (tonumber (cc,16))
end))
end

function SetLIFXOff (pIPAddress,pPort,pPacket)
local socket = require (“socket”)
local udp = socket.udp()
udp:sendto (pPacket:fromhex(),pIPAddress,pPort)
end

SetLIFXOff (“192.168.1.213”,56700,“240000340000000000000000000000000000000000000000000000000000000075000000000000000000”)[/code]

It’s bare bones, right, but you can do anything with the right packet (I’m keeping the ‘source’ as a hex chunk right now as it’s easier to spot the necessary changes)… but the responsiveness is all there. Happier doing this than going via the LIFX Cloud.

All that’s in here is the length of the packet, a constant value, loads of zeroes, the message type for power, some more zeroes… 0 power = completely off.

On would be: 240000340000000000000000000000000000000000000000000000000000000075000000FFFF00000000 = completely on / maximum brightness.

I currently don’t use any LIFX bulbs because the ones I bought became unresponsive and then after a hard reset they would not “onboard” again. LIFX support was very responsive but even with all of their efforts could not remedy the situation, so offered me a refund. I still look forward to a future firmware update that might allow me to salvage the bulbs. …but I digress…

I was wondering if any of you programming geniuses have considered building a Vera plugin that uses the LAN API offered by LIFX? It’s right there waiting for you guys! :wink:
Full functionality using solely the Vera would be beautiful, even allow us to use them off-grid in some cases. The API requires a server running at all times, but it seems like the Vera may be well-suited to fill that role.
What do you guys think in your expert opinions?
Thanks,

Derek

Hippogriff,

Kudos for answering your own questions…multiple times…and then posting them here for others to learn/consume. I know there is a Daemon that uses RPC to keep communications local. It seems like this is aged and not clear if it works with the latest changes.

I second a plug in approach. Unfortunately I do not have the skills, but would be happy to support via donation. I’m sure there are others in the same situation.

Sorry bro i am still noob. Is this lua code? do you have steps by steps how to integrate lifx in vera?

[quote=“Hippogriff, post:3, topic:193948”]This will turn a specific LIFX light off…

[code]function string.fromhex (str)
return (str:gsub (‘…’, function (cc)
return string.char (tonumber (cc,16))
end))
end

function SetLIFXOff (pIPAddress,pPort,pPacket)
local socket = require (“socket”)
local udp = socket.udp()
udp:sendto (pPacket:fromhex(),pIPAddress,pPort)
end

SetLIFXOff (“192.168.1.213”,56700,“240000340000000000000000000000000000000000000000000000000000000075000000000000000000”)[/code]

It’s bare bones, right, but you can do anything with the right packet (I’m keeping the ‘source’ as a hex chunk right now as it’s easier to spot the necessary changes)… but the responsiveness is all there. Happier doing this than going via the LIFX Cloud.

All that’s in here is the length of the packet, a constant value, loads of zeroes, the message type for power, some more zeroes… 0 power = completely off.

On would be: 240000340000000000000000000000000000000000000000000000000000000075000000FFFF00000000 = completely on / maximum brightness.[/quote]

Very cool that you have this working!

22 LIFX bulbs in my house. I like them a lot, but I don’t have direct control of them through Vera.

Instead, I have a kludge solution that was pretty easy to set up, but has a fairly significant time delay (15-60 seconds). I have varied scenes send an email notification which IFTT reads and then triggers LIFX cloud command. Not great at all.

I’m a Product Owner by trade, so this meets MVP, but sure isn’t ideal. Lol

Would love to use/buy a more extensible plugin or command set that could bypass the LIFX cloud and communicate locally.

Sent from my iPhone using Tapatalk