sunix_ledstrip_controller 1.0.1

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • new63

Sunix ledstrip controller

A dart library for controlling the Sunix® RGB / RGBWWCW WiFi LED strip controller.

Features

  • Power the controller off and on
  • Change the color of the led controller
    • For RGB or RGBWWCW (warm white and cold white) colors
  • Receive the current status of the controller, including the power state and color values
  • Send multiple requests in quick succession
    • Can be used to create a smooth transition from one color to another

Installation

You can install the package by adding the following to your pubspec.yaml:

dependencies:
  sunix_ledstrip_controller: ^1.0.0

Usage

A simple usage example:

import 'package:sunix_ledstrip_controller/sunix_ledstrip_controller.dart';

main() async {
  // create a new controller object with a static ip
  LedController controller = LedController("192.168.178.50");

  // power the controller on
  if (await controller.powerOn()) {
    // methods return true when the request was successfully sent
    print("successfully powered on");
  }

  // change the controller color
  controller.updateColorRgb(192, 255, 238);

  // get the status of the controller
  StatusResponse status;
  await controller
      .requestStatus()
      .then((response) => status = response);

  print("powered on: ${status?.poweredOn}");
  print("red:   ${status?.red}");
  print("blue:  ${status?.green}");
  print("green: ${status?.blue}");
}

Example

See the example directory for a basic example.

Attributions

A big thanks goes to @markusressel for his python library sunix-ledstrip-controller-client.

1.0.1

  • Update readme

1.0.0

  • Initial version

example/sunix_ledstrip_controller_example.dart

import 'dart:io';

import 'package:sunix_ledstrip_controller/sunix_ledstrip_controller.dart';

main() async {
  // create a new controller object with a static ip
  LedController controller = LedController("192.168.178.50");

  // power the controller on
  if (await controller.powerOn()) {
    // methods return true when the request was successfully sent
    print("successfully powered on");
  }

  // change the controller color
  controller.updateColorRgb(192, 255, 238);

  // also change the warm and cold white (if the controller supports it)
  controller.updateColorRgbww(192, 255, 238, 128, 128);

  // get the status of the controller
  StatusResponse status;
  await controller
      .requestStatus()
      .then((response) => status = response ?? status);

  print("powered on: ${status?.poweredOn}");
  print("red:   ${status?.red}");
  print("blue:  ${status?.green}");
  print("green: ${status?.blue}");

  // send a list of requests
  // can be used to update the color in quick succession
  List<LedRequest> requests = [
    UpdateColorRequest.rgb(red: 0, green: 0, blue: 0),
    UpdateColorRequest.rgb(red: 60, green: 0, blue: 0),
    UpdateColorRequest.rgb(red: 120, green: 0, blue: 0),
    UpdateColorRequest.rgb(red: 180, green: 0, blue: 0),
    UpdateColorRequest.rgb(red: 240, green: 0, blue: 0),
  ];

  // when using sendRequest or sendRequests an exception can be thrown and
  // should be caught
  try {
    controller.sendRequests(requests, Duration(seconds: 10));
  } on SocketException {
    print("exception while changing color");
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  sunix_ledstrip_controller: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

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

3. Import it

Now in your Dart code, you can use:


import 'package:sunix_ledstrip_controller/sunix_ledstrip_controller.dart';
  
Version Uploaded Documentation Archive
1.0.1 Sep 23, 2018 Go to the documentation of sunix_ledstrip_controller 1.0.1 Download sunix_ledstrip_controller 1.0.1 archive
1.0.0 Sep 23, 2018 Go to the documentation of sunix_ledstrip_controller 1.0.0 Download sunix_ledstrip_controller 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
26
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
63
Learn more about scoring.

We analyzed this package on Oct 10, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0
  • pana: 0.12.4

Platforms

Detected platforms: Flutter, other

Primary library: package:sunix_ledstrip_controller/sunix_ledstrip_controller.dart with components: io.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
logging ^0.11.3+2 0.11.3+2
Dev dependencies
test ^1.0.0