#sma ev charger in HA usnig bash / curl

25 messages · Page 1 of 1 (latest)

stuck ferry
#

hi any of you familliar with bash and or curl stuff eshwhy
i'm trying to integrate a sma ev charger and the peice of shit has no real api
i got sensor whit bash but am a bit stuck whit the controles
this is what i have now to try and get it to respond
IP_EV_Charger='11.3.3.8'

USER='xxxx'
PASSWORD='xxx'


TOKENREQUEST=$(curl  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
echo "$bearer_token_string" 

test=$(curl -i -s -k -X 'PUT' http://$IP_EV_Charger/api/v1/parameters/IGULD:SELF -H 'Content-Type: application/json'  -H "Referer: http://$IP_EV_Charger/webui/Plant:1,IGULD:SELF/configuration/view-parameters" -d '{\"values\":[{\"channelId\":\"Parameter.Inverter.AcALim\",\"value\":\"6\"}]}' -H "Authorization: Bearer $bearer_token_string")
echo "$test"
and this is the part that works 
IP_EV_Charger='11.3.3.8' ;
USER='xxxxx' ;
PASSWORD='xxxx' ;


TOKENREQUEST=$(curl --silent curl 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"}"
```
#

but unfortunatly oi seem to be stuck

vestal zenith
#

What error do you get?

stuck ferry
vestal zenith
#

What about if you try running the curl without it being in the bash script just to see what the outputs of each one are

stuck ferry
#
{"access_token":"eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzgxOTYwNTYsInN1YiI6IkRvdHJvbml4IiwidWlkIjoiOGY5ZDg1Y2QtNzBjMy00NTk5LWI1MjItMGZmNzFlYjMyNDk3IiwiZXhwIjoxNjc4MTk5NjU2fQ.aeDqxPl7YGy4CrsAH9xIKbn04i284gysCFiIznNSclg","expires_in":3600,"refresh_token":"eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzgxOTYwNTYsInN1YiI6IkRvdHJvbml4IiwidWlkIjoiOGY5ZDg1Y2QtNzBjMy00NTk5LWI1MjItMGZmNzFlYjMyNDk3IiwiZXhwIjoxNjc4MjgyNDU2LCJ0eXBlIjoicmVmcmVzaCJ9.esuQQhlqg79kT_xK3V-B6D6FbZuJMycCd6qKe5DRR7Q","token_type":"bearer","uiIdleTime":"60"}
C:\Users\gebruiker>curl -i -s -k -X 'PUT' http://11.3.3.8/api/v1/parameters/IGULD:SELF -H 'Content-Type: application/json' -H 'Referer: http://11.3.3.8/webui/Plant:1,IGULD:SELF/configuration/view-parameters' -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzgxOTYwNTYsInN1YiI6IkRvdHJvbml4IiwidWlkIjoiOGY5ZDg1Y2QtNzBjMy00NTk5LWI1MjItMGZmNzFlYjMyNDk3IiwiZXhwIjoxNjc4MTk5NjU2fQ.aeDqxPl7YGy4CrsAH9xIKbn04i284gysCFiIznNSclg"
HTTP/1.1 500 Server Error
Date: Tue, 07 Mar 2023 13:35:12 GMT
Cache-Control: no-cache,no-store,must-revalidate
Content-Length: 0

HTTP/1.1 302 Found
Date: Tue, 07 Mar 2023 13:35:14 GMT
Location: https://11.3.3.8/webui/Plant:1,IGULD:SELF/configuration/view-parameters'
Content-Length: 0

vestal zenith
#

What are the expected results?

stuck ferry
#

a paremiter in the charger needs to change so i can controle its maximum electricity draw but it is pretty locked down and has no decent api

vestal zenith
#

You see the 302 found near the bottom? That's a redirect, I think its saying that the new page is at the URL it gives you in the location on the second last line

stuck ferry
#

yeah that url is in the script but whitout httpS so i'l try that now

vestal zenith
#

Yeah or try repeat the curl command but changing it to the new one

stuck ferry
#

that gives this error ```
C:\Users\gebruiker>curl http://11.3.3.8/api/v1/token -d "grant_type=password&username=Dotronix&password=Expedio2021!
{"access_token":"eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzgxOTc5NjcsInN1YiI6IkRvdHJvbml4IiwidWlkIjoiOGY5ZDg1Y2QtNzBjMy00NTk5LWI1MjItMGZmNzFlYjMyNDk3IiwiZXhwIjoxNjc4MjAxNTY3fQ.ixfh9FBc-nVrc0bGrBeYsXrbopon6d0O1A3IeYI5wb4","expires_in":3600,"refresh_token":"eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzgxOTc5NjcsInN1YiI6IkRvdHJvbml4IiwidWlkIjoiOGY5ZDg1Y2QtNzBjMy00NTk5LWI1MjItMGZmNzFlYjMyNDk3IiwiZXhwIjoxNjc4Mjg0MzY3LCJ0eXBlIjoicmVmcmVzaCJ9.a6Sz7OGCJlv6ZG3D-7Tv_U0bQbFp6BOm-JOQwDmDMo0","token_type":"bearer","uiIdleTime":"60"}
C:\Users\gebruiker>curl -i -s -k -X 'PUT' http://11.3.3.8/api/v1/parameters/IGULD:SELF -H 'Content-Type: application/json' -H "Referer: https://$IP_EV_Charger/webui/Plant:1,IGULD:SELF/configuration/view-parameters" -d '{"values":[{"channelId":"Parameter.Inverter.AcALim","value":"6"}]}' -H "Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJpYXQiOjE2NzgxOTc5NjcsInN1YiI6IkRvdHJvbml4IiwidWlkIjoiOGY5ZDg1Y2QtNzBjMy00NTk5LWI1MjItMGZmNzFlYjMyNDk3IiwiZXhwIjoxNjc4MjAxNTY3fQ.ixfh9FBc-nVrc0bGrBeYsXrbopon6d0O1A3IeYI5wb4"
HTTP/1.1 500 Server Error
Date: Tue, 07 Mar 2023 14:06:28 GMT
Cache-Control: no-cache,no-store,must-revalidate
Content-Length: 0

vestal zenith
#

Hmmmm that is strange

stuck ferry
#

yeah

stuck ferry
#

yeah not really finding anything myself

rough garden
#

It's possible that they locked it down... I've got the Shell EV charger and I can only retrieve usage data without login. It's a login from them, I can't get into it...

#

Are you sure you can get into using the credentials you've got?

stuck ferry
#

yeah we installed it :p

rough garden
#

Isn't it possible to contact the manufacturar?

stuck ferry
#

yeah but they aren't really known for updates

#

it looks the same as it did 5 years age and 50 years from now kekw

fading onyx
#

have you tried with postman, i find it helps to decipher whats req'd a lot easier