sean9keenan / homebridge-bigAssFans

A Homebridge plugin for Big Ass Fans
MIT License
28 stars 15 forks source link

Homebridge fails to start port binding error: #1

Closed dsully closed 7 years ago

dsully commented 8 years ago

Given:

      {
          "accessory": "BigAssFan",
          "name": "Master Bedroom Fan",
          "fan_name": "Master Bedroom Fan",
          "fan_id": "20:F8:5E:AB:32:56",
          "fan_ip_address": "192.168.0.134"
      }

Homebridge fails to start:

[6/28/2016, 6:38:05 AM] [Master Bedroom Fan] Initializing BigAssFan accessory...
events.js:154
      throw er; // Unhandled 'error' event
      ^

Error: bind EADDRINUSE 0.0.0.0:31415
    at Object.exports._errnoException (util.js:856:11)
    at exports._exceptionWithHostPort (util.js:879:20)
    at dgram.js:214:18
    at nextTickCallbackWith3Args (node.js:485:9)
    at process._tickCallback (node.js:391:17)
    at Function.Module.runMain (module.js:449:11)
    at startup (node.js:139:18)
    at node.js:999:3

There's nothing listening on 31415. Except for when the plugin code tries to bind:

    this.server.bind(this.fanPort, (function () {
        this.server.setBroadcast(true);
        this.connectionOpen = true;
        this.rescanUntilAllFans();
    }).bind(this));
sean9keenan commented 8 years ago

Is it possible that you're running another instance of BigAssAPI? Although from what I've seen that doesn't cause a Address in use error, just unexpected behavior.

Do you have other accessories in homebridge that might also be binding to that same port?

Try running the following to find which processes might already be bound to the port (If you don't find anything without homebridge running, try running it without the BigAssFan in the config)

lsof -i :31415
dsully commented 8 years ago

Already ran lsof, as root. Nothing there. No other instances. Rebooted the box as well.

I have 4 Big Ass Haiku fans, Sonos & a HarmonyHub. Nothing else on that port.

sean9keenan commented 8 years ago

I just realized the way this is written, it might fail spectacularly if you have more than one fan. Did you try and run just one fan? Thanks for testing this out, sorry it's not working as expected :|

dsully commented 8 years ago

I've not tried just one fan.. I'll be back in a place where I can do that on Saturday (7/2).

sean9keenan commented 8 years ago

More fans on the network should be fine, as long as you're only specifying one fan in the config file. (My setup is 3 fans visible over wifi, but making HomeKit only work for one right now)

On Wednesday, June 29, 2016, Dan Sully notifications@github.com wrote:

I've not tried just one fan.. I'll be back in a place where I can do that on Saturday (7/2).

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sean9keenan/homebridge-bigAssFans/issues/1#issuecomment-229363905, or mute the thread https://github.com/notifications/unsubscribe/ACAn3Acc0QNy86BDURuXEr04FGCGtvZoks5qQnn8gaJpZM4JAHO_ .

dsully commented 8 years ago

Ok.. ideally they would all work via HomeKit, yes?

sean9keenan commented 8 years ago

Haha, yup. I'm just going to have to change where the "FanMaster" is stored so that any accessory that starts can access it. Just need to figure out the best way to do that inside of homebridge.

Should be able to test it tonight or Thursday night, but haven't been near my fan for a little bit

On Wednesday, June 29, 2016, Dan Sully notifications@github.com wrote:

Ok.. ideally they would all work via HomeKit, yes?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sean9keenan/homebridge-bigAssFans/issues/1#issuecomment-229384180, or mute the thread https://github.com/notifications/unsubscribe/ACAn3DmNhj4RNIo7c7Dp668Ys1_Vb1eUks5qQoi1gaJpZM4JAHO_ .

pedroserano commented 8 years ago

Or can the homebridge plugin be changed from an accessory to a platform and have it pull all fans from the FanMaster when it starts?

sean9keenan commented 8 years ago

Yeah, that's my current plan after talking a bit on the homebridge slack channel - I just haven't gotten a chance to start work on it. I'll assign this issue to myself when I start so that you can know that I'm working on it. My guess is that I'll be able to get to it within the next week.

pedroserano commented 8 years ago

Awesome! I already love how the homebridge plugin works with my haiku. Now I might have to get more fans :)

dsully commented 8 years ago

Hey Sean - have you had any time to work on this? Thanks

smokey-live commented 8 years ago

I just installed this home bridge plugin and it works fantastically for a single fan. I would love to get it working for both of my fans though but it fails when I add 2 fans as accessories. Any progress on getting this to work with 2 fans?

Thanks!

sean9keenan commented 8 years ago

Hey guys - sorry for not working on this for a while.

I spent some time getting at least something kind of passable working. You can try it out here: https://github.com/sean9keenan/homebridge-bigAssFans/tree/discovery

Haven't updated the readme fully, but... jist of it is now you do this:

    "platforms": [
        {
            "platform": "BigAssFans",
            "name": "Big Ass Fan"
        }
    ]

in the config, and it shouldn't break compatibility with the old way two major issues I want to fix:

sean9keenan commented 8 years ago

Also - if it wasn't clear, this now does discovery of fans on your network, so you don't have to specify the fan's IP addresses or the name.

smokey-live commented 8 years ago

Ok, I just got back home from being out of town for 3 weeks. I'm confused. Do I not need the accessory section anymore? Is all that is needed is this?

"platforms": [ { "platform": "BigAssFans", "name": "Big Ass Fan" } ]

Do I need to upgrade the plugin somehow?

sean9keenan commented 8 years ago

That's all you need in the config in order to test this - unfortunately you need to grab the plugin from the git repo and try the discovery branch I made.

One way of doing this is by cloning the repo:

git clone git@github.com:sean9keenan/homebridge-bigAssFans.git
git checkout discovery

and then following instructions here to run a local copy of homebridge-bigAssFans

gsxdsm commented 8 years ago

Thanks sean!

I was able to fix the need to clear the cachedAccessories after every run, will submit a PR

sean9keenan commented 8 years ago

Thanks gsxdsm!

Look forward to seeing the PR, as soon as that goes in I'll update the NPM package as well!

gsxdsm commented 8 years ago

https://github.com/sean9keenan/homebridge-bigAssFans/pull/5

It was a little more involved than I anticipated

sean9keenan commented 7 years ago

Merged this into master, should be all working now 👍