Semantic technologies are currently spreading across several application domains as a reliable and consistent mean to address challenges related to organization, manipulation, visualization and exchange of data and knowledge. Different roles are actually played by these techniques depending on the application domain, on the timing constraints, on the distributed nature of applications, and so on. This paper provides an overview of the roles played by semantic technologies in the domain of smart grids and smart environments, with a particular focus on changes brought by such technologies in the adopted architectures, programming techniques and tools. Motivations driving the adoption of semantics in these different, but strictly intertwined, fields are introduced using a strong application-driven perspective. Two real-world case studies in smart grids and smart environments are presented to exemplify the roles covered by such technologies and the changes they fostered in software engineering processes. Learned lessons are then distilled and future adoption scenarios discussed.