Skip to content

Very simple yeelight control without discover

Notifications You must be signed in to change notification settings

Ghardo/yeelight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 

Repository files navigation

yeelight

Very simple yeelight control without discover

basic example

package main

import (
	"fmt"
	"log"

	"github.com/Ghardo/yeelight"
)

func main() {
	yl := yeelight.Yeelight{Address: "<local-ip>:55443"}
	yl.SetHexColor("#f59542")
	yl.SetOn()
	fmt.Println(yl.IsOn())

	p := []string{"rgb", "bright"}
	r, err := yl.GetProperties(p)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(r.Result)
}

how to use matrix functions this example is for 1 dot matrix and a spot light

package main

import (
	"log"

	"github.com/Ghardo/yeelight"
)

func main() {
	var err error
	yl := yeelight.Yeelight{Address: "<local-ip>:55443", Persistent: true}
	err = yl.SetDirectMode()
	if err != nil {
		log.Fatal(err)
	}

	// Method with predefined array of hex values
	colors1 := []string{"#FF0000", "#000000", "#000000", "#000000", "#FF0000",
		"#FF0000", "#FF0000", "#000000", "#FF0000", "#FF0000",
		"#FF0000", "#FF0000", "#FF0000", "#FF0000", "#FF0000",
		"#FF0000", "#FFFFFF", "#FF0000", "#FFFFFF", "#FF0000",
		"#000000", "#FF0000", "#FF0000", "#FF0000", "#000000"}
	matrix1 := yeelight.MakeFromHexColors(colors1)
	matrix1 = matrix1.Rotate(90.0)
	
	//matrix1 := yeelight.MakeMatrix("#0000FF", 25)
	//v2 := yeelight.Vector{Row: 1, Column: 2}
	//matrix1.SetHex(v2, "#FF0000")

	matrix2 := yeelight.MakeSpotMatrix("#ff9100")

	m := []yeelight.ColorMatrix{matrix1, matrix2}

	err = yl.SetMatrix(m)

	if err != nil {
		log.Fatal(err)
	}
}

About

Very simple yeelight control without discover

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages