Playing with the lights Control WiFi-enabled LIFX light bulbs Louis - - PowerPoint PPT Presentation

playing with the lights
SMART_READER_LITE
LIVE PREVIEW

Playing with the lights Control WiFi-enabled LIFX light bulbs Louis - - PowerPoint PPT Presentation

Playing with the lights Control WiFi-enabled LIFX light bulbs Louis Opter <louis@opter.org> Fosdem 2017, IoT track Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 1 / 24 Intro About me $ whoami


slide-1
SLIDE 1

Playing with the lights

Control WiFi-enabled LIFX light bulbs Louis Opter <louis@opter.org> Fosdem 2017, IoT track

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 1 / 24

slide-2
SLIDE 2

Intro About me

$ whoami

Hello, my name is Louis (Opter) and I:

◮ am a decent software engineer; ◮ do not really know anything about hardware.

Anyway, it doesn’t really matter, let’s get started!

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 2 / 24

slide-3
SLIDE 3

Intro Plan

Agenda

T wo related projects to talk about: monolight An UI for a 128 buttons matrix and lightsd; lightsd A daemon to easily control LIFX light bulbs.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 3 / 24

slide-4
SLIDE 4

Intro Plan

Agenda

T wo related projects to talk about: monolight An UI for a 128 buttons matrix and lightsd; lightsd A daemon to easily control LIFX light bulbs. Outline:

◮ monolight: explanation, demo, implementation, ideas; ◮ lightsd: API demo, implementation, ideas, about LIFX; ◮ Q&A, discussion.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 3 / 24

slide-5
SLIDE 5

Intro Plan

High-level architecture

monolight lightsd

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 4 / 24

slide-6
SLIDE 6

Intro Plan

High-level architecture

monolight lightsd Talk part 1 (monolight) part 2 (lightsd)

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 4 / 24

slide-7
SLIDE 7

monolight Controller UI

monolight

A controller (Monome grid 128 varibright):

◮ A matrix of 128 programmable button; ◮ 16 levels of brightness per button; ◮ Serial/RS232 (FTDI) connection.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 5 / 24

slide-8
SLIDE 8

monolight Controller UI

monolight

A controller (Monome grid 128 varibright):

◮ A matrix of 128 programmable button; ◮ 16 levels of brightness per button; ◮ Serial/RS232 (FTDI) connection.

Controlling a "smart" bulb (LIFX Original 1000):

◮ A ~1000 lumens programmable light bulb; ◮ Nice colors, nice range of whites; ◮ Wi-Fi 802.11bgn, 2.4gHz.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 5 / 24

slide-9
SLIDE 9

monolight Controller UI

monolight

A controller (Monome grid 128 varibright):

◮ A matrix of 128 programmable button; ◮ 16 levels of brightness per button; ◮ Serial/RS232 (FTDI) connection.

Controlling a "smart" bulb (LIFX Original 1000):

◮ A ~1000 lumens programmable light bulb; ◮ Nice colors, nice range of whites; ◮ Wi-Fi 802.11bgn, 2.4gHz.

Let’s have a look at the controller UI.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 5 / 24

slide-10
SLIDE 10

monolight Controller UI

The grid

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 6 / 24

slide-11
SLIDE 11

monolight Controller UI

General functions/scenes row

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 7 / 24

slide-12
SLIDE 12

monolight Controller UI

General functions/scenes row

  • n/off

toggle

  • ff
  • n
  • scenes. . .

toggle UI

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 7 / 24

slide-13
SLIDE 13

monolight Controller UI

General functions/scenes row

Other ideas:

◮ Navigation controls (pagination. . . ); ◮ MPD control.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 7 / 24

slide-14
SLIDE 14

monolight Controller UI

T arget control pads x4

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 8 / 24

slide-15
SLIDE 15

monolight Controller UI

T arget control pads x4

INC inc dec DEC Functions/status row (toggle, TBD. . . ) 4 sliders (Hsbk, “color wheel”):

◮ Hue: 0.0–360.0°; ◮ Saturation: 0.0–1.0; ◮ Brightness: 0.0–1.0; ◮ T

emperature: 2500–9000K.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 8 / 24

slide-16
SLIDE 16

monolight Demo

monolight live

◮ Controls; ◮ UI feedback; ◮ monolight layer definitions.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 9 / 24

slide-17
SLIDE 17

monolight Demo

monolight live

◮ Controls; ◮ UI feedback; ◮ monolight layer definitions.

One last (unimplemented) idea I wanna show you. . .

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 9 / 24

slide-18
SLIDE 18

monolight One last idea

Timer/Alert effect

Let’s add two more functions: timer alert

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 10 / 24

slide-19
SLIDE 19

monolight One last idea

Timer/Alert effect

Time selection (1 lit button = 1 unit of time): dec/inc time unit

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 10 / 24

slide-20
SLIDE 20

monolight One last idea

Timer/Alert effect

T arget and alert selection: alert B B B B

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 10 / 24

slide-21
SLIDE 21

monolight One last idea

Timer/Alert effect

Timer activity feedback

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 10 / 24

slide-22
SLIDE 22

monolight Implementation details

monolight implementation

High-level details:

◮ Python ≥ 3.5 (pondering ≥ 3.6); ◮ Fully async (using asyncio with the stream API); ◮ Fully typed, it’s great; ◮ Very slow, no tests

;

◮ Uses Artem Popov’s pymonome/aiosc libraries; ◮ 2/3 months of work, GPLv3.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 11 / 24

slide-23
SLIDE 23

monolight Implementation details

monolight implementation

