def _async_check_condition(self, action, variables): """Test if condition is matching.""" self.last_action = action.get(CONF_ALIAS, action[CONF_CONDITION]) check = condition.async_from_config(action, False)( self.hass, variables) self._log("Test condition {}: {}".format(self.last_action, check)) return check
def _async_check_condition(self, action, variables): """Test if condition is matching.""" self.last_action = action.get(CONF_ALIAS, action[CONF_CONDITION]) check = condition.async_from_config(action, False)(self.hass, variables) self._log("Test condition {}: {}".format(self.last_action, check)) return check
def _async_check_condition(self, action, variables): """Test if condition is matching.""" config_cache_key = frozenset((k, str(v)) for k, v in action.items()) config = self._config_cache.get(config_cache_key) if not config: config = condition.async_from_config(action, False) self._config_cache[config_cache_key] = config self.last_action = action.get(CONF_ALIAS, action[CONF_CONDITION]) check = config(self.hass, variables) self._log("Test condition {}: {}".format(self.last_action, check)) return check
def _async_process_if(hass, config, p_config): """Process if checks.""" if_configs = p_config.get(CONF_CONDITION) checks = [] for if_config in if_configs: try: checks.append(condition.async_from_config(if_config, False)) except HomeAssistantError as ex: _LOGGER.warning('Invalid condition: %s', ex) return None def if_action(variables=None): """AND all conditions.""" return all(check(hass, variables) for check in checks) return if_action