Development

How to Set Up Build Light with YeeLight WIFI Bulb

Introduction

In the agile software development world, continuous integration is a widely used practice and it is very helpful in building quality software. It is vital to bring failed builds to the attention of responsible developers as quickly as possible. This problem can be easily solved in a fun way by using YeeLight WiFi Bulb for agile development team.

Architecture

The system starts with an on-premise Continuous Integration Server with building systems (Jenkins, GitLab CI), YeeLight WIFI Bulb, program deployed PC.

How to Set Up Build Light with YeeLight WIFI Bulb

Build a customized program to collect the Build events from the Build Server, then invoke YeeLight Open API to control the WIFI Bulb for ON/OFF and color change.

How to Set Up Build Light with YeeLight WIFI Bulb

YeeLight WIFI Bulb (Color)

Hardware

YeeLight Led WIFI Bulb (Color) is one of products from Qingdao Yeelink Information Technology Co., Ltd.

Yeelink is an emerging innovative enterprise that was founded in 2012 with the help of the American incubator SOSven-tures.

How to Set Up Build Light with YeeLight WIFI Bulb

Features

  • Works with Amazon Alexa ( voice control ), IFTTT MIJIA,
  • Wi-Fi access – control your lights by smartphone app through home Wi-Fi
  • 16 million colors bulb, dimmable and Color temperature range 1700k-6500k
  • Set time schedules and Countdowns, energy efficient
  • Music sync and Group control via app, no hub is required

For more YeeLight Led WIFI Bulb(Color) product details, please refer Product Introduction.

Configuration

To activate the YeeLight WIFI Bulb, download “YeeLight” from the App Store or the Google Store. Follow the below steps to initialize the bulb and enable the “Development” mode.

1.Scan the QR code to download the Yeelight Application

How to Set Up Build Light with YeeLight WIFI Bulb

2.Add Yeelight smart LED device

How to Set Up Build Light with YeeLight WIFI Bulb

3.Turn on [Developer Mode] in the settings page

How to Set Up Build Light with YeeLight WIFI Bulb

OpenAPI

The WIFI Bulb has two control mode, one is remote controlled through the¬†internet. The other is locally controlled through your¬†local WIFI network. A 3rd party API is used to control the bulb under the same local WIFI network. Below is a diagram of the bulb’s discover procedure for the local network environment.

How to Set Up Build Light with YeeLight WIFI Bulb

The bulb signal broadcasts and can be discovered as a UDP protocol. Control is through TCP. Following is the list of all supported methods and parameters.

How to Set Up Build Light with YeeLight WIFI Bulb

Yeelight WiFi Light Inter-Operation Specification: API Document

Continuous Integration System Integration

Jenkins

Jenkins provides a machine-consumable remote access API to its functionalities. Currently, it comes in three flavors:

  • XML
  • JSON with JSONP support
  • Python

Remote access API is offered in a REST-like style. That is, there is no single entry point for all features, and instead, they are available under the “…/api/” URL where “…” portion is the data that it acts on.

Remote API can be used to do things like these:

  • retrieve information from Jenkins for programmatic consumption.
  • trigger a new build
  • create/copy jobs

We will use the Jenkins API to retrieve the latest build results.

http://user:password@<Jenkins URL>/job/<job name>/lastBuild/api/xml?<Filter_Condition>

Jenkins Remote Access API

Jenkins Remote Access API Java demo

Example

Request command:

Curl http://10.2.7.84:9000/job/Bosch%20Prototype%20Production/lastBuild/api/xml?tree=*

Response from Jenkins server:

How to Set Up Build Light with YeeLight WIFI Bulb

GitLab CI

A pipeline is a group of jobs that get executed in stages (batches). All of the jobs in a stage are executed in parallel (if there are enough concurrent Runners), and if they all succeed, the pipeline moves on to the next stage. If one of the jobs fails, the next stage is not (usually) executed. You can access the pipelines page in your project’s Pipelines tab.

In the following image, you can see that the pipeline consists of four stages (build, test, staging, production) each one having one or more jobs.

How to Set Up Build Light with YeeLight WIFI Bulb

GitLab Pipelines API helps to retrieve the latest pipeline result from GitLab CI.

Create an access token for your API to invoke, through the below GitLab screen from “Settings” menu.

How to Set Up Build Light with YeeLight WIFI Bulb

Example

Request command:

curl –header “PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK” “https://gitlab.example.com/api/v4/projects/1/pipelines

Response from GitLab Server:

How to Set Up Build Light with YeeLight WIFI Bulb

Java Example Code

This Java example code implemented the below functions:

  1. Invoke Jenkins Latest build API to retrieve job result
  2. Discover YeeLight WIFI Bulb from local network
  3. Change Bulb color according to Job result

The code refers from GitHub Death111’s YeelightJava project which encapsulates the YeeLight HTTP methods and library.

How to Set Up Build Light with YeeLight WIFI Bulb

How to Set Up Build Light with YeeLight WIFI Bulb

How to Set Up Build Light with YeeLight WIFI Bulb

Running Result:

How to Set Up Build Light with YeeLight WIFI Bulb

How to Set Up Build Light with YeeLight WIFI Bulb

How to Set Up Build Light with YeeLight WIFI Bulb

How to Set Up Build Light with YeeLight WIFI Bulb

 

About the Author

I am Senior Project Manager located at Perficient China GDC. 16 years in IT industry, growing up from developer, I involved in various development projects as project manager. My interests are Project Managment, Agile Development and some edge Technical knowledge.

More from this Author

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Subscribe to the Weekly Blog Digest:

Sign Up