High-level details:

◮ Python ≥ 3.5 (pondering ≥ 3.6); ◮ Fully async (using asyncio with the stream API); ◮ Fully typed, it’s great; ◮ Very slow, no tests

;

◮ Uses Artem Popov’s pymonome/aiosc libraries; ◮ 2/3 months of work, GPLv3.

As we’ve seen, lot of fun stuff left:

◮ More UI features; ◮ UI animations; ◮ Control other things.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 11 / 24

slide-24
SLIDE 24

lightsd Intro

High-level architecture

monolight lightsd part 1 (monolight) Talk part 2 (lightsd)

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 12 / 24

slide-25
SLIDE 25

lightsd Demo

lightsd API live

◮ get_light_state; ◮ power_toggle, targeting; ◮ set_light_from_hsbk; ◮ set_waveform.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 13 / 24

slide-26
SLIDE 26

lightsd Implementation details

lightsd

The “parent” project:

◮ C99, libevent2, CMake — that’s all; ◮ Daemon, low memory footprint, fast enough1; ◮ 32/64 bits, big/little endian, FPU optional; ◮ Runs on nearly everything but Windows2; ◮ First PoC in 2014, mostly written through 2015.

1A bit of a CPU consumer. 2LXSS will fix that though?

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 14 / 24

slide-27
SLIDE 27

lightsd Implementation details

lightsd

Original ideas:

◮ Remove discovery delays and glitches; ◮ While exposing a high-level vendor agnostic API; ◮ While offering network isolation; ◮ No cloud nor Internet required; ◮ GPLv3 with non-GPL users in mind; ◮ “Accessible”: pretty good C, unit-tests, good docs.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 14 / 24

slide-28
SLIDE 28

lightsd Implementation details

lightsd

Implementation details:

◮ Uses LIFX’s faster and harder LAN API; ◮ Proxies all communications to the bulb; ◮ Keeps track of the current state of the bulbs (sampling); ◮ High-level API in JSON-RPC over TCP, Unix sockets or a

named “command” pipe1.

1The pipe is unidirectional: only usable to send commands.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 14 / 24

slide-29
SLIDE 29

lightsd Implementation details

The (

| ) parts

In no particular order: C C asyncio tasks cleanup Python 3.5+ Buildbot Continuous integration Portability “Stack position” Wi-Fi Playing with the lights Reverse engineering. . . in reasonable amounts Firmwares bugs User feedback OS Packaging

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 15 / 24

slide-30
SLIDE 30

lightsd Implementation details

“Stack position”

One thing I really like: LIFX lightsd monolight hardware daemon GUI embedded C Python Lower-level Higher-level

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 16 / 24

slide-31
SLIDE 31

lightsd Implementation details

“Stack position”

One thing I really like: LIFX lightsd monolight hardware daemon GUI embedded C Python Lower-level Higher-level lightsd opens-up to a wide range of topics.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 16 / 24

slide-32
SLIDE 32

lightsd Implementation details

Notes on the LIFX bulbs

◮ Get them on sale; ◮ Best brightness/colors (AFAIK); ◮ Standby power consumption; ◮ Cool LAN API, hope they keep it; ◮ Only Gen 1 (EOLed in 2015) doesn’t crash for me;

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 17 / 24

slide-33
SLIDE 33

lightsd Implementation details

Notes on the LIFX bulbs

◮ Get them on sale; ◮ Best brightness/colors (AFAIK); ◮ Standby power consumption; ◮ Cool LAN API, hope they keep it; ◮ Only Gen 1 (EOLed in 2015) doesn’t crash for me; ◮ Binary blobs suck.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 17 / 24

slide-34
SLIDE 34

lightsd Next

“My Roadmap”

Things I wanna do:

◮ Time based releases; ◮ Better CI/automation; ◮ “State-enforcement”; ◮ Effects API and effects plugins.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 18 / 24

slide-35
SLIDE 35

lightsd Next

Not on my roadmap

Things I wanna have:

◮ JSON-RPC extensions: streaming, auth, server notifs; ◮ A reversed-engineered LIFX firmware; ◮ A firmware that doesn’t crash; ◮ Support for other brands (Hue?); ◮ Color calibration; ◮ LIFX stripe support.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 19 / 24

slide-36
SLIDE 36

Thanks

Time for Q&A and discussion

◮ @1opter ◮ #lightsd on IRC (chat.freenode.net) ◮ https://www.lightsd.io/

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 20 / 24

slide-37
SLIDE 37

Extras

Links

LIFX website, forum, github; lightsd docs, sources, downloads; monolight sources; monome website, forum, github; pymonome sources.

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 21 / 24

slide-38
SLIDE 38

Extras

Questions for you!

◮ Hardware hacks? ◮ UX with other projects and products? ◮ “Education” opportunities opinions?

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 22 / 24

slide-39
SLIDE 39

Extras

Detailed architecture

serialoscd Serial (FTDI) monolight lightsd OSC

(UDP)

JSON-RPC

(TCP/Unix) (UDP)

LIFX-LAN

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 23 / 24

slide-40
SLIDE 40

Extras

LIFX products tables

Generation Models Available Gen 1 Original 1000, Color 650 No Gen 2 Color 1000, White 800 Yes Gen 3 A19, BR30, Z (stripe) Yes Generation Notes Gen 1 Has 802.11 and (unused) 802.15.4 Gen 2 QCA 4002, AllJoyn, crashes Gen 3 + versions have IR, still crashes

Louis Opter <louis@opter.org> Playing with the lights Fosdem 2017, IoT track 24 / 24