Trying to integrate with smartthings refridgerator

I am trying to add a Samsung refrigerator to HA via Smart-things. I’ve created the token following the instructions at SmartThings - Home Assistant

However, when I try to add the token to HA, I get an error message:

SmartThings could not validate the webhook URL. Please ensure the webhook URL is reachable from the internet and try again.

The web hook that was presented is available from the internet. I do get a log of the attempt:

Logger: homeassistant.components.smartthings.config_flow
Source: components/smartthings/config_flow.py:131
Integration: SmartThings (documentation, issues)
First occurred: 7:35:54 PM (1 occurrences)
Last logged: 7:35:54 PM

API error setting up the SmartApp: {‘requestId’: ‘6054496568871730221’, ‘error’: {‘code’: ‘ConstraintViolationError’, ‘message’: ‘The request is malformed.’, ‘details’: [{‘code’: ‘TargetNon200Error’, ‘target’: ‘https://ha.theunimatrix.com/api/webhook/1fff68e1c9d07ef7df6f908f97cf1c163a3fd8f0b700cf4e0c8c963a47fcba13’, ‘message’: ‘Target did not respond with a 200 status. Upstream status code=403’, ‘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”: “6054496568871730221”, “error”: {“code”: “ConstraintViolationError”, “message”: “The request is malformed.”, “details”: [{“code”: “TargetNon200Error”, “target”: “https://ha.theunimatrix.com/api/webhook/1fff68e1c9d07ef7df6f908f97cf1c163a3fd8f0b700cf4e0c8c963a47fcba13”, “message”: “Target did not respond with a 200 status. Upstream status code=403”, “details”: }]}}

I’ve tried to do this several times and run into the same issues.

Any help would be appreciated.

Mike.

Are you using cloudflare?
Edit (adding additional info in case you are using cloudflare):

I think is has to do with cloudflare blocking it as a bot, so you need to make a custom rule to allow it to pass. Using their domain name doesn’t work since for this service they seem to use amazon services. Try this:

  1. Log in and select your site
  2. Go to Security>>WAF
  3. Click on Tools (from the horizontal tabs) (to create a rule to allow SmartThings to pass)
  4. Under “IP, IP range, country name, or ASN” type in “AS16509” then for Action select Allow for Zone select This Website then click Add.
  5. Go back to Home Assistant and try again …

Note: Not sure if AS16509 will work for you, you may need to search there to see which one they may be using for you.

Other option is to disable “Bot Fight Mode” (Under Security>> Bots), but then you don’t have that help/protection.

2 Likes

Nice Catch! I had to turn bot blocking off, but that’s OK.

Thanks for your time.

Mike.

No problem, glad to help. FYI, I ended up with lots more additional traffic when I turned bot blocking off, so I ended up adding the rule instead. If you need help finding the AS# let me know - will try to trace back my steps :slight_smile: on how I found the one above.

Can you please tell us where and how you found out the code “AS16509”? So I can similarly find for my region

I think it was under Security >> Events … you should see activity log.

1 Like

@eftimg I can’t thank you enough for this. I’ve been pulling my hair out all day on this.