hue_dart 0.1.1

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

hue_dart

A library for creating Philips Hue apps in Flutter and/or AngularDart.

This library aims to make it easier to handle with the Philips Hue bridge.

Using

Discovery

Import the library and search for bridges.

import 'package:http/http.dart';
import 'package:hue_dart/hue_dart.dart';

final client = new Client();
final discovery = new BridgeDiscovery(client);

List<DiscoveryResult> discoverResults = await discovery.automatic();
final discoveryResult = discoverResults.first;

final bridge = new Bridge(client, discoveryResult.ipAddress);

For web, use the BrowserClient.

import 'package:http/browser_client.dart';
import 'package:hue_dart/hue_dart.dart';

final client = new BrowserClient();
final discovery = new BridgeDiscovery(client);

List<DiscoveryResult> discoverResults = await discovery.automatic();
final discoveryResult = discoverResults.first;

final bridge = new Bridge(client, discoveryResult.ipAddress);

Searching for a bridge by entering an IP address is also supported.

import package:hue_dart/hue.dart;

final client = new Client();
final discovery = new BridgeDiscovery(client);

DiscoveryResult discoverResult = await discovery.manual('192.168.1.2');

final bridge = new Bridge(client, discoveryResult.ipAddress);

Create a new user

To create a user press the push link button before calling the createUser method

final bridge = new Bridge(client, discoveryResult.ipAddress);
final whiteListItem = bridge.createUser('hue_dart');
bridge.username = whiteListItem.username;

Lights

To get the current lights on the bridge, create a Bridge, set a username and

final lights = bridge.lights();

Changing a light's color while respecting its current color mode is done by using the Light#changeColor method.

final light = lights.first;
light.changeColor(red: 1.0, green: 0.3, blue: 1.0);
await bridge.updateLightState(light);

Different light state attributes can also be changed.

final light = lights.first;
light.state.brightness = 100;
await bridge.updateLightState(light);

To get the light's current color in rgb values (and other known means) use the Light#colors method

final light = lights.first;
HueColor colors = light.colors();
print('red:${colors.red}, green: ${colors.green}, blue:${colors.blue}');

[0.1.1] - 28-07-2018

  • Bumped sdk version

[0.1.0] - 28-07-2018

  • Initial version

example/example.dart

import 'package:http/http.dart';
import 'package:hue_dart/src/core/bridge.dart';
import 'package:hue_dart/src/core/bridge_discovery.dart';
import 'package:hue_dart/src/light/light.dart';

main(List<String> arguments) async {

  final client = new Client();
  /// search for bridges
  final discovery = new BridgeDiscovery(client);

  List<DiscoveryResult> discoverResults = await discovery.automatic();
  final discoveryResult = discoverResults.first;

  //create bridge
  var bridge = new Bridge(client, discoveryResult.ipAddress);

  /// create a user, press the push link button before calling this
  final whiteListItem = await bridge.createUser('dart_hue#example');

  // use username for consequent calls to the bridge
  bridge.username = whiteListItem.username;

  /// get lights
  List<Light> lights = await bridge.lights();

  // update light state
  final light = lights.first;
  light.state.on = true;
  light.state.brightness = 10;
  await bridge.updateLightState(light);
}

Use this package as a library

1. Depend on it

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


dependencies:
  hue_dart: ^0.1.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:hue_dart/hue_dart.dart';
  
Version Uploaded Documentation Archive
0.1.1 Jul 28, 2018 Go to the documentation of hue_dart 0.1.1 Download hue_dart 0.1.1 archive
0.1.0 Jul 28, 2018 Go to the documentation of hue_dart 0.1.0 Download hue_dart 0.1.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
27
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
59
Learn more about scoring.

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

  • Dart: 2.0.0
  • pana: 0.11.8

Platforms

Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

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 hue_dart depends on math any which requires SDK version >=1.0.0 <2.0.0, version solving failed.

Fix platform conflicts.

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Package is pre-v1 release.

While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction of the API.

Format lib/src/configuration/configuration.dart.

Run dartfmt to format lib/src/configuration/configuration.dart.

Format lib/src/configuration/configuration_api.dart.

Run dartfmt to format lib/src/configuration/configuration_api.dart.

Fix additional 11 files with analysis or formatting issues.

Additional issues in the following files:

  • lib/src/core/bridge.dart (Run dartfmt to format lib/src/core/bridge.dart.)
  • lib/src/core/bridge_client.dart (Run dartfmt to format lib/src/core/bridge_client.dart.)
  • lib/src/core/color_helper.dart (Run dartfmt to format lib/src/core/color_helper.dart.)
  • lib/src/group/group.dart (Run dartfmt to format lib/src/group/group.dart.)
  • lib/src/group/group_api.dart (Run dartfmt to format lib/src/group/group_api.dart.)
  • lib/src/light/light.dart (Run dartfmt to format lib/src/light/light.dart.)
  • lib/src/scene/scene.dart (Run dartfmt to format lib/src/scene/scene.dart.)
  • lib/src/scene/scene_api.dart (Run dartfmt to format lib/src/scene/scene_api.dart.)
  • lib/src/schedule/alarm.dart (Run dartfmt to format lib/src/schedule/alarm.dart.)
  • lib/src/schedule/timer.dart (Run dartfmt to format lib/src/schedule/timer.dart.)
  • lib/src/sensor/sensor_api.dart (Run dartfmt to format lib/src/sensor/sensor_api.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.69.0 <3.0.0