sean9keenan / homebridge-bigAssFans

A Homebridge plugin for Big Ass Fans
MIT License
27 stars 14 forks source link

Error: This callback function has already been called by someone else; it can only be called one time #7

Open webdeck opened 8 years ago

webdeck commented 8 years ago

Tried the new platform version, and got this error whenever the iOS Home app tried to identify one of my fans:

Sun, 18 Sep 2016 22:54:28 GMT Accessory [Family Room Fan] Identification request [9/18/2016, 3:54:28 PM] [Haiku Fan] Family Room Fan Identify!!! [9/18/2016, 3:54:28 PM] [Haiku Fan] Family Room Fan Identified fan (homekit setup) /opt/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11 throw new Error("This callback function has already been called by someone else; it can only be called one time."); ^

Error: This callback function has already been called by someone else; it can only be called one time. at /opt/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11:13 at PlatformAccessory. (/opt/local/lib/node_modules/homebridge-bigAssFans/index.js:101:5) at emitTwo (events.js:92:20) at PlatformAccessory.emit (events.js:172:7) at PlatformAccessory. (/opt/local/lib/node_modules/homebridge/lib/platformAccessory.js:142:12) at emitTwo (events.js:87:13) at Accessory.emit (events.js:172:7) at Accessory._identificationRequest (/opt/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:109:10) at Accessory. (/opt/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Accessory.js:818:14) at emitThree (events.js:97:13)

sean9keenan commented 8 years ago

Oi. I think I ran into this when I was developing. Can you try and clear out the cached devices and run it again?

I think this is an issue when you update to the new scanning version, because otherwise it tries to restore accessories from the "old" way of doing it.

Let me know if that fixes it for you!

webdeck commented 8 years ago

I hadn't ever used the plugin before - this was my first time running it, so there were no cached accessories.

sean9keenan commented 8 years ago

Ah, darn. What does your config look like? I'll look into this now.

webdeck commented 8 years ago
{
    "bridge": {
        "name": "Homebridge",
        "username": "REDACTED",
        "port": 51826,
        "pin": "REDACTED"
    },

    "description": "WebDeck",

    "platforms": [
        {
            "platform": "Indigo",
            "name": "Indigo",
            "host": "REDACTED",
            "port": "REDACTED"
        },
    {               
            "platform": "BigAssFans",
            "name": "Haiku Fan"
    }
    ],

    "accessories": [
    ]
}
sean9keenan commented 8 years ago

That looks good to me, ruled out a few things. Thanks for sending that.

Are you pressing the "identify" button when you go through setup in the Home App? If you are - does it work if you skip pressing the "identify" button?

The line that it crashed on is related to that identify function getting called - apparently twice. I could remove that callback since the identify function really doesn't do anything for the fan.

sean9keenan commented 8 years ago

Ah shoot. I think I found it. I'll have a new branch for you test and quick instructions in a few minutes.

webdeck commented 8 years ago

I had to blow away my HomeKit home and start over. When I did that, using the iOS 10 Home app, after I added Homebridge, it immediately walked me through putting each accessory under Homebridge into a room and selecting whether or not it was a favorite. The error happened when it got to my fan (I have two, so it happened twice.)

sean9keenan commented 8 years ago

Gah, I'm sorry about that.

Ok. I have a new version up. You should be able to run: sudo npm install -g sean9keenan/homebridge-bigAssFans#identifyFix To install the package from the branch that I believe has a fix. If this works I'll merge it in and update npm.

Thanks for being patient with this!

webdeck commented 8 years ago

To make sure it was working, I created a second homebridge instance and added it from a different device so as not to mess up my real home config. It looks like that fixed it. Now the only open issue I have is the non-existant light accessory, since one of my fans doesn't have the light kit installed. Thanks for the super quick response on this!

sean9keenan commented 8 years ago

Awesome, glad that fixed it, and thank you for testing that the fix worked! I'll merge that back in now. I can try and write something to only populate the light if it's a visible component, but I don't have an easy way to validate that my changes work. If you're willing I can make a branch that I throw over the fence to you for testing.

webdeck commented 8 years ago

I'm happy to test that as well. Thanks for writing the plug-in!

sean9keenan commented 8 years ago

Haha, thanks for the appreciation! Here is a branch that might work: sudo npm install -g sean9keenan/homebridge-bigAssFans#lightFix It at least doesn't seem to break anything on my end - so that's a good step forwards 😅

Thanks again for testing

webdeck commented 8 years ago

I have 2 fans, one with the light kit, and one without. Previously, both showed a light, and the one that didn't really exist was always showing a communication error.

With this branch, unfortunately, neither shows a light now.

sean9keenan commented 8 years ago

Interesting. I just pushed a new version. the fix I'm trying in this won't work if you have a cached accessory with a light on it though, since if it sees a cached light service it will blindly add it. Hopefully during the scan it will see whether the light exists or not.

I've also tested this on the fans in my house (all with light kits) and they all seem to work as expected. If this doesn't work I might recommend hiding the light service in another room / removing it from your favorites in the home app. Not really a fix, but at least something that might help :/

webdeck commented 8 years ago

Still not seeing any lights. I've been deleting the accessories folder between runs. Here's all I see in the log from the plugin, but it's the same I see with the old and new version, so it doesn't say much:

[9/18/2016, 10:28:50 PM] [Haiku Fan] Initializing BigAssFans platform...
[9/18/2016, 10:28:50 PM] [Haiku Fan] Big Ass Fans Platform Init
[9/18/2016, 10:28:50 PM] [Haiku Fan] Family Room Fan Configure Accessory 3e7154e6-65fb-4f1f-ab0b-9d9c47afbe03
[9/18/2016, 10:28:50 PM] [Haiku Fan] Master Bedroom Fan Configure Accessory 71fc0cee-2db1-4630-b019-1040a73f2e1a
[9/18/2016, 10:28:50 PM] [Haiku Fan] DidFinishLaunching
sean9keenan commented 8 years ago

Oi. It looks like I had a stupid mistake in there. I really think it should work this time 😓

webdeck commented 8 years ago

Sorry to say, now it's back to the original behavior. Both fans have a light, and the phantom light keeps alternating between updating and not responding.

sean9keenan commented 8 years ago

Damnit. I'll... look into this more, probably next weekend (but maybe later). Ping me if it's really bothering you or I don't get back to this in a reasonable time and I'll try to get a fix in sooner. Gonna try and get some work in for my actual job before I go to bed 😅

webdeck commented 8 years ago

No worries, and thanks again!

davidvanvo commented 7 years ago

Checking status on this. I'm seeing the same error.

pponce commented 7 years ago

i started seeing the same error. More often recently for some reason.

/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11 throw new Error("This callback function has already been called by someone else; it can only be called one time."); ^

Error: This callback function has already been called by someone else; it can only be called one time. at /home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11:13 at /home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/index.js:316:7 at BigAssProperty. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:191:17) at BigAssProperty. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:158:48) at BigAssFan. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:319:36) at FanMaster. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:72:40) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:550:8)

sean9keenan commented 7 years ago

Can you try to update homebridge? I realized that I had a few pending changes that I might not have pushed via NPM. The latest on NPM should now be up to date with master and should now have occupancy sensor support thanks to @pedroserano.

pponce commented 7 years ago

sounds good. Just updated to 1.1.2. I'll monitor things and report back.

davidvanvo commented 7 years ago

unfortunately the error still occurs. this update also throws a "No light exists for: " error.

pponce commented 7 years ago

yup i got the error again about an hour ago and also see the "No light exists for:" message.

/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11 throw new Error("This callback function has already been called by someone else; it can only be called one time."); ^

Error: This callback function has already been called by someone else; it can only be called one time. at /home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11:13 at /home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/index.js:324:7 at BigAssProperty. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:191:17) at BigAssProperty. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:158:48) at BigAssFan. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:319:36) at FanMaster. (/home/pi/.nvm/versions/node/v6.9.5/lib/node_modules/homebridge-bigAssFans/node_modules/BigAssFansAPI/BigAssApi.js:72:40) at emitTwo (events.js:106:13) at Socket.emit (events.js:191:7) at UDP.onMessage (dgram.js:550:8)

sean9keenan commented 7 years ago

I just pushed a hack that should "fix" it by just not allowing that callback to be called multiple times. It's just not ideal, because it's not fixing the underlying issue - I also don't have any way of testing since I'm away from my fan for a bit.

The branch is here if someone wants to try to run from it and let me know if it's working. https://github.com/sean9keenan/homebridge-bigAssFans/tree/callbackOnceHack

@davidvanvo - That message shouldn't cause any issues - I believe it's just logging that it wasn't able to find a light on your device. Does your fan have a light on it?

pponce commented 7 years ago

I'll test the new build out. Just installed it. I'll monitor the callback error situation. As for the no light message: I get the error for each of my fans that do have a light, and am not able to control my lights. Confirmed the same light errors on the callbackOnceHack branch.

davidvanvo commented 7 years ago

confirming what @pponce is seeing. all of my fans have lights and i'm getting that "No Lights" error.