Merge branch 'dev'

* dev:
  Fix a config bug in Automation
  Fixes for remote instances Home Assistant
  Fixes for new release PyLint
pull/62/head
Paulus Schoutsen 2015-03-14 19:13:15 -07:00
commit 1dc002f180
4 changed files with 17 additions and 11 deletions

View File

@ -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

View File

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

View File

@ -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):

View File

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