Building Smart Environments in the Cloud