NOVELTY - The method comprises introducing a biomass into a fermenter (6), introducing the biomass into a closed reactor (5), pretreating the biomass by a hydrothermal carbonization process at a temperature 100-270 degrees C and 5-55 bars for 0.5-5 hours in the reactor, introducing the pretreated biomass to the fermenter, and fermenting the pretreated biomass to produce biogas. The method further comprises separately removing water from the pre-treated biomass in the reactor during dehydration treatment. The reactor is heated and thermal stabilized by a passage of gases and/or water vapor.    USE - The method is useful for generating renewable energy such as biogas (all claimed), where the biomass includes animal biomass and plant biomass including green waste, wood chips, plants and plant residues, straw, silage, residues from agriculture, paper or sewage sludge.    ADVANTAGE - The method is capable of efficiently generating the renewable energy with high yield.    DETAILED DESCRIPTION - The method comprises introducing a biomass into a fermenter (6), introducing the biomass into a closed reactor (5), pretreating the biomass by a hydrothermal carbonization process at a temperature 100-270 degrees C and 5-55 bars for 0.5-5 hours in the reactor, introducing the pretreated biomass to the fermenter, and fermenting the pretreated biomass to produce biogas. The method further comprises separately removing water from the pre-treated biomass in the reactor during dehydration treatment. The reactor is heated and thermal stabilized by a passage of gases and/or water vapor using a heat exchanger (10) located at an interior of the reactor so that flue gases are formed during combustion of biogas for the production of electrical energy. The biomass is heated in a preheater before introduction into the reactor. An INDEPENDENT CLAIM is included for a device for generating renewable energy.    DESCRIPTION OF DRAWING(S) - The figure shows a schematic view of a device for production of renewable energy from biomass.    Biomass Task (2)    Reactor (5)    Fermenter (6)    Combined heat and power (9)    Heat exchanger. (10)