Bluebie / homebridge-miio

Xiaomi Mi Home Plugin for Homebridge
112 stars 26 forks source link

plugin conflict with yeelight and homebridge-aqara? #2

Closed astrojetson8 closed 7 years ago

astrojetson8 commented 7 years ago

please ignore my previous thread.

I suspect your plugin is clashing with yeelight plugin and gateway. just earlier, i couldn't even control few bulbs via yeelight app (weird) and i hate to reset them. I have also tested the scenario whereby I had all bulbs on and zigbee switch on, and as well as v2 plug on, and it still didn't work

The gateway is on China server, and Lights are using Singapore server.

My error log file: [3/28/2017, 11:17:30 AM] Loaded plugin: homebridge-aqara [3/28/2017, 11:17:30 AM] Registering platform 'homebridge-aqara.AqaraPlatform' [3/28/2017, 11:17:30 AM] --- [3/28/2017, 11:17:30 AM] Loaded plugin: homebridge-miio homebridge API version: 2.1 [3/28/2017, 11:17:30 AM] Registering platform 'homebridge-miio.XiaomiMiio' [3/28/2017, 11:17:30 AM] --- [3/28/2017, 11:17:30 AM] Loaded plugin: homebridge-yeelight [3/28/2017, 11:17:30 AM] Registering platform 'homebridge-yeelight.yeelight' [3/28/2017, 11:17:30 AM] --- [3/28/2017, 11:17:30 AM] Loaded config.json with 0 accessories and 3 platforms. [3/28/2017, 11:17:30 AM] --- [3/28/2017, 11:17:30 AM] Loading 3 platforms... [3/28/2017, 11:17:30 AM] [yeelight] Initializing yeelight platform... [3/28/2017, 11:17:30 AM] [yeelight] YeePlatform Init [3/28/2017, 11:17:30 AM] Initializing AqaraPlatform platform... [3/28/2017, 11:17:30 AM] [XiaomiMiio] Initializing XiaomiMiio platform... [3/28/2017, 11:17:30 AM] [XiaomiMiio] Setting up Miio platform [3/28/2017, 11:17:30 AM] Loading 0 accessories... Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ redacted│     
└────────────┘     

[3/28/2017, 11:17:30 AM] [yeelight] DidFinishLaunching [3/28/2017, 11:17:30 AM] [XiaomiMiio] DidFinishLaunching [3/28/2017, 11:17:30 AM] Homebridge is running on port 51826. add to multicast group listen on 0.0.0.0 no did or loc found! [3/28/2017, 11:17:30 AM] [XiaomiMiio] Investigating Miio device at udp://lumi-gateway-v3_miio52051385.local.:54321 [3/28/2017, 11:17:30 AM] [XiaomiMiio] Miio Accessory detected: 52051385 events.js:160 throw er; // Unhandled 'error' event ^

ReferenceError: accessory is not defined at XiaomiMiio.addAccessory (/usr/local/lib/node_modules/homebridge-miio/index.js:237:3) at Browser.browser.on (/usr/local/lib/node_modules/homebridge-miio/index.js:45:16) at emitTwo (events.js:106:13) at Browser.emit (events.js:191:7) at on_resolver_done (/usr/local/lib/node_modules/mdns/lib/browser.js:31:14) at next (/usr/local/lib/node_modules/mdns/lib/browser.js:104:7) at Array.makeAddressesUnique (/usr/local/lib/node_modules/mdns/lib/resolver_sequence_tasks.js:177:5) at next (/usr/local/lib/node_modules/mdns/lib/browser.js:107:21) at MDNSService.on_get_addr_info_done (/usr/local/lib/node_modules/mdns/lib/resolver_sequence_tasks.js:83:15) at SocketWatcher.MDNSService.self.watcher.callback (/usr/local/lib/node_modules/mdns/lib/mdns_service.js:18:40)

My config file (I've redacted credentials, and other data) { "bridge": { "name": "HomeBridge", "username": "redacted", "port": 51826, "pin": "redacted" },

"accessories": [],

"platforms": [
    {
        "platform" : "yeelight",
        "name" : "yeelight"
    },
    {
        "platform" : "AqaraPlatform",
        "sid" : ["redacted"],
        "fakeLightBulbForLightSwitch": true,
        "password": ["redacted"]
     },
     {
        "platform" : "XiaomiMiio",
        "name" : "XiaomiMiio",
        "pollChanges": true,
        "pollInterval": 15
     }
]

}

Bluebie commented 7 years ago

