rodtoll / homebridge-isy-js

Homebridge platform plugin for the ISY series of home controllers from Universal Devices.
MIT License
22 stars 27 forks source link

Error: This callback function has already been called by someone else" #44

Closed VeniceNerd closed 7 years ago

VeniceNerd commented 7 years ago

Hey,

I installed Homebridge and the ISY Homebridge plugin but I'm having a hard time getting getting it running. Once I add the the ISY code into my config.json Homebridge will no longer start. It'll quit with the following error message:

Philipp-iMac-Home:~ Philipp$ homebridge
[1/22/2017, 3:27:26 PM] Loaded plugin: homebridge-isy-js
[1/22/2017, 3:27:26 PM] Registering platform 'homebridge-isy-js.isy-js'
[1/22/2017, 3:27:26 PM] ---
[1/22/2017, 3:27:26 PM] Loaded config.json with 0 accessories and 1 platforms.
[1/22/2017, 3:27:26 PM] ---
[1/22/2017, 3:27:26 PM] Loading 1 platforms...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing isy-js platform...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Mirror'...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Shower'...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Ceiling'...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Keypad 1A'...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Keypad 1B'...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Keypad 1C'...
[1/22/2017, 3:27:26 PM] [isy-js] Initializing platform accessory 'Keypad 1D'...
Scan this code with your HomeKit App on your iOS device to pair with Homebridge:

    ┌────────────┐     
    │ 032-45-156 │     
    └────────────┘     

/usr/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 /usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/util/once.js:11:13
    at /usr/local/lib/node_modules/homebridge-isy-js/index.js:207:3
    at ISY.finishInitialize (/usr/local/lib/node_modules/homebridge-isy-js/node_modules/isy-js/isy.js:368:5)
    at /usr/local/lib/node_modules/homebridge-isy-js/node_modules/isy-js/isy.js:539:30
    at Request.<anonymous> (/usr/local/lib/node_modules/homebridge-isy-js/node_modules/isy-js/isy.js:410:13)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request._fireSuccess (/usr/local/lib/node_modules/homebridge-isy-js/node_modules/restler/lib/restler.js:229:10)
    at /usr/local/lib/node_modules/homebridge-isy-js/node_modules/restler/lib/restler.js:161:20
    at IncomingMessage.auto (/usr/local/lib/node_modules/homebridge-isy-js/node_modules/restler/lib/restler.js:402:7)

ISY is the only plugin I'm currently running. Here is my config.json:

{
    "bridge": {
        "name": "Homebridge",
        "username": "CC:22:3D:E3:CE:40",
        "port": 50920,
        "pin": "032-45-156"
    },

    "platforms": [{
        "platform": "isy-js",
        "name": "isy-js",
        "host": "192.168.7.100",
        "username": "admin",
        "password": "purell8fl",
        "elkEnabled": false,
        "useHttps": false,
        "debugLoggingEnabled": false,
        "includeAllScenes": false,
        "includedScenes": [
            ""
        ],

        "ignoreDevices": [{
            "nameContains": "ApplianceLinc",
            "lastAddressDigit": "",
            "address": ""
        }, {
            "nameContains": "Bedroom.Side Gate",
            "lastAddressDigit": "",
            "address": ""
        }, {
            "nameContains": "Remote",
            "lastAddressDigit": "",
            "address": ""
        }, {
            "nameContains": "Test",
            "lastAddressDigit": "",
            "address": ""
        }]

    }]
    }

Any help would be very much appreciated. I'd really love to get this running.

Thanks!

Philipp

VeniceNerd commented 7 years ago

Btw, just installed everything again on a fresh system and I am getting the exact same error message. Tried both Mac OS 10.11 and 10.12. Same problem.

VeniceNerd commented 7 years ago

@rodtoll do you have any idea what may be causing this issue? Seems like other users on new installs have similar issues. Thanks!

VeniceNerd commented 7 years ago

@suderman what version of NPM do you have installed on your machine? Do you think a newer version of NPM may be causing this issue?

suderman commented 7 years ago

@VeniceNerd I have this running without problems on my Ubuntu server (which hasn't been updated in a while) as well as my Mac (recent install):

Ubuntu 14.04:

macOS 10.12:

Here's the output when I run homebridge from my Mac. It has two plugins installed, including homebridge-isy-js. Not sure if this is helpful. :-/

macos

VeniceNerd commented 7 years ago

@suderman Thanks! So I have:

Mac OS 10.11.6 Node 6.9.4 NPM 3.10.10 Homebridge 0.4.16 Home bridge ISY JS 0.1.8

Do you think my problems could have anything to do with my versions of Node or NPM? It's so frustrating that I can't get Homebridge to start with the ISY-JS plugin enabled.

rodtoll commented 7 years ago

I have been unable to reproduce this locally. Did you recently update to a new version of homebridge?

What is the ISYMaker plugin? Do you get the same error if you remove that plugin?

If they both use isy-js under the covers it's possible it could conflict.

On Tue, Jan 24, 2017 at 9:20 AM VeniceNerd notifications@github.com wrote:

@suderman https://github.com/suderman Thanks! So I have:

Mac OS 10.11.6 Node 6.9.4 NPM 3.10.10

I don't know how to check the Homebrige and ISY-JS versions but I just installed them so I assume they are the most recent.

Do you think my problems could have anything to do with my versions of Node or NPM? It's so frustrating that I can't get Homebridge to start with the ISY-JS plugin enabled.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/44#issuecomment-274872758, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyYQxhY-wq739M0NVCZ0N4Z3T0_608Xks5rVjKtgaJpZM4LqjGM .

rodtoll commented 7 years ago

In the meantime I'm going to do a full fresh install on a clean raspberry pi image tonight and see if I can get it to repro. Should have an update tonight.

On Tue, Jan 24, 2017 at 9:26 AM Rod Toll rod_toll@hotmail.com wrote:

I have been unable to reproduce this locally. Did you recently update to a new version of homebridge?

What is the ISYMaker plugin? Do you get the same error if you remove that plugin?

If they both use isy-js under the covers it's possible it could conflict.

On Tue, Jan 24, 2017 at 9:20 AM VeniceNerd notifications@github.com wrote:

@suderman https://github.com/suderman Thanks! So I have:

Mac OS 10.11.6 Node 6.9.4 NPM 3.10.10

I don't know how to check the Homebrige and ISY-JS versions but I just installed them so I assume they are the most recent.

Do you think my problems could have anything to do with my versions of Node or NPM? It's so frustrating that I can't get Homebridge to start with the ISY-JS plugin enabled.

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/44#issuecomment-274872758, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyYQxhY-wq739M0NVCZ0N4Z3T0_608Xks5rVjKtgaJpZM4LqjGM .

suderman commented 7 years ago

@rodtoll Sorry to confuse, but I'm not having problems. I was just providing @VeniceNerd the version numbers I have in my working configuration. All is well for me. :-)

rodtoll commented 7 years ago

No problems. Hoping I found a potential root cause but sounds like not.

(Looks like the ISYMaker plugin is yours -- cool to see more usage of ISY).

Clean install tonight it is.

On Tue, Jan 24, 2017 at 9:30 AM Jonathan Suderman notifications@github.com wrote:

@rodtoll https://github.com/rodtoll Sorry to confuse, but I'm not having problems. I was just providing @VeniceNerd https://github.com/VeniceNerd the version numbers I have in my working configuration. All is well for me. :-)

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/44#issuecomment-274875796, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyYQ7LQek9KqgQybuttY1Xy38ST1vYbks5rVjU1gaJpZM4LqjGM .

VeniceNerd commented 7 years ago

@rodtoll My error message is actually in the first post. The only other plugin I'm running is "Harmony Hub" but even with "ISY-JS" running as my only plugin I am still getting the same error message.

This is all on a fresh install of Homebridge as I've never used any of this before. I tried it both on my iMac 10.11.6 and my MacBook 10.12.2 and having the same issues on both.

Thanks for looking into it. Looking forward to what you find!

rodtoll commented 7 years ago

@VeniceNerd, @crumbolt - No repro on either my macbook (10.12.2) or my raspberry pi, both clean installs from scratch with latest node.js v7.4 and latest homebridge-isy and homebridge-isy-js.

Looking at the code the path that is throwing the error is the callback from the isy-js library upon successful initialization which should only happen once which means something strange is going on. We need to find something common amongst your setups.

So some questions:

  1. What version of node are you running? Run node -v.
  2. What ISY are you running? ISY 99i or ISY 994i?
  3. What version of firmware are you running on the ISY?

On Tue, Jan 24, 2017 at 9:35 AM VeniceNerd notifications@github.com wrote:

@rodtoll https://github.com/rodtoll My error message is actually in the first post. The only other plugin I'm running is "Harmony Hub" but even with "ISY-JS" running as my only plugin I am still getting the same error message.

This is all on a fresh install of Homebridge as I've never used any of this before. I tried it both on my iMac 10.11.6 and my MacBook 10.12.2 and having the same issues on both.

Thanks for looking into it. Looking forward to what you find!

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/44#issuecomment-274877145, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyYQ1YlzYyZlzENgvxF93U6oi4kJjbcks5rVjZmgaJpZM4LqjGM .

VeniceNerd commented 7 years ago

@rodtoll –

Node: 6.9.4 ISY 994i ISY Firmware: 4.5.4

screen shot 2017-01-25 at 12 18 49 am

Please let me know if you need any other information or logs. I'm really bummed out I can't get this to work.

Thanks,

Philipp

PaulWieland commented 7 years ago

This is a shot in the dark, but are you sure that homebridge isn't trying to start twice (or load the plugin twice)?

Run ps aux | grep homebridge to make sure you dont already have an instance of homebridge running in the background.

crumbolt commented 7 years ago

@rodtoll -

Ubuntu 14 Node: 4.x.x (I seemed to have broke something updating to v7.4) ISY 994i ISY FW: 4.5.4

I am updating my server to Ubuntu 16 so will try a fresh install when complete.

Let me know if there is anything else that could help.

Thanks

VeniceNerd commented 7 years ago

@fahrvergnuugen so I ran your command "ps aux | grep homebridge".

Before I started homebridge it gave me this output:

screen shot 2017-01-25 at 10 22 13 am

Then I ran homebridge and got this output:

screen shot 2017-01-25 at 10 21 08 am

Then I quit homebridge (ctrl+c) and got this output:

screen shot 2017-01-25 at 10 23 25 am

I'm currently only running the Harmony Hub plug-in since Homebridge won't start with ISY-JS enabled.

Does that tell you anything?

crumbolt commented 7 years ago

I did a complete refresh of my server so that I now have:

Ubuntu Server 16.04 LTS Node 6.9.4 NPM 4.1.1 Homebridge 0.4.16 Homebridge-ISY-JS 0.1.8

Starting homebridge without the isy-js platform and things work fine. When I add the isy-js platform to the config.json I get the same error.

Also, when the error occurs there are no other homebridge processes running.

@rodtoll - is there something on the ISY itself that could cause this error? My setup is pretty basic, a few lights and a couple of scenes.

What version of the FW are you currently running?

rodtoll commented 7 years ago

Two things to try -- 1) Do you have at least one variable of each type defined? If not, do so and see if that helps. 2) Make sure you have at least one program and that it's enabled. Even if it doesn't do anything.

I'll try repros again tonight -- this time I'll remove elk support and try and use your exact config file and see what happens.

On Wed, Jan 25, 2017 at 5:11 PM crumbolt notifications@github.com wrote:

I did a complete refresh of my server so that I now have:

Ubuntu Server 16.04 LTS Node 6.9.4 NPM 4.1.1 Homebridge 0.4.16 Homebridge-ISY-JS 0.1.8

Starting homebridge without the isy-js platform and things work fine. When I add the isy-js platform to the config.json I get the same error.

Also, when the error occurs there are no other homebridge processes running.

@rodtoll https://github.com/rodtoll - is there something on the ISY itself that could cause this error? My setup is pretty basic, a few lights and a couple of scenes.

What version of the FW are you currently running?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/rodtoll/homebridge-isy-js/issues/44#issuecomment-275282464, or mute the thread https://github.com/notifications/unsubscribe-auth/ADyYQ1_UUnHYBH3KWYRl9JZLTihtDuL7ks5rV_KFgaJpZM4LqjGM .

VeniceNerd commented 7 years ago

@rodtoll could you explain what "one variable of each type defined" means?

I have a few programs running on my end (to sync the Insteon keypad buttons with the state of each light). Besides that I have 1 6 button keypad, 2 DIN modules, and a couple of scenes in my ISY right now.

PaulWieland commented 7 years ago

@venicenerd the ISY has two types of variables you can define. Integer and state.

I think rodtoll wants you to create one of each and see what happens

VeniceNerd commented 7 years ago

@fahrvergnuugen and @rodtoll I hate to admit it but I don't know how to do implement the integer and state. Hopefully @crumbolt will know what to do in order to test this.

