Reorg: Merged observers, actors and HTTPInterface into components
This commit is contained in:
1 parent
c5f5dcbce2
commit
dd271febae
19 files changed
+795
-659
No files matched your search
@@ -16,8 +16,10 @@ logging.basicConfig(level=logging.INFO)
|
||||
|
||||
ALL_EVENTS = '*'
|
||||
|
||||
|
||||
DOMAIN_HOMEASSISTANT = "homeassistant"
|
||||
|
||||
SERVICE_TURN_ON = "turn_on"
|
||||
SERVICE_TURN_OFF = "turn_off"
|
||||
SERVICE_HOMEASSISTANT_STOP = "stop"
|
||||
|
||||
EVENT_HOMEASSISTANT_START = "homeassistant.start"
|
||||
@@ -89,6 +91,27 @@ def _matcher(subject, pattern):
|
||||
return '*' in pattern or subject in pattern
|
||||
|
||||
|
||||
def get_grouped_state_cats(statemachine, cat_format_string, strip_prefix):
|
||||
""" Get states that are part of a group of states.
|
||||
|
||||
Example category_format_string can be "devices.{}"
|
||||
|
||||
If input states are devices, devices.paulus and devices.paulus.charging
|
||||
then the output will be paulus if strip_prefix is True, else devices.paulus
|
||||
"""
|
||||
group_prefix = cat_format_string.format("")
|
||||
|
||||
if strip_prefix:
|
||||
id_part = slice(len(group_prefix), None)
|
||||
|
||||
return [cat[id_part] for cat in statemachine.categories
|
||||
if cat.startswith(group_prefix) and cat.count(".") == 1]
|
||||
|
||||
else:
|
||||
return [cat for cat in statemachine.categories
|
||||
if cat.startswith(group_prefix) and cat.count(".") == 1]
|
||||
|
||||
|
||||
def create_state(state, attributes=None, last_changed=None):
|
||||
""" Creates a new state and initializes defaults where necessary. """
|
||||
attributes = attributes or {}
|
||||
|
||||
Reference in new issue
Block a user