Split Long Sensor Data for value_template

Hello,

I want to retrieve a bearer token from an auth rest url and store it in a sensor. However, the token is longer than 255 characters and I get an error message.
Therefore I want to split the token (length 876 characters) to different sensors and reassemble it later.
Unfortunately I do not get further at this point:

  sensor:  
      - name: "Solarman API Access Token Bearer 1"
        value_template: "Bearer{{ value_json.access_token }}"
        name: "Solarman API Access Token Bearer 2"
        value_template: "Bearer {{ value_json.access_token }}"

How could I cut the token after 255 characters and then save the next part?

Use this

{{var_name[start:end]}}

So something like this

sensor:  
      - name: "Solarman API Access Token Bearer 1"
        value_template: "Bearer{{ value_json.access_token[:255] }}"
        name: "Solarman API Access Token Bearer 2"
        value_template: "Bearer {{ value_json.access_token[256:] }}"

If you save the bearer token in an attribute, you won’t need to split it. An attribute doesn’t have a 255 character limit.

    sensor:  
      - name: "Solarman API Access Token Bearer"
        value_template: "{{ now().isoformat() }}"
        attributes:
          token: "Bearer{{ value_json.access_token }}"

You can access the token attribute using the state_attr() function.

I have my code inside rest.yaml, and now this works with your hint:

- resource: 'https://globalapi.solarmanpv.com/account/v1.0/token?appId=<ID>&language=en&='
  method: POST
  scan_interval: 60000
  headers:
    Content-Type: application/json
  payload: '{"appSecret": "<secret>","email": "<mail>","password": "<PW>"}'
  sensor:  
     - name: "Solarman API Access Token Bearer"
       value_template: "{{ now().isoformat() }}"
       unique_id: ssensor.solarman_api_access_token_bearer
       json_attributes:
          - access_token

- resource: 'https://globalapi.solarmanpv.com/device/v1.0/currentData?appId=<ID>&language=en&='
  method: POST
  scan_interval: 60
  headers:
    Authorization: "bearer {{ state_attr('sensor.solarman_api_access_token_bearer', 'access_token') }}"
    Content-Type: application/json
  payload: '{  "deviceSn": "<Id>"}'
  sensor:
      - name: "DC Voltage PV1"
        unit_of_measurement:  V
        value_template: "{{ value_json.dataList[9]['value'] }}"
        unique_id: sensor.rest_solarman_pv1_voltage
        ....