wizz

package module
v0.0.0-...-1a37bcf Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2023 License: MIT Imports: 9 Imported by: 0

README

wizz

Phillips Wizz Local Connection, see main.go for detail example.

Install package go get github.com/ouwe-knutselaarh/wizz

Available methods

  1. getState get current state bulb
  2. getConfig get current config
  3. turnOnLight turn on light bulb
  4. turnOffLight turn off light bulb
  5. setColorTemp set bulb color temperature
  6. setBrightness set brightness light bulb
  7. setColorRGB set RGB color light bulb
  8. setColorScene set color scheme based on available scheme
  9. setColorWarmWhite set color warm light bulb
  10. setColorColdWhite set color cold light bulb

Reference project from https://github.com/sbidy/wiz_light

Example

package main

import (
	"encoding/json"
	"fmt"
	phillipWhizz "github.com/ouwe-knutselaar/wizz"
	responseModel "github.com/ouwe-knutselaar/wizz/models"
	"log"
)

func main() {
	var (
		bulbIp   = "192.168.1.10"
		response = new(responseModel.ResponsePayload)
		result   []byte
		err      error
	)
	//--------- Example Get Bulb Config -----------
	if response, err = phillipWhizz.GetConfig(bulbIp); err != nil {
		log.Fatalf(`Unable to read response: %s`, err)
	}
	if result, err = json.Marshal(response); err != nil {
		log.Fatalf(`Unable to convert to json string: %s`, err)
	}
	fmt.Println(string(result))

	// --------- Example Turn Off light -----------
	if response, err = phillipWhizz.TurnOffLight(bulbIp); err != nil {
		log.Fatalf(`Unable to read response: %s`, err)
	}
	if result, err = json.Marshal(response); err != nil {
		log.Fatalf(`Unable to convert to json string: %s`, err)
	}
	fmt.Println(string(result))
	...
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetConfig

func GetConfig(bulbIp string) (*models.ResponsePayload, error)

func GetState

func GetState(bulbIp string) (*models.ResponsePayload, error)

func SearchLamp

func SearchLamp(a, b, c byte)

func SetBrightness

func SetBrightness(bulbIp string, value float64) (*models.ResponsePayload, error)

func SetColorColdWhite

func SetColorColdWhite(bulbIp string, value float64) (*models.ResponsePayload, error)

func SetColorRGB

func SetColorRGB(bulbIp string, r, g, b float64) (*models.ResponsePayload, error)

func SetColorScene

func SetColorScene(bulbIp string, sceneId int64) (*models.ResponsePayload, error)

func SetColorTemp

func SetColorTemp(bulbIp string, value float64) (*models.ResponsePayload, error)

func SetColorWarmWhite

func SetColorWarmWhite(bulbIp string, value float64) (*models.ResponsePayload, error)

func TurnOffLight

func TurnOffLight(bulbIp string) (*models.ResponsePayload, error)

func TurnOnLight

func TurnOnLight(bulbIp string) (*models.ResponsePayload, error)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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