diff --git a/homeassistant/__init__.py b/homeassistant/__init__.py index bfbb944b23f..f5129fd1c95 100644 --- a/homeassistant/__init__.py +++ b/homeassistant/__init__.py @@ -598,23 +598,15 @@ class ServiceRegistry(object): if call.data[ATTR_SERVICE_CALL_ID] == call_id: executed_event.set() - self._bus.remove_listener( - EVENT_SERVICE_EXECUTED, service_executed) - self._bus.listen(EVENT_SERVICE_EXECUTED, service_executed) self._bus.fire(EVENT_CALL_SERVICE, event_data) if blocking: - # wait will return False if event not set after our limit has - # passed. If not set, clean up the listener - if not executed_event.wait(SERVICE_CALL_LIMIT): - self._bus.remove_listener( - EVENT_SERVICE_EXECUTED, service_executed) - - return False - - return True + success = executed_event.wait(SERVICE_CALL_LIMIT) + self._bus.remove_listener( + EVENT_SERVICE_EXECUTED, service_executed) + return success def _event_to_service_call(self, event): """ Calls a service from an event. """ @@ -675,8 +667,8 @@ class Config(object): def temperature(self, value, unit): """ Converts temperature to user preferred unit if set. """ - if not (unit and self.temperature_unit and - unit != self.temperature_unit): + if not (unit in (TEMP_CELCIUS, TEMP_FAHRENHEIT) and + self.temperature_unit and unit != self.temperature_unit): return value, unit try: @@ -783,7 +775,7 @@ def create_timer(hass, interval=TIMER_INTERVAL): hass.bus.listen_once(EVENT_HOMEASSISTANT_START, start_timer) -def create_worker_pool(): +def create_worker_pool(worker_count=MIN_WORKER_THREAD): """ Creates a worker pool to be used. """ def job_handler(job): @@ -807,4 +799,4 @@ def create_worker_pool(): _LOGGER.warning("WorkerPool:Current job from %s: %s", date_util.datetime_to_local_str(start), job) - return util.ThreadPool(job_handler, MIN_WORKER_THREAD, busy_callback) + return util.ThreadPool(job_handler, worker_count, busy_callback) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index fe1991c7ed1..3d1408b49bf 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -205,8 +205,8 @@ def setup(hass, config): for light in target_lights: light.turn_off(**params) - if light.should_poll: - for light in target_lights: + for light in target_lights: + if light.should_poll: light.update_ha_state(True) return diff --git a/homeassistant/helpers/event.py b/homeassistant/helpers/event.py index 194cacdc19d..60377fd1f5d 100644 --- a/homeassistant/helpers/event.py +++ b/homeassistant/helpers/event.py @@ -68,6 +68,8 @@ def track_point_in_utc_time(hass, action, point_in_time): """ Adds a listener that fires once after a specific point in UTC time. """ + # Ensure point_in_time is UTC + point_in_time = dt_util.as_utc(point_in_time) @ft.wraps(action) def point_in_time_listener(event):