Skip to content

Commit

Permalink
reformat and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
jschlyter committed Sep 20, 2024
1 parent b0ce669 commit 11c27e5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
36 changes: 9 additions & 27 deletions custom_components/chargeamps/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,23 +192,17 @@ async def _ensure_token(self) -> None:
async def _post(self, path, **kwargs) -> ClientResponse:
await self._ensure_token()
headers = kwargs.pop("headers", self._headers)
return await self._session.post(
urljoin(self._base_url, path), ssl=self._ssl, headers=headers, **kwargs
)
return await self._session.post(urljoin(self._base_url, path), ssl=self._ssl, headers=headers, **kwargs)

async def _get(self, path, **kwargs) -> ClientResponse:
await self._ensure_token()
headers = kwargs.pop("headers", self._headers)
return await self._session.get(
urljoin(self._base_url, path), ssl=self._ssl, headers=headers, **kwargs
)
return await self._session.get(urljoin(self._base_url, path), ssl=self._ssl, headers=headers, **kwargs)

async def _put(self, path, **kwargs) -> ClientResponse:
await self._ensure_token()
headers = kwargs.pop("headers", self._headers)
return await self._session.put(
urljoin(self._base_url, path), ssl=self._ssl, headers=headers, **kwargs
)
return await self._session.put(urljoin(self._base_url, path), ssl=self._ssl, headers=headers, **kwargs)

async def get_chargepoints(self) -> list[ChargePoint]:
"""Get all owned chargepoints"""
Expand All @@ -231,18 +225,14 @@ async def get_all_chargingsessions(
query_params["startTime"] = start_time.isoformat()
if end_time:
query_params["endTime"] = end_time.isoformat()
request_uri = (
f"/api/{API_VERSION}/chargepoints/{charge_point_id}/chargingsessions"
)
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/chargingsessions"
response = await self._get(request_uri, params=query_params)
res = []
for session in await response.json():
res.append(ChargingSession.from_dict(session))
return res

async def get_chargingsession(
self, charge_point_id: str, session: int
) -> ChargingSession:
async def get_chargingsession(self, charge_point_id: str, session: int) -> ChargingSession:
"""Get charging session"""
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/chargingsessions/{session}"
response = await self._get(request_uri)
Expand All @@ -256,9 +246,7 @@ async def get_chargepoint_status(self, charge_point_id: str) -> ChargePointStatu
payload = await response.json()
return ChargePointStatus.from_dict(payload)

async def get_chargepoint_settings(
self, charge_point_id: str
) -> ChargePointSettings:
async def get_chargepoint_settings(self, charge_point_id: str) -> ChargePointSettings:
"""Get chargepoint settings"""
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/settings"
response = await self._get(request_uri)
Expand All @@ -272,28 +260,22 @@ async def set_chargepoint_settings(self, settings: ChargePointSettings) -> None:
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/settings"
await self._put(request_uri, json=payload)

async def get_chargepoint_connector_settings(
self, charge_point_id: str, connector_id: int
) -> ChargePointConnectorSettings:
async def get_chargepoint_connector_settings(self, charge_point_id: str, connector_id: int) -> ChargePointConnectorSettings:
"""Get all owned chargepoints"""
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/settings"
response = await self._get(request_uri)
payload = await response.json()
return ChargePointConnectorSettings.from_dict(payload)

async def set_chargepoint_connector_settings(
self, settings: ChargePointConnectorSettings
) -> None:
async def set_chargepoint_connector_settings(self, settings: ChargePointConnectorSettings) -> None:
"""Get all owned chargepoints"""
payload = settings.to_dict()
charge_point_id = settings.charge_point_id
connector_id = settings.connector_id
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/settings"
await self._put(request_uri, json=payload)

async def remote_start(
self, charge_point_id: str, connector_id: int, start_auth: StartAuth
) -> None:
async def remote_start(self, charge_point_id: str, connector_id: int, start_auth: StartAuth) -> None:
"""Remote start chargepoint"""
payload = start_auth.to_dict()
request_uri = f"/api/{API_VERSION}/chargepoints/{charge_point_id}/connectors/{connector_id}/remotestart"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/chargeamps/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Base component constants
DOMAIN = "chargeamps"
DOMAIN_DATA = f"{DOMAIN}_data"
VERSION = "1.11.0"
VERSION = "1.11.1"
PLATFORMS = ["sensor", "switch", "light"]
ISSUE_URL = "https://github.com/kirei/hass-chargeamps/issues"
CONFIGURATION_URL = "https://my.charge.space"
Expand Down
2 changes: 1 addition & 1 deletion custom_components/chargeamps/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
"homeassistant>=2024.1.0",
"dataclasses-json>=0.5.2"
],
"version": "1.11.0"
"version": "1.11.1"
}

0 comments on commit 11c27e5

Please sign in to comment.