From cdeceb140da22183e33fd71cc06e08e94cf6a34a Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 14 Mar 2015 12:38:30 -0700 Subject: [PATCH 1/3] Fixes for new release PyLint --- homeassistant/components/light/__init__.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/homeassistant/components/light/__init__.py b/homeassistant/components/light/__init__.py index 6e3bb7667f0..a0bcd742aa2 100644 --- a/homeassistant/components/light/__init__.py +++ b/homeassistant/components/light/__init__.py @@ -190,7 +190,6 @@ def setup(hass, config): if service.service == SERVICE_TURN_OFF: for light in target_lights: - # pylint: disable=star-args light.turn_off(**params) else: @@ -248,7 +247,6 @@ def setup(hass, config): params[ATTR_FLASH] = FLASH_LONG for light in target_lights: - # pylint: disable=star-args light.turn_on(**params) for light in target_lights: From 633d0453be11a2aa4bc313b458beb65f502eedf4 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 14 Mar 2015 12:58:18 -0700 Subject: [PATCH 2/3] Fixes for remote instances Home Assistant --- homeassistant/remote.py | 18 ++++++++++++------ tests/test_remote.py | 4 ++-- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/homeassistant/remote.py b/homeassistant/remote.py index 955af0900e6..9065c359c19 100644 --- a/homeassistant/remote.py +++ b/homeassistant/remote.py @@ -14,6 +14,7 @@ import logging import json import enum import urllib.parse +import os import requests @@ -49,13 +50,16 @@ class API(object): """ Object to pass around Home Assistant API location and credentials. """ # pylint: disable=too-few-public-methods - def __init__(self, host, api_password, port=None): + def __init__(self, host, api_password=None, port=None): self.host = host self.port = port or SERVER_PORT self.api_password = api_password self.base_url = "http://{}:{}".format(host, self.port) self.status = None - self._headers = {HTTP_HEADER_HA_AUTH: api_password} + self._headers = {} + + if api_password is not None: + self._headers[HTTP_HEADER_HA_AUTH] = api_password def validate_api(self, force_validate=False): """ Tests if we can communicate with the API. """ @@ -95,7 +99,7 @@ class API(object): class HomeAssistant(ha.HomeAssistant): """ Home Assistant that forwards work. """ - # pylint: disable=super-init-not-called + # pylint: disable=super-init-not-called,too-many-instance-attributes def __init__(self, remote_api, local_api=None): if not remote_api.validate_api(): @@ -106,13 +110,15 @@ class HomeAssistant(ha.HomeAssistant): self.remote_api = remote_api self.local_api = local_api - self._pool = pool = ha.create_worker_pool() + self.pool = pool = ha.create_worker_pool() self.bus = EventBus(remote_api, pool) self.services = ha.ServiceRegistry(self.bus, pool) self.states = StateMachine(self.bus, self.remote_api) self.components = [] + self.config_dir = os.path.join(os.getcwd(), 'config') + def start(self): # Ensure a local API exists to connect with remote if self.local_api is None: @@ -142,9 +148,9 @@ class HomeAssistant(ha.HomeAssistant): disconnect_remote_events(self.remote_api, self.local_api) # Wait till all responses to homeassistant_stop are done - self._pool.block_till_done() + self.pool.block_till_done() - self._pool.stop() + self.pool.stop() class EventBus(ha.EventBus): diff --git a/tests/test_remote.py b/tests/test_remote.py index 38131e10a4e..7c00cbfd526 100644 --- a/tests/test_remote.py +++ b/tests/test_remote.py @@ -208,7 +208,7 @@ class TestRemoteClasses(unittest.TestCase): slave.states.set("remote.test", "remote.statemachine test") # Wait till slave tells master - slave._pool.block_till_done() + slave.pool.block_till_done() # Wait till master gives updated state hass.pool.block_till_done() @@ -228,7 +228,7 @@ class TestRemoteClasses(unittest.TestCase): slave.bus.fire("test.event_no_data") # Wait till slave tells master - slave._pool.block_till_done() + slave.pool.block_till_done() # Wait till master gives updated event hass.pool.block_till_done() From 6da0257bb66150dfd75af902dfb519d5c875a4da Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sat, 14 Mar 2015 19:13:03 -0700 Subject: [PATCH 3/3] Fix a config bug in Automation --- config/configuration.yaml.example | 3 ++- homeassistant/components/automation/__init__.py | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/configuration.yaml.example b/config/configuration.yaml.example index 51217c090bb..c758833d336 100644 --- a/config/configuration.yaml.example +++ b/config/configuration.yaml.example @@ -101,7 +101,8 @@ automation 2: time_seconds: 0 execute_service: notify.notify - service_data: {"message":"It's 4, time for beer!"} + service_data: + message: It's 4, time for beer! sensor: platform: systemmonitor diff --git a/homeassistant/components/automation/__init__.py b/homeassistant/components/automation/__init__.py index 33eef9fe3dc..6184d53ebf6 100644 --- a/homeassistant/components/automation/__init__.py +++ b/homeassistant/components/automation/__init__.py @@ -54,8 +54,7 @@ def _get_action(hass, config): if CONF_SERVICE in config: domain, service = split_entity_id(config[CONF_SERVICE]) - service_data = convert( - config.get(CONF_SERVICE_DATA), json.loads, {}) + service_data = config.get(CONF_SERVICE_DATA, {}) if not isinstance(service_data, dict): _LOGGER.error(