def set_level(self, level):
        """Set device level."""
        if self._json_state['control_url']:
            url = CONST.BASE_URL + self._json_state['control_url']

            level_data = {
                'level': str(level)
            }

            response = self._abode.send_request(
                "put", url, data=level_data)
            response_object = json.loads(response.text)

            _LOGGER.debug("Set Level Response: %s", response.text)

            if response_object['id'] != self.device_id:
                raise AbodeException((ERROR.SET_STATUS_DEV_ID))

            if response_object['level'] != str(level):
                raise AbodeException((ERROR.SET_STATUS_STATE))

            self.update(response_object)

            _LOGGER.info("Set device %s level to: %s", self.device_id, level)

            return True

        return False
Set device level.