diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index 7b836af8d05..8ebbe16f41d 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -610,7 +610,7 @@ class Timer(threading.Thread): threading.Thread.__init__(self) self.daemon = True - self._bus = hass.bus + self.hass = hass self.interval = interval or TIMER_INTERVAL self._stop = threading.Event() @@ -622,12 +622,12 @@ class Timer(threading.Thread): hass.listen_once_event(EVENT_HOMEASSISTANT_START, lambda event: self.start()) - hass.listen_once_event(EVENT_HOMEASSISTANT_STOP, - lambda event: self._stop.set()) - def run(self): """ Start the timer. """ + self.hass.listen_once_event(EVENT_HOMEASSISTANT_STOP, + lambda event: self._stop.set()) + _LOGGER.info("Timer:starting") last_fired_on_second = -1 @@ -658,7 +658,7 @@ class Timer(threading.Thread): last_fired_on_second = now.second - self._bus.fire(EVENT_TIME_CHANGED, {ATTR_NOW: now}) + self.hass.bus.fire(EVENT_TIME_CHANGED, {ATTR_NOW: now}) class HomeAssistantError(Exception): diff --git a/homeassistant/components/http/__init__.py b/homeassistant/components/http/__init__.py index 8c6ddc1e5e0..7f054190128 100644 --- a/homeassistant/components/http/__init__.py +++ b/homeassistant/components/http/__init__.py @@ -136,10 +136,6 @@ def setup(hass, config): lambda event: threading.Thread(target=server.start, daemon=True).start()) - hass.listen_once_event( - ha.EVENT_HOMEASSISTANT_STOP, - lambda event: server.shutdown()) - # If no local api set, set one with known information if isinstance(hass, rem.HomeAssistant) and hass.local_api is None: hass.local_api = \ @@ -173,6 +169,10 @@ class HomeAssistantHTTPServer(ThreadingMixIn, HTTPServer): def start(self): """ Starts the server. """ + self.hass.listen_once_event( + ha.EVENT_HOMEASSISTANT_STOP, + lambda event: self.shutdown()) + _LOGGER.info( "Starting web interface at http://%s:%d", *self.server_address) diff --git a/test/test_component_chromecast.py b/test/test_component_chromecast.py index 27e5bbb0370..82cb511c5b7 100644 --- a/test/test_component_chromecast.py +++ b/test/test_component_chromecast.py @@ -33,7 +33,7 @@ class TestChromecast(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() def test_is_on(self): """ Test is_on method. """ diff --git a/test/test_component_core.py b/test/test_component_core.py index eb56112f906..24d66a6a3bb 100644 --- a/test/test_component_core.py +++ b/test/test_component_core.py @@ -26,7 +26,7 @@ class TestComponentsCore(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() def test_is_on(self): """ Test is_on method. """ diff --git a/test/test_component_light.py b/test/test_component_light.py index 04db6d9ec13..255187ea253 100644 --- a/test/test_component_light.py +++ b/test/test_component_light.py @@ -29,7 +29,7 @@ class TestLight(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() user_light_file = self.hass.get_config_path(light.LIGHT_PROFILES_FILE) diff --git a/test/test_component_sun.py b/test/test_component_sun.py index f7cf7c90dab..d37c8f678f9 100644 --- a/test/test_component_sun.py +++ b/test/test_component_sun.py @@ -22,7 +22,7 @@ class TestSun(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() def test_is_on(self): """ Test is_on method. """ diff --git a/test/test_component_switch.py b/test/test_component_switch.py index ca207972720..f81fcdd8f89 100644 --- a/test/test_component_switch.py +++ b/test/test_component_switch.py @@ -34,7 +34,7 @@ class TestSwitch(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() def test_methods(self): """ Test is_on, turn_on, turn_off methods. """ diff --git a/test/test_core.py b/test/test_core.py index 91a56df14fa..d8b4e2d1283 100644 --- a/test/test_core.py +++ b/test/test_core.py @@ -30,7 +30,7 @@ class TestHomeAssistant(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() def test_get_config_path(self): """ Test get_config_path method. """ diff --git a/test/test_loader.py b/test/test_loader.py index ceb398815b4..bbabc44ed59 100644 --- a/test/test_loader.py +++ b/test/test_loader.py @@ -24,7 +24,7 @@ class TestLoader(unittest.TestCase): def tearDown(self): # pylint: disable=invalid-name """ Stop down stuff we started. """ - self.hass._pool.stop() + self.hass.stop() def test_set_component(self): """ Test if set_component works. """