goyeelight

package module
v0.0.0-...-97d60f7 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2017 License: MIT Imports: 5 Imported by: 2

README

goyeelight

Control the Yeelight LED Bulb with Go

GoDoc

Usage

The "Developer Mode" need to be enabled to discover and operate the device.

Quick Start
Install

go get github.com/nunows/goyeelight

Example to control the Yeelight WiFi LED
package main

import "fmt"
import "github.com/nunows/goyeelight"

func main() {
      // new Yeelight instance
      lamp := goyeelight.New("192.168.1.255", "55443")

      var r string

      // turn on the smart LED
      r = lamp.On()
      fmt.Println(r)
      // get the "power" and "bright" propertys
      r = lamp.GetProp(`"power","bright"`)
      fmt.Println(r)
      // set the bright to 50
      lamp.SetBright("50","smooth","500")
      fmt.Println(r)
      // turn off the smart LED
      r = lamp.Off()
      fmt.Println(r)
}
Methods available in the package:
  • GetProp
  • SetCtAbx
  • SetRGB
  • SetHSV
  • SetBright
  • SetPower
  • Toogle
  • SetDefault
  • StartCf
  • StopCf
  • SetScene
  • CronAdd
  • CronDel
  • CronGet
  • SetAdjust
  • SetName
  • On
  • Off

Note: Only tested with Yeelight LED Bulb (Color) with the firmware 1.4.1_45

Documentation

Overview

Package goyeelight - Control the Yeelight LED Bulb with Go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

Error struct is used on the ResponseError payload

type ResponseError

type ResponseError struct {
	ID    int   `json:"id"`
	Error Error `json:"error"`
}

ResponseError struct is used on the error responses

type ResponseOk

type ResponseOk struct {
	ID     int         `json:"id"`
	Result interface{} `json:"result"`
}

ResponseOk struct is used on the success responses

type Result

type Result struct {
	Status bool        `json:"status"`
	Data   interface{} `json:"data"`
}

Result struct is used on the standard response message

type Yeelight

type Yeelight struct {
	// contains filtered or unexported fields
}

Yeelight instance. Create an instance of Yeelight, by using New()

func New

func New(host, port string) *Yeelight

New returns a new Yeelight instance.

func (*Yeelight) CronAdd

func (y *Yeelight) CronAdd(t, value string) string

CronAdd method is used to start a timer job on the smart LED.

func (*Yeelight) CronDel

func (y *Yeelight) CronDel(t string) string

CronDel method is used to stop the specified cron job.

func (*Yeelight) CronGet

func (y *Yeelight) CronGet(t string) string

CronGet method is used to retrieve the setting of the current cron job of the specified type.

func (*Yeelight) GetProp

func (y *Yeelight) GetProp(values string) string

GetProp method is used to retrieve current property of smart LED.

func (*Yeelight) Off

func (y *Yeelight) Off() string

Off method is used to switch off the smart LED

func (*Yeelight) On

func (y *Yeelight) On() string

On method is used to switch on the smart LED

func (*Yeelight) SetAdjust

func (y *Yeelight) SetAdjust(action, prop string) string

SetAdjust method is used to change brightness, CT or color of a smart LED without knowing the current value, it's main used by controllers.

func (*Yeelight) SetBright

func (y *Yeelight) SetBright(brightness, effect, duration string) string

SetBright method is used to change the brightness of a smart LED.

func (*Yeelight) SetCtAbx

func (y *Yeelight) SetCtAbx(value, effect, duration string) string

SetCtAbx method is used to change the color temperature of a smart LED.

func (*Yeelight) SetDefault

func (y *Yeelight) SetDefault() string

SetDefault method is used to save current state of smart LED in persistent memory. So if user powers off and then powers on the smart LED again (hard power reset), the smart LED will show last saved state.

func (*Yeelight) SetHSV

func (y *Yeelight) SetHSV(hue, sat, effect, duration string) string

SetHSV method is used to change the color of a smart LED.

func (*Yeelight) SetName

func (y *Yeelight) SetName(name string) string

SetName method is used to name the device. The name will be stored on the device and reported in discovering response. User can also read the name through “get_prop” method

func (*Yeelight) SetPower

func (y *Yeelight) SetPower(power, effect, duration string) string

SetPower method is used to switch on or off the smart LED (software managed on/off).

func (*Yeelight) SetRGB

func (y *Yeelight) SetRGB(value, effect, duration string) string

SetRGB method is used to change the color RGB of a smart LED.

func (*Yeelight) SetScene

func (y *Yeelight) SetScene(class, values string) string

SetScene method is used to set the smart LED directly to specified state. If the smart LED is off, then it will turn on the smart LED firstly and then apply the specified command.

func (*Yeelight) StartCf

func (y *Yeelight) StartCf(count, action, flowExpression string) string

StartCf method is used to start a color flow. Color flow is a series of smart LED visible state changing. It can be brightness changing, color changing or color temperature changing.This is the most powerful command. All our recommended scenes, e.g. Sunrise/Sunset effect is implemented using this method. With the flow expression, user can actually “program” the light effect.

func (*Yeelight) StopCf

func (y *Yeelight) StopCf() string

StopCf method is used to stop a running color flow.

func (*Yeelight) Toogle

func (y *Yeelight) Toogle() string

Toogle method is used to toggle the smart LED. Note: This method is defined because sometimes user may just want to flip the state without knowing the current state.

Jump to

Keyboard shortcuts

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