however I would like to generalize this template for all entities like phone_*_battery, however I don’t know how to pass/substitute the value device_tracker.google_maps_XXX:
My idea was to define an attribute e.g. entity_reference: "device_tracker.google_maps_XXX" in sensors definition but how to access current / this attributes list from the template?
You can’t generalize templates because templates need an entity_id to create a listener. Without that listener, they won’t update.
EDIT: Also, customize is for customizing. Adding value_template to customize will just add a value_template attribute with the template as a string. You can’t add templates to your configuration outside the specific fields that accept templates. As a whole, customize does not allow templates.
That’s pity. Actually this is only a matter of when the templates are processed. At the end the glob is resolved to a sets of entities, each having the entity_id.
Anyway, what’s the way out? Copy hudge templates from one entity to another?
Another option is to use something like AppDaemon to create the entities. It can loop through your devices (device_tracker or otherwise) and create/update entities as they change, just like a Template Sensor does.