Git Product home page Git Product logo

wizgo's Introduction

Wizgo

Wizgo Logo (Main) logo.

GitHub go.mod Go version (subdirectory of monorepo) GitHub Go Reference Go Report Card

YouTube Channel Subscribers X (formerly Twitter) Follow

A golang library to control your WiZ lights

At this moment, the library is not covering the whole API as it is discovered by reverse engineering If you want to cover more things, consider contributing

Motivation

Domotic devices are cool, but they will be cooler when Matter protocol lands, finally, into the industry.

As a fact, before Matter, only some protocols such as Zigbee had some standardization mercy.

But there are a lot of devices out there connected by Wi-Fi, and they are completely non-standard. Manufacturers decided to design them without thinking about potential integration between different stuff.

The big question is: what are you doing with your legacy WiZ devices that are not going to be updated by the company, once when Matter has landed? Are you thinking about throwing them to the trash?

With this library you can make your own automations with them. And now it's as easy as you should forgive about throwing... what?

Methods

Just read these wonderful lines:

package main

import (
	"log"

	// Include the library in your code
	"github.com/achetronic/wizgo/pkg/wizgo"
)

func main() {

	// The first step is to start a client to interact with your devices
	wizClient, err := wizgo.CreateWizClient("192.168.2.107", 38899)

	// Devices can be turned on/off with single commands
	_, err = wizClient.TurnOn()
	if err != nil {
		log.Fatalf("error turning on the light: %s", err)
	}

	// Lights can be visually found sending a pulse
	_, err = wizClient.Pulse()
	if err != nil {
		log.Fatalf("error sending a pulse: %s", err)
	}

	// Scenes are supported too. Just set the ID you want
	_, err = wizClient.SetScene(35)
	if err != nil {
		log.Fatalf("error setting the scene: %s", err)
	}

	// May be you want to set the speed for a party?
	_, err = wizClient.SetSpeed(200)
	if err != nil {
		log.Fatalf("error setting the speed: %s", err)
	}

	// Oh, some romantic moment. Understood.
	_, err = wizClient.SetTemperature(2000)
	if err != nil {
		log.Fatalf("error setting temperature: %s", err)
	}

	// Studying is better with bright light
	_, err = wizClient.SetColdWhite(255)
	if err != nil {
		log.Fatalf("error setting cold white level: %s", err)
	}

	// But if it's too much, brightness can be set
	_, err = wizClient.SetBrightness(100)
	if err != nil {
		log.Fatalf("error setting the brightness level: %s", err)
	}

	// Feel like Grinch-y today?
	_, err = wizClient.SetRgb(0, 255, 0)
	if err != nil {
		log.Fatalf("error setting the color: %s", err)
	}

	// Let me sleep, uh?
	_, err = wizClient.TurnOff()
	if err != nil {
		log.Fatalf("error turning off the device: %s", err)
	}

	// There are a lot of more things implemented
	_, err = wizClient.GetPilot()
	_, err = wizClient.GetModelConfig()
	_, err = wizClient.GetDevInfo()
	_, err = wizClient.GetSystemConfig()
	_, err = wizClient.SetRatio(100)
	_, err = wizClient.SetWarmWhite(100)
	_, err = wizClient.IsDw()
	_, err = wizClient.IsTw()
	_, err = wizClient.IsRgb()
	_, err = wizClient.IsSceneAvailable(32)
	_, err = wizClient.Registration("192.168.2.173", "704F7C84524A", true)
}

How to contribute

Of course, we are open to external collaborations for this project. For doing it you must:

  • Open an issue to discuss what is needed and the reason
  • Fork the repository
  • Make your changes to the code
  • Open a PR. The code will be reviewed and tested (always)

We are developers and hate bad code. For that reason we ask you the highest quality on each line of code to improve this project on each iteration.

License

Copyright 2022.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Special mention

This project was done using IDEs from JetBrains. They helped us to develop faster, so we recommend them a lot! ๐Ÿค“

JetBrains Logo (Main) logo.

wizgo's People

Contributors

achetronic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

wizgo's Issues

issue with package slices required by pkg/wizgo

There is a small issue with imports in pkg/wizgo resulting with error:

error while importing github.com/achetronic/wizgo/pkg/wizgo: package slices is not in GOROOT (/usr/local/go/src/slices)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.