HTTP commands to bulb over LAN?

I’ve recently gotten my first smart-bulb, from LIFX. I’ve written a web app (HTML/PHP) that I’d like to be able to use to control the bulb on my LAN. I’m aware, from looking over this site, that there is a LAN protocol available for this type of endeavor, as well as an HTTP API.

After reading the documentation for each method, the documentation and assembly of the LAN packets feels a little obtuse to me, and the HTTP API feels more natural and intuitive. But, I’d like to keep the bulb messages from being internet-connection-dependent messages. I figure there must be a way that I could send the same HTTP messages that the LIFX HTTP API would create and send to the bulb, to the bulb directly over my LAN, right? Shouldn’t that be possible? I can’t tell from any of the documentation. Also, is there any documentation regarding the open ports on the bulb and what port one would send such traffic to?

1 Like

It should be possible. And if you figure it out, let everyone know and the developer community will erect a statue in your honor - because the LAN protocol does not work. The cloud protocol works perfectly every time. If you can figure out a way to use the cloud protocol locally, then LIFX can implement your idea, and they will stay in business.

Of course it isn’t possible. The LAN API requires the cloud, end points etc to work. Never going to happen.

The LAN protocol works just fine, I use it all the time with Logitech Pop and other processes.

Github has heaps of resources and utilities that you can run and provide a cloud like process.

Check on here for lightsd it can run on Raspberry Pi or one of many Python scripts you can incorporate.

there are soooooo many options but by it’s nature the HTTP commands require a webserver endpoint to work and that is cloud based over the internet.

1 Like

I agree, a wrapper layer on top of the LAN protocol to simulate making HTTP Requests would be a great idea; although, because of the nature of the LIFX Cloud, it might not be feasible.

I think the best option is to have a local server running that itself connects to the LAN protocol. If you run a webserver on that same machine, it can give you access to HTTPs requests similar to those in the LIFX HTTP API.

That’s what you’re looking for right?

I was able to build something to do what you’re asking using Node.js and a library that gives you access to the LAN protocol. It was a lot of work because you still need to hook into the cloud to get your scenes and groups. You can cache those responses so you don’t have to do them each time you wanna enable something.

@Sawtaytoes, that sounds fantastic! Have you made it available anywhere for download? I’d love to take a look at it!

@Slizbury, you can view the project here:

By default, it’ll load up port 3000 on localhost. You can use the few routes I setup already such as /toggle-scene/:sceneName which should give you a good impression of how to get it working.

Just realized I forgot to document you’ll need your authToken in a config file to get scenes and groups from the LIFX HTTP API as they’re not available in the LAN API; at least, not through the node-lifx package.

I’ll check it out @Sawtaytoes, thanks!!