I got an Easee EV charger, and there is an API available. I found this python script that works, and there is a API documentation https://api.easee.cloud/index.html
Currently I only need basic functionality:
get a token
get a switch in openhab that
starts the charging: /api/chargers/[CHARGERID ex. EH123456]/commands/start_charging
stops the charging: /api/chargers/[CHARGERID ex. EH123456]/commands/stop_charging
Is there some one that can give me some guidance how to make this in Openhab? I have no experience of working with API in Openhab
import requests, json, time
from pprint import pprint
class connect:
def init(self,
access_token=None,
):
if (access_token is None):
access_token_resp = self.get_access_token()
access_token = access_token_resp["accessToken"]
self.headers = {"Authorization": "Bearer {}".format(access_token)}
def get_access_token(self):
return requests.post("https://api.easee.cloud/api/accounts/token", json={"grantType":"password","username":"+46[PHONENO]","password":"[PASSWORD]"}).json()
def get_data_request(self):
return requests.get(
'https://api.easee.cloud/api/chargers/[CHARGERID ex. EH123456]/state',headers=self.headers).json()
my_charger = connect()
resp = my_charger.get_data_request()
print(resp[‘latestPulse’] + " ", end=’’)
print(str(round(resp[‘inCurrentT3’],1)) + "A ", end=’’)
print(str(round(resp[‘inCurrentT4’],1)) + "A ", end=’’)
print(str(round(resp[‘inCurrentT5’],1)) + "A ", end=’’)
print(str(round(resp[‘sessionEnergy’],3)) + "kWh ", end=’’)
print(str(round(resp[‘totalPower’],3)) + “kWh”)