hue_dart 0.1.2

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

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.2] - 04-09-2018

  • Fixed dependencies and formatting
  • Tweaked the parsing of some classes

[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.2

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:hue_dart/hue_dart.dart';
  
Version Uploaded Documentation Archive
0.1.2 Sep 4, 2018 Go to the documentation of hue_dart 0.1.2 Download hue_dart 0.1.2 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]
11
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]
55
Learn more about scoring.

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

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:hue_dart/hue_dart.dart.

Health suggestions

Format lib/src/resource_link/resource_links_bloc.dart.

Run dartfmt to format lib/src/resource_link/resource_links_bloc.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.69.0 <3.0.0
http ^0.11.3+16 0.11.3+17 0.12.0
intl ^0.15.6 0.15.7
json_serializable ^0.5.8 0.5.8+1 2.0.0
Transitive dependencies
analyzer 0.32.6 0.34.0
args 1.5.1
async 2.0.8
build 0.12.8 1.0.1
build_config 0.3.1+2 0.3.1+4
charcode 1.1.2
collection 1.14.11
convert 2.0.2
crypto 2.0.6
csslib 0.14.6
dart_style 1.1.3 1.2.1
front_end 0.1.4+2 0.1.7
glob 1.1.7
html 0.13.3+3
http_parser 3.1.3
json_annotation 0.2.9+1 2.0.0
kernel 0.3.4+2 0.3.7
logging 0.11.3+2
meta 1.1.6
package_config 1.0.5
path 1.6.2
plugin 0.2.0+3
pub_semver 1.4.2
pubspec_parse 0.1.2+2 0.1.2+3
source_gen 0.8.3+1 0.9.1+3
source_span 1.4.1
string_scanner 1.0.4
typed_data 1.1.6
utf 0.9.0+5
watcher 0.9.7+10
yaml 2.1.15
Dev dependencies
build_runner any
mockito ^3.0.0
test ^1.2.0