dotsam / homebridge-milight

MiLight/LimitlessLED/Easybulb Plugin for Homebridge
MIT License
63 stars 12 forks source link

New Milight controller #10

Closed cis2131 closed 7 years ago

cis2131 commented 7 years ago

Does this works with the new milight controller.

http://www.milight.com/milight-wifi-receiver-bridge-3-0-controller-box/

Claus

dotsam commented 7 years ago

Hi Claus,

The new controller will have to be supported by @mwittig in the node-milight-promise project. But it looks like they're already aware (https://github.com/mwittig/node-milight-promise/issues/7) so I will make any changes that might be required once that module is updated.

duecedriver commented 7 years ago

thanks.. same boat here.. just got a new v3 hub .. can you ping us when you push the update..

duecedriver commented 7 years ago

found the api for the v6 if it helps anyone on the limitlessled website

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}

zuroph commented 7 years ago

Hi guys, quite new to this, but set up homebridge today on my mac and after much playing with config managed to get it communicating properly with my iOs device on iOS 10. The homebridge works and connects, and the 2 milight zones show as named in the config, but don't appear to be linked to the actual lights/hub at all, and are unresponsive to home app commands. Have I done something wrong, or is it just because this new wifi iBox light isn't supported yet?

dotsam commented 7 years ago

@zuroph Yes, since the protocol for the v5 and below bridge is completely 1-way, there is nothing in the plugin to fail if it's not talking to the right bridge. It's just blasting UDP out with no expectation of getting anything back.

Keep an eye on the node-milight-promise issue I mentioned earlier for updates on the underlying library being updated to support the new bridge, and I'll hopefully be able to update this homebridge plugin shortly afterwards.

dotsam commented 7 years ago

Initial support for the new bridge is now in node-milight-promise, so I have this in my dev branch now. That code isn't final/published yet however, so I'm going to hold off on pushing these changes to npm just yet. To test out these changes, please update the plugin with the command npm install -g git+https://github.com/dotsam/homebridge-milight.git#dev

Please leave me any feedback here, and if there are any bugs, we can determine if it's a problem with this code or the node-milight-promise library.

zuroph commented 7 years ago

maybe I'm making a massive noob error here, but when I try to install from the above I'm getting an error..

npm ERR! git rev-list -n1 dev: fatal: ambiguous argument 'dev': unknown revision or path not in the working tree.

dotsam commented 7 years ago

Sorry @zuroph, had the wrong URL in there. I've edited my comment to have the correct URL, can you try it now?

I also failed to mention that you'll need to set the "version" key in the config, and the type to "fullColor" if you have the new bulbs. It's written up in the updated readme: https://github.com/dotsam/homebridge-milight/blob/dev/README.md#configuration

zuroph commented 7 years ago

ok, trying now. updated config file and installed using above address. on launch home bridge I get

Unhandled rejection Error: getaddrinfo ENOTFOUND 192.168.0.101/24 at errnoException (dns.js:28:10) at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)

dotsam commented 7 years ago

@zuroph Can you post your config here? Do you have 192.168.0.101/24 as the ip_address in the config? If so, you shouldn't have the CIDR notation in the config file, and I think the error here is from something trying to do a DNS lookup on that string as it doesn't see it as a plain IP address.

zuroph commented 7 years ago

spot on, edited the "/24" out and took out another troublesome accessory from config, and had first successful launch, and switched a lamp on and off.

I have what I think are the older type bulb, so left the bulb value to RGBW in config.

First crash was during attempt to edit the colour choices in Home App.

TypeError: commands[this.type].hsvToMilightColor is not a function at MiLightAccessory.setHue (/usr/local/lib/node_modules/homebridge-milight/index.js:226:75) at emitMany (events.js:127:13) at emit (events.js:201:7) at Characteristic.setValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:155:10) at Bridge. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:740:22) at Array.forEach (native) at Bridge.Accessory._handleSetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:685:8) at emitMany (events.js:127:13) at HAPServer.emit (events.js:201:7) at HAPServer._handleCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:972:10) at HAPServer. (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/HAPServer.js:209:39) at emitNone (events.js:86:13) at IncomingMessage.emit (events.js:185:7) at endReadableNT (_stream_readable.js:974:12) at _combinedTickCallback (internal/process/next_tick.js:74:11) at process._tickCallback (internal/process/next_tick.js:98:9)

