  We target the problem of controlling electrical microgrids with little
inertia in real time. We consider a central controller and a number of
resources, where each resource is either a load, a generator, or a combination
thereof, like a battery. The controller periodically computes power setpoints
for the resources based on the estimated state of the grid and an overall
objective, and subject to safety constraints. Each resource is augmented with a
resource agent that a) implements the setpoint requests sent by the controller
on the resource, and b) translates device-specific information about the
resource into a device-independent representation and transmits this to the
controller.
  We focus on the resource agents and their impact on the overall system's
behavior. Intuitively, for the system to converge to the objective, the
resource agents should be obedient to the requests from the controller, in the
sense that the actually implemented setpoint should be close to the requested
setpoint, at least on average. This can be important especially when a
controller that performs continuous optimization is used (for the sake of
performance) to control discrete resources (which have a discrete set of
implementable setpoints).
  We formalize obedience by defining the notion of $c$-bounded
accumulated-error. We then demonstrate its usefulness, by presenting
theoretical results (for a simple scenario) and simulation results (for a more
realistic setting) that indicate that, if all resource agents in the system
have bounded accumulated-error, the closed-loop system converges on average to
the objective. Finally, we show how to design resource agents that provably
have bounded accumulated-error for various types of resources, such as
resources with uncertainty (e.g., PV panels) and resources with a discrete set
of implementable setpoints (e.g., on-off heating systems).
