Added Code from Electric imp. Device and Agent