- Platform information:
- Hardware: _Intel 7i/ 32GB /500 GB
- OS: _Windows 11
- openHAB version: 4.0.1
Hello All,
I would just like to check my understanding with guys to ensure I implement this correctly. I have spent a lot of time on the documentation and on the community and it seems that this step can only be done through command line execution.
I am using http binding to make API calls to a service offered by my backup power vendor. I get details like gird power consumption, battery state of charge etc from this API by making several calls to it.
(Below is code of the HTTP Thing for reference).
In order to get the data, I need to provide a token (which is of course specified in the header.) The token I get by making a specific call providing my username + password. Currently I make this call manually using reqbin or postman and copy and paste the token into the header of the HTTP Thing. It runs for a few days before it needs to be refreshed. This of course needs to be automated which means the token in the header of the HTTP Thing needs to be a variable.
Is my understanding correct that this can only be done using an executeCommandLine?
Is there no way that I can setup another HTTP Thing or a new channel on the current HTTP Thing that can first retrieve the token to be used by the subsequent calls?
Thanks in advance for any insights.
The code for the HTTP after I have manually put the token in the header:
UID: http:url:binHTTPSunSynk
label: HTTP URL Sunsynk
thingTypeUID: http:url
configuration:
authMode: DIGEST
headers:
- Authorization = Bearer zYbQoYNKe3Vu3_nx8C8M3t-xxxx
ignoreSSLErrors: false
baseURL: https://api.sunsynk.net/api/v1
delay: 0
stateMethod: GET
refresh: 10
commandMethod: GET
contentType: application/json
timeout: 3000
bufferSize: 2048
channels:
- id: chnInverterGridData
channelTypeUID: http:string
label: Inverter Grid Data
description: “”
configuration:
mode: READONLY
stateExtension: /inverter/grid/230218xxxx/realtime - id: chnInverterBatteryData
channelTypeUID: http:string
label: Sunsynk Battery
description: “”
configuration:
mode: READWRITE
stateExtension: /inverter/battery/230218xxxx/realtime?lan=en - id: chlPlant
channelTypeUID: http:string
label: "Plant "
description: “”
configuration:
mode: READONLY
stateExtension: /plant/energy/25xxxx/flow