FYI, here's my config

{ "bridge": { "name": "Homebridge", "username": "CC:22:3D:E3:CE:31", "port": 51826, "pin": "031-45-154" },

      "platforms": [
    {
      "platform":"MiLight",
      "name":"MiLight",
      "bridges": [
        {
          "ip_address": "192.168.0.101",
          "type": "rgbw",
          "version": "v6",
          "zones": ["Kitchen","Sittingroom"],
          "repeat": 1,
          "delay": 30
        }]

} ] }

mwittig commented 7 years ago

@dotsam Sorry, my fault. I have removed hsvToMilightColor without documenting it. I will put it back in as part of helper.js. See README for details.

Note beyond, rgb lights are not yet supported. I'll try to figure out what the control sequences are if v6 bridge supports. It is not described on the web site and elsewhere.

mwittig commented 7 years ago

Note, there are also some subtle differences in the command layout. For v6, all commands requires the zone id as first parameter! For the the future, I am planning to add a simpler API, something like a zone controller.

dnewton1133 commented 7 years ago

@mwittig - I've been trialling the dev milight plugin against both my old v4 bridge and my new v6. A few issues to note:

  1. When including both bridges in my config file, (v4 first, v6 second) - the lights controlled by the v4 bridge (RGBW) don't operate, yet they show in the Home app. When v6 is removed from the config file, the v4 bridge works fine.

  2. Colour changing on the v6 (when configured with the v4 included in config file) is very hit and miss. Colours change 1 in every 6 or more changes.

  3. Finally, the v6 bridge includes all bulb types and I have some old White lights installed on it as well. What's the correct way to setup the config to control those as well as the FullColor lights?

Config file extract below:

{ "platform": "MiLight", "name": "MiLight", "bridges": [ { "ip_address": "101.1.1.XX", "type": "rgbw", "zones": ["B light","Bedroom",null,null], "repeat": 5, "delay": 28 }, { "ip_address": "101.1.1.XXX", "type": "fullColor", "version": "v6", "zones": ["Kitchen 1","Kitchen 2","Lounge Lamps",null], "repeat": 3, "delay": 28 }

                  ]
    }
AlexNoop commented 7 years ago

Hello, I would like test the dev version, but I can not install it ...

Npm automatically installs version 0.1.3...

see :

