HomeAssistant variables to maximize reuse?

Is there a way to set some static variable? I tried using a sensor template to put in some hardcoded docker IDs which are then leveraged in rest sensors but it doesnt seem to work at all… the hardcoded sensors arent getting any values.

template:
  sensor:
    - unique_id: my_var
      state: somevalueid

rest:
  - resource_template: "http://192.168.1.201:8126/container/{{ 
 states('sensor.template_my_var') }}/stats"
    scan_interval: 15
    <sensor definitions>

the my_var (or template_my_var) does not exist in HA after defining this…
which is annoying because I have other template sensors that are based on other integrations, and they work fine.

Thanks!

template:
  sensor:
    - unique_id: my_var
      name: my var
      state: somevalueid
rest:
  - resource_template: "http://192.168.1.201:8126/container/{{ 
 states('sensor.my_var') }}/stats"