Skip to content
forked from Jairzinno/hue_dart

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

License

Notifications You must be signed in to change notification settings

smiLLe/hue_dart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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}');

About

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

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Dart 100.0%