How to setup 20 devices with 70 sensors = 1400 sensors with templates?

You could build a script with your code above that writes the output to a file that you would !include in your configuration.yaml.

You would need a file type notify to write the file and a shell script to remove the heading lines that the file notify puts in there.

You can see an example of the script to write to a file along with the shell script using sed to remove the two lines here:
Food in the Freezer Tracker - Share your Projects! - Home Assistant Community (home-assistant.io)