Sorry, it took a while.
I decided to go for a Home Assistant only route so that there is no need for an external dependency (using Apache).That caused my some headache, but I finally came up with a solution.
I came across Extracting data from JSON array from rest sensor that is longer than 255 characters - #5 by tmeringer which contains a very useful and clever trick.
So what I did: I am using Command Line - Home Assistant with a bash script.
This is the bash script that’s called from Home Assistant:
#!/bin/sh
IP_EV_Charger='<IP.OF.YOUR.EV22>';
USER='<USERNAME>';
PASSWORD='<SUPERSECRETPASSWORD>';
TOKENREQUEST=$(curl --silent http://$IP_EV_Charger/api/v1/token -d "grant_type=password&username="$USER"&password="$PASSWORD)
bearer_token_string=$(echo $TOKENREQUEST | jq -r .access_token) # -r removes surrounding quotes
SMA_EV_Return=$(curl --silent http://$IP_EV_Charger/api/v1/measurements/live/ -d "[{\"componentId\":\"IGULD:SELF\"}]" -H "Authorization: Bearer $bearer_token_string")
echo "{\"sma_ev_json\":"$SMA_EV_Return"}"
And the sensor being used is
- platform: command_line
name: SMA EV Charger
scan_interval: 60
command_timeout: 30
command: "/opt/homeassistant/sma-ev-getdata.sh"
value_template: 'SMA_EV_CHG'
json_attributes:
- sma_ev_json
This results in a new sensor that contains the json data from the SMA EV Charger as attributes:
Data can be accessed like this then:
{{ states.sensor.sma_ev_charger.attributes['sma_ev_json'][1]['values'][0]['value'] }}
Result: