home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.18k stars 30.2k forks source link

found milight 3 / limitlessled v6 api codes.. here they are #4676

Closed duecedriver closed 6 years ago

duecedriver commented 7 years ago

Update: an archive of limitlessled.com/dev can be found here: https://github.com/Fantasmos/LimitlessLED-DevAPI


Section 1. Manual Web Browser Wifi Bridge v6 Setup. Connect Phone to Milight AccessPoint Use Phone Web Browser to http://10.10.100.254 Username: admin Password: admin Work Mode: change to STA mode, press Save STA Setting: Scan for your Home Wifi Router Encryption Method: WPA2PSK Encryption Algorithm: AES Password: enter your home wifi router password here. Obtain an IP address automatically: Enable Restart: Click Ok Now put your phone back on your home wifi network, and open the app, it should see the wifi bridge, assuming you entered your wifi password correctly a few steps back. :) Section 2. Searching for LimitlessLED v6 Bridge/s on the LAN. We have a Windows App for this called LimitlessLED Admin tool v5/v6 If you are building your own Program, use the following (If you want more exact C# code for this, email us) UDP.IP = “255.255.255.255″; // IP.Broadcast UDP.PORT = 48899; UDP.SendBytes(UTF8.GetBytes(“HF-A11ASSISTHREAD”)); // v6 Bridge (for v5 use “Link_Wi-Fi”) receiveBytes = UDP.Receive(); response = UTF8.GetString(receiveBytes); //returns IP address of the wifi bridge, the unique MAC address, and the name(which is always the same) // 10.1.1.27,ACCF23F57AD4,HF-LPB100 // 10.1.1.31,ACCF23F57D80,HF-LPB100 Section 3. Wifi Bridge v6 Protocol UDP.IP = “255.255.255.255″; (or direct Wifi Bridge IP Address) UDP.PORT = 5987; UDP.SEND (hex bytes, see below) SN = Sequential Hex Number (Sequence Number) 0×01 -> 0xFF WB = Wifi Bridge ID 0×01 -> 0xFF RGBW/WW/CW Commands UDP Hex Send Format: 80 00 00 00 11 {WifiBridgeID} 00 00 {SequenceNumber} 00 {COMMAND} {ZONE NUMBER} 00 {Checksum} UDP Hex Response: 88 00 00 00 03 00 {SequenceNumber} 00 List of {COMMAND}s: 31 00 00 08 04 01 00 00 00 = Light ON 31 00 00 08 04 02 00 00 00 = Light OFF 31 00 00 08 04 05 00 00 00 = Night Light ON 31 00 00 08 05 64 00 00 00 = Dual White Light ON (Color RGB OFF) 31 00 00 08 01 BA BA BA BA = Set Color to Blue (BA) (FF = Red, D9 = Lavender, BA = Blue, 85 = Aqua, 7A = Green, 54 = Lime, 3B = Yellow, 1E = Orange) 31 00 00 08 02 SS 00 00 00 = Saturation (SS hex values 0×00 to 0×64 : examples: 00 = 0%, 19 = 25%, 32 = 50%, 4B, = 75%, 64 = 100%) 31 00 00 08 03 BN 00 00 00 = BrightNess (BN hex values 0×00 to 0×64 : examples: 00 = 0%, 19 = 25%, 32 = 50%, 4B, = 75%, 64 = 100%) 31 00 00 08 05 KV 00 00 00 = Kelvin (KV hex values 0×00 to 0×64 : examples: 00 = 2700K (Warm White), 19 = 3650K, 32 = 4600K, 4B, = 5550K, 64 = 6500K (Cool White)) 31 00 00 08 06 MO 00 00 00 = Mode Number (MO hex values 0×01 to 0×09 : examples: 01 = Mode1, 02 = Mode2, 03 = Mode3 .. 09 = Mode9) 31 00 00 08 04 04 00 00 00 = Mode Speed Decrease– 31 00 00 08 04 03 00 00 00 = Mode Speed Increase++ 3D 00 00 08 00 00 00 00 00 = Link (Sync Bulb within 3 seconds of lightbulb socket power on) 3E 00 00 08 00 00 00 00 00 = UnLink (Clear Bulb within 3 seconds of lightbulb socket power on) Wifi Bridge iBox LED Lamp {COMMAND}s (Zone Number = 0×01) 31 00 00 00 03 03 00 00 00 = Wifi Bridge Lamp ON 31 00 00 00 03 04 00 00 00 = Wifi Bridge Lamp OFF 31 00 00 00 04 MO 00 00 00 = Mode Number (MO hex values 0×01 to 0×09 : examples: 01 = Mode1, 02 = Mode2, 03 = Mode3 .. 09 = Mode9) 31 00 00 00 03 01 00 00 00 = Mode Speed Decrease– 31 00 00 00 03 02 00 00 00 = Mode Speed Increase++ 31 00 00 00 01 BA BA BA BA = Set Color to Blue (BA) (FF = Red, D9 = Lavender, BA = Blue, 85 = Aqua, 7A = Green, 54 = Lime, 3B = Yellow, 1E = Orange) 31 00 00 00 03 04 00 00 00 = Set Color to White (is ignored when Lamp is OFF, it does NOT turn the Lamp ON) 31 00 00 00 02 BN 00 00 00 = BrightNess (BN hex values 0×00 to 0×64 : examples: 00 = 0%, 19 = 25%, 32 = 50%, 4B, = 75%, 64 = 100%) Valid List for {ZONE NUMBER} 0×00 All 0×01 Zone1 0×02 Zone2 0×03 Zone3 0×04 Zone4 Checksum: RGBW/WW/CW Checksum Byte Calculation is the sum of the last 11 bytes before end of the UDP packet. The checksum is then added to the end of the UDP message. e.g. SUM((31 00 00 08 04 01 00 00 00)(command) 01(zone) 00) = 3F(chksum) EXAMPLES LimitlessLED Wifi Bridge Light ON 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 00 03 03 00 00 00)(cmd) 01(zone) 00 38(chksum) UDP response: (88 00 00 00 03 00 SN 00) LimitlessLED Wifi Bridge Light OFF 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 00 03 04 00 00 00)(cmd) 01(zone) 00 39(chksum) UDP response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 1 ON 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 01 00 00 00)(cmd) 01(zone) 00 3F(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone1 OFF 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 02 00 00 00)(cmd) 01(zone) 00 40(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 2 ON 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 01 00 00 00)(cmd) 02(zone) 00 40(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone2 OFF 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 02 00 00 00)(cmd) 02(zone) 00 41(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 3 ON 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 01 00 00 00)(cmd) 03(zone) 00 41(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone3 OFF 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 02 00 00 00)(cmd) 03(zone) 00 42(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 4 ON 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 01 00 00 00)(cmd) 04(zone) 00 42(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone4 OFF 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 02 00 00 00)(cmd) 04(zone) 00 43(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW ZoneALL ON 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 01 00 00 00)(cmd) 00(zone) 00 3E(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW ZoneALLOFF 80 00 00 00 11 WB 00 00 SN 00 (31 00 00 08 04 02 00 00 00)(cmd) 00(zone) 00 3F(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 1 Link 80 00 00 00 11 WB 00 00 SN 00 (3D 00 00 08 00 00 00 00 00)(link cmd) 01(zone) 00 46(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 2 Link 80 00 00 00 11 WB 00 00 SN 00 (3D 00 00 08 00 00 00 00 00)(link cmd) 02(zone) 00 47(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 3 Link 80 00 00 00 11 WB 00 00 SN 00 (3D 00 00 08 00 00 00 00 00)(link cmd) 03(zone) 00 48(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 4 Link 80 00 00 00 11 WB 00 00 SN 00 (3D 00 00 08 00 00 00 00 00)(link cmd) 04(zone) 00 49(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 1 UnLink 80 00 00 00 11 WB 00 00 SN 00 (3E 00 00 08 00 00 00 00 00)(unlink cmd) 01(zone) 00 47(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 2 UnLink 80 00 00 00 11 WB 00 00 SN 00 (3E 00 00 08 00 00 00 00 00)(unlink cmd) 02(zone) 00 48(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 3 UnLink 80 00 00 00 11 WB 00 00 SN 00 (3E 00 00 08 00 00 00 00 00)(unlink cmd) 03(zone) 00 49(chksum) response: (88 00 00 00 03 00 SN 00) RGBW/WW/CW Zone 4 UnLink 80 00 00 00 11 WB 00 00 SN 00 (3E 00 00 08 00 00 00 00 00)(unlink cmd) 04(zone) 00 4A(chksum) response: (88 00 00 00 03 00 SN 00) Keep Alive Messages KEEP ALIVES (Every 5 seconds) Wifi Bridge 1: D0 00 00 00 02 (WB) 00 (response: D8 00 00 00 07 (AC CF 23 F5 7A D4) 01) KEEP ALIVES (Every 5 seconds) Wifi Bridge 1: D0 00 00 00 02 1D 00 (response: D8 00 00 00 07 (AC CF 23 F5 7A D4) 01) KEEP ALIVES (Every 5 seconds) Wifi Bridge 2: D0 00 00 00 02 7C 00 (response: D8 00 00 00 07 (AC CF 23 F5 7D 80) 01) Click Search for Devices: UDP.Send (255.255.255.255:5987) Bytes: 10 00 00 00 24 02 ee 3e 02 39 38 35 62 31 35 37 62 66 36 66 63 34 33 33 36 38 61 36 33 34 36 37 65 61 33 62 31 39 64 30 64 GET ALL WIFI BRIDGE CLOUD KEYS on LAN using UDP UDP.IP = “255.255.255.255″ UDP.port = 5987 UDP.SEND hex bytes: 10 00 00 00 0A 02 D3 E6 01 (AC CF 23 F5 7A D4)(MAC address) UDP.Response: 18 00 00 00 40 02 (AC CF 23 F5 7A D4)(mac) 00 20 (985b157bf6fc43368a63467ea3b19d0d)(ASCII Tokenkey) 01 00 01 17 63 00 00 05 00 09 (xlinkdev)(ASCII) 07 5B CD 15 UDP.SEND hex bytes: 20 00 00 00 16 02 62 3A D5 ED A301 AE 08 2D 46 61 41 A7 F6 DC AF D3 E6 00 00 1E UDP.Response: 28 00 00 00 11 00 02 (AC CF 23 F5 7A D4)(mac) 69 F0 3C 23 00 01 05 00 00 UDP.SEND hex bytes: D0 00 00 00 02 05(WB) 00 (response: D8 00 00 00 07 (AC CF 23 F5 7A D4) 01) example2: 10 00 00 00 0A 02 FE E7 01 (AC CF 23 F5 7A D4)(MAC address) example3: 10 00 00 00 0A 02 FE 51 01 (AC CF 23 F5 7D 80)(MAC address) Section 4. Smart Link Setup Services Warning only have one wifi bridge powered up at a time when setup using smart link (In case you have more than one in your home) Smart-link is all about getting your brand new wifi bridge onto your home wifi router network. SmartLink saves the user time during the setup phase, from having to switch to the bridge in the wifi settings to set it up. Instead it is done using a sync button underneath the Wifi Bridge v6 and an app. If you want to build smart-link into your own app. SMART LINK UDP port 49999 Default Password “8888″ UDP.IP = “10.1.1.255″ UDP.PORT = 49999 UDP.Send Whilst Waiting: 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 05 Section 5. Cloud Remote Internet access Services If you want to build an app that controls the lights over the internet, more information will be made available here. http://www.xlink.cn/ So that enterprises have the power of things. Cloud-to-cloud platform, easily and securely connected devices, rapid development of Internet of things applications, In the Internet of Things data extraction value. Default Cloud Server: Amazon Web Services Cloud ec2-52-63-118-215.ap-southeast-2.compute.amazonaws.com [52.63.118.215] cm2.xlink.cn Default Cloud Port: 23778 Cloud Server Login TCP.Send: 10 00 00 00 1A 02 4B 4B 59 DB 00 10 32 32 30 66 61 32 61 66 66 65 36 63 61 32 30 30 00 00 3C Cloud TCP.Read Login Response: 18 00 00 00 02 00 00 Cloud Keep Alive: TCP.Send: D0 00 00 00 00 Cloud Keep Alive: TCP.Read: D8 00 00 00 00 Cloud TCP sent: A0 00 00 00 07 69 F0 3D F3 00 0B 00 Cloud response: A8 00 00 00 13 69 F0 3D F3 00 0B 00 07 00 09 x l i n k d e v Cloud TCP sent: Cloud response: 6{“device_id”:1777352179,”type”:”offline”,”operator”:0}

ash-vd commented 7 years ago

This information, in a more readable way, can also be found here: http://www.limitlessled.com/dev/.

I will receive a new (v6) hub this week, I will look into it when I find the time.

duecedriver commented 7 years ago

Thanks... right now dead in the water!!

Hamish over at limitlessled is a developer with the mfg... and has been working with devs in the HA field helping them with the new api and writing sample scripts. Etc.. he can probably help as well..

ash-vd commented 7 years ago

I think this can be closed now, because of https://github.com/home-assistant/home-assistant/pull/5958.

granata79 commented 7 years ago

Hi there, I am getting crazy to develop the driver for Mi-Light in Lua code. Could you support me? Have you any details?

basvinken commented 7 years ago

@granata79 What do you need? I developed lua code for limitlessled v6 for my fibaro system.

granata79 commented 7 years ago

@basvinken I do not use Fibaro but a knx system which can be programmed in Lua. I open UDP socket but I do not understand the reason why when I cannot send the udp telegram in the correct way,

I mean that I am sending the 0x4c,0x69,0x6e,0x6b,0x5f,0x57,0x69,0x2d,0x46,0x69. It is part of the same char which I read with Wireshark when I command light using android app of Milight. I do not understand the reason why when I send commands by Milight Android app telegram lenght is 52 instead sending telegram (just string above) lenght is 60.

