lifx 0.2.1

  • README.md
  • Example
  • Installing
  • Versions
  • 0

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)

example/main.dart

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:


dependencies:
  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';
  
Version Uploaded Documentation Archive
0.2.1 May 9, 2018 Go to the documentation of lifx 0.2.1 Download lifx 0.2.1 archive
0.2.0 May 8, 2018 Go to the documentation of lifx 0.2.0 Download lifx 0.2.0 archive
0.1.0 May 8, 2018 Go to the documentation of lifx 0.1.0 Download lifx 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
0
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

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 
 Because lifx depends on unittest >=0.2.8+2 which requires SDK version <2.0.0, version solving failed.

Health suggestions

Format lib/lifx.dart.

Run dartfmt to format lib/lifx.dart.

Maintenance issues and suggestions

Add SDK constraint in pubspec.yaml. (-50 points)

For information about setting SDK constraint, please see https://www.dartlang.org/tools/pub/pubspec#sdk-constraints.

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Maintain CHANGELOG.md. (-20 points)

Changelog entries help clients to follow the progress in your code.