iOS component hotfixes (#4015)

* iOS component hot fixes around component/platform loading, logging, and more

* Load device_tracker and zeroconf in deps instead of bootstraping

* Change conditional check on status code
This commit is contained in:
Robbie Trencheny 2016-10-23 19:17:34 -07:00 committed by Paulus Schoutsen
parent 5df8477536
commit 626763a7c3
2 changed files with 35 additions and 45 deletions

View file

@ -13,8 +13,6 @@ from voluptuous.humanize import humanize_error
from homeassistant.helpers import config_validation as cv
import homeassistant.loader as loader
from homeassistant.helpers import discovery
from homeassistant.components.http import HomeAssistantView
@ -22,13 +20,11 @@ from homeassistant.components.http import HomeAssistantView
from homeassistant.const import (HTTP_INTERNAL_SERVER_ERROR,
HTTP_BAD_REQUEST)
from homeassistant.components.notify import DOMAIN as NotifyDomain
_LOGGER = logging.getLogger(__name__)
DOMAIN = "ios"
DEPENDENCIES = ["http"]
DEPENDENCIES = ["device_tracker", "http", "zeroconf"]
CONF_PUSH = "push"
CONF_PUSH_CATEGORIES = "categories"
@ -245,34 +241,17 @@ def setup(hass, config):
if CONFIG_FILE == {}:
CONFIG_FILE[ATTR_DEVICES] = {}
device_tracker = loader.get_component("device_tracker")
if device_tracker.DOMAIN not in hass.config.components:
device_tracker.setup(hass, {})
# Need this to enable requirements checking in the app.
hass.config.components.append(device_tracker.DOMAIN)
if "notify.ios" not in hass.config.components:
notify = loader.get_component("notify.ios")
notify.get_service(hass, {})
# Need this to enable requirements checking in the app.
if NotifyDomain not in hass.config.components:
hass.config.components.append(NotifyDomain)
zeroconf = loader.get_component("zeroconf")
if zeroconf.DOMAIN not in hass.config.components:
zeroconf.setup(hass, config)
# Need this to enable requirements checking in the app.
hass.config.components.append(zeroconf.DOMAIN)
# Notify needs to have discovery
# notify_config = {"notify": {CONF_PLATFORM: "ios"}}
# bootstrap.setup_component(hass, "notify", notify_config)
discovery.load_platform(hass, "sensor", DOMAIN, {}, config)
hass.wsgi.register_view(iOSIdentifyDeviceView(hass))
if config.get(DOMAIN) is not None:
app_config = config[DOMAIN]
if app_config.get(CONF_PUSH) is not None:
push_config = app_config[CONF_PUSH]
hass.wsgi.register_view(iOSPushConfigView(hass, push_config))
app_config = config.get(DOMAIN, {})
hass.wsgi.register_view(iOSPushConfigView(hass,
app_config.get(CONF_PUSH, {})))
return True