PaulWieland commented 7 years ago

@VeniceNerd it's quite easy. launch your ISY admin (java applet).

Go to

  1. Programs tab
  2. Variables tab
  3. Find the Integer tab
  4. Click Add then Save
  5. Click the State tab
  6. Click Add then Save

Here's the wiki article from UDI on it

VeniceNerd commented 7 years ago

@fahrvergnuugen Ah ok. Yes, that was easy! Thank you! And HOLY SHIT @rodtoll THAT WORKED:

screen shot 2017-01-26 at 9 04 04 am

It even imported my Keypad buttons and they show up in HomeKit!!!!! That means I can control other HomeKit accessories and scenes simply by pressing one of the Insteon buttons. This is the holy grail. WOW!

Maybe make this part of the release notes that an Integer and State is needed for this to work?

PaulWieland commented 7 years ago

@VeniceNerd - thats awesome glad you got it working.

Just a heads up, the keypad buttons are not super useful because they do not control a load. I started down the same path as you before realizing that ignoring them all and interacting with the scenes was a better approach.

To do what you are suggesting is possible but I think you have to use ISY programs to trigger the other insteon devices which actually carry the load.

VeniceNerd commented 7 years ago

@fahrvergnuugen You don't think so? I set up an automation in HomeKit saying: if "Keypad Button D" is "On" execute scene "I'm Home". It works perfectly! I press Keypad Button B and my Lutron shades go down, the Hue lights turn on, and my Insteon devices as well. It simply executes the HomeKit scene once the keypad button is "on". You could set a reverse scene for when the keypad button is "off".

I guess the one thing I couldn't do with this is execute different scenes depending on if I press the button once or double tap it. Looks the same to HomeKit. But this is still pretty awesome!

PaulWieland commented 7 years ago

Ahh, ok - i didn't know you were using triggers in homekit. I try to keep all the logic on my ISY.

Where does the homekit trigger logic execute? What happens if your phone battery is dead (or you are out of the house) and someone physically presses the keypad button?

VeniceNerd commented 7 years ago

@fahrvergnuugen since iOS 9 (or 10 I'm not sure anymore...) the logic executes locally on the AppleTV 4 or any iPad inside the house that's enabled as a HomeKit Hub. So as long as one of those devices is inside the house the triggers will execute.

So if my iPhone is turned off and someone presses the button it will still execute. It's pretty nice. Give it a shot.

VeniceNerd commented 7 years ago

@rodtoll there's still one issue, though, seems like Homebridge quits eventually with this error message:

screen shot 2017-01-26 at 11 53 41 am

Do you happen to know what that is about?

PaulWieland commented 7 years ago

The TCP connection to whatever is on 10.0.1.32 port 5222 is timing out.

What is on that IP? Is that your ISY?

VeniceNerd commented 7 years ago

@fahrvergnuugen It's the Logitech Harmony Hub through the Homebridge Harmony Hub plugin.

Seems like a common issue with that plugin, though, so I should probably take it over there. But if you do have any suggestion on how I can keep that from crashing my entire Homebridge I'd be all ears anyways. ;)

PaulWieland commented 7 years ago

Yeah, that's not a problem/bug with the ISY plugin.

Without looking at it, I guess there needs to be some code wrapped around the connection statements in their plugin to catch the thrown error. Why the Harmony Hub is going AWOL is yet an entire other question.

crumbolt commented 7 years ago

The variable fix worked for me as well. Thanks @rodtoll and @fahrvergnuugen for helping out.

Including that requirement in the docs might help others from encountering this issue.

Plugin is working great, thanks again.

VeniceNerd commented 7 years ago

@fahrvergnuugen Hey, I would love to discuss HomeKit vs ISY scenes in some more detail with you in regards which one is better to use as triggers. I have some thoughts and ideas. Where do you suggest we take that conversation? I don't want to clutter up this thread with it.

PaulWieland commented 7 years ago

I'm on the homebridge slack group. You can PM me there

Vyrolan commented 2 years ago

Two things to try -- 1) Do you have at least one variable of each type defined? If not, do so and see if that helps. 2) Make sure you have at least one program and that it's enabled. Even if it doesn't do anything. I'll try repros again tonight -- this time I'll remove elk support and try and use your exact config file and see what happens.

Five and a half years later and your comment saved me a lot of headache. Thanks!