This article presents the theory of thermopiezoelectricity in which the second displacement gradient and the second electric potential gradient are included in the set of independent constitutive variables. This is achieved by using the entropy production inequality proposed by Green and Laws. At first, appropriate thermodynamic restrictions and constitutive equations are obtained, using the well-established Coleman and Noll procedure. Then, the balance equations and the constitutive equations of linear theory are derived, and the mixed initial-boundary value problem is set. For this problem a uniqueness result is established. Next, the basic equations for the isotropic case are derived. Finally, a set of inequalities is obtained for the constant constitutive coefficients of the isotropic case that, on the basis on the previous theorem, ensure the uniqueness of the solution of the mixed initial-boundary value problem.