AlexisTM / yeelight-ws

yeelight websocket interface

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

yeelight-ws

This is an example of a web-based Yeelight control system handled with a websocket. It allows to control all the lights in your house simultaneously, including the JIAYOUE 650 background light.

This is a project is about testing the capabilities of different libraries and is not for users.

Note that I am not a graphic designer.

This is running on a Raspberry Pi Zero

Starring:

Install

git clone http://github.com/AlexisTM/yeelight-ws
cd yeelight-ws
npm install
node index.js

Install redis-server

sudo apt install redis-server

Setup of the config.json

{
    "redis": {
        "ip": "192.168.178.23"
    },
    "discover_lights": false,
    "lights": [
        {
            "ip": "192.168.178.32",
            "type": "ceiling4"
        }
    ]
}

Setup a user

node setup.js
#? Username:  AlexisTM
#? Password:  [hidden]
#? Roles:  admin, user

Redis db template

users/[username]:mmd5 = md5(md5(password)) // stores md5(md5(password))
users/[username]:roles = '["admin", "user"]' // roles
users/[username]:token-[token] = [token] // stores the valid tokens, they expire currently after 10 days, the data 

Install and autoboot on a Raspberry Pi

SSH with the user pi and install it the same way as on a desktop.

git clone http://github.com/AlexisTM/yeelight-ws
cd yeelight-ws
npm install
sudo apt install redis-server # will be at 127.0.0.1

Enable the autoboot by creating the follwoing file /etc/systemd/system/yeelight.service

#
# Service file for systems with systemd to run Yeelight websocket control
#

[Unit]
Description=Yeelight
After=network.target

[Service]
Type=simple
user=pi
WorkingDirectory=/home/pi/yeelight-ws
ExecStart=/usr/bin/node /home/pi/yeelight-ws/index.js
SendSIGKILL=no

[Install]
WantedBy=multi-user.target

Finally, start and enable the service.

sudo systemctl start yeelight
sudo systemctl status yeelight # ensure the service works
sudo systemctl enable yeelight

Quickview

Quickview

About

yeelight websocket interface

License:MIT License


Languages

Language:JavaScript 57.4%Language:CSS 24.2%Language:HTML 18.4%