BobRak / OpenHAB-Smartthings

53 stars 54 forks source link

connection refused errors possibly after upgrading to 2.3 #43

Closed kociubin closed 5 years ago

kociubin commented 6 years ago

I recently upgraded to Openhab 2.3 on linux. Shortly after upgrading I noticed that the integration no longer works for sending commands to my SmartThings devices (status update events still work though). I'm not sure if it's because of the upgrade to 2.3 or some other change on the Samsung's side.

I'm getting the following errors:

==> /var/log/openhab2/openhab.log <== 2018-06-10 16:16:44.603 [INFO ] [ings.handler.SmartthingsThingHandler] - Attempt to send command to the Smartthings hub failed with: {} java.util.concurrent.ExecutionException: java.net.ConnectException: Connection refused at org.eclipse.jetty.client.util.FutureResponseListener.getResult(FutureResponseListener.java:118) [72:org.eclipse.jetty.client:9.3.21.v20170918] at org.eclipse.jetty.client.util.FutureResponseListener.get(FutureResponseListener.java:110) [72:org.eclipse.jetty.client:9.3.21.v20170918] at org.eclipse.jetty.client.HttpRequest.send(HttpRequest.java:676) [72:org.eclipse.jetty.client:9.3.21.v20170918] at org.openhab.binding.smartthings.internal.SmartthingsHttpClient.sendDeviceCommand(SmartthingsHttpClient.java:58) [189:org.openhab.binding.smartthings:2.2.0.201801151705] at org.openhab.binding.smartthings.handler.SmartthingsThingHandler.handleCommand(SmartthingsThingHandler.java:105) [189:org.openhab.binding.smartthings:2.2.0.201801151705] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?] at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [101:org.eclipse.smarthome.core:0.10.0.oh230] at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [101:org.eclipse.smarthome.core:0.10.0.oh230] at com.sun.proxy.$Proxy137.handleCommand(Unknown Source) [189:org.openhab.binding.smartthings:2.2.0.201801151705] at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [108:org.eclipse.smarthome.core.thing:0.10.0.oh230] at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [108:org.eclipse.smarthome.core.thing:0.10.0.oh230] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?] at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?] at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [101:org.eclipse.smarthome.core:0.10.0.oh230] at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [101:org.eclipse.smarthome.core:0.10.0.oh230] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?] at java.lang.Thread.run(Thread.java:748) [?:?] Caused by: java.net.ConnectException: Connection refused at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[?:?] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717) ~[?:?] at org.eclipse.jetty.io.SelectorManager.finishConnect(SelectorManager.java:355) ~[?:?] at org.eclipse.jetty.io.ManagedSelector.processConnect(ManagedSelector.java:352) ~[?:?] at org.eclipse.jetty.io.ManagedSelector.access$900(ManagedSelector.java:56) ~[?:?] at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.processSelected(ManagedSelector.java:289) ~[?:?] at org.eclipse.jetty.io.ManagedSelector$SelectorProducer.produce(ManagedSelector.java:181) ~[?:?] at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.executeProduceConsume(ExecuteProduceConsume.java:249) ~[?:?] at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:148) ~[?:?] at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.execute(ExecuteProduceConsume.java:100) ~[?:?] at org.eclipse.jetty.io.ManagedSelector.run(ManagedSelector.java:147) ~[?:?] at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:671) ~[?:?] at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:589) ~[?:?] ... 1 more

BobRak commented 6 years ago

@kociubin : Are you still having this issue? Is you linux setup on a Raspberry Pi or other type of box? If on a RPi are you using the standard OpenHAB RPi setup? Have you tried looking at the Smartthings log? Is there anything there? Have you double checked your config on the Smartthings developers website, if not please let me know if there is anything there.

Right now I'm in the process of moving and it has been dragging on longer that I anticipated it would. Currently my PC is in one state and my Smartthings hub, RPi, etc is a state away. Once I finish my move I'll see what is happening on my setup. Unfortunately that could be as late as early August.

Bob

kociubin commented 6 years ago

Yes, still happening. It's a linux VM running Ubuntu 16.04. It used to work fine. There is nothing in the Smartthings log. I double and triple checked the configuration. The only thing I can think of is that Samsung made some change that prevents commands to be sent to devices but allows events to be received.

BobRak commented 6 years ago

I know very little about using VM slices but is it possible the VM isn't allowing the connection? Can you successfully ping the Smartthings hub? If not, can you successfully ping it from another computer on the same network?

I don't have a good idea how many people are using this binding. But, I haven't heard of other issues where openHAB doesn't work after upgrading to 2.3. But, that might just mean your the first.

If I had my Smartthings hub and computer in the same house I would try an upgrade. But, that isn't possible right now. I'll be up in WA in late June and will bring the hub and an SD card back an see how it goes for me.

Bob

kociubin commented 6 years ago

Thank you for offering to look into it. I'll wait.

I tried moving the installation from my VM to a raspberry Pi and I'm having the same issue. Yes, I can successfully ping the hub.

I'm starting to think that this may have something to do with my hub. I'm using a smarthings USB stick plugged into my Nvidia Shield. It's possible that as a result of a recent Shield upgrade or a change on Samsung's side things simply stopped working. I have no idea how to troubleshoot this theory. Any help would be appreciated.

toddsgolfin commented 5 years ago

I'm having the same issue when install on OpenHAB v2.3. I'm running a vanilla install on a Pi3B+. Has there been any resolution to this issue?

Todd

BobRak commented 5 years ago

I am currently trying to build the binding under openhab 2.3 and am running into lots of problems. When I get it figured out I'll upload a new version.

toddsgolfin commented 5 years ago

Cool...if there's anything I can do to help...please let me know.

Thanks Bob!!

BobRak commented 5 years ago

Hi:

I have rebuilt the binding using the current development/build environment which is v 2.4. And, I deployed openHAB 2.3.0-1 to my RPi. This time I configured the system using the PaperUI and a sitemap. The Sitemap is correctly displaying the status of the things I have connected and changing them in the sitemap works correctly. And, the sitemap is updated at devices are turned on and off.

Please try downloading the new jar file which can be found here and let me know if you are still having issues.

Thanks,

Bob

rbarahonav commented 5 years ago

Hi,

I'm seeing the same issue on Windows 10.

The complete Exception stack looks like this:

20:53:02.086 [INFO ] [hings.handler.SmartthingsThingHandler] - Attempt to send command to the Smartthings hub failed with: {} java.util.concurrent.TimeoutException: Total timeout 3000 ms elapsed at org.eclipse.jetty.client.HttpDestination$TimeoutTask.onTimeoutExpired(HttpDestination.java:515) ~[?:?] at org.eclipse.jetty.io.CyclicTimeout$Wakeup.run(CyclicTimeout.java:271) ~[?:?] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[?:?] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) ~[?:?] at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[?:?] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?] at java.lang.Thread.run(Thread.java:748) [?:?]

I'm using openHab 2.4 and the latest bindings jar org.openhab.binding.smartthings-2.4.0.jar

Also I've disabled Windows firewall and I'm able to reach port 39500 on the Smartthings Hub v2.

Nmap scan report for 192.168.xx.xx Host is up (0.076s latency). PORT STATE SERVICE 39500/tcp open unknown

If there is any way I can help Bob just let me know. I'm looking forward to getting this binding to work.

Regards,

Rodrigo

BobRak commented 5 years ago

Hi @rbarahonav My development environment runs on Windows and I am not having any problem connecting to my hub. My hub is a V2 but V3 should work the same. So, I don't think it has to do with you being on Windows.

Are you configuring through the PaperUI or files? If you are using PaperUI make sure you configure the Smartthing Hub first with the IP of the hub and the port (39500). If you are using files then you specify the IP and port in the Bridge line in the things file.

Also, have you gone through the Smartthings Installation instructions. Especially the part titled "Create the Device". Have you put the IP and Port of your PC as described?

Let me know how it goes.

Bob

rbarahonav commented 5 years ago

Bob,

My bad... I had the wrong port... XD I'm using PaperUI and have read the Smartthings installation instructions you provide.

Now I'm having trouble with autodiscovery not working but I'll look into it tomorrow.

From the Inbox I'm clicking Search for Things, then I click on the Smartthings Binding but don't get anything back. I'm just trying to link to a Sengled Element classic Light Bulb that's configured on my v2 hub.

The last line of the log says: [INFO ] [things.internal.SmartthingsHttpClient] - Sent message "{"discovery": "yes", "openHabStartTime": 1550542574896}" with path "/discovery" to the Smartthings hub, recieved HTTP status 202

I'll let you know how it goes...

Thanks!,

Rodrigo

BobRak commented 5 years ago

@rbarahonav The last section of the Installation of Smartthings Code describes configuring the Smartthings App on your phone. Have you added your Bulb there? If not OpenHAB won't see it.

rbarahonav commented 5 years ago

@BobRak Must have been sleep deprivation because today I checked each step and it turns out that I entered my Smartthings Hub MAC address instead of the OpenHab's Server MAC address when I was creating the OpenHabDevice. Corrected that and it's working :)

Autodiscovery works great and inmediately found my Light bulb, Motion Sensor and Open/Close Door Sensor.

What can I say Bob, great work! 🥇

I'll be reading some more to better understand how you managed to put all these pieces together. This setup is not for the faint hearted because of all the steps involved but I got a great time out of it.

Thank you very much!

Rodrigo

BobRak commented 5 years ago

@rbarahonav Glad you got it working. I agree that it is a lot of steps. One thing that would help is if I could publish the Smartthings code on the Smartthings website but that is currently closed. I will rearrange the documentation a little to make it easier to follow, I hope.