Restful sensors should support dynamic header templates

Came across this thread and it seems that many are in the same boat as me.

Using any of the rest sensors is a bit limited as most modern APIs require bearer-tokens that often are loaded in a separate call.
If the header: attribute of i.e. the the restful sensor supports templating, it would be possible to use one restful sensor to get the token and store it in a sensor attribute or state and then use another restful sensor to fetch data using the previously stored token in the second calls header template.

This feature request is about adding template support for the headers on all rest sensors.

sensor:
  - platform: rest
    resource: `http://domain/my/api`
    name: foo_status
    headers:
      Authorization: 'Bearer {{ state_attr("sensor.access_token", "token") }}'
    value_template: '{{}}'
    scan_interval: 30

Hi @esbenr

I’m facing the same situation. Did you found any solution or workaround you’d like to share?

Greetings

No unfortunately not.
I decided to build my own component for this and other architectural reasons.
But feel free to pick up the idea and make a pull request.

/Esben

Thanks for reply. I think I’ll go a similar way. To get a little competence in components is a nice side-effect.

Greetings