Add cloudhook support to SmartThings component (#21905)

* Add support for Nabu Casa cloudhooks

* Added tests to cover cloudhook creation and removal

* Remove cloud dependency
This commit is contained in:
Andrew Sayre 2019-03-11 07:33:25 -05:00 committed by Charles Garwood
parent 3fd6aa0ba9
commit c401f35a43
9 changed files with 176 additions and 33 deletions

View file

@ -13,7 +13,8 @@ from .const import (
CONF_LOCATION_ID, CONF_OAUTH_CLIENT_ID, CONF_OAUTH_CLIENT_SECRET, DOMAIN,
VAL_UID_MATCHER)
from .smartapp import (
create_app, find_app, setup_smartapp, setup_smartapp_endpoint, update_app)
create_app, find_app, setup_smartapp, setup_smartapp_endpoint, update_app,
validate_webhook_requirements)
_LOGGER = logging.getLogger(__name__)
@ -56,10 +57,6 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow):
from pysmartthings import APIResponseError, AppOAuth, SmartThings
errors = {}
if not self.hass.config.api.base_url.lower().startswith('https://'):
errors['base'] = "base_url_not_https"
return self._show_step_user(errors)
if user_input is None or CONF_ACCESS_TOKEN not in user_input:
return self._show_step_user(errors)
@ -81,6 +78,10 @@ class SmartThingsFlowHandler(config_entries.ConfigFlow):
# Setup end-point
await setup_smartapp_endpoint(self.hass)
if not validate_webhook_requirements(self.hass):
errors['base'] = "base_url_not_https"
return self._show_step_user(errors)
try:
app = await find_app(self.hass, self.api)
if app: