The smart grid has been proposed as the panacea to address systemic challenges of the over fifty year old legacy electrical grid, the single largest machine on the planet. A core component central to realizing the smart grid concept is the microgrid. The microgrid is a self-sustaining entity, capable of data interchange and real-time monitoring and control of its distributed generation, storage and load components. In this paper we introduce ongoing research that uses a software engineering approach to user-driven control of the microgrid. Our approach uses a domain-specific modeling language (DSML), MGridML. and a virtual machine, MGridVM, which interprets user-defined models representing domain-level abstractions of the microgrid. MGridML captures high-level representations of pertinent domain features, based on a centralized hierarchical model of demand side energy management. A metamodel for MGridML and a prototype of the MGridVM arc presented to show the feasibility and practicality of our approach.