Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SmartThings could not validate the webhook URL #98343

Closed
chrwei opened this issue Aug 13, 2023 · 12 comments
Closed

SmartThings could not validate the webhook URL #98343

chrwei opened this issue Aug 13, 2023 · 12 comments

Comments

@chrwei
Copy link

chrwei commented Aug 13, 2023

The problem

When setting up Smartthings after entering the access token I get the error "SmartThings could not validate the webhook URL. Please ensure the webhook URL is reachable from the internet and try again.". the logs show this timeout error, but the error comes immediately, less than 2 seconds, it doesn't feel like a timeout.

I have done the curl -X lifecycle PING from an external linux host and it succeeds. I have tried adding the debug log config yaml, but it has no change, I'm guessing because the error is from configflow? I also do not have a .storage folder.

Additionally, if I put the callback URL into a browser on an outside host, I do get the expected "Webhook only supports PUT,POST methods but GET was received" error, so I believe my ssl and external access is working fine.

What version of Home Assistant Core has the issue?

core-2023.8.1

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Smartthings

Link to integration documentation on our website

https://www.home-assistant.io/integrations/smartthings

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: homeassistant.components.smartthings.config_flow
Source: components/smartthings/smartapp.py:145
Integration: smartthings (documentation, issues)
First occurred: 9:48:38 AM (1 occurrences)
Last logged: 9:48:38 AM

API error setting up the SmartApp: {'requestId': '4258879409799745033', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://xx:8123/api/webhook/xx', 'message': 'Upstream target timed out', 'details': []}]}}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 126, in async_step_pat
    app, client = await create_app(self.hass, self.api)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app
    app, client = await api.create_app(app)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/smartthings.py", line 110, in create_app
    entity = await self._service.create_app(app.to_data())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 171, in create_app
    return await self.post(API_APPS, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 395, in post
    return await self.request("post", self._api_base + resource, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 368, in request
    raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "4258879409799745033", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "https://xx:8123/api/webhook/xx", "message": "Upstream target timed out", "details": []}]}}

Additional information

My home assistant OS is running as a virtual machine on a Synology NAS, and https to http reverse proxied via Synology's such that Synology handles the SSL cert. I'm also using ducknds DDNS. The HA Android app on cell data and Google's Assistant connections work via https without issue.

@home-assistant
Copy link

Hey there @andrewsayre, mind taking a look at this issue as it has been labeled with an integration (smartthings) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of smartthings can trigger bot actions by commenting:

  • @home-assistant close Closes the issue.
  • @home-assistant rename Awesome new title Renames the issue.
  • @home-assistant reopen Reopen the issue.
  • @home-assistant unassign smartthings Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


smartthings documentation
smartthings source
(message by IssueLinks)

@chrwei
Copy link
Author

chrwei commented Aug 23, 2023

Do i need to provide more info? what info is needed?

@omerfaruk-aran
Copy link

I'm experiencing the same issue exactly as chrwei described. The only difference is that I'm using DNS and SSL through Cloudflare. This way, I can establish a smooth connection both on mobile and in browsers. Moreover, my integrations with Amazon Alexa work flawlessly with this SSL. My operating system is installed on RPi 4 8GB, and the system details are as follows:

Home Assistant 2023.8.4
Supervisor 2023.08.1
Operating System 10.5
Frontend 20230802.1 - latest

Log Details (ERROR)
Logger: homeassistant.components.smartthings.config_flow
Source: components/smartthings/smartapp.py:145
Integration: smartthings ([documentation](https://www.home-assistant.io/integrations/smartthings), [issues](https://github.com/home-assistant/core/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+smartthings%22))
First occurred: 09:24:27 (4 occurrences)
Last logged: 09:27:13

API error setting up the SmartApp: {'requestId': '5573183918012285512', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': '/api/webhook/2b6e779...', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '6534203956123346958', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': '/api/webhook/2b6e779...', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '1901616718122077496', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': '/api/webhook/2b6e779...', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '6753328904072833241', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': '/api/webhook/2b6e779...', 'message': 'Upstream target timed out', 'details': []}]}}
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 126, in async_step_pat
    app, client = await create_app(self.hass, self.api)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app
    app, client = await api.create_app(app)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/smartthings.py", line 110, in create_app
    entity = await self._service.create_app(app.to_data())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 171, in create_app
    return await self.post(API_APPS, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 395, in post
    return await self.request("post", self._api_base + resource, data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 368, in request
    raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "5573183918012285512", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "/api/webhook/2b6e779...", "message": "Upstream target timed out", "details": []}]}}

@omerfaruk-aran
Copy link

I solved the problem. As a solution, I uninstalled and reinstalled cloudflare and connected with the automatic auth method, then the addition was successful.

@prnzngr
Copy link

prnzngr commented Sep 18, 2023

I have exact the same issue with Cloudflare. Reinstall didn't help.

`Logger: homeassistant.components.smartthings.config_flow
Source: components/smartthings/smartapp.py:145
Integration: SmartThings (documentation, issues)
First occurred: 13:53:09 (5 occurrences)
Last logged: 14:10:39

API error setting up the SmartApp: {'requestId': '725981169526911936', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/1da392fff310eccdad2a2ad956a627bfc63ff77152448c1a4db893abd4c6181d', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '5883238091828785214', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/94f5b82960a8a59aef4d04d8afc54d5ba41535aa727cf68984b7a72cd046cb4f', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '535054231601118605', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/dcae343d2b95f82339cbcec41bc2a743bb3ae5546f9c3942a16214f70518a705', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '1039467506842162658', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/7dd13f452788c3f3c78aff3b7c0b550fd097844db8181d6e3bb3e4ffe5182d1f', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '8361644855247551492', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://XXXXXX/api/webhook/b27ba6e1500be92d8088bdd4e075d592e3ae00ce94a428644b1b370d1936c65a', 'message': 'Upstream target timed out', 'details': []}]}}
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 131, in async_step_pat
app, client = await create_app(self.hass, self.api)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app
app, client = await api.create_app(app)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/smartthings.py", line 110, in create_app
entity = await self._service.create_app(app.to_data())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 171, in create_app
return await self.post(API_APPS, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 395, in post
return await self.request("post", self._api_base + resource, data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 368, in request
raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "725981169526911936", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "https://XXXXXX/api/webhook/1da392fff310eccdad2a2ad956a627bfc63ff77152448c1a4db893abd4c6181d", "message": "Upstream target timed out", "details": []}]}}
`

Curl test is working fine ("pingData": { "challenge": "00000000-0000-0000-0000-000000000000"}}')
Any Idea?

@Martijn085
Copy link

Martijn085 commented Sep 18, 2023

Home Assistant 2023.9.2
Supervisor 2023.09.2
Operating System 10.5
Frontend-versie: 20230911.0 - latest

I have also been trying to link SmartThinks for days but am having the exact same problem.

What I do notice, no idea if this affects link creation, is that when you click on the SmartThinks API url from the token page, you get the error message: 503 Service Temporarily Unavailable

This link points to this url: https://smartthings.developer.samsung.com/develop/api-ref/st-api.html

HA log:

Logger: homeassistant.components.smartthings.config_flow
Source: components/smartthings/smartapp.py:145
Integration: SmartThings (documentation, issues)
First occurred: 22:38:17 (4 occurrences)
Last logged: 22:41:54

API error setting up the SmartApp: {'requestId': '2104654276707856377', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://homeassistant.subdomain.com/api/webhook/', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '7904859109895804767', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://homeassistant.subdomain.com/api/webhook/', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '7957508019790748509', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://homeassistant.subdomain.com/api/webhook/', 'message': 'Upstream target timed out', 'details': []}]}}
API error setting up the SmartApp: {'requestId': '5764256793384984815', 'error': {'code': 'ConstraintViolationError', 'message': 'The request is malformed.', 'details': [{'code': 'TargetTimeoutError', 'target': 'https://homeassistant.subdomain.com/api/webhook/', 'message': 'Upstream target timed out', 'details': []}]}}
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/smartthings/config_flow.py", line 131, in async_step_pat
app, client = await create_app(self.hass, self.api)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/components/smartthings/smartapp.py", line 145, in create_app
app, client = await api.create_app(app)
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/smartthings.py", line 110, in create_app
entity = await self._service.create_app(app.to_data())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 171, in create_app
return await self.post(API_APPS, data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 395, in post
return await self.request("post", self._api_base + resource, data=data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/pysmartthings/api.py", line 368, in request
raise APIResponseError(
pysmartthings.errors.APIResponseError: Unprocessable Entity (422): {"requestId": "2104654276707856377", "error": {"code": "ConstraintViolationError", "message": "The request is malformed.", "details": [{"code": "TargetTimeoutError", "target": "https://homeassistant.subdomain.com/api/webhook/", "message": "Upstream target timed out", "details": []}]}}

The URL seems to work fine from external connections.

Postman log:

Response Headers:

Server: nginx/1.18.0
Date: Mon, 18 Sep 2023 20:40:33 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 67
Connection: keep-alive
Referrer-Policy: no-referrer
X-Content-Type-Options: nosniff
X-Frame-Options: SAMEORIGIN

Response Body:
{"pingData": {"challenge": "00000000-0000-0000-0000-000000000000"}}

@andrewsayre
Copy link
Member

TargetTimeoutError is what the ST API indicates when it can't connect to the webhook endpoint for any reason. If it's failing immediately, it's likely a certificate or SSL configuration issue. Check the notes in the documentation, particularly step 3: https://www.home-assistant.io/integrations/smartthings#webhook-troubleshooting-checklist

@omerfaruk-aran
Copy link

Hello,

You can resolve the issue by following the steps in the video linked below to install Cloudflare. Before installing it, you may need to reset the configuration.yaml settings. If Cloudflare is already installed, you should uninstall it, restart the system, and then proceed with these steps. After installing Cloudflare, restart the system and proceed with the SmartThings setup.

Cloudflare Installation Video

I hope this information helps you resolve your issues. If you have any other questions, please feel free to ask. Have a great day!

@prnzngr
Copy link

prnzngr commented Sep 19, 2023

Hello,

You can resolve the issue by following the steps in the video linked below to install Cloudflare. Before installing it, you may need to reset the configuration.yaml settings. If Cloudflare is already installed, you should uninstall it, restart the system, and then proceed with these steps. After installing Cloudflare, restart the system and proceed with the SmartThings setup.

Cloudflare Installation Video

I hope this information helps you resolve your issues. If you have any other questions, please feel free to ask. Have a great day!

Your tipps dont resolve this issue.

@Martijn085
Copy link

My current configuration has a webserver on a raspberry pi with a reverse proxy configured with Nginx.
I have tried all possible settings but after days of testing it has not worked yet.

Finally I found a temporary solution that still adds the SmartThink intergration correctly.

Install the NGINX Home Assistant SSL proxy add-in and configure it with your own (already active) domain and open port 443 to Home Assistant.

SmartThinks can now be added (with the same certificate I already had active) to Home Assistant using the webhook.
I then reset the port to my web server after which SmartThinks continues to function without problems.

@prnzngr
Copy link

prnzngr commented Sep 20, 2023

No. I won’t open a port. Every other Cloud Integration is working without opening a port like Tado, Gardena, Alexa, Nuki, BMW, Ring and so on. So the Devs should get this working without bothering the users

@andrewsayre
Copy link
Member

Sorry y'all are having issues configuring the prerequisites for this integration. I'm closing this thread as there isn't an issue with the integration in HA and GitHub is not a support forum.

@home-assistant home-assistant locked as off-topic and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants