Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions homeassistant/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
ATTR_COMPONENT = 'component'

ERROR_LOG_FILENAME = 'home-assistant.log'
_PERSISTENT_ERRORS = {}
DATA_PERSISTENT_ERRORS = 'bootstrap_persistent_errors'
HA_COMPONENT_URL = '[{}](https://home-assistant.io/components/{}/)'


Expand Down Expand Up @@ -601,9 +601,14 @@ def _async_persistent_notification(hass: core.HomeAssistant, component: str,

This method must be run in the event loop.
"""
_PERSISTENT_ERRORS[component] = _PERSISTENT_ERRORS.get(component) or link
errors = hass.data.get(DATA_PERSISTENT_ERRORS)

if errors is None:
errors = hass.data[DATA_PERSISTENT_ERRORS] = {}

errors[component] = errors.get(component) or link
_lst = [HA_COMPONENT_URL.format(name.replace('_', '-'), name)
if link else name for name, link in _PERSISTENT_ERRORS.items()]
if link else name for name, link in errors.items()]
message = ('The following components and platforms could not be set up:\n'
'* ' + '\n* '.join(list(_lst)) + '\nPlease check your config')
persistent_notification.async_create(
Expand Down
2 changes: 1 addition & 1 deletion homeassistant/components/sleepiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
DATA = None

CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.Schema({
vol.Required(DOMAIN): vol.Schema({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a new standard? I haven't seen any other component that does it like this.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From my testing, it looked like not having this meant that not having sleepiq in your config was ok too (but it shouldn't, username is required)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How could the component be setup without the domain in the config? From another component?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All the platforms depend on the main component.

vol.Required(CONF_USERNAME): cv.string,
vol.Required(CONF_PASSWORD): cv.string,
}),
Expand Down
8 changes: 8 additions & 0 deletions tests/components/sensor/test_sleepiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import requests_mock

from homeassistant.bootstrap import setup_component
from homeassistant.components.sensor import sleepiq

from tests.components.test_sleepiq import mock_responses
Expand Down Expand Up @@ -39,6 +40,13 @@ def test_setup(self, mock):
"""Test for successfully setting up the SleepIQ platform."""
mock_responses(mock)

assert setup_component(self.hass, 'sleepiq', {
'sleepiq': {
'username': '',
'password': '',
}
})

sleepiq.setup_platform(self.hass,
self.config,
self.add_devices,
Expand Down