The problem is thay I should send further data but telegram will be longer. What is your thoughs?

granata79 commented 7 years ago

Thank you @basvinken

basvinken commented 7 years ago

@granata79 There's a huge difference between the api versions. Which version of the wifi bridge do you use ? Are you sure you use limitlessled? I don't recognize the hex code you use. All the information you need can be found on this page http://www.limitlessled.com/dev/

granata79 commented 7 years ago

@basvinken Did you use exact the same code shown in page http://www.limitlessled.com/dev/? I use milight system hence I think that limitlessled api is the same. Furthermore consider that openhab has a binding to integrate milight and instrution point out exactly to http://www.limitlessled.com/dev/. Have an exactract of lua code?

basvinken commented 7 years ago

@granata79 Yes milight and limitless are the same. You need a Wifi iBox Controller (which is version 6) to use my code. I attached an example that works for me. I hope it works for you as well.

local IP = 192.168.1.2 local Port = 5987 local ZoneID = string.char(0x01)

--List of Commands local Init = string.char (0x20,0x00,0x00,0x00,0x16,0x02,0x62,0x3A,0xD5,0xED,0xA3,0x01,0xAE,0x08,0x2D,0x46,0x61,0x41,0xA7,0xF6,0xDC,0xAF,0xFE,0xF7,0x00,0x00,0x1E) local Preample = string.char (0x80,0x00,0x00,0x00,0x11) local Filler = string.char (0x00) local On = string.char (0x31,0x00,0x00,0x08,0x04,0x01,0x00,0x00,0x00) local Off = string.char(0x31,0x00,0x00,0x08,0x04,0x02,0x00,0x00,0x00)

--Generate random Sequential Byte just helps with keeping commands in the correct order, and it helps to ignore duplicate packets already received. math.randomseed(os.time()) math.random(); math.random(); math.random() local RandomNumber = math.random(255) local SequentialByte = string.char(RandomNumber)

--Action local Command = On

--Send Init and wait for response local Response={} socket = Net.FUdpSocket() socket:setBroadcast(true) bytes, ErrorCode = socket:write (Init, IP, Port) if ErrorCode == 0 then local ResponseLength = 1 while (ErrorCode==0 and ResponseLength>0 and ResponseLength~=22) do Response, ErrorCode = socket:read() ResponseLength = string.len(Response) end end

--Extract data from UDP response local MAC = Response:sub(0x09,0x0E) local WifiBridgeSessionID1 = Response:sub(0x14,0x14) local WifiBridgeSessionID2 = Response:sub(0x15,0x15) local Payload = Preample..WifiBridgeSessionID1..WifiBridgeSessionID2..Filler..SequentialByte..Filler..Command..ZoneID..Filler local ChksumString = Payload:sub(0x0B)

--Calculate Checksum local i = 1 local Chksum = 0 while i <= ChksumString:len() do Number = ChksumString:sub(i,i) Chksum = Chksum + tonumber(Number:tohex(),16) i = i + 1 end --Calculate remainder Chksum%256 same as &0xFF Chksum = (Chksum - math.floor(Chksum/256)*256) local Chksumchar = string.char(Chksum) Payload = Payload..Chksumchar

Response={} bytes, ErrorCode = socket:write (Payload, IP, Port) if ErrorCode == 0 then local ResponseLength = 1 while (ErrorCode==0 and ResponseLength>0 and ResponseLength~=8) do Response, ErrorCode = socket:read() ResponseLength = string.len(Response) end end socket = nil

--Extract data from UDP response local Result = "" local ResultByte = Response:sub(0x08,0x08) local ResponseSequentialByte = Response:sub(0x07,0x07) if (ResponseSequentialByte==SequentialByte and ResultByte==Filler) then Result = "Successfull" else Result = "Failed" end

balloobbot commented 7 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

corneyl commented 7 years ago

Aren't v6 bridges already supported? See: https://home-assistant.io/components/light.limitlessled/

duecedriver commented 7 years ago

yes.. they are... in a limitied way.. NOW...

my original post was back in Dec.. and they were not

The code for limiltess/milight plugin to homebridge seems to be a more complete implementation than we are using here.

they support night light mode and some others...

there are still issues here when you have a mix of rgbw and the newer rgbww lights on the same AP as well as white only controllers.. only way around it at the moment is really to have more than one AP hub and segregate out the bulb types which is a PITA....

hopefully basvinkin can find some time to incorporate more fully the correct codebase for the newer bulbs and v6 features

Corbia commented 7 years ago

hello is there a vd for the fibero that works with v6 form milight ?

balloobbot commented 6 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment :+1:

dr-boss commented 6 years ago

This week I will finish test and I will publish on forum.fibaro.com or domotique-fibaro.fr the Fibaro HC2 VD for milight v6. in UDP version. I based on @basvinken code from 28 feb.

amelchio commented 6 years ago

I will close this now, please open a new issue if you have found an error in the current limitlessled support.