An integrated approach to context specification and recognition in smart homes