IoT, smart cities, cyber-physical systems and sensor networks are context-aware, highly dynamic and reactive systems. Their implementation should take into account the heterogeneity of their components and make easy the management of events unplanned at design time. According to these requirements, in this paper we propose an ontology-based approach to provide runtime models of the physical entities characterizing context-aware reactive systems. We extend SSN, a W3C standard ontology, to support complex reactive behaviors through the modeling of Logical Sensors and Actuators (LSA ontology); we also present a software architecture in which a knowledge base, structured coherently with this semantic model, is bound to real world entities by grounding (via web services) semantic elements to physical sensors and actuators. To validate the approach we discuss a case study related to smart buildings for cultural heritage preservation.