Light

Factories

class lifx.lan.light.State_Factory
static make(state: str, fields_values: Dict) Union[lifx.lan.light.SetColor, lifx.lan.light.SetWaveform, lifx.lan.light.SetPower, lifx.lan.light.GetPower, lifx.lan.light.GetService, lifx.lan.light.StateService, lifx.lan.light.State]

Make a Lifx Msg given a dictionary of values

Parameters
  • state – a string representation of a Lifx State

  • fields_values – a dictionary of values for the State

>>> import lifx
>>> factory = lifx.lan.light.State_Factory()
>>> state = factory.make("SetColor", {"rgb": (20, 20, 20), "kelvin": 3500, "duration": 1024})
>>> state.rgb
(20, 20, 20)
>>> state.kelvin
3500
>>> state.duration
1024
>>> state = factory.make("SetColor", {"hue": 360, "saturation": 89, "brightness": 89, "kelvin": 3500, "duration": 1024})
>>> state.hue
360
>>> state.saturation
89
>>> state.brightness
89
class lifx.lan.light.Description_Factory
static make(state: Union[lifx.lan.light.SetColor, lifx.lan.light.SetWaveform, lifx.lan.light.SetPower, lifx.lan.light.GetPower, lifx.lan.light.GetService, lifx.lan.light.StateService, lifx.lan.light.State]) Dict
Parameters

state – a list of bytes to be interpreted as a state

:return a dict

>>> import lifx
>>> factory = lifx.lan.light.Description_Factory()
>>> color = lifx.lan.light.SetColor()
>>> s = factory.make(color)
>>> s[1]['rgb'] = (0, 0, 0)
>>> s[1]['kelvin'] = 0
>>> s[1]['duration'] = 0
>>> s[1]['hue'] = 0
>>> s[1]['brightness'] = 0
>>> s[1]['saturation'] = 0

Messages

Service

class lifx.lan.light.GetService
state = 'get_service'
class lifx.lan.light.StateService
state = 'state_service'
property service
property port
bytes

Structure/Union member

field

Structure/Union member

Color/Waveform

class lifx.lan.light.Get
state = 'get_light'
class lifx.lan.light.SetColor
>>> import lifx
>>> body = lifx.lan.light.SetColor()
>>> body.rgb = (0, 255, 0)
>>> body.field.color.rgb
(0, 255, 0)
>>> body.kelvin = 3500
>>> body.field.color.kelvin
3500
>>> body.duration = 0xAABBCCDD
>>> body.field.duration
2864434397
state = 'set_color_light'
property duration
bytes

Structure/Union member

field

Structure/Union member

class lifx.lan.light.SetWaveform
>>> import lifx
>>> body = lifx.lan.light.SetWaveform()
>>> body.rgb = (0, 255, 0)
>>> body.field.color.rgb
(0, 255, 0)
>>> body.kelvin = 3500
>>> body.field.color.kelvin
3500
>>> body.waveform = "triangle"
>>> body.field.waveform
3
>>> body.waveform == body.Waveform.triangle
True
>>> body.skew_ratio = 0
>>> body.field.skew_ratio
-32768
>>> body.skew_ratio = 0.5
>>> body.field.skew_ratio
0
>>> body.skew_ratio = 1
>>> body.field.skew_ratio
32767
>>> body.transient = True
>>> body.field.transient
1
>>> body.transient = False
>>> body.field.transient
0
state = 'set_waveform_light'
class Waveform(value)

An enumeration.

saw = 0
sine = 1
halfsine = 2
triangle = 3
pulse = 4
property transient
property period
property cycles
property skew_ratio
property waveform
bytes

Structure/Union member

field

Structure/Union member

class lifx.lan.light.State
>>> import lifx
>>> body = lifx.lan.light.State()
>>> body.rgb = (0, 255, 0)
>>> body.field.color.rgb
(0, 255, 0)
>>> body.kelvin = 3500
>>> body.field.color.kelvin
3500
>>> body.label = "pippo"
>>> body.label
'pippo'
>>> body.power = 11
>>> body.field.power
11
>>> body.hue
120
>>> body.field.color.hue
21845
>>> body.saturation
100
>>> body.field.color.saturation
65535
>>> body.brightness
100
>>> body.field.color.brightness
65279
>>> body.hue = 240
>>> body.hue
240
>>> body.saturation = 100
>>> body.saturation
100
>>> body.brightness = 100
>>> body.brightness
100
state = 'state_light'
property power
property label
bytes

Structure/Union member

field

Structure/Union member

Power

class lifx.lan.light.GetPower
state = 'get_power_light'
class lifx.lan.light.SetPower
ON = 65535
OFF = 0
bytes

Structure/Union member

field

Structure/Union member

state = 'set_power_light'
class lifx.lan.light.StatePower
bytes

Structure/Union member

field

Structure/Union member

ON = 65535
OFF = 0
state = 'state_power_light'