Common tasks with the CLI
A full list of available tasks is returned by running lifx help.
Note
The <reference> used in these common tasks is explained in
the CLI reference. It determines which devices
will be affected by the task used.
find_devicesandfind_ipsList the serial numbers of all discovered devices on the local network:
$ lifx lan:find_devices
List the serial numbers and associated IP address of all discovered devices:
$ lifx lan:find_ips
The
find_ipsaction also comes with different output options. For example to get the ips as aHARDCODED_DISCOVERYexport command:$ lifx lan:find_ips -- '{"env_output": true}'And to get them as yaml you can put in your configuration:
$ lifx lan:find_ips -- '{"settings_output": true}'transformThis task changes the power and colour of the target devices over an optionally specified duration. It can also perform waveform-based transformations similar to the Breathe and Pulse effects available via the LIFX HTTP API.
For example, turn off all the devices on the network
$ lifx lan:transform -- '{"power": "off"}'Turn on a specific device:
$ lifx lan:transform d073d5001337 -- '{"power": "on"}'Power on a group of devices and set to the color to red and brightness to 100% followed by a waveform to cycle between red and blue three times over three seconds at 50% brightness:
$ lifx lan:transform match:group_name=kitchen -- '{"color": "red", "brightness": 1, "power": "on"}' $ lifx lan:transform match:group_name=kitchen -- '{"color": "blue", "brightness": 0.5, "effect": "SINE", "cycles": 3, "period": 1}'attrThis task gets or sets attributes on a device using a specific packet type. The packet type is specified in the
<artifact>field of thelifxutility syntax, i.e.lifx lan:attr <reference> <artifact> -- <options>.For example, get the color attribute value from all devices:
$ lifx lan:attr _ GetColor
Not all packet types include defaults for the available fields. For those types, a value must be explicity provided in the
<options>field in valid JSON syntax:$ lifx lan:attr match:label=den SetPower -- '{"level": 0}'A full list of packet types and values is found on the packets page.
unpackLIFX binary messages are a string of bytes represented as a hexadecimal value. For example a DeviceMessages.GetLabel in hex look likes:
2400001403b6cf3bd073d522932200000000000000000301000000000000000017000000
Use the
unpacktask to retrieve the values from a LIFX binary message:$ lifx unpack -- 2400001403b6cf3bd073d522932200000000000000000301000000000000000017000000 | jq { "frame_address": { "ack_required": true, "res_required": true, "reserved2": "000000000000", "reserved3": "00", "sequence": 1, "target": "d073d52293220000" }, "frame_header": { "addressable": true, "protocol": 1024, "reserved1": "00", "size": 36, "source": 1003468291, "tagged": false }, "protocol_header": { "pkt_type": 23, "reserved4": "0000000000000000", "reserved5": "0000" } }Note
Tip: Pipe the output of the
lifx unpacktask through thejqutility to convert the JSON into human-readable format.packThis task translates a dictionary of values into a LIFX binary message in hexadecimal format.
Using the same example as above, the
packcommand outputs the hexadecimal representation of the provided JSON:$ lifx pack -- '{"frame_address": {"ack_required": true, "res_required": true, "reserved2": "000000000000", "reserved3": "00", "sequence": 1, "target": "d073d52293220000"}, "frame_header": {"addressable": true, "protocol": 1024, "reserved1": "00", "size": 36, "source": 1003468291, "tagged": false}, "protocol_header": {"pkt_type": 23, "reserved4": "0000000000000000", "reserved5": "0000"}}' 2400001403b6cf3bd073d522932200000000000000000301000000000000000017000000It is not necessary to provide values for all fields. The
packcommand only requires mandatory fields to be specified. For example, constructing a DeviceMessages.SetLabel message:$ lifx pack -- '{"protocol": 1024, "pkt_type": 24, "source": 1, "sequence": 1, "target": "d073d5229322", "label": "basement"}' 4400001401000000d073d522932200000000000000000301000000000000000018000000626173656d656e74000000000000000000000000000000000000000000000000get_effectsReturns the currently running firmware effects on the specified devices. This only applies to devices with firmware effects, i.e. the Tile, Candle, Strip and Beam. Currently active waveforms are not considered an effect.
tile_effectStarts a firmware effect on a Tile or Candle Colour device:
$ lifx lan:tile_effect _ morph
In the case of a range of device types being returned by the provided reference, only those with matrix firmware effects will be affected.
The available effects are
morph,flameandoff.multizone_effectStarts a firmware effect on a Z Strip or Beam device:
$ lifx lan:multizone_effect _ move
In the case of a range of device types being returned by the provided reference, only those with multizone firmware effects will be affected.
The available effects are
moveandoff.apply_themeSet a theme on your devices. By default, this applies a seven colour theme at 30% brightness onto the device.
Apply the default theme to all devices:
$ lifx lan:apply_theme
Apply a theme using only red and blue:
$ lifx lan:apply_theme -- '{"colors": ["red", "blue"]}'Apply a theme using only red and blue at 100% brightness:
$ lifx lan:apply_theme -- '{"colors": ["red", "blue"], "overrides": {"brightness": 1}}'- Tile animations