Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions python_chargepoint/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,31 @@ def set_amperage_limit(self, charger_id: int, amperage_limit: int, max_retry: in
raise ChargePointCommunicationException(
response=response, message="New amperage limit did not persist to charger after retries"
)

@_require_login
def restart_home_charger(self, charger_id: int) -> None:
_LOGGER.debug("Sending restart command for panda: %s", charger_id)
restart = {
"user_id": self.user_id,
"restart_panda": {"device_id": charger_id, "mfhs": {}},
}
response = self._session.post(
f"{self._global_config.endpoints.webservices}mobileapi/v5", json=restart
)

if response.status_code != codes.ok:
_LOGGER.error(
"Failed to restart charger! status_code=%s err=%s",
response.status_code,
response.text,
)
raise ChargePointCommunicationException(
response=response, message="Failed to restart charger."
)

status = response.json()
_LOGGER.debug(status)
return

@_require_login
def get_charging_session(self, session_id: int) -> ChargingSession:
Expand Down
25 changes: 25 additions & 0 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,31 @@ def test_client_get_get_user_charging_status_failure(authenticated_client: Charg

assert exc.value.response.status_code == 500

@responses.activate
def test_client_restart_home_charger(authenticated_client: ChargePoint, home_charger_json: dict):
responses.add(
responses.POST,
f"{authenticated_client.global_config.endpoints.webservices}mobileapi/v5",
status=200,
json={"restart_panda": {}},
)

status = authenticated_client.restart_home_charger(1234567890)

assert status is None

@responses.activate
def test_client_restart_home_charger_failure(authenticated_client: ChargePoint, home_charger_json: dict):
responses.add(
responses.POST,
f"{authenticated_client.global_config.endpoints.webservices}mobileapi/v5",
status=500,
)

with pytest.raises(ChargePointCommunicationException) as exc:
authenticated_client.restart_home_charger(1234567890)

assert exc.value.response.status_code == 500

@responses.activate
def test_start_session(
Expand Down