pi@raspberrypi:~/.homebridge $ sudo npm install -g git+https://github.com/dotsam/homebridge-milight.git#dev
/usr/lib
homebridge-milight@0.1.3  (git+https://github.com/dotsam/homebridge-milight.git#116cb59a759ee34f84165d4cd454a31bd777f84c)
node-milight-promise@0.0.9  (git+https://github.com/mwittig/node-milight-promise.git#2f2250daf612e577057f77404d9688e0c507851f)

Can you help me please ? Thanks ^^

dotsam commented 7 years ago

@dnewton1133:

  1. This is a bug I'm working on right now, should be fixed shortly
  2. This may be related to the first problem. I'll have you re-test after I've pushed the fix
  3. You'll define two bridges, both with the same IP and both as version v6, but set one type as fullColor and the other as white.

@AlexNoop You are in fact installing the dev version, as seen by the git commit IDs in the output. Neither this plugin or the node-milight-promise module have upped the version numbers in the development version, so they'll still show as 0.1.3 and 0.0.9 respectively.

dotsam commented 7 years ago

@dnewton1133 If you install again from the git URL, then you should get the fix for multiple bridge types in the same config. Can you test it out and let me know if it's working for you?

AlexNoop commented 7 years ago

@dotsam Hello, thank you very much, it works great! However, the colors do not match ... for example, when I select the blue color on the home application, my light bulbs turn pink ... similar when I select a white temperature, my light bulbs select a random color.

Furthermore,

Will you implement a accessory for the bridge lamp like a bulb?

Also a button for night mode?

Thank you for all, for your superb work! ^^

AlexNoop commented 7 years ago

If I can help, do not hesitate (I do not know how to code) =D

mwittig commented 7 years ago

@AlexNoop wrote:

... However, the colors do not match ... for example, when I select the blue color on the home application, my light bulbs turn pink ... similar when I select a white temperature, my light bulbs select a random color.

@dotsam See my note on the color model of the v6 bridge - https://github.com/mwittig/node-milight-promise#color-model. Enabling the transformation by passing true as the second actual parameter to the hue command should do the trick.


this.light.sendCommands(commands.rgbw.hue(commands.rgbw.hsvToMilightColor(hue), true))
//                                                                               ^^^
dotsam commented 7 years ago

Thanks @mwittig, I am doing that as seen here so I'm not sure why @AlexNoop is seeing this odd behaviour.

@AlexNoop can give me the output of running npm -g list homebridge-milight to confirm you're running code pushed after I made the changes yesterday? The bridge light should be fairly simple to add, so yes, I'll try and get that done today or tomorrow. Also, night mode is implemented when brightness <= 5%. I don't think there's a standard way to add a button for this that will work well with all Homekit apps and Siri as well.

dnewton1133 commented 7 years ago

I've now had the chance to test the latest version as well and the changes you've made have worked - so thanks for making them so quickly.

There was a minor issue that some of the v6 fullColor lamps re-booted and needed re-pairing to the bridge on the first interaction after installing the new code (the MR16s I have) however since then the on/off interaction, dimming etc works perfectly.

I'm also experiencing the same colour issues as AlexNoop though. No real pattern that I can find as to where in the colour spectrum the lights will actually end up when I press colours - it's just not what I'm selecting.

@dotsam, as requested, here's the npm output for you to check I have the right version of your code pulled......

npm -g list homebridge-milight /usr/local/lib └── homebridge-milight@0.1.3 (git+https://github.com/dotsam/homebridge-milight.git#07f785a7df78437c666d74f1b9f6b0812fdeb2f8)

dotsam commented 7 years ago

@dnewton1133 @AlexNoop Strange. I've just pushed a change with @mwittig's colour wheel correction code disabled. Can you do the npm install from the git repo again and see if that's now the correct behaviour?

reedm commented 7 years ago

@dotsam From what I can tell, the hsvToMilightColor function from @mwittig doesn't match what I'm seeing on limitless.com/dev documentation. The transformation should indeed switch from 360 to 255, but red is not at 176, but instead at 255.

I replaced the hsvToMilightColor return in helper.js

return (256 + 176 - Math.floor(Number(hsv[0]) / 360.0 * 255.0)) % 256;

with

return (Math.floor(Number(hsv[0]) / 360.0 * 255.0)) % 256;

which seemed to work.

Separately from the hue discussion, saturation control, seems inverted. It can also become erratic in nature, possibly related to white modes. "Color temperature" (for white) remains totally off-base in my experience as well...

mwittig commented 7 years ago

@reedm Are you referring to new full color RGB WW/CW bulbs?

Note, the different bulb types RGBW, bridge light, RGB WW/CW have different color circles. The limitless.com/dev documentation does not match for RGBW and bridgle lights according to my findings. I haven't been able to test with RGB WW/CW yet.

mwittig commented 7 years ago

I have received a RGB WW/CW bulb, today. So, I am now in the position to do testing for full color as well. As supstected ealier some bulbs do not seem to be callibrated properly. Mine shows red at 0x08 instead of 0x00 / 0xFF where it shows magenta.

Regarding saturation I can confirm the value Milight value is inverted to what you'd expect. The maximum saturation is 0 instead of 100. The milight app is showing the same behavior, at 100% the color is almost white. I am not yet sure on how I am going to fix that. Perhaps, I should invert the value by default.

dnewton1133 commented 7 years ago

Still doing some testing to see if the colours have improved, however one strange behaviour I'm seeing is that after re-starting homebridge and interacting with the devices for a short period of time (say 15 mins) the milight plugin seems to stop working/responding. A reboot sorts it out, however it's consistently stopping the same amount of time after each reboot.

The Milight app still woks, so I know it's not the the wifi bridge that's erred. Anyone else seeing this behaviour?

reedm commented 7 years ago

@dnewton1133 I'm seeing the same. It just stops working and a reboot is required. I'll add that this seems to only affect the new v6 bridge, not the older bridge.

@dotsam It looks like @mwittig has added whiteTemperature() as well!

mwittig commented 7 years ago

@dnewton1133 @reedm Thanks for the notice!

Note, interaction with a Milight bridge happens in the context of a session which needs to be established first. Unfortunately, the available documentation does not tell much about the bridge session lifecycle and how keep alive message are related to this. Personally, I don't like the idea of sending keep-alives every 5 seconds. I'll add a strategy to re-establish a sessions soon.

dotsam commented 7 years ago

I've reverted the last change that tried to disable the colour wheel correction now that it's properly implemented for rgbw bulbs.

I'm going to go ahead and push the dev branch live as there are other helpful changes in it, and the bugs still present will mostly be resolved in @mwittig's library.

@reedm As for the white colour temperature, I'm going to have to see how well this is supported by Homekit. I know the Home app has a separate colour wheel for colour temperature, but it still sends "change hue" commands, so I'll have to see how this can be managed.

dotsam commented 7 years ago

Hello All,

I've fixed an error today that I had actually been making for a long time (one bridge connection/object being created per bulb type to the same bridge when there should have only been one connection with just the commands sent differing) which I think could have also been contributing to the issues with the v6 bridge if you had multiple entries configured for multiple bulb types. Can you update to the latest version of the plugin from npm, check the README for the new config syntax, and let me know if controlling the v6 bulbs works any better now?

reedm commented 7 years ago

@dotsam I installed the latest version from npm and updated my config.json to match, but the problem persists. After ~ 15 minutes, the bulbs stop responding without a restart. This does seem like an issue with sessions closing after some pre-determined amount of time.

As far as color temperature, it sounds like "Color Temperature" is often a custom characteristic, which not all HomeKit apps support. There's an enhancement over on homebridge-hue for this too: https://github.com/ebaauw/homebridge-hue/issues/35

dnewton1133 commented 7 years ago

@dotsam - I've also had the chance to install the latest version now and am experiencing the same issue as @reedm. The new config syntax works fine, colours seem to have improved a lot so all in all a good step forward.

Just need to resolve the session closing issue now

lipdila commented 7 years ago

Hello, I've a Problem with my MiLight WIFI Bridge 3.0 (with intigrated light) and my two "rgbw" lights. With the original Miligt 3.0 App, everythins works fine. In Zone 1 is my First bulb/light in Zone 2 is my Second bulb/light. I can turn on/off the bulbs, also I can Switch the Colours. Everything works fine... I used the second Layout in the App, to connect my bulbs/lights.

Now I installed the Last Version of your homebridge-milight 0.1.6 and in Apples HOME App I've see my two configured bulbs/lights. Looks good until now. But when I try to turn off or on a bulb, nothing's happened!? In homebridge I see the right command for turn off / turn on. As well as color changing!?

Can everyone helps me? What's wrong?!

Here is my actual config: ..... "platforms": [ { "platform":"MiLight", "name":"MiLight", "bridges": [ { "ip_address": "192.168.2.100", "version": "v6", "lights": {"rgbw": ["Zone1","Zone2",null,null]}, "repeat": 1, "delay": 30 } ] } ] ....

mwittig commented 7 years ago

@lipdila You're using a configuration for Milight v6 with your MiLight WIFI Bridge 3.0. Milight v6 is a new generation of the bridge with a different command layout which is not compatibly with your bridge model. Simply remove the "version" property from the config and it should work fine.

lipdila commented 7 years ago

I've tried, but the same problem...nothing happens!?

My bridge is this: http://www.milight.com/milight-wifi-receiver-bridge-3-0-controller-box/

I thought it's v6!?

Other ideas what I do wrong!?

mwittig commented 7 years ago

@lipdila I am sorry. I've been mistaken by the product name. You're right it is v6, so it must be set as part of the config.

lipdila commented 7 years ago

Ok, I've change the config and add version "v6". But my Problem is the same?! Everyone an idea, whats wrong?

zuroph commented 7 years ago

how about the rest of your config? I had this when updating the plug in. I removed the home bridge from the home app, then force quite app. quit homebridge on computer. updated the "username" for the home bridge in the config file (change the last two digits to anything else). restart home bridge, and then go through the add process in home app again, issue resolved.

lipdila commented 7 years ago

I've did everything what you told. I removed the home bridge from my Home in the home app, forced quit the app, also home bridge on my raspberry pi. updated the config file (username, last 2 digits) and restarted the raspberry pi and so the home bridge. After this done, I added the new home bridge in my home app...but the result is the same :( nothing works...

Here is my complete config, maybe this helps to find my error:

{ "bridge": { "name": "Homebridge", "username": "CD:21:3D:E3:CE:12", "port": 51826, "pin": "011-17-238" },

"platforms": [
    {
        "platform": "homebridge-fhem.FHEM",
        "name": "FHEM",
        "server": "127.0.0.1",
        "port": "8083",
        "auth": {"user": „myhome“, "pass": "5hd3u3j_34FFF3"},
        "filter": "room=Badezimmer"
    },
    {
        "platform": "homebridge-fhem.FHEM",
        "name": "FHEM",
        "server": "127.0.0.1",
        "port": "8083",
        "auth": {"user": "myhome", "pass": "5hd3u3j_34FFF3"},
        "filter": "room=Kinderzimmer"
    },
    {
        "platform": "homebridge-fhem.FHEM",
        "name": "FHEM",
        "server": "127.0.0.1",
        "port": "8083",
        "auth": {"user": "myhome", "pass": "5hd3u3j_34FFF3"},
        "filter": "room=Wohnküche"
    },
    {
        "platform": "homebridge-fhem.FHEM",
        "name": "FHEM",
        "server": "127.0.0.1",
        "port": "8083",
        "auth": {"user": "myhome", "pass": "5hd3u3j_34FFF3"},
        "filter": "room=Schlafzimmer"
    },
   {
        "platform": "homebridge-fhem.FHEM",
        "name": "FHEM",
        "server": "127.0.0.1",
        "port": "8083",
        "auth": {"user": "myhome", "pass": „5hd3u3j_34FFF3“},
        "filter": "room=Flur"
    },
   {
    "platform": "Camera-ffmpeg",
    "cameras": [
        {
        "name": "Überwachungskamera",
        "videoConfig": {
        "source": "-re -i http://192.168.2.111:8081",
        "stillImageSource": "-i http://192.168.2.111:8765/picture/1/current/?_username=admin&_signature=83f3dej64102e87320a59f01246111e3d29b61998",
        "maxStreams": 2,
        "maxWidth": 1280,
        "maxHeight": 720,
        "maxFPS": 30
                }
        }
        ]
},
   {
    "platform":"MiLight",
        "name":"MiLight",
        "bridges": [
            {
        "ip_address": "192.168.2.100",
        "version": "v6",
        "lights": {"rgbw": ["Zone1","Zone2",null,null]},
        "repeat": 1,
        "delay": 30
            }
           ]
},
{
        "platform": "People",
        "threshold" : 15,
        "anyoneSensor" : true,
        "nooneSensor" : true,
        "webhookPort": 51828,
        "cacheDirectory": "./.node-persist/storage",
        "pingInterval": 10000,
        "ignoreReEnterExitSeconds": 0,
        "people" : [
                {
                "name" : „lipdila“, 
                "target" : "192.168.2.92“,
                "threshold" : 15,
                "pingInterval": 10000,
                "ignoreReEnterExitSeconds": 0
                },
                {
                "name" : „Micky“, 
                "target" : "192.168.2.85“,
                "threshold" : 15,
                "pingInterval": 10000,
                "ignoreReEnterExitSeconds": 0
                }
    ]
    },
{
    "platform": "AmazonDash",
    "buttons": [
        {
            "name": "Button",
            "mac": "ac:63:ae:15:ad:f1"
        }  ]
}
],

"accessories": [

{ "accessory": "Computer", "name": "Homeserver", "mac": „4C:07:54:FF:99:53“, "ip": "192.168.2.1", "pingInterval": 45, "wakeGraceTime": 90, "shutdownGraceTime": 15, "shutdownCommand": "sshpass -p '5hd3u3j_34FFF3' ssh -oStrictHostKeyChecking=no admin@192.168.2.1 sudo shutdown -s now" } ] }

lipdila commented 7 years ago

Here's also my settings from the milight bridge: bildschirmfoto 2017-01-12 um 12 52 26 bildschirmfoto 2017-01-12 um 12 53 08

Maybe there's somting wrong?! Version, Ports,...!?

lipdila commented 7 years ago

Everyone any idea what's wrong in my case? I despair slowly but surely :-(

samsonrosen commented 7 years ago

It took me a bit of trial and error to get mine working with similar errors.

I had my bulbs labelled as fullColor when they were actually RGBW so it might be worth switching the bulb types incase they are not actually RGBW? Also I ditched the 'nulls' so my config looks like this:

{ "platform": "MiLight", "name": "MiLight", "bridges": [ { "ip_address": "255.255.255.255", "version": "v6", "lights": {"rgbw": ["Light", "Lamp"]}, "repeat": 1, "delay": 30 }

mlinzner commented 7 years ago

@dotsam I can see the same issue as @reedm and @dnewton1133 have described. Controlling the lights works perfectly fine until a point where they no longer respond at all and a homebridge restart is necessary. Will make some additional tests and check if I can track it down. I'm happy to provide any useful data to track that down.

lipdila commented 7 years ago

Some glass of wine and i solved my problem :)

I only changed my value for delay from 30 to 300. Now I can control my bulbs !? ... { "platform":"MiLight", "name":"MiLight", "bridges": [ { "ip_address": "192.168.2.100", "version": "v6", "lights": {"rgbw": ["Zone1","Zone2"]}, "repeat": 1, "delay": 300 }] }, ...

dotsam commented 7 years ago

Just to make sure everyone is on the same page, @mwittig is working on session management in the node-milight-promise library now, which should let long-running plugins/programs like this continue working past the 10 minute session timeout.

mwittig commented 7 years ago

@dotsam Fyi, I have implemented basic session handling which creates a new session periodically (every 5 mins). This should solve the "stops working after ~10mins" issue for most users.

I am planning to further ellaborate on this to handle various error cases, e.g. "bridge had been unreachable" for some time and "error response received from bridge". I am also experimenting with "keep-alive" which is part of the Milight protocol but not documented well as such.

duecedriver commented 7 years ago

can someone walk me through the status of limitlessly v6 support...

was this inclued in the 36.1 update? if not... what is the walkthrough to install the required components .. kind make it noobproof!! hehe for ubuntu

lastly I have a mix of 2ch strip controllers, rgbw, and the new rgbww bulbs...

so how it the yaml configured for these new v6 bridges?

thanks

samsonrosen commented 7 years ago

Thanks @mwittig this has totally resolved my connectivity issues!

zuroph commented 7 years ago

looking great with latest updates!

interesting little bug, changing hue of bulb only works at 100% brightness.

IE 1) I have the light at 100% brightness, white. 2) I tell siri dim the light to 25% brightness, it works 3) I tell siri to turn the bulb blue, instead the bulb returns to 100% white 4) I tell siri again to turn the light blue, it works.