That error describes a straight up bug. I didn't test things adequately. If you install the new version of homebridge-miio, you might have more luck. This plugin only operates over the LAN, so it wont matter what server your devices are on. Let me know how it goes? I don't have any of these other kinds of miio devices to experiment with yet.

astrojetson8 commented 7 years ago

Thanks for getting back to me!

From what I can gather from below, looks like plug did initialise but your plugin along with yeelight are trying to add yeelights. also, I had bunch of Home icons with appear in Home with not supported message. yeelight plugin https://github.com/vvpossible/homebridge_yeelight are

Timestamp A/R Flags if Domain Service Type Instance Name 16:10:21.677 Add 3 4 local. _miio._udp. chuangmi-plug-m1_miio50259675 16:10:21.677 Add 3 4 local. _miio._udp. yeelink-light-color1_miio53882119 16:10:21.677 Add 3 4 local. _miio._udp. yeelink-light-color1_miio53852297 16:10:21.677 Add 3 4 local. _miio._udp. yeelink-light-strip1_miio52079493 16:10:21.677 Add 3 4 local. _miio._udp. yeelink-light-color1_miio53882900 16:10:21.677 Add 3 4 local. _miio._udp. yeelink-light-strip1_miio52080409 16:10:21.677 Add 3 4 local. _miio._udp. lumi-gateway-v3_miio52051385 16:10:21.677 Add 2 4 local. _miio._udp. yeelink-light-color1_miio54989566

Error log: [3/28/2017, 4:08:33 PM] Loaded plugin: homebridge-aqara [3/28/2017, 4:08:33 PM] Registering platform 'homebridge-aqara.AqaraPlatform' [3/28/2017, 4:08:33 PM] --- [3/28/2017, 4:08:33 PM] Loaded plugin: homebridge-miio homebridge API version: 2.1 [3/28/2017, 4:08:33 PM] Registering platform 'homebridge-miio.XiaomiMiio' [3/28/2017, 4:08:33 PM] --- [3/28/2017, 4:08:33 PM] Loaded plugin: homebridge-yeelight [3/28/2017, 4:08:33 PM] Registering platform 'homebridge-yeelight.yeelight' [3/28/2017, 4:08:33 PM] --- [3/28/2017, 4:08:33 PM] Loaded config.json with 0 accessories and 3 platforms. [3/28/2017, 4:08:33 PM] --- [3/28/2017, 4:08:33 PM] Loading 3 platforms... [3/28/2017, 4:08:33 PM] [yeelight] Initializing yeelight platform... [3/28/2017, 4:08:33 PM] [yeelight] YeePlatform Init [3/28/2017, 4:08:33 PM] Initializing AqaraPlatform platform... [3/28/2017, 4:08:33 PM] [XiaomiMiio] Initializing XiaomiMiio platform... [3/28/2017, 4:08:33 PM] [XiaomiMiio] Setting up Miio platform Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

┌────────────┐     
│ XXXXX│     
└────────────┘     

[3/28/2017, 4:08:33 PM] [yeelight] DidFinishLaunching [3/28/2017, 4:08:33 PM] [XiaomiMiio] DidFinishLaunching [3/28/2017, 4:08:33 PM] Homebridge is running on port 51826. add to multicast group listen on 0.0.0.0 no did or loc found! [3/28/2017, 4:08:33 PM] [XiaomiMiio] Investigating Miio device at udp://chuangmi-plug-m1_miio50259675.local.:54321 [3/28/2017, 4:08:33 PM] [XiaomiMiio] Miio Accessory detected: 50259675 [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x00000000034712fe [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x000000000335b889 already in device list! [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x0000000003362d07 already in device list! [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x0000000002f5f23d already in device list! already in device list! [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x00000000031aaf19 already in device list! [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x0000000003363014 already in device list! [3/28/2017, 4:08:34 PM] [yeelight] cached accessory: 0x00000000031aab85 already in device list! connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x00000000034712fe true connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x000000000335b889 true connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x0000000003362d07 true connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x0000000002f5f23d true connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x0000000003363014 true connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x00000000031aaf19 true connect ok! [3/28/2017, 4:08:34 PM] [yeelight] accesseory reachable [3/28/2017, 4:08:34 PM] [yeelight] dev connected 0x00000000031aab85 true [3/28/2017, 4:08:34 PM] [XiaomiMiio] Investigating Miio device at udp://yeelink-light-color1_miio53882119.local.:54321 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Miio Accessory detected: 53882119 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Investigating Miio device at udp://yeelink-light-color1_miio53852297.local.:54321 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Miio Accessory detected: 53852297 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Investigating Miio device at udp://yeelink-light-strip1_miio52079493.local.:54321 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Miio Accessory detected: 52079493 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Investigating Miio device at udp://yeelink-light-color1_miio53882900.local.:54321 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Miio Accessory detected: 53882900 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Investigating Miio device at udp://yeelink-light-strip1_miio52080409.local.:54321 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Miio Accessory detected: 52080409 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Investigating Miio device at udp://lumi-gateway-v3_miio52051385.local.:54321 [3/28/2017, 4:08:34 PM] [XiaomiMiio] Miio Accessory detected: 52051385 [3/28/2017, 4:08:35 PM] [XiaomiMiio] Investigating Miio device at udp://yeelink-light-color1_miio54989566.local.:54321 [3/28/2017, 4:08:35 PM] [XiaomiMiio] Miio Accessory detected: 54989566 [3/28/2017, 4:08:38 PM] [XiaomiMiio] Miio device unreachable during setup: yeelink-light-color1_miio53882900.local. Error: Timeout at Timeout.send [as _onTimeout] (/usr/local/lib/node_modules/miio/device.js:133:13) at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5) [3/28/2017, 4:08:38 PM] [XiaomiMiio] Miio device unreachable during setup: yeelink-light-strip1_miio52080409.local. Error: Timeout at Timeout.send [as _onTimeout] (/usr/local/lib/node_modules/miio/device.js:133:13) at ontimeout (timers.js:365:14) at tryOnTimeout (timers.js:237:5) at Timer.listOnTimeout (timers.js:207:5)

