A thermal management system for an electric vehicle comprising an energy storage system and a vehicle component that requires cooling, wherein there is a preferred temperature range within which the energy storage system is to be operated, and the range is between a minimum temperature and a maximum temperature , the system comprising: - a heater arranged to heat the energy storage system , wherein the heater is arranged to be powered by either the energy storage system or an external power source , - a cooling unit arranged to cool the energy storage system , wherein the cooling unit is arranged to be powered by either the energy storage system or an external power source , - a control unit arranged to control the heater and the cooling unit , and the control unit is configured to identify (S0) when the heater and the cooling unit are powered by the external power source , and to, when the heater and the cooling unit are powered by the external power source : o receive (S1) data associated with the ambient temperature, o determine (S2) whether the ambient temperature is below or above the minimum temperature , o control (S3) the heater to heat, when the ambient temperature is below the minimum temperature , the energy storage system up to a temperature which is higher than the minimum temperature and below or equal to the maximum temperature , and o control (S4) the cooling unit to cool, when the ambient temperature is above the minimum temperature , the energy storage system to a predetermined temperature that is equal to or above the minimum temperature , the vehicle component is any kind of e-motor, inverter, or DC/DC converter, and the control unit is arranged to direct excess heat from the vehicle component to the energy storage system when the heater is powered by the energy storage system , characterized in that the control unit is arranged to control (S5) the heater to heat the vehicle component when the heater is powered by the external power source and the ambient temperature is below the minimum temperature . - a heater arranged to heat the energy storage system , wherein the heater is arranged to be powered by either the energy storage system or an external power source , - a cooling unit arranged to cool the energy storage system , wherein the cooling unit is arranged to be powered by either the energy storage system or an external power source , - a control unit arranged to control the heater and the cooling unit , and the control unit is configured to identify (S0) when the heater and the cooling unit are powered by the external power source , and to, when the heater and the cooling unit are powered by the external power source : o receive (S1) data associated with the ambient temperature, o determine (S2) whether the ambient temperature is below or above the minimum temperature , o control (S3) the heater to heat, when the ambient temperature is below the minimum temperature , the energy storage system up to a temperature which is higher than the minimum temperature and below or equal to the maximum temperature , and o control (S4) the cooling unit to cool, when the ambient temperature is above the minimum temperature , the energy storage system to a predetermined temperature that is equal to or above the minimum temperature , o receive (S1) data associated with the ambient temperature, o determine (S2) whether the ambient temperature is below or above the minimum temperature , o control (S3) the heater to heat, when the ambient temperature is below the minimum temperature , the energy storage system up to a temperature which is higher than the minimum temperature and below or equal to the maximum temperature , and o control (S4) the cooling unit to cool, when the ambient temperature is above the minimum temperature , the energy storage system to a predetermined temperature that is equal to or above the minimum temperature , <EOS>