Help us shape the future of Go! Take the 2026 Go Developer Survey

fluxwifi

package module
v0.0.0-...-f529002 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2016 License: MIT Imports: 5 Imported by: 1

README

fluxwifi

A golang library to scan and control Flux WIFI smart bulbs

##Documentation See godoc

##Installation

go get github.com/go-home-iot/fluxwifi

##Package

import "github.com/go-home-iot/fluwifi"

##Using the library Some functions take an io.Writer interface, i.e. the TurnOn, TurnOff functions. The io.Writer needs to be an open connection to the Flux WIFI bulb. To open a connection, you would first call Scan() then in the responses, the IP field contains the address of the device, using that address, you can do a net.Dial to get a connection, then pass in the connection object to the functions as the io.Writer interface.

conn, err := net.Dial("tcp", scanResponse.IP) 

##Version History ###0.1.0 Initial release, support for scanning for devices and TurnOn/TurnOff/SetValue

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetLevel

func SetLevel(r, g, b byte, w io.Writer) error

SetLevel changes the RGB values of the bulb.

func TurnOff

func TurnOff(w io.Writer) error

TurnOff turns the bulb off

func TurnOn

func TurnOn(w io.Writer) error

TurnOn turns the bulb on

Types

type BulbInfo

type BulbInfo struct {
	IP    string
	ID    string
	Model string
}

BulbInfo contains the information returned from scanning the local network for Flux WIFI bulbs

func Scan

func Scan(waitTimeSeconds int) ([]BulbInfo, error)

Scan scans the local network looking for Flux WIFI bulbs. waitTimeSeconds determines how long the function waits until it stops listening for responses on the network

type State

type State struct {
	// Power - 0 -> off, 1 -> on, 2-> unknown
	Power int

	// Mode - ww|color|custom|unknown
	Mode string

	// R - red value if in color mode
	R byte

	// G - green value if in color mode
	G byte

	// B - blue value if in color mode
	B byte
}

State represents the current state of the bulb

func FetchState

func FetchState(conn net.Conn) (*State, error)

FetchState returns the current state of the bulb

Jump to

Keyboard shortcuts

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