Sun, 13 Nov 2016

Scripting A Light Bulb

This is adapted from an email I sent to an internal "gadget fan" mailing list at work in response to a question someone asked about controlling lighting electronically.

I went “simple” and I’m pretty happy with it.

I bought this bulb from Amazon.

It’s made in China and sold under several different brand names, most commonly “Flux” and “Magichome.”

You can get the WiFi RGBW version from Amazon (and a domestic seller) for ~$35.

If you feel comfortable shopping via Alibaba (I don’t) you could probably get it for ~$20.

There are several client tools for interacting with them. I’ve used one written in Go and an (easier to work with, IMO) one written in Python.

It doesn't do the dumb thing (UPnP on the open internet) so no, my light bulb isn't helping to bring down Twitter.

In addition, if you live in the iOS universe there’s a plugin that makes it work with Homebridge (and hence HomeKit.)

I can tell Siri to control my lights. Useless, but fun.

More practically, I wrote a Python script that turns on the lamp in my son’s room in the morning and gradually eases him up with subtle color changes.

It kicks off from a cron job running on a Raspberry Pi. (It doesn’t have to be a Pi, of course — any Linux machine or Mac would work.)

I’m sure it could be made to work from Windows, too, but that’s Somebody Else’s Problem. 😁

:: 19:57
:: /tech/gadgets | [+]
::Comments (0)

The Magic Word:
Which planet is closest to the sun? (hint -- it's Mercury...)

I made it a rule to forbear all direct contradictions to the sentiments of
others, and all positive assertion of my own. I even forbade myself the use
of every word or expression in the language that imported a fixed opinion,
such as “certainly”, “undoubtedly”, etc. I adopted instead of them “I
conceive”, “I apprehend”, or “I imagine” a thing to be so or so; or “so it
appears to me at present”.

When another asserted something that I thought an error, I denied myself the
pleasure of contradicting him abruptly, and of showing him immediately some
absurdity in his proposition. In answering I began by observing that in
certain cases or circumstances his opinion would be right, but in the present
case there appeared or semed to me some difference, etc.

I soon found the advantage of this change in my manner; the conversations I
engaged in went on more pleasantly. The modest way in which I proposed my
opinions procured them a readier reception and less contradiction. I had
less mortification when I was found to be in the wrong, and I more easily
prevailed with others to give up their mistakes and join with me when I
happened to be in the right.
— Autobiography of Benjamin Franklin