2024年11月24日星期日 下午5:03:10

[developer]使用代码控制Yeelight 1S color8 LED Wi-Fi 智能灯泡 discovery -diy api (.net core)

2 年 前
#9189 引用
使用代码控制Yeelight LED Wi-Fi 智能灯泡-diy api (.net core)

port 55443  ssdp

https://blog.csdn.net/winniezhang/article/details/85641418


产品名称:Yeelight LED灯泡(彩光版)
产品型号:YLDP06YL
产品接口:E26 / E27
光通量:800 流明
产品色温:1700K-6500K
使用寿命:约 25000 小时
无线连接:Wi-Fi IEEE 802.11 b/g/n 2.4GHz
额定输入:100V-240V~50/60Hz
额定功率:10W




http://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf
0
2 年 前
#9190 引用

获得智能灯的ip地址:

CMDString:= 'M-SEARCH * HTTP/1.1'+' '+'HOST: 239.255.255.250:1982'+' '+ 'MAN: ' +
    '"ssdp:discover"'  +' '+ 'ST: wifi_bulb' ;
IdUDPClient1.Broadcast(CMDString,43210);
ListBox1.Items.Add(IdUDPClient1.ReceiveString());
开关灯:

if CheckBox1.Checked then
   Self.ClientSocket1.Socket.SendText('{"id":0x00000000035ddcdf,' +
   '"method":"set_power","params":["on"]}'+#13#10)
else
   Self.ClientSocket1.Socket.SendText('{"id":0x00000000035ddcdf,' +
'"method":"set_power","params":["off"]}'+#13#10) ;
设置灯颜色:

var
  Color: TColor;
  R, G, B: integer;
  rgbcolor:Integer;

begin
  Color := Self.ColorBox1.Selected;
  R := Color and $FF;
  G := (Color and $FF00) shr 8;
  B := (Color and $FF0000) shr 16;
  rgbcolor:=R*65536+G*256+B;
  Self.ClientSocket1.Socket.SendText(' {"id":0x00000000035ddcdf,"method":"set_rgb","params":['+IntToStr(rgbcolor)+', "smooth", 500]}'+#13#10)
end;
设置灯亮度:

Self.ClientSocket1.Socket.SendText('{"id":0x00000000035ddcdf,"method":"set_bright","params":['+IntToStr(Self.TrackBar1.Position)+', "smooth", 500]}'+#13#10)



0
2 年 前
#9191 引用
http://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf
0
2 年 前
#17722 引用
Yeelight lan control with packetsender    discovery

https://community.home-assistant.io/t/yeelight-lan-control-with-packetsender/296685

I want to share some knowalage about control yeelight lamps and strips over the lan by sending commands to those devices. I have a lot of those lamps at home and from time to time HA which controls them became crazy with 100% cpu because one of them start to refuse the network connection. Anyway, that info can help someone debug their problems.

We have manual with detail https://www.yeelight.com/download/Yeelight_Inter-Operation_Spec.pdf
We need install tool https://packetsender.com/

Step 1:send “discovery” package

First you should send “discovery” package - it is udp on 239.255.255.250 port 1982 and all yeelight devices will replay to you with their location, status and available settings



0
2 年 前
#17723 引用
Step 2:response package


response looks like that



Cache-Control: max-age=3600
Date:
Ext:
Location: yeelight://192.168.1.120:55443
Server: POSIX UPnP/1.0 YGLC/1
id: 0x0000000010e0de00
model: ceiling20
fw_ver: 27
support: get_prop set_default set_power toggle set_bright set_scene cron_add cron_get cron_del start_cf stop_cf set_adjust adjust_bright set_name set_ct_abx adjust_ct bg_set_rgb bg_set_hsv bg_set_ct_abx bg_start_cf bg_stop_cf set_scene_bundle bg_set_default bg_set_power bg_set_bright bg_set_adjust bg_adjust_bright bg_adjust_color bg_adjust_ct bg_toggle dev_toggle
power: off
bright: 98
color_mode: 2
ct: 3773
rgb: 0
hue: 0
sat: 0
name:

0
2 年 前
#17724 引用
Step 3:Control package


Like you can see there are Location, power status and features that device have. More info in manual.

Next you can control each of them - simple case turn on/off the power. For that you should send TCP package to device address with command you want run - in our case it is (please make sure it have \r\n in the end!)

{ “id”: 1, “method”: “set_power”, “params”:[“on”]}\r\n





Also it works if you use telnet telnet 192.168.1.120 55443 and run the same command
 { “id”: 1, “method”: “set_power”, “params”:[“on”]} \r\n
0
1 年 前
#20008 引用
Color8 0x1c598a45 by yeelink

Color8 0x1c598a45 by yeelink
Yeelight
Retrying setup: Failed to read from the socket at 192.168.2.100:55443: [Errno 111] Connect call failed ('192.168.2.100', 55443).
0
1 年 前
#20136 引用
yeelight integration discovery

https://www.home-assistant.io/integrations/yeelight/

https://github.com/home-assistant/core/blob/dev/homeassistant/components/yeelight/config_flow.py

from homeassistant.components import dhcp, onboarding, ssdp, zeroconf


https://github.com/home-assistant/core/blob/dev/homeassistant/components/yeelight/const.py

NIGHTLIGHT_SWITCH_TYPE_LIGHT = "light"

DISCOVERY_INTERVAL = timedelta(seconds=60)
SSDP_TARGET = ("239.255.255.250", 1982)
SSDP_ST = "wifi_bulb"
DISCOVERY_ATTEMPTS = 3
DISCOVERY_SEARCH_INTERVAL = timedelta(seconds=2)
DISCOVERY_TIMEOUT = 8


https://github.com/home-assistant/core/blob/dev/homeassistant/components/yeelight/manifest.json


"iot_class": "local_push",
  "dhcp": [
    {
      "hostname": "yeelink-*"
    }
  ],
  "zeroconf": [{ "type": "_miio._udp.local.", "name": "yeelink-*" }],
  "homekit": {
    "models": ["YL*"]
  },
  "after_dependencies": ["ssdp"],
  "loggers": ["async_upnp_client", "yeelight"]



https://github.com/home-assistant/core/blob/dev/homeassistant/components/yeelight/scanner.py

from .const import (
    DISCOVERY_ATTEMPTS,
    DISCOVERY_INTERVAL,
    DISCOVERY_SEARCH_INTERVAL,
    DISCOVERY_TIMEOUT,
    DOMAIN,
    SSDP_ST,
    SSDP_TARGET,
)
0
1 年 前
#20141 引用
yeelight New devices discovered (Homekit)
https://github.com/home-assistant/core/issues/26129



Some additional info:

LAN control is enabled and port 54321 is open.

Starting Nmap 7.60 ( https://nmap.org ) at 2019-08-23 07:49 WEST
Nmap scan report for 192.168.110.125
Host is up (0.069s latency).

PORT STATE SERVICE
54321/udp open|filtered bo2k
MAC Address: 7C:49:EB:B3:xx:xx (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 1.10 seconds

Starting Nmap 7.60 ( https://nmap.org ) at 2019-08-23 07:49 WEST
Nmap scan report for 192.168.110.111
Host is up (0.068s latency).

PORT STATE SERVICE
54321/udp open|filtered bo2k
MAC Address: 7C:49:EB:B3:xx:xx (Unknown)

Nmap done: 1 IP address (1 host up) scanned in 1.11 seconds

0