golightmyroom

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2023 License: BSD-3-Clause Imports: 7 Imported by: 0

README

golightmyroom

A go library for controlling Philips Hue light(s) with bluetooth.

My motivation for this project started with not being able to control my light with my laptop, but also that Philips is now forcing users to make an account in order to use their purchased light(s), so now I've gotten a bigger reason to make this!

Example

An example can be found at example.go

Contributing

Currently, contributing is a bit difficult right now, since a lot the code for controlling a light is shared logic. I haven't gotten around to separating it yet.

Documentation

Index

Constants

View Source
const (
	TemperatureDefault    = 2732
	TemperatureWarmOrange = 2000
	TemperatureWarmWhite  = 2600
	TemperatureWhite      = 4000
	TemperatureCoolWhite  = 5000
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorControl

type ColorControl interface {
	// Color returns the current color.
	Color() color.Color
	// SetColor sets the (supported) color of the light.
	// It may not be the exact color you set, since some lights have a limited color gamut.
	SetColor(color.Color)
}

ColorControl hold the color controls for Hue lights that support it.

type Light

type Light interface {
	// On turns on the light.
	On()
	// Off turns off the light.
	Off()
	// Powered returns true if the light is turned on and returns false if it's off.
	Powered() bool
	// Brightness returns a value from [1.0, 0.0], highest meaning brightest.
	Brightness() float64
	// SetBrightness set a brightness from [1.0, 0.0], highest meaning brightest.
	SetBrightness(float64)
	// Model shows the model name of the light, this is used for ColorControl.
	Model() string
}

Light holds the main controls that every Hue light has.

func ConnectToBluetooth

func ConnectToBluetooth(macAddress string) (Light, error)

func ConnectToBluetoothWithContext

func ConnectToBluetoothWithContext(macAddress string, ctx context.Context) (Light, error)

type NameControl

type NameControl interface {
	// Name gets the light's name
	Name() string
	// SetName sets the light's name
	SetName(string)
}

NameControl holds the name controls that every Hue light has. Though this has been seperated if some lights should not have their name changed.

type TemperatureControl

type TemperatureControl interface {
	// Temperature returns a temperature as Kelvin. (Search for "kelvin color temperature scale" for examples
	// or use default values, like TemperatureDefault)
	Temperature() uint16
	// SetTemperature allows you to set a Kelvin color temperature for the light.
	SetTemperature(uint16)
}

TemperatureControl hold the temperature controls for Hue lights that support it.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL