BobRak / OpenHAB-Smartthings

53 stars 54 forks source link

ADT Smartthings hub not detected #101

Open odror opened 3 years ago

odror commented 3 years ago

Hi I followed up the installation process on ubuntu (20.10)

  1. I installed the OpenhabAppV2 on the smartthing app. I was able to enable all my devices.
  2. In the addons I have added the binding-smartthings - 2.5.10
  3. On the inbox selected + then Smartthing Nothing is discovered.
  4. I have added the hub manually. I can see it online in configuration->things.
  5. going back to inbox + smartthings. Nothing is detected.

Google home can detect all my devices. So there is no issue with my hub.

BobRak commented 3 years ago

In PaperUI do you have: Configuration > Things > Smartthings Hub? If you select that you should be able to enter the IP of your Smartthings Hub.

In the Installation of Smartthings Code have you completed the Create a Device section and provided the IP. mac and port of your openhab server?

Also, you need to have fixed IP addresses configured in your router for the ST hub and openHAB devices.

odror commented 3 years ago

I have done all of that. The smartthubg hub is online. I have fixed IPs When I go top inbox + smartthing nothing is detected. Even the hub is not detected. It is online on configuration -> things, but is not detected in the inbox. Is there a way to get a useful debuging information.

BobRak commented 3 years ago

Are you configuring with files or just through the PaperUI? If through files please send me the Smartthings related part of your ?.things file.

In the ST config done on your phone in the ST app do you have some entries that look like this: image

If you look at issue #95 you will find instructions for using curl to send a discovery request to the hub.

Please double check the installation steps. Unfortunately it is a long and complicated process. 99% of the time I spend a lot of time answering questions only to find that the requester missed something in the installation instructions.

odror commented 3 years ago

I have reviewed all the items. My setup is correct. port 39500 is open on the hub. I use Ubuntu. I used the nc command to listen to port 8089. As soon as I connected to the port I got

