I am currently facing an issue while trying to retrieve my data through the API using Rest.
The process involves two steps. First, I use my API key to obtain the bearer token, and then I use that bearer token to access the desired data. So far, the initial step is functioning correctly.
For my second request, I am able to utilize my secret file for the header section, but not a sensor value.
So actually found a workaround by not using secrets.
The issue is the token bearer is being refresh every time the home assistant starts, and when running the query to get the prices, the â!secret api_key_bearer_staticâ is equals to âunknownâ
My solution is:
Create helpers as input text where you will store your API key (static) and you bearer key (dynamic) and in my case some static authentication header
Store your bearer token from the API in a sensor
Create an automation that every time the bearer token sensor change value, change the helper text
This seems like a nice solution, but it seems states are limited to 255 characters. This isnt working for the DaikinOne cloud API which returns a much longer access token. Any thoughts?
I had the same problem with token that has more than 255 characters, what I did was similar to @Gautch, but Iâm storing the token into multiple 255-character-state sensors. Assuming the token is a little bit more than 510 characters, but it can be any length