Bluebie commented 7 years ago

I've pushed version 0.1.0 to npm. If you install this update and restart homebridge, homebridge-miio should automatically remove all the unsupported devices it had added, and leave only the power plug devices. It shouldn't make any network contact with unsupported devices beyond a simple MDNS query to find out their name, so hopefully it wont affect your yeelights anymore. It should also be more reliable. Can you confirm this works?

astrojetson8 commented 7 years ago

@Bluebie

brilliant, and great job! and thank you! the current property is a switch, and shouldn't this be an outlet?

do let me know if you want me to QA future release with other accessories. i've following:

Bluebie commented 7 years ago

You're right! It should be an outlet. I don't think we can implement the OutletInUse characteristic though. I'll have a play, and maybe just hard code OutletInUse to true, since, well, that's less likely to cause problems than false, I think.

I've been thinking of getting some yeelights in the future. What do you think of them? I currently have some LIFX, but they're the friggin worst. Not sure if they should be implemented in this library, since there's already a yeelight plugin for homekit. Maybe it's worth merging the functionality in?

As for hub stuff, I haven't seen anyone figure out the protocol stuff for talking to the bridged accessories on those things, so that might not happen for a while. The author of the miio npm library which this uses, has done some MITM stuff to figure out how the phone apps talk to the device they have, so it should be possible, I think, or perhaps via reverse decompiling the Xiaomi mobile apps. Xiaomi has an official SDK for android I think, but it's not open source.

astrojetson8 commented 7 years ago

there's a plugin for aqara aka hub. i believe the author of following plugin is using lumi's API. https://github.com/snOOrz/homebridge-aqara http://lumiunited.com/ this plugin has the issue you mentioned above.

for current yeelight plugin, you need to enable dev mode within the app. maybe leave it out as they are officially supporting this? or work with them to add it in here.

lot of xiaomi branded stuff is actually from other companies that are under xiaomi ecosystems like yeelight, lumi, etc.

i got few of yeelight bulbs. they are great for small rooms as they are rated 600 lumens. they are looking to release new products with higher lumens later in the year. i do like the build quality, and aesthetics of the yeelight bulbs. plus, they are around ~$20 shipped. yeelight lamp (not xiaomi) is really great looking, and it cost around ~$60 shipped. i really like form and function of their lamp.

looks like they have new wi-fi power strip coming soon: www.chingmi.com/#main

bluefoxlee commented 7 years ago

@astrojetson8 is this plugin within Xiaomi wi-fi power strip you mentioned?

And ChingMi wifi power strip (with our without USB) has been sell at China for awhile.

astrojetson8 commented 7 years ago

@bluefoxlee no, it doesn't. looks like this power strip is made by zimi.

ChingMi wifi power strip looks pretty interesting. I couldn't find any details in English. If you've any details feel free to share...

astrojetson8 commented 7 years ago

@Bluebie with your plugin this little ~$15 plug goes from being just a good option to a great and must have!!! thank you!!!!!

I updated the new plugin. I did so after killing homebridge. And after the update, when I first launched homebridge I got an error as per below.

I relaunched homebridge, and it's working fine now.

