Messages
Every message from/to the Lifx bus is represented as a lifx_plugin.message.Description() entity.
Both triggers and commands are lifx_plugin.message.Description() entities.
- class lifx_plugin.message.Description(data: dict)
A Lifx LAN protocol message description.
The description contains those fields of interest for a Trigger or a Command definition.
>>> definition = {"type": "lifx", ... "name": "SetColor", ... "fields": {"hue": 1, "saturation": 1, "brightness": 1, "kelvin": 3500, "duration": 1000}, ... "addresses": [["172.31.10.245", 56700]]} >>> description = Description(definition) >>> print(description) SetColor {hue: 1, saturation: 1, brightness: 1, kelvin: 3500, rgb: (3, 3, 3), duration: 1000}: [172.31.10.245:56700]
>>> definition = {"name": "SetWaveform", ... "fields": {"hue": 1, "saturation": 90, "brightness": 90, "kelvin": 3500, "duration": 1000, ... "transient": True, "period": 180000, "cycles": 30, "skew_ratio": 0.5, "waveform": "sine"}, ... "addresses": [["172.31.10.245", 56700]]} >>> description = Description(definition) >>> another_definition = {"name": "SetWaveform", ... "fields": {"hue": 2, "saturation": 20, "brightness": 20, "kelvin": 2500, "duration": 2000, ... "transient": True, "period": 80, "cycles": 20, "skew_ratio": 0.5, "waveform": "sine"}, ... "addresses": [["172.31.10.245", 56700]]} >>> another_description = Description(another_definition) >>> print(description) SetWaveform {hue: 1, saturation: 90, brightness: 90, kelvin: 3500, rgb: (230, 26, 23), transient: 1, period: 180000, cycles: 30.0, skew_ratio 32768, waveform 1}: [172.31.10.245:56700]
>>> description == another_description True
>>> d = Description.make_from(lifx.lan.Msg.from_bytes([0x31, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x00, 0x39, 0x0E, 0x33, 0x33, 0x33, 0x33, 0xAC, 0x0D, 0x00, 0x04, 0x00, 0x00])) >>> "SetColor" in str(d) True
>>> Description.State["name"] = "SetColor" >>> d = Description.make([["172.31.10.245", 56700]]) >>> "SetColor" in str(d) True
- PROTOCOL = 'lifx'
- State = {'addresses': [], 'fields': {}, 'name': 'Fake'}
- property state: home.appliance.state.State
- property addresses: List[Address]
- classmethod make(addresses: List[Address]) lifx_plugin.Description
Make a protocol message Description given the arguments.
- Parameters
args –
kwargs –
- Returns
a protocol message Description
- classmethod make_from_yaml(addresses: List[Address]) lifx_plugin.Description
Make a protocol message Description given the yaml arguments.
- Parameters
args –
kwargs –
- Returns
a protocol message Description
- classmethod make_from(msg: lifx.lan.msg.Msg) lifx_plugin.Description
Make a protocol message Description given the protocol message
- Parameters
msg – a protocol message
- Returns
a protocol message Description