tonesto7 / homebridge-smartthings

SmartThings Homebridge Plugin
383 stars 767 forks source link

Home bridge Plugin 0.4.4 through 0.4.6 - Losing devices #58

Closed pdlove closed 7 years ago

pdlove commented 8 years ago

It isn't yet, but please post here if it is.

Wildcat1 commented 8 years ago

@pdlove Testing the new build tonight, thanks for all your hard work !

Couple of things I have seen so far:

1) Dimmable items, or those that open/close to your (user) choice of brightness percentage seem to error out after adjusting brightness. On/Off shows correct power state but after setting brightness (opening close amount equivalent) then going back in (via a chosen app of course) I see an Error listed on brightness even though powered state is still showing good. For reference your Homebridge-Smarthings script is picking them up as Group - Lights. If you kill Homebridge and restart, everything comes back into sync until you set brightness again. Therefore restarting is the only way to get back in sync every time at the moment. Forgot to mention the devices I am referencing here are Keen Home Smart Vents that have Power (on/off) and open/close adjustment (showing as brightness in app) which show up as dimmable lights currently through the port.

2) The other issue I am seeing which has caused the new version of your script to break twice in my testing to far is Nest control. Specifically when I have tried to set the Nest to a temperature, it does it then kills Homebridge with the error below. At that point of course all items are lost and the script needs to be restarted:

/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 null. (/usr/local/lib/node_modules/homebridge-smartthings/accessories/smartthings.js:418:21) at emitTwo (events.js:87:13) at emit (events.js:172:7) at Characteristic.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:120:10) at processIncrementalUpdate (/usr/local/lib/node_modules/homebridge-smartthings/index.js:132:20) at /usr/local/lib/node_modules/homebridge-smartthings/lib/smartthingsapi.js:109:29 at IncomingMessage. (/usr/local/lib/node_modules/homebridge-smartthings/lib/smartthingsapi.js:46:29) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:905:12) at nextTickCallbackWith2Args (node.js:441:9) at process._tickCallback (node.js:355:17)

Hope the error above helps and as always if you want me to test anything just let me know.

Thanks again so much for your help with this !

thoward1234 commented 8 years ago

I am seeing the same thing. I have looked at the file and configuration. I have used the "most devices" to define my 47 devices. I always "loose" devices after the following device types: Remotec Dry Contact Sensor, GE lamp dimmer (12718), Aeon Labs DSC06106-ZWUS - Z-Wave Smart Energy Switch, or GE Link, Wireless A19 Smart Connected LED Light Bulb. Last night, I moved the Remotec Dry Contact Sensor to the "switch" section and the devices "lost" moved to the ones after the Smart Energy Switch. This morning, I moved the list above to the "switch" section. I'll have result later on today...

Wildcat1 commented 8 years ago

@pdlove After testing through the night, I did see the same issue re-appear, namely that the service would hit the unreach issue and lose the devices. Only way again to resolve is to restart. Here are the errors I saw, I masked out my IP but everything else including port is included, let me know if you want me to test anything else:

error at req: getaddrinfo ENOTFOUND graph.api.smartthings.com graph.api.smartthings.com:443 error at req: getaddrinfo ENOTFOUND graph.api.smartthings.com graph.api.smartthings.com:443 error at req: getaddrinfo ENOTFOUND graph.api.smartthings.com graph.api.smartthings.com:443 error at req: getaddrinfo ENOTFOUND graph.api.smartthings.com graph.api.smartthings.com:443 error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63911) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63913) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63914) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63915) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63916) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63919) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63922) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63925) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:63928) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:64759) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:64760) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:64761) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49169) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49174) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49264) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49354) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49358) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49398) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49401) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49405) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49488) error at req: connect EHOSTUNREACH 174.129.9.165:443 - Local (MASKED LOCAL IP:49527) error at req: connect EHOSTUNREACH 107.20.201.51:443 - Local (MASKED LOCAL IP:62285) error at req: connect EHOSTUNREACH 107.20.201.51:443 - Local (MASKED LOCAL IP:62286) error at req: connect EHOSTUNREACH 107.20.201.51:443 - Local (MASKED LOCAL IP:62287) error at req: connect EHOSTUNREACH 107.20.201.51:443 - Local (MASKED LOCAL IP:62290) error at req: connect EHOSTUNREACH 107.20.201.51:443 - Local (MASKED LOCAL IP:62291) [homebridge-smartthings.SmartThings] Invalid Response from API call error at req: read ECONNRESET error at req: read ECONNRESET error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:55448) error at req: connect EHOSTUNREACH 54.243.74.147:443 - Local (MASKED LOCAL IP:55449)

pdlove commented 8 years ago

This agrees with the problems I had last night with Smartthings in general. I'm almost done updating the plugin to hombridge's plugin framework version 2. I'm going to continue digging into these problems after that.

Wildcat1 commented 8 years ago

@pdlove Thanks for the update. Let us know if you want to test anything, code, devices etc. Will the update to the newer framework bring any new features, control etc ? Thanks again !

pdlove commented 8 years ago

The main thing that framework version 2 brings is the ability to dymically add/remove devices. So if Smartthings is down when you reboot homebridge, it will have the devices cached and not delete them on IOS. And I can get this to where it runs more than a few days without problems then adding/removing devices to smartthings would reflect in IOS without restarting homebridge.

Wildcat1 commented 8 years ago

@pdlove Thats great, thanks for the explanation. With regards to what I am seeing with dimmable items (vents in this case) is that something that you believe is an issue with the script itself and could be fixed or indicative of something else ? The SmartThings unreachable bit seems to be the biggest issue in terms of being recoverable etc

asrusch commented 8 years ago

FYI - I am now running more than 48 hours and everything is still there and working. Previous to 0.4.4, I would get around 36 hours before everything would freak out. I still see etimedout errors, but pretty far and few between and everything working fine after.

humac commented 8 years ago

I've had problems with 0.4.4 still. I'm also running netatmo and harmonyhub plugins so I am going to remove them and just run ST and see if that helps

Update: This didn't work for me when just running ST plugin I lost all devices after a few hours

asrusch commented 8 years ago

Update- all my accessories and homebridge disappeared.

leoneleone commented 8 years ago

same problem here with the plugin. Accessories disappear, then after some time, Homebridge itself disappears from my HomeKit config

Apparently this is due to the plugin accessories returning invalid characters/characteristics? Any thoughts on how to resolve this?

pdlove commented 8 years ago

I have some characteristic cleanup done it 4.5 that I just published. The accessory Json files helped a lot to track down potential problem areas.

thoward1234 commented 8 years ago

So...good news: Homebridge survived an overnight run. Bad news: I still lost 60% of my devices. The failure point has moved. It is now failing at one of my 2 my hue light strips. I have rearranged things and will report back

pdlove commented 8 years ago

Try this with 0.4.6. I finally started looking at datatypes in the JSON file and found brightness was being sent as a string in several occasions. Most programs that use JSON are able to handle this datatype issue, but not Apple apparently. I was able to duplicate it last night. What would happen is that everything would be fine until I adjusted the brightness at my light switch. After that, HomeKit would refuse to do any updates and, eventually, it would drop out every device after that light switch. This latest version is confirmed to not do that. I am opening a support case with SmartThings to find out why the streaming updates are sending numbers as strings.

thoward1234 commented 8 years ago

Thanks for the quick response! I updated and I'll report back

pdlove commented 8 years ago

Interestingly enough, fixing this makes it so it now works through my Apple TV when I'm away from home.

edasque commented 8 years ago

Anyone seeing: Error: Cannot find module './build/Release/bignum' ?

pdlove commented 8 years ago

@edasque From what I see on googling it, it's from a module called bignum that is missing or invalid. Over the last few releases, I'm only using round and ParseInt which are both built-ins. You can try to correct it with "npm install -g bignum".... but I don't think this is caused by homebridge-smartthings.

leoneleone commented 8 years ago

@pdlove I remember pointing out this datatype mismatch issue when you were working on the homebridge-sensibo plugin. You had mentioned that NodeJS should be able to handle datatype translation.

Maybe my intuition was correct then? 😊

It's great that things are working for you remotely via AppleTV now! So it seems far more beneficial for developers to consider DataTypes matching/mismatching when developing Homebridge plugins. I think other Homebridge developers should be told about this.

leoneleone commented 8 years ago

My intuition also tells me Apple has been making changes to HomeKit on the server side recently. Especially when it comes to HomeKit Siri Commands. I'm finding certain Siri Commands work one day and then the next day they don't. I have to change the wording and syntax of the commands to get the same desired command to be recognised.

pdlove commented 8 years ago

@leoneleone I've noticed that some of my Siri commands have changed up even not related to Home kit. I asked Siri to "tell me when my wife gets here" and it had no idea when it used to know. I had to change it to "tell me when my wife gets to my current location"

leoneleone commented 8 years ago

@pdlove it's as if they're experimenting with Siri command specificity. I've just tried using a command which used to work then stopped working a few days ago, and guess what? - now that original Siri command is working again.

This can't be a bug. I've noticed these "changes" to Siri Voice Commands lasting a couple of days at least.

Wildcat1 commented 8 years ago

@pdlove This was/is looking better from a dimmable device perspective for me. Specifically the vents (which show as dimmable items for open/close) seem to keep their setting, don't error.

However I am still seeing this script break when issuing a command to my Nest thermostat. Specifically when I set a temperature change I see the change show in the script and the action completes then the script breaks with the error below. It seemed to work at first but then broke using the same command.

Can this be fixed, or indicative of another issue ?:

/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 null. (/usr/local/lib/node_modules/homebridge-smartthings/accessories/smartthings.js:438:21) at emitTwo (events.js:87:13) at emit (events.js:172:7) at Characteristic.getValue (/usr/local/lib/node_modules/homebridge/node_modules/hap-nodejs/lib/Characteristic.js:120:10) at processIncrementalUpdate (/usr/local/lib/node_modules/homebridge-smartthings/index.js:132:20) at /usr/local/lib/node_modules/homebridge-smartthings/lib/smartthingsapi.js:109:29 at IncomingMessage. (/usr/local/lib/node_modules/homebridge-smartthings/lib/smartthingsapi.js:46:29) at emitNone (events.js:72:20) at IncomingMessage.emit (events.js:166:7) at endReadableNT (_stream_readable.js:905:12) at nextTickCallbackWith2Args (node.js:441:9) at process._tickCallback (node.js:355:17)

Wildcat1 commented 8 years ago

@All, quick update on the issue I posted above. I was able to track down and resolve it. Basically it seems to be generated when Homebridge is seeing two instances of the same device and only when using Siri. In this case because I am already using the Nest script by KraigM (which BTW also lets you bring your Nest Protects into the mix which is great) and had selected my Nest thermostat using your JSON Complete API, SIRI did not know which one to address, caused the issue and crashed the script.

After testing first by making adjustments within each instance (Nest’s own app, then SmartThings Nest control) I noticed they did not crash, knowing now it was due to addressing the single instance in that workflow. Again, issuing commands via Siri to ‘Nest’ tried to send to both instances being picked up by Homebridge (KraigM’s script and your SmartThings script where I had added the Nest to JSON).

Removing the instance within SmartThings and the JSON SmartApp, leaving the KraigM control of the device, solved the issue and right now Siri commands are working without crashing the script, wahoo !

On another note I also have noticed that although the connectivity issues (to SmartThings IP’s) are still happening every day that now I do not lose the devices from Homebridge and they can still be controlled the next day.

Will continue to test but this is looking a lot more stable now. Thank you so much to @pdlove for all your hard work on this, very much appreciate it !

pdlove commented 8 years ago

@wildcat1 thanks for the feedback. I always recommend that you use the home bridge plug in which goes directly to the API of the device and remove the JSON API from that device in smart things. I currently have everything going through smart things just to make sure all combinations that I can test I'm working, but now that we have the issue resolved I will be switching them out for the more specific plug-in and writing new plug-ins where needed. Also, the issue that we found has been fixed in home bridge. And I'm told it has improved The stability on a number of plug-ins. Thank you everyone for your patience and assistance in finding the problems with the plug-in.

thoward1234 commented 8 years ago

Much better news; First overnight run without losing any devices or crashing. Here's what I did:

  1. I updated homebridge.
  2. I updated the nest plugin. This turned out to be a lot more complicated than before due to the new nest requirements.
  3. I updated the smartthings plugin.

So nothing really special. Thanks for all your hard work on this @pdlove

Wildcat1 commented 8 years ago

