Moved stuff away from core. Made component interface more uniform.

This commit is contained in:
Paulus Schoutsen
2014-01-23 22:03:13 -08:00
parent b387f9d9d7
commit 0fc3d359cb
13 changed files with 302 additions and 158 deletions

View File

@@ -38,3 +38,18 @@ def str_to_datetime(dt_str):
return datetime.datetime.strptime(dt_str, DATE_STR_FORMAT)
except ValueError: # If dt_str did not match our format
return None
def split_entity_id(entity_id):
""" Splits a state entity_id into domain, object_id. """
return entity_id.split(".", 1)
def filter_entity_ids(entity_ids, domain_filter=None, strip_domain=False):
""" Filter a list of entities based on domain. Setting strip_domain
will only return the object_ids. """
return [
split_entity_id(entity_id)[1] if strip_domain else entity_id
for entity_id in entity_ids if
not domain_filter or entity_id.startswith(domain_filter)
]