lifx 0.2.1

dart_lifx #

Another attempt at a LIFX library, this time written in Dart.

  • Requires LIFX API key when creating a new object.
  • Optional named parameter, loggingEnabled enables or disables status codes and response body printing.
import 'package:lifx/lifx.dart';

void main() {
    var lifx = new LIFX("api_key_here", loggingEnabled: true);

    lifx.getLights().then((res) => print(res));

Methods #

All methods are asynchronous and most contain optional light parameter, by default all lights are selected. Pass light ID, found with getLights() to control individual lights.

Read more about setState here.

Future<Map> getLights({String light = "all"})
Future<Map> getScenes()
Future<bool> activateScene(String uuid, {double duration = 1.0})
Future<bool> togglePower({String light = "all"}) 
Future<bool> setState({String light = "all", String power = "on", String color = "", double brightness = 0.5, double duration = 1.5, double infrared = 0.0})

Extra #

Gets the hexidecimal value from standard RGB (0 - 255) values to easily set color in setState().

String getHexFromRGB(int red, int green, int blue)


import 'package:lifx/lifx.dart';
import 'dart:io' show Platform;

void main() {
    Map<String, String> envVars = Platform.environment;

    var lifx = new LIFX(envVars["DART_LIFX"], loggingEnabled: false);
    lifx.setState(brightness: 0.5, color: "red").then((res) => print(res));

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  lifx: ^0.2.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:lifx/lifx.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see