Thanks for changing the property name to Outlet . Outlet In Use value is Yes regardless, and I don't know if this can't be properly reflected based on similar issue with zigbee plugs.

For future release, is it possible to provide persistent names for plugs via config? I had an issue with other plugin whereby names would default to default names and room. Few others had similar issues with other plugin. 10.3 seems to have resolved the update. Earlier, it happened to me with your plugin. I suspect the update may have done that or sync issues with my iphone and other iOS devices.

/usr/local/lib/node_modules/homebridge-miio/index.js:72
    if (accessory.context.features.switchPlug) queries.push("power");
                 ^

TypeError: Cannot read property 'context' of null
    at XiaomiMiio.pollDevices (/usr/local/lib/node_modules/homebridge-miio/index.js:72:18)
    at API.XiaomiMiio.api.on (/usr/local/lib/node_modules/homebridge-miio/index.js:63:12)
    at emitNone (events.js:91:20)
    at API.emit (events.js:185:7)
    at Server.run (/usr/local/lib/node_modules/homebridge/lib/server.js:93:13)
    at module.exports (/usr/local/lib/node_modules/homebridge/lib/cli.js:40:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/homebridge/bin/homebridge:17:22)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
Bluebie commented 7 years ago

@astrojetson8 thanks for the crash log. I'm making some changes to the pollDevices code which should make it more resilient to whatever caused that.

As for setting names, I would really like to support that, but I haven't yet figured out the API for setting and fetching the names of the devices. Xiaomi's lightbulbs expose it via SSDP discovery, but i haven't yet figured out how to apply that system to power plugs, or if they even support it. In my personal setup, I just rename the devices in the Home app on my iPhone. I'll look in to ways to make the identity of the devices more persistent. I don't think configuring default names in the homebridge config is the right answer.

bluefoxlee commented 7 years ago

@astrojetson8 So far I know Xiaomi have these 3 smart power strips product on sell in China.

  1. Xiaomi Smart Power Strip 69RMB(6 Plugs ) ZNCXB01ZM Made by Zumi
  2. Chingmi Smart Power Strip 89RMB(5 Plugs) Made by Chingmi
  3. Chingmi Smart Power Strip 99RMB(3 Plugs+3 USB) Made by Chingmi

Thanking about to get 3. but would really like to see it got Homebridge support first. (Xiaomi did have their Homebridge clone plug for Xiaomi Router only at moment.)

astrojetson8 commented 7 years ago

@bluefoxlee thanks for sharing this info.

I got 1st one from Zumi. Most of the UI is in MI app is Chinese. So, I can't understand it. I can't see an option to buy either Chingmi Smart Power Strip from anywhere that ships to Australia. Strangely, I can't find them listed on Xiaomi mainland China website.

Question for you, can you independently power on and off each powerpoint or is it universal on and off for Chingmi Smart Power Strip?

If I'm not mistaken, isn't following also made my Chingmi http://www.mi.com/socket/

If you are in China, maybe you can send 1 to @Bluebie and hopefully she can update the plugin to work. It would be difficult to support a hardware if Bluebie doesn't have access to.

bluefoxlee commented 7 years ago

@astrojetson8 if you update MiJia App to the latest version, you should able to find market tab there and it's under Chingmi, otherwise you will have to get it from Taobao (Aliexpress). Those ecosystem companies product normally won't list on Xiaomi website for some reason.

it's a universal on and off one sadly. Not quite who made for socket you mentioned since I prefer Zigbee version for better home-bridge compatible.

I live in Taiwan acutely. but sure, if @Bluebie is ok. I can send her one. should not be too hard to get it from Taiwan.

astrojetson8 commented 7 years ago

@bluefoxlee thats how i found about them. thank for letting me features. still pretty good for the price.

i got mix of zigbee and wifi plugs.

Bluebie commented 7 years ago

I haven't done any of the reverse engineering stuff with these gadgets yet. I'm starting to experiment with it to try and discover more of the API to the WiFi plugs, but i'm not sure it will hold my attention. Maybe better to include @aholstenson who wrote the miio library this plugin uses to communicate with Mi Ecosystem devices. It should be fairly easy for me to add support for any device type that gets supported in the miio library.

wadjj commented 7 years ago

Just a sidenote: the Homebridge Aqara plugin(which covers most if not all zigbee devices connected to Mijia/Xiaomi bridge) and Yeelight plugin(which covers all Yeelight products including Mijia Desklamp) are written by the Xiaomi and Yeelight employees, respectively.

Therefore, my two cents are that the dev's resource might be better put into devices not supported by these two plugins, such as wifi power plug, air purifier, vacuum robot, etc.