Zacknetic / HomebridgeMagicHome-DynamicPlatform

Homebridge Plugin for MagicHome LED controllers and light bulbs
Apache License 2.0
61 stars 11 forks source link

RGB controller is being recognized as RGBW controller #27

Closed skbeez closed 3 years ago

skbeez commented 4 years ago

First off I love the fact that I don't need to manually add LED controllers for this plugin, but it appears I may have run into a minor issue here...

I ordered a new RGB controller and it seems to be recognized as a RGBW by the plugin so anytime it wants to create anything that has a white component, the strip goes dim or turns off. I am able to control the LED strip perfectly fine via the MagicHome iOS app.

Here's what's in my config file:

        {
            "platform": "homebridge-magichome-dynamic-platform",
            "pruning": {
                "pruneMissingCachedAccessories": false,
                "restartsBeforeMissingAccessoriesPruned": 3,
                "pruneAllAccessoriesNextRestart": false
            },
            "whiteEffects": {
                "simultaniousDevicesColorWhite": true,
                "colorWhiteThreshold": 10,
                "colorWhiteThresholdSimultaniousDevices": 50,
                "colorOffThresholdSimultaniousDevices": 5
            },
            "deviceManagement": {
                "blacklistOrWhitelist": "whitelist",
                "whitelistedUniqueIDs": [
                    "2462AB2D4157",
                    "10521CCE4142"
                ]
            }
        }

I turned on verbose mode for debug to get the following information:

HAP Warning: Characteristic 000000E3-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 00000043-0000-1000-8000-0026BB765291. Adding anyway.
[9/21/2020, 6:39:29 PM] [homebridge-magichome-dynamic-platform] 
Registering new accessory 'RGBW Non-Simultanious' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Version 8 
Version Modifier: 51

If there's anything else you'd like for me to show, please let me know. I whitelisted the LED strips because I had an issue where the plugin was not finding the lights and deleting them every so often.

Zacknetic commented 3 years ago

Hello and apologies for the very delayed response. You can always disable the "prune magichome accessories" feature in the settings if your devices are getting pruned for no reason.

I have updated the plugin to better assign the led version. It may address your problem, if not please let me know.

Please update your plugin to version 1.5.1 . Note: if you are updating from version 1.4.x you'll need to purge all your magichome devices first.

With help, I found a bug in the code that caused duplicate device to register if the user had multiple subnets. Thus the crash. I was trying to scan on more than one subnet but didn't account for devices showing up on more than one.

Let me know how it goes. Thank you.

skbeez commented 3 years ago

It appears that I have 2 of each LED strip now, but the RGB LED strip is still being recognized as an RGBW. Also when I open the Home App homebridge crashes with the following error:

[11/1/2020, 9:27:31 AM] [homebridge-magichome-dynamic-platform] 
Registering existing accessory 'RGBW Simultanious' 
Model: 'AK001-ZJ200' 
Unique ID: '2462AB2D4157' 
IP-Address: '192.168.1.33' 
Light Version 5 
Version Modifier: 4
Protocol Version: 10

[11/1/2020, 9:27:31 AM] [homebridge-magichome-dynamic-platform] 
Registering existing accessory 'RGBW Simultanious' 
Model: 'AK001-ZJ200' 
Unique ID: '2462AB2D4157' 
IP-Address: '192.168.1.33' 
Light Version 5 
Version Modifier: 4
Protocol Version: 10

[11/1/2020, 9:27:31 AM] [homebridge-magichome-dynamic-platform] 
Registering existing accessory 'RGBW Non-Simultanious' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Light Version 8 
Version Modifier: 51
Protocol Version: 8

[11/1/2020, 9:27:31 AM] [homebridge-magichome-dynamic-platform] 
Registering existing accessory 'RGBW Non-Simultanious' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Light Version 8 
Version Modifier: 51
Protocol Version: 8

[11/1/2020, 9:27:31 AM] [homebridge-magichome-dynamic-platform] 
Registered 4 Magichome device(s). 
New devices: 0 
Cached devices that were seen this restart: 4 
Cached devices that were not seen this restart: 0

[11/1/2020, 9:29:09 AM] Error: This callback function has already been called by someone else; it can only be called one time.
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
    at RGBWBulb.getHue (/homebridge/node_modules/homebridge-magichome-dynamic-platform/src/PlatformAccessory.ts:218:5)
    at Characteristic.emit (events.js:326:22)
    at Characteristic.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at Characteristic._this.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1239:22
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._this._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1167:10)
    at HAPServer.emit (events.js:314:20)
    at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
[11/1/2020, 9:29:09 AM] Got SIGTERM, shutting down Homebridge...

I deleted the cached accessories as you had mentioned prior to installing the plugins but it still recognizes 2 each.

Thank you for looking into this.

skbeez commented 3 years ago

I should mention that I followed the procedure in Issue 24 to remove old accessories and restarted homebridge twice and still ended up with the same issue.

dmzimmerman commented 3 years ago

I'm having the same issue with an RGB device being recognized as RGBW; after clearing all the cached devices, this was its registration:

[11/7/2020, 10:59:50 PM] [homebridge-magichome-dynamic-platform] 
 Platform.ts.createAccessory(): 
Assigning controller to device: UniqueId: '10521CCD6B1D' 
IpAddress '192.168.86.153' 
Model: 'AK001-ZJ2101'
Original Light Version: 8
Light Version Modifier: 51

[11/7/2020, 10:59:50 PM] [homebridge-magichome-dynamic-platform] ( Modified) Light version: 8 matches known device type records
HAP Warning: Characteristic 000000E3-0000-1000-8000-0026BB765291 not in required or optional characteristics for service 00000043-0000-1000-8000-0026BB765291. Adding anyway.
[11/7/2020, 10:59:50 PM] [homebridge-magichome-dynamic-platform] 
Registering new accessory 'RGBW Non-Simultanious' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCD6B1D' 
IP-Address: '192.168.86.153' 
Light Version 8 
Version Modifier: 51
Protocol Version: 8
Zacknetic commented 3 years ago

@skbeez @dmzimmerman Hey, I've just posted an update that changed the way discovery logic works. I have a full list of devices after decompiling the android magichome APK so protocol detection should be much easier going forward.

Please let me know if updating solves your issue. Be sure to purge your magichome devices before hand.

Additionally, please join the official MagicHome Discord server. I am able to respond more quickly there. Additionally you'll be able to see update change log announcements.

dmzimmerman commented 3 years ago

With that update, my lights are recognized as "Simple GRB" (which sounds better). I haven't tested them yet (as they're a couple floors away and I'm working), but will this evening.

Zacknetic commented 3 years ago

@skbeez @dmzimmerman Closing this issue due to lack of activity. Feel free to reopen if you are experiencing additional issues. The introduction of version 1.7.3 should solve many issues. If not, let me know. Thank you.

skbeez commented 3 years ago

I still have the same issues. Nothing changes with 1.7.3. I was upgrading from 1.4.5 because that's the only version that works reliably for me. The only issue there was my RGB controller shows up as RGBW but works for the most part. I did prune all accessories and restarted twice after upgrading to version 1.7.3.

Here's what I see:

Setup Payload:
X-HM://0023ISYWZ7681
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ xxx-xx-xxx │     
    └────────────┘     

[11/15/2020, 1:36:32 PM] Homebridge v1.2.3 is running on port 51190.
[11/15/2020, 1:36:34 PM] [homebridge-magichome-dynamic-platform] 
Discovered 4 devices.

[11/15/2020, 1:36:34 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
1 - Display Name: 'RGBW Simultanious' 
Model: 'AK001-ZJ200' 
Unique ID: '2462AB2D4157' 
IP-Address: '192.168.1.33' 
Firmware Version: 5 
Device Type: '4'

[11/15/2020, 1:36:34 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
2 - Display Name: 'RGBW Simultanious' 
Model: 'AK001-ZJ200' 
Unique ID: '2462AB2D4157' 
IP-Address: '192.168.1.33' 
Firmware Version: 5 
Device Type: '4'

[11/15/2020, 1:36:34 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
3 - Display Name: 'Simple GRB' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Firmware Version: 8 
Device Type: '33'

[11/15/2020, 1:36:34 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
4 - Display Name: 'Simple GRB' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Firmware Version: 8 
Device Type: '33'

[11/15/2020, 1:36:34 PM] [homebridge-magichome-dynamic-platform] 
Registered 4 Magichome device(s). 
New devices: 0 
Cached devices that were seen this restart: 4
Cached devices that were not seen this restart: 0

[11/15/2020, 1:36:37 PM] Error: This callback function has already been called by someone else; it can only be called one time.
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
    at RGBWStrip.getOn (/homebridge/node_modules/homebridge-magichome-dynamic-platform/src/PlatformAccessory.ts:254:5)
    at Characteristic.emit (events.js:326:22)
    at Characteristic.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at Characteristic._this.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1239:22
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._this._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1167:10)
    at HAPServer.emit (events.js:314:20)
    at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
[11/15/2020, 1:36:37 PM] Got SIGTERM, shutting down Homebridge...
[11/15/2020, 1:36:42 PM] [HB Supervisor] Homebridge Process Ended. Code: 143, Signal: null
[11/15/2020, 1:36:47 PM] [HB Supervisor] Restarting Homebridge...
[11/15/2020, 1:36:47 PM] [HB Supervisor] Starting Homebridge with extra flags: -I -P /homebridge/node_modules
[11/15/2020, 1:36:47 PM] [HB Supervisor] Started Homebridge v1.2.3 with PID: 17140
[11/15/2020, 1:36:47 PM] Loaded config.json with 0 accessories and 2 platforms.
[11/15/2020, 1:36:47 PM] ---
[11/15/2020, 1:36:48 PM] Loaded plugin: homebridge-dummy@0.4.1
[11/15/2020, 1:36:48 PM] Registering accessory 'homebridge-dummy.DummySwitch'
[11/15/2020, 1:36:48 PM] ---
[11/15/2020, 1:36:48 PM] Loaded plugin: homebridge-magichome-dynamic-platform@1.7.3
[11/15/2020, 1:36:48 PM] Registering platform 'homebridge-magichome-dynamic-platform.homebridge-magichome-dynamic-platform'
[11/15/2020, 1:36:48 PM] ---
[11/15/2020, 1:36:48 PM] Loaded plugin: homebridge-config-ui-x@4.32.0
[11/15/2020, 1:36:48 PM] Registering platform 'homebridge-config-ui-x.config'
[11/15/2020, 1:36:48 PM] ---
[11/15/2020, 1:36:48 PM] Loading 2 platforms...
[11/15/2020, 1:36:48 PM] [homebridge-magichome-dynamic-platform] Initializing homebridge-magichome-dynamic-platform platform...
[11/15/2020, 1:36:48 PM] [homebridge-magichome-dynamic-platform] Finished initializing homebridge-magichome-dynamic-platform '1.7.3'
[11/15/2020, 1:36:48 PM] [Config] Initializing config platform...
[11/15/2020, 1:36:48 PM] [Config] Running in Service Mode
[11/15/2020, 1:36:48 PM] [homebridge-magichome-dynamic-platform] Scanning broadcast-address: '192.168.1.255' for Magichome devices... 

[11/15/2020, 1:36:48 PM] [homebridge-magichome-dynamic-platform] Scanning broadcast-address: '192.168.1.255' for Magichome devices... 

Setup Payload:
X-HM://0023ISYWZ7681
Enter this code with your HomeKit app on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ xxx-xx-xxx │     
    └────────────┘     

[11/15/2020, 1:36:48 PM] Homebridge v1.2.3 is running on port 51190.
[11/15/2020, 1:36:50 PM] [homebridge-magichome-dynamic-platform] 
Discovered 4 devices.

[11/15/2020, 1:36:50 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
1 - Display Name: 'RGBW Simultanious' 
Model: 'AK001-ZJ200' 
Unique ID: '2462AB2D4157' 
IP-Address: '192.168.1.33' 
Firmware Version: 5 
Device Type: '4'

[11/15/2020, 1:36:50 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
2 - Display Name: 'RGBW Simultanious' 
Model: 'AK001-ZJ200' 
Unique ID: '2462AB2D4157' 
IP-Address: '192.168.1.33' 
Firmware Version: 5 
Device Type: '4'

[11/15/2020, 1:36:50 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
3 - Display Name: 'Simple GRB' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Firmware Version: 8 
Device Type: '33'

[11/15/2020, 1:36:50 PM] [homebridge-magichome-dynamic-platform] Registering existing accessory...
4 - Display Name: 'Simple GRB' 
Model: 'AK001-ZJ2101' 
Unique ID: '10521CCE4142' 
IP-Address: '192.168.1.34' 
Firmware Version: 8 
Device Type: '33'

[11/15/2020, 1:36:50 PM] [homebridge-magichome-dynamic-platform] 
Registered 4 Magichome device(s). 
New devices: 0 
Cached devices that were seen this restart: 4
Cached devices that were not seen this restart: 0

[11/15/2020, 1:36:53 PM] Error: This callback function has already been called by someone else; it can only be called one time.
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/util/once.ts:6:13
    at RGBWStrip.getOn (/homebridge/node_modules/homebridge-magichome-dynamic-platform/src/PlatformAccessory.ts:254:5)
    at Characteristic.emit (events.js:326:22)
    at Characteristic.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
    at Characteristic._this.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Characteristic.ts:489:12)
    at /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1239:22
    at Array.forEach (<anonymous>)
    at Bridge.Accessory._this._handleGetCharacteristics (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/Accessory.ts:1167:10)
    at HAPServer.emit (events.js:314:20)
    at HAPServer.EventEmitter.emit (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/src/lib/EventEmitter.ts:42:22)
[11/15/2020, 1:36:53 PM] Got SIGTERM, shutting down Homebridge...
skbeez commented 3 years ago

The plugin loads up fine, but crashes as soon as I open the home app on my iPhone.

I don't believe this issue is resolved but I am unable to re-open the issue on Github...

Zacknetic commented 3 years ago

Its re-opened now! I didn't realize it couldn't be re-opened by users. I'll look into that.

I see the issue. You have duplicate devices due to a bug that has since been squashed! This issue has been resolved in 1.7.4. Take a look at the tiny variable name mismatch that caused the error.

All you need to do now is delete the extra devices.

If you're using config ui x, go into settings (3 vertical dots top right) > Homebridge Settings > Remove Single Cached Accessory > Delete one "RGBW Simultanious" and one "Simple GRB".

Alternatively you can just purge the magichome devices in the magichome settings.

Zacknetic commented 3 years ago

@skbeez let me know how that goes. Alternatively you can use the purge function in the magichome settings menu to purge the devices.

skbeez commented 3 years ago

I just upgraded to 1.8.3 from 1.4.5 and didn't see any issues. I didn't have to manually delete anything which was nice!

Also I like the new added comment:

[11/21/2020, 8:36:53 AM] [homebridge-magichome-dynamic-platform] 
2 - A device has been discovered that already exists. Likely due to a "fun" network layout...
UniqueId: '10521CCE4142' 
IpAddress '192.168.1.34' 
Model: 'AK001-ZJ2101'
 already exists.
[11/21/2020, 8:36:53 AM] [homebridge-magichome-dynamic-platform] 
4 - A device has been discovered that already exists. Likely due to a "fun" network layout...
UniqueId: '2462AB2D4157' 
IpAddress '192.168.1.33' 
Model: 'AK001-ZJ200'
 already exists.
[11/21/2020, 8:36:55 AM] [homebridge-magichome-dynamic-platform] 
Discovered 2 devices.

Looks like you're handling the duplicate device in the background. Thank you for working on this plugin! I truly appreciate it. It appears that this issue is resolved on my end.