This chapter introduces a framework for enabling context-aware behaviors in smart environment applications, with a special emphasis on smart homes and similar scenarios. In particular, an ontology-based architecture is described that allows system designers to specify non-trivial situations the system must be able to detect on the basis of available sensory data. Relevant situations may include activities and events that could be prolonged over long periods of time. Therefore, the ontology encodes temporal operators that, once applied to sensory information, allow the recognition and efficient correlation of different human activities and other events whose temporal relationships are contextually important. Special emphasis is devoted to actual representation and recognition of temporally distributed situations. The proof of the concept is validated through a thoroughly described example of system usage.