{"capabilityAttribute":"motion","deviceDisplayName":"Front Porch","value":"inactive"}POST /smartthings/state HTTP/1.1
Accept: */*
User-Agent: Linux UPnP/1.0 SmartThings
HOST: 192.168.0.2:8089
Content-Type: application/json
Content-Length: 85

I got additional responses like that before issuing the curl command.

This indicated the my smartthing setup is correct.

But When I sent the command:

curl -H "Content-Type: application/json" -H "192.168.0.62:39500" --data "{"discovery": "yes" }" http://192.168.0.62:39500/discovery

Nothing happens. I only get random response that is unrelated to the curl command.

The IP address of the hub is also listed in smartthings as 192.168.0.62

BobRak commented 3 years ago

First of all, by default port for openHAB is 8080. Why are you using 8089? Is the url you use for paperui: http://xx.xx.xx.xx:8089/paperui/index.html or port 8080. The Device Handler should be configured for the same port that you use with paperui.

The message you sent looks like your hub is notifying openHAB that the state of "capabilityAttribute":"motion","deviceDisplayName":"Front Porch" is inactive.

For debugging you can logon to the ST developers website and then click on Live Logging. Then run the curl command and see what ST logs. I have quite a few log messages in the SmartApp and Device Handler. That might give you some clue.

You never answered my question about using files or paperui for configuration. I would highly recommend that you start with files (.things, .items, .sitemap). The files don't use or depend on discovery. And, start with a switch if possible.

Just so I am clear, what is the IP of your openHAB server and of your ST hub?

What devices are configured in your ST hub and included in the smart app?

Looking at your OpenHAB Device in the ST IDE please tell me what the IP, port and mac are. Do these match those values on your openhab server?

If you have additional questions please make sure to answer the questions I have asked.

Bob

odror commented 3 years ago

I used port 8089 for testing with curl as recommend in that post ( may be to avoid conflict with the server port). Now I changed it back to port 8080 (using this port I can do the testing with curl command only when the server is not running. It is not possible for me and the server to listen to the same port) When I listen to the port I get all the notification from the ST server.

I use paper ui. with the default ubuntu installation. (not manual install) The openhab ip is 192.168.0.2 and the ST hub is 192.168.0.62

All the possible devices are included and enabled (multiple motion detectors, switches and AC)

in the ST IDE the network ID is 0201CF8ACEAF and the ip is 192.168.0.2 mac is 02:01:cf:8a:ce:af

No event shows up when I send the curl command from the openhab computer, but I get and error event when I send from a different computer. That tells me that the curl command is received, but it is also ignored.

BobRak commented 3 years ago

From my last response:

  1. Does the mac (02:01:cf:8a:ce:af) match the mac of your linux server? ST uses this to figure out where to send the response.
  2. What is the live logging telling you?
odror commented 3 years ago

The mac address matches.

I get no response on live loging from openhab. I get other events that are not related. I know that it receives the curl command, because if I run the same curl command from a different computer I get an error in the event log.

BobRak commented 3 years ago

I'm running out of ideas.

  1. Have you looked at the ST Live Logs? What do they say?
  2. When you look at the configuration of the hub does it have the IP and port of your ST hub? You may have to change this URL to match your setup.
  3. Have you tried configuration using files? If not that would be worth a try.
odror commented 3 years ago

The live log shows the follwing when search for smartthings:

1e1d4799-2698-457e-8320-0ab5404ce33b 1:49:51 PM: debug Msg '[index:15, mac:0201CF8ACEAF, ip:C0A80002, port:1F90, requestId:be0c304e-f3c0-400d-98ec-798dee7ecc7e, headers:[content-length:0, http/1.1 200 ok:null, server:Jetty(9.4.20.v20190813)], body:null, header:HTTP/1.1 200 OK
Content-Length: 0
Server: Jetty(9.4.20.v20190813), status:200]'
1e1d4799-2698-457e-8320-0ab5404ce33b 1:49:51 PM: debug Msg '[index:15, mac:0201CF8ACEAF, ip:C0A80002, port:1F90, requestId:be0c304e-f3c0-400d-98ec-798dee7ecc7e, headers:[content-length:0, http/1.1 200 ok:null, server:Jetty(9.4.20.v20190813)], body:null, header:HTTP/1.1 200 OK
Content-Length: 0
Server: Jetty(9.4.20.v20190813), status:200]'

My configuration looks good:

Configuration Parameters
Configure parameters for the thing.

IP Address
192.168.0.62
IP address of the Smartthings Hub

IP Port Number
39500
Port number of the Smartthings Hub

When I use the following curl command:

curl -H "Content-Type: application/json" -H "192.168.0.62:39500" --data "{\"discovery\": \"yes\" }" http://192.168.0.62:39500/discovery

I get in the live log:

1e1d4799-2698-457e-8320-0ab5404ce33b 2:06:59 PM: debug Creating event with message: [path:discovery]
1e1d4799-2698-457e-8320-0ab5404ce33b 2:06:59 PM: debug Msg '[index:04, mac:0201CF8ACEAF, headers:[post /discovery http/1.1:null, 192.168.0.62:39500, content-length:21, host:192.168.0.62:39500, user-agent:curl/7.68.0, content-type:application/json, accept:*/*], body:{"discovery": "yes" }, header:POST /discovery HTTP/1.1
Host: 192.168.0.62:39500
User-Agent: curl/7.68.0
Accept: */*
Content-Type: application/json
192.168.0.62:39500
Content-Length: 21, data:[discovery:yes], json:[discovery:yes]]'

But I do not get the list of things.

If I use configuration files. Do I need purge my installation and reinstall again.

BobRak commented 3 years ago

Here is what my live logging looks like when I run discovery from the paperui:

81e2ad40-7821-4328-9171-c6f613efe3e5 3:17:41 PM: debug Discovery is returning FINAL JSON: {"path":"/smartthings/discovery","body":["{\"capability\": \"battery\", \"attribute\": \"battery\", \"name\": \"Garage Door\", \"id\": \"fe147198-9c03-4c88-bb1d-b46749bf2fad\" }","{\"capability\": \"colorControl\", \"attribute\": \"hue\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"colorControl\", \"attribute\": \"saturation\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"colorControl\", \"attribute\": \"color\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"colorTemperature\", \"attribute\": \"colorTemperature\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"contactSensor\", \"attribute\": \"contact\", \"name\": \"Garage Door\", \"id\": \"fe147198-9c03-4c88-bb1d-b46749bf2fad\" }","{\"capability\": \"outlet\", \"attribute\": \"switch\", \"name\": \"Christmas Tree Ligh...[TRUNCATED] 81e2ad40-7821-4328-9171-c6f613efe3e5 3:17:41 PM: debug Discovery returned data for 21 devices. 6ea8cd77-60be-4480-b6d1-1a36fc38ac69 3:17:41 PM: debug Sending '{"path":"/smartthings/discovery","body":["{\"capability\": \"battery\", \"attribute\": \"battery\", \"name\": \"Garage Door\", \"id\": \"fe147198-9c03-4c88-bb1d-b46749bf2fad\" }","{\"capability\": \"colorControl\", \"attribute\": \"hue\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"colorControl\", \"attribute\": \"saturation\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"colorControl\", \"attribute\": \"color\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"colorTemperature\", \"attribute\": \"colorTemperature\", \"name\": \"Sengled Bulb\", \"id\": \"e5878a31-3d0a-44e0-b61b-9c5c34075239\" }","{\"capability\": \"contactSensor\", \"attribute\": \"contact\", \"name\": \"Garage Door\", \"id\": \"fe147198-9c03-4c88-bb1d-b46749bf2fad\" }","{\"capability\": \"outlet\", \"attribute\": \"switch\", \"name\": \"Christmas Tree Lights\", \"id\": \"8eba18b3-4...[TRUNCATED] 81e2ad40-7821-4328-9171-c6f613efe3e5 3:17:41 PM: debug Received device event from Message : [path:discovery] 81e2ad40-7821-4328-9171-c6f613efe3e5 3:17:41 PM: debug Entered discovery handler with mapIn: [path:discovery] 6ea8cd77-60be-4480-b6d1-1a36fc38ac69 3:17:40 PM: debug Creating event with message: [path:discovery] 6ea8cd77-60be-4480-b6d1-1a36fc38ac69 3:17:40 PM: debug Msg '[index:5A, mac:DCA63245BEB2, headers:[post /discovery http/1.1:null, content-length:20, accept-encoding:gzip, host:192.168.87.37:39500, user-agent:Jetty/9.4.20.v20190813, content-type:application/json], body:{"discovery": "yes"}, header:POST /discovery HTTP/1.1 Accept-Encoding: gzip User-Agent: Jetty/9.4.20.v20190813 Content-Type: application/json Host: 192.168.87.37:39500 Content-Length: 20, data:[discovery:yes], json:[discovery:yes]]'

I would expect the response you are seeing if you have not selected any devices when you run the OpenHabAppV2 SmartApp from the SmartthingsApp on your phone. But you say that you have selected the devices. Just to be sure, here are the steps:

  1. Run the Smartthings app on your phone
  2. From the top hamburger menu select SmartApps
  3. Make sure the OpenHabAppV2 is enabled
  4. Select the OpenHabAppV2
  5. For each device that doesn't have "No devices found" tap the device name
  6. On the next screen select the devices you want to control with Openhab. It is only these devices that can be discovered.
  7. Click "Done"

Configuration with files You can do both Discovery and configuration with files. There live together very nicely. And, everytime you save a file it is reloaded and the devices are updated. Make sure to to the .things first. The .item which needs the things to connect to. And lastly the .sitemap which needs the items.

Additional curl commands

--- Ask for state 
curl -H "Content-Type: application/json" -H "192.168.87.37:39500" -d '{"capabilityKey": "switch", "deviceDisplayName": "Simulated Dryer", "capabilityAttribute": "switch"  }' http://192.168.87.37:39500/state
--- Update state 
curl -H "Content-Type: application/json" -H "192.168.87.37:39500" -d '{"capabilityKey": "switch", "deviceDisplayName": "Simulated Dryer", "capabilityAttribute": "switch", "value": "on"  }' http://192.168.87.37:39500/update

Edit to fit your system. But, you can check the status of devices and control them.

odror commented 3 years ago

Something is wrong on my computer setup. It is hard to pin down.

After a long delay when I send the discovery curl command, I get a full list of things in the live logging, but when I send it again I get this response

92957f86-6349-4e87-b2f8-de5175ffbec5 12:58:39 PM: debug refresh() is called

92957f86-6349-4e87-b2f8-de5175ffbec5 12:58:39 PM: debug refresh() is called
92957f86-6349-4e87-b2f8-de5175ffbec5 12:58:39 PM: debug refresh() is called
3ad3694f-7496-4e8c-b78c-00d4d8db3b14 12:58:38 PM: debug refresh() is called
3ad3694f-7496-4e8c-b78c-00d4d8db3b14 12:58:38 PM: debug refresh() is called
186a8280-f0cd-4dcf-9b16-850757038705 12:58:32 PM: debug refresh() is called
186a8280-f0cd-4dcf-9b16-850757038705 12:58:32 PM: debug refresh() is called
186a8280-f0cd-4dcf-9b16-850757038705 12:58:32 PM: debug refresh() is called
1e1d4799-2698-457e-8320-0ab5404ce33b 12:58:28 PM: debug Creating event with message: [path:discovery]
1e1d4799-2698-457e-8320-0ab5404ce33b 12:58:28 PM: debug Msg '[index:06, mac:0201CF8ACEAF, headers:[post /discovery http/1.1:null, 192.168.0.62:39500, content-length:21, host:192.168.0.62:39500, user-agent:curl/7.68.0, content-type:application/json, accept:*/*], body:{"discovery": "yes" }, header:POST /discovery HTTP/1.1
Host: 192.168.0.62:39500
User-Agent: curl/7.68.0
Accept: */*
Content-Type: application/json
192.168.0.62:39500
Content-Length: 21, data:[discovery:yes], json:[discovery:yes]]'

Also when I try to make any thing manually using the paperui I get the following error:

error 500 request failed

It is clear that there is some issue in my openhab setup. Not in smartthing setup on the web or app. I do not see any debugging info in my system. Is there anyway to debug it.

BobRak commented 3 years ago

Only a couple of thoughts

  1. have you tried rebooting the ST hub? If not it is worth a try
  2. Is it possible that your openHAB server has multiple ethernet ports or a wired port and wireless port? And, the mac you put in the device handler does not match the port you are using.
  3. There is a section in the openhab doc for changing the openhab log level (click here). Set log level to DEBUG.
  4. Try flushing the openhab cache. Instructions here.

If I think of anything else I'll send it to you.

BobRak commented 3 years ago

Hi @odror I know this is a long time after you opened this issue but... A few days ago I setup a new openHAB server and used the Smartthings binding from the openHAB repository and I also discovered the Discovery service is broken. I'm very sorry it has taken me so long to discover that. In the future I'll do a new update whenever there is a new release.

Today I am installing the development environment and will investigate. I'll let you know when I have a new binding you can download. Maybe you don't care and have moved on. But, I did want you to know.

Bob