Help troubleshooting RESTful sensor

I can make a rest request using curl like this:

curl --request GET \
  --url 'https://services.cnet.se/checkwattapi/v2/user/LoginEiB?audience=eib' \
  --header 'Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXX'

And I get this response:

But when trying to create a restful sensor I do not get any response:

- platform: rest
    name: CheckWatt Token
    resource: https://services.cnet.se/checkwattapi/v2/user/LoginEiB?audience=eib
    method: GET
    authentication: basic
    headers:
      Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    value_template: "{{ value_json.JwtToken }}"

I have tried updating the entity using the Services-tab in developer tools but I do not get any other result. Can anyone tell me what I am doing wrong ?

Look in Settings → System → Logs for errors related to this sensor.

Is the token you are attempting to retrieve longer than 255 characters?

States are limited to 255 characters, attributes do not have this limit (their limit is ~65k IRRC).

Thanks, yes when looking in the logs I see this: “Invalid state with length 392. State max length is 255 characters”
So how do I solve this ? How can I store the value in a attribute ?

See: https://www.home-assistant.io/integrations/sensor.rest/#json_attributes

- platform: rest
    name: CheckWatt Token
    resource: https://services.cnet.se/checkwattapi/v2/user/LoginEiB?audience=eib
    method: GET
    authentication: basic
    headers:
      Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    value_template: "{{ value_json.LoggedIn }}" # or whatever other short value you want
    json_attributes_path: "$"
    json_attributes:
      - JwtToken

Great, thanks. I just got some more questions. I noticed when looking at the logs that the sensor updated very frequently. I just want it to update when I trigger it manually. I tried setting scan_interval: 0 but it looked like that did not work at all. From the logs it seams to update even more often than default. Can you disable the automatic update in some way ?

Set the scan interval to years.

I can’t really get it to work. Am I doing something obvious wrong ?

- platform: rest
    name: CheckWatt Token
    resource: https://services.cnet.se/checkwattapi/v2/user/LoginEiB?audience=eib
    method: GET
    authentication: basic
    headers:
      Authorization: Basic XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    value_template: "{{ value_json }}"
    json_attributes_path: "$"
    json_attributes:
      - JwtToken
      - RefreshToken
      - RefreshTokenExpires
    scan_interval: 31536000