@pdlove Thanks for the response and again for your hard work so far ! Yes the issue I had with passing the Nest through a Device Handler and into JSON was that on the receiving end (in this case a HomeKit app) there were errors with the device that wouldn't give full functionality. Therefore using it direct with KraigMs script and granted (as thoward mentioned) the rather convoluted way (using developer account on Nest) of getting access, works extremely well and again brings back the Nest Protects as well as the Thermostat.

Certainly interested in any plugins you may put in play. I know for me one of the ones I would like to get sorted is for the Keen Vents (HVAC) as I have not found a dedicated script at this time. Would love a more dedicated version so rather than showing as dimmable bulbs they do show up as vents. Certainly workable using as bulbs now (thanks to the fixes !) but like you said, always better if we can get something direct that addresses the full functionality of the underlying device.

Now if we could only get Samsung to solve their IP unavailability issues, timing problems, platform stability issues :)

Thanks again for your hard work on this, really do appreciate it. Look forward to what else you may have planned on this script in the future !

pdlove commented 8 years ago

I'm not sure if anyone is interested, but I have two other projects I'm working on right now.

1) A better HomeKit app that gives a more logical flow to device control including the use of Beacons to display controls relevant to where you currently are in your house. It should be able to pin point where you are with 4-6 long range beacons. It would also allow a wall mounted iPad to have a configurable set of items and server as a central trigger device to ensure your triggers fire quickly when you aren't home.

2) A raspberry pi with Zigbee and ZWave support and running homebridge. Essentially, an open source hub that is a more direct and local bridge from HomeKit to Zigbee and ZWave devices.

I'm not sure when either project will be in a usable state, but those are my side projects. I think #1 will come first

Wildcat1 commented 8 years ago

@pdlove sign me up for testing item 1, that sounds great !

asrusch commented 8 years ago

1 sounds great! that would be great

Side note: I'm still having issues with devices disappearing (all of them), but I updated to latest Homebridge, we'll see if that helps.

pdlove commented 8 years ago

@coolcom What other plugins do you have? @Wildcat1 I'm testing Khaost's app for him, but it's a considerably different approach to a HomeKit app than I'd like. I'm going to give hime information about how I envision workflow to work in a way that both me and my technologically deficient wife (If you ever happen to read this, I don't mean anything bad by this) would be able to use.

thoward1234 commented 8 years ago

Up for 1 full day; no issues! I'd love to help test as well....

asrusch commented 8 years ago

I have no other plugins

—

You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/pdlove/homebridge-smartthings/issues/58#issuecomment-200593174

thoward1234 commented 8 years ago

@coolcom: Run this command on a terminal (assuming you are running linux) tail /var/log/homebridge.err

This will print out the last lines of the error log. This is what I used (after the latest build) to figure out that my nest plugin was killing me. Maybe it won't reveal anything, but worth a try.

pdlove commented 8 years ago

@coolcom I'm having this issue after a restart last night... The smartthings plugin detects everything but HomeKit never says "Initializing" on each device. Does this match what you see?

rickybloomfield commented 8 years ago

I'm having an issue where it looks like items are initializing, but Homebridge never shows up as a device when I try to add it via any of the apps ...

pdlove commented 8 years ago

Have you previously associated Homebridge with a device? If so, you may need to clear out your persist folder.

rickybloomfield commented 8 years ago

It was a clean install. And I've deleted the persist folder a couple times for good measure. The only thing I did differently this time was to use the latest version of Node vs. the 4.x version I had before. But I wouldn't think that would make a difference.

pdlove commented 8 years ago

Was the phone previously connected? You can try changing the "User ID" in your config.json file to a different MAC and it may pop up.

rickybloomfield commented 8 years ago

I've done that, too. I'll keep checking - maybe there's something else I missed.

pdlove commented 8 years ago

Last idea.. reset HomeKit on the phone and delete the persist. If that doesn't fix it... check your network and use a bonjour browser app to make sure you see hombridge... I'm all out of ideas after that.

rickybloomfield commented 8 years ago

Cool, thanks.

thoward1234 commented 8 years ago

From my point of view, you can close this. I have been up continuously for the past week more stable than I have ever been. I have not had SIRI delay or refuse commands once! Thanks for the hard work! Here is my configuration for the curious:

asrusch commented 8 years ago

I'm finally running without issues for ~5+ days! Yay!