def check_constraint(key, value): unconstrained = True if key == "constrain_input_boolean": values = value.split(",") if len(values) == 2: entity = values[0] state = values[1] else: entity = value state = "on" if entity in conf.ha_state and conf.ha_state[entity]["state"] != state: unconstrained = False if key == "constrain_input_select": values = value.split(",") entity = values.pop(0) if entity in conf.ha_state and conf.ha_state[entity]["state"] not in values: unconstrained = False if key == "constrain_presence": if value == "everyone" and not ha.everyone_home(): unconstrained = False elif value == "anyone" and not ha.anyone_home(): unconstrained = False elif value == "noone" and not ha.noone_home(): unconstrained = False if key == "constrain_days": if today_is_constrained(value): unconstrained = False return unconstrained
def noone_home(self): return ha.noone_home()