Compare commits

...

8 Commits

Author SHA1 Message Date
Paulus Schoutsen 3de51bf75d Merge pull request #1807 from balloob/release-0.17.3
0.17.3
2016-04-11 19:56:41 -07:00
Paulus Schoutsen 4023021b21 Version bump to 0.17.3 2016-04-11 19:48:37 -07:00
Jan Harkes 2c665ca3e4 Do not propagate api password (#1797)
* Do not propagate API password in service requests.

It makes service validation fail. The choice is to either handle it as an
optional key in every service handler and make sure it doesn't end up in event
stream and notifications, or to strip it as early as possible.

* Some places still need a forwarded api password.

- Event forwarding/remote api uses the local api password to
  authenticate against the remote instance.
- The generated index.html at '/' embeds the api password.
2016-04-11 19:48:16 -07:00
Paulus Schoutsen c98b56a807 Merge pull request #1778 from balloob/hotfix/0.17.2
Hotfix/0.17.2
2016-04-09 16:23:20 -07:00
Paulus Schoutsen fa0be21342 Version bump to 0.17.2 2016-04-09 16:16:05 -07:00
Jan Harkes 7be29468d5 Make yaml config parser errors look less like bugs. (#1776)
Instead of nested tracebacks, show a simpler error message.

    Config directory: /home/user/.homeassistant
    ERROR:homeassistant.util.yaml:duplicate key: "script"
      in "/home/user/.homeassistant/configuration.yaml", line 95, column 0
      in "/home/user/.homeassistant/configuration.yaml", line 108, column 0
2016-04-09 16:15:49 -07:00
Paulus Schoutsen 9924351a42 Prevent device tracker from creating invalid YAML (#1774) 2016-04-09 16:15:49 -07:00
Paulus Schoutsen a41514ca50 0.17.1 (#1771)
* We need to allow extra keys on top level componenet config

fixes #1756

* Add comment about location of hass (fixes #1723)

* Fix for MQTT config validation on the protocol field. (#1765)

* Update frontend with weblink fix

* Fix for light service validation. (#1770)

Incorrect validation tested if passed value was a list instead of
a member of the list.

* Accept group without entities in configuration. (#1768)

* Accept group without entities in configuration.

People seem to use these as placeholders for future expansion of their
home automation dreams, and we used to accept them.  We still have to
specify at least one of 'name', 'view' or 'icon' so that the group is
parsed as a dictionary.

* Also accept empty entities: key in a group.

* Additional fix for empty entities value in a group config.

* Version bump to 0.17.1
2016-04-09 09:55:52 -07:00
16 changed files with 58 additions and 19 deletions
+5 -1
View File
@@ -22,6 +22,7 @@ from homeassistant.const import (
CONF_CUSTOMIZE, CONF_LATITUDE, CONF_LONGITUDE, CONF_NAME,
CONF_TEMPERATURE_UNIT, CONF_TIME_ZONE, EVENT_COMPONENT_LOADED,
TEMP_CELCIUS, TEMP_FAHRENHEIT, PLATFORM_FORMAT, __version__)
from homeassistant.exceptions import HomeAssistantError
from homeassistant.helpers import (
event_decorators, service, config_per_platform, extract_domain_configs)
from homeassistant.helpers.entity import Entity
@@ -293,7 +294,10 @@ def from_config_file(config_path, hass=None, verbose=False, daemon=False,
enable_logging(hass, verbose, daemon, log_rotate_days)
config_dict = config_util.load_yaml_config_file(config_path)
try:
config_dict = config_util.load_yaml_config_file(config_path)
except HomeAssistantError:
return None
return from_config_dict(config_dict, hass, enable_log=False,
skip_pip=skip_pip)
@@ -204,6 +204,7 @@ class DeviceTracker(object):
return
# If no device can be found, create it
dev_id = util.ensure_unique_string(dev_id, self.devices.keys())
device = Device(
self.hass, self.consider_home, self.home_range, self.track_new,
dev_id, mac, (host_name or dev_id).replace('_', ' '))
+1 -1
View File
@@ -1,2 +1,2 @@
"""DO NOT MODIFY. Auto-generated by build_frontend script."""
VERSION = "4062ab87999fd5e382074ba9d7a880d7"
VERSION = "c2932592a6946e955ddc46f31409b81f"
@@ -3658,7 +3658,7 @@ e.bindAnimationForKeyframeEffect(this)),(this.effect instanceof window.SequenceE
text-transform: capitalize;
line-height: 40px;
margin-left: 16px;
}</style><template><state-badge state-obj="[[stateObj]]" in-dialog="[[inDialog]]"></state-badge><a href="[[stateObj.entityDisplay]]" target="_blank" class="name" id="link">[[stateObj.entityDisplay]]</a></template></dom-module><dom-module id="ha-entities-card" assetpath="cards/"><style is="custom-style" include="iron-flex"></style><style>.states {
}</style><template><state-badge state-obj="[[stateObj]]" in-dialog="[[inDialog]]"></state-badge><a href="[[stateObj.state]]" target="_blank" class="name" id="link">[[stateObj.entityDisplay]]</a></template></dom-module><dom-module id="ha-entities-card" assetpath="cards/"><style is="custom-style" include="iron-flex"></style><style>.states {
padding-bottom: 16px;
}
.state {
+2 -2
View File
@@ -39,7 +39,7 @@ def _conf_preprocess(value):
return value
_SINGLE_GROUP_CONFIG = vol.Schema(vol.All(_conf_preprocess, {
vol.Required(CONF_ENTITIES): cv.entity_ids,
vol.Optional(CONF_ENTITIES): vol.Any(None, cv.entity_ids),
CONF_VIEW: bool,
CONF_NAME: str,
CONF_ICON: cv.icon,
@@ -145,7 +145,7 @@ def setup(hass, config):
"""Setup all groups found definded in the configuration."""
for object_id, conf in config.get(DOMAIN, {}).items():
name = conf.get(CONF_NAME, object_id)
entity_ids = conf[CONF_ENTITIES]
entity_ids = conf.get(CONF_ENTITIES) or []
icon = conf.get(CONF_ICON)
view = conf.get(CONF_VIEW)
+5 -1
View File
@@ -27,7 +27,7 @@ from homeassistant.const import (
HTTP_HEADER_CONTENT_LENGTH, HTTP_HEADER_CONTENT_TYPE, HTTP_HEADER_EXPIRES,
HTTP_HEADER_HA_AUTH, HTTP_HEADER_VARY, HTTP_METHOD_NOT_ALLOWED,
HTTP_NOT_FOUND, HTTP_OK, HTTP_UNAUTHORIZED, HTTP_UNPROCESSABLE_ENTITY,
SERVER_PORT)
SERVER_PORT, URL_ROOT, URL_API_EVENT_FORWARD)
DOMAIN = "http"
@@ -207,6 +207,10 @@ class RequestHandler(SimpleHTTPRequestHandler):
self.server.api_password or
self.verify_session())
# we really shouldn't need to forward the password from here
if url.path not in [URL_ROOT, URL_API_EVENT_FORWARD]:
data.pop(DATA_API_PASSWORD, None)
if '_METHOD' in data:
method = data.pop('_METHOD')
+2 -2
View File
@@ -92,8 +92,8 @@ LIGHT_TURN_ON_SCHEMA = vol.Schema({
ATTR_XY_COLOR: vol.All(vol.ExactSequence((cv.small_float, cv.small_float)),
vol.Coerce(tuple)),
ATTR_COLOR_TEMP: vol.All(int, vol.Range(min=154, max=500)),
ATTR_FLASH: [FLASH_SHORT, FLASH_LONG],
ATTR_EFFECT: [EFFECT_COLORLOOP, EFFECT_RANDOM, EFFECT_WHITE],
ATTR_FLASH: vol.In([FLASH_SHORT, FLASH_LONG]),
ATTR_EFFECT: vol.In([EFFECT_COLORLOOP, EFFECT_RANDOM, EFFECT_WHITE]),
})
LIGHT_TURN_OFF_SCHEMA = vol.Schema({
+1 -1
View File
@@ -90,7 +90,7 @@ CONFIG_SCHEMA = vol.Schema({
vol.Optional(CONF_PASSWORD): cv.string,
vol.Optional(CONF_CERTIFICATE): cv.isfile,
vol.Optional(CONF_PROTOCOL, default=DEFAULT_PROTOCOL):
[PROTOCOL_31, PROTOCOL_311],
vol.All(cv.string, vol.In([PROTOCOL_31, PROTOCOL_311])),
vol.Optional(CONF_EMBEDDED): _HBMQTT_CONFIG_SCHEMA,
}),
}, extra=vol.ALLOW_EXTRA)
+1 -1
View File
@@ -65,7 +65,7 @@ CONFIG_SCHEMA = vol.Schema({
vol.Optional(ATTR_DEBUG, default=False): cv.boolean,
vol.Optional(ATTR_DUMMY, default=False): cv.boolean,
}),
})
}, extra=vol.ALLOW_EXTRA)
def setup(hass, config):
+1 -1
View File
@@ -1,7 +1,7 @@
# coding: utf-8
"""Constants used by Home Assistant components."""
__version__ = "0.17.0"
__version__ = "0.17.3"
REQUIRED_PYTHON_VER = (3, 4)
PLATFORM_FORMAT = '{}.{}'
+9 -7
View File
@@ -29,10 +29,9 @@ def load_yaml(fname):
# If configuration file is empty YAML returns None
# We convert that to an empty dict
return yaml.load(conf_file, Loader=SafeLineLoader) or {}
except yaml.YAMLError:
error = 'Error reading YAML configuration file {}'.format(fname)
_LOGGER.exception(error)
raise HomeAssistantError(error)
except yaml.YAMLError as exc:
_LOGGER.error(exc)
raise HomeAssistantError(exc)
def _include_yaml(loader, node):
@@ -55,9 +54,12 @@ def _ordered_dict(loader, node):
line = getattr(node, '__line__', 'unknown')
if key in seen:
fname = getattr(loader.stream, 'name', '')
raise yaml.YAMLError("ERROR: duplicate key: \"{}\""
" in {} line {} and {}"
.format(key, fname, seen[key], line))
first_mark = yaml.Mark(fname, 0, seen[key], -1, None, None)
second_mark = yaml.Mark(fname, 0, line, -1, None, None)
raise yaml.MarkedYAMLError(
context="duplicate key: \"{}\"".format(key),
context_mark=first_mark, problem_mark=second_mark,
)
seen[key] = line
return OrderedDict(nodes)
+3
View File
@@ -1,5 +1,7 @@
# This is a simple service file for systems with systemd to tun HA as user.
#
# For details please check https://home-assistant.io/getting-started/autostart/
#
[Unit]
Description=Home Assistant for %i
After=network.target
@@ -9,6 +11,7 @@ Type=simple
User=%i
# Enable the following line if you get network-related HA errors during boot
#ExecStartPre=/usr/bin/sleep 60
# Use `whereis hass` to determine the path of hass
ExecStart=/usr/bin/hass
SendSIGKILL=no
@@ -197,3 +197,16 @@ class TestComponentsDeviceTracker(unittest.TestCase):
mock_see.assert_called_once_with(
mac=mac, dev_id=dev_id, host_name=host_name,
location_name=location_name, gps=gps)
def test_not_write_duplicate_yaml_keys(self):
"""Test that the device tracker will not generate invalid YAML."""
self.assertTrue(device_tracker.setup(self.hass, {}))
device_tracker.see(self.hass, 'mac_1', host_name='hello')
device_tracker.see(self.hass, 'mac_2', host_name='hello')
self.hass.pool.block_till_done()
config = device_tracker.load_config(self.yaml_devices, self.hass,
timedelta(seconds=0), 0)
assert len(config) == 2
+11
View File
@@ -58,6 +58,17 @@ class TestMQTT(unittest.TestCase):
}
})
def test_setup_protocol_validation(self):
"""Test for setup failure if connection to broker is missing."""
with mock.patch('paho.mqtt.client.Client'):
self.hass.config.components = []
assert _setup_component(self.hass, mqtt.DOMAIN, {
mqtt.DOMAIN: {
mqtt.CONF_BROKER: 'test-broker',
mqtt.CONF_PROTOCOL: 3.1,
}
})
def test_publish_calls_service(self):
"""Test the publishing of call to services."""
self.hass.bus.listen_once(EVENT_CALL_SERVICE, self.record_calls)
+1
View File
@@ -226,6 +226,7 @@ class TestComponentsGroup(unittest.TestCase):
'view': True,
},
'test_group': 'hello.world,sensor.happy',
'empty_group': {'name': 'Empty Group', 'entities': None},
}
})