Merge pull request #1674 from jaharkes/group-order

Maintain group ordering across validation.
This commit is contained in:
Paulus Schoutsen 2016-04-01 08:06:01 -07:00
commit a0df7d9ff3

View File

@ -5,6 +5,7 @@ For more details about this component, please refer to the documentation at
https://home-assistant.io/components/group/ https://home-assistant.io/components/group/
""" """
import threading import threading
from collections import OrderedDict
import voluptuous as vol import voluptuous as vol
@ -47,7 +48,7 @@ _SINGLE_GROUP_CONFIG = vol.Schema(vol.All(_conf_preprocess, {
def _group_dict(value): def _group_dict(value):
"""Validate a dictionary of group definitions.""" """Validate a dictionary of group definitions."""
config = {} config = OrderedDict()
for key, group in value.items(): for key, group in value.items():
try: try:
config[key] = _SINGLE_GROUP_CONFIG(group) config[key] = _SINGLE_GROUP_CONFIG(group)
@ -59,7 +60,7 @@ def _group_dict(value):
CONFIG_SCHEMA = vol.Schema({ CONFIG_SCHEMA = vol.Schema({
DOMAIN: vol.All(dict, _group_dict) DOMAIN: vol.All(dict, _group_dict)
}, extra=True) }, extra=vol.ALLOW_EXTRA)
# List of ON/OFF state tuples for groupable states # List of ON/OFF state tuples for groupable states
_GROUP_TYPES = [(STATE_ON, STATE_OFF), (STATE_HOME, STATE_NOT_HOME), _GROUP_TYPES = [(STATE_ON, STATE_OFF), (STATE_HOME, STATE_NOT_HOME),