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( 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()