From 5e22894c844acbe5ec8be369aa3377654f3e0691 Mon Sep 17 00:00:00 2001 From: Jakob Schlyter Date: Fri, 28 Jun 2024 11:20:05 +0200 Subject: [PATCH] sync --- chargeamps/local.py | 17 ++++++++++------- tests/test_local.py | 8 ++++---- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/chargeamps/local.py b/chargeamps/local.py index bb36400..47c0f4c 100644 --- a/chargeamps/local.py +++ b/chargeamps/local.py @@ -49,7 +49,7 @@ class LocalChargePointConnectorStatus(BaseModel): status_text: str | None = None -class LocalChargePointStatus(BaseModel): +class LocalChargePointBase(BaseModel): connector_settings: list[ChargePointConnectorSettings] connector_status: list[LocalChargePointConnectorStatus] @@ -81,7 +81,7 @@ def process_message(self, message: str): logging.warning("Unknown preamble %d", preamble) -class LocalChargePointStatusHalo(LocalChargePointStatus): +class LocalChargePointStatusHalo(LocalChargePointBase): connector_settings: list[ChargePointConnectorSettings] = Field( default=[ ChargePointConnectorSettings( @@ -109,7 +109,7 @@ class LocalChargePointStatusHalo(LocalChargePointStatus): ] ) - def process_message(self, message: str): + def process_message(self, message: str) -> None: parameters = message.split(",") match int(parameters[0]): @@ -133,7 +133,7 @@ def process_message(self, message: str): return super().process_message(message) -class LocalChargePointStatusAura(LocalChargePointStatus): +class LocalChargePointStatusAura(LocalChargePointBase): connector_settings: list[ChargePointConnectorSettings] = Field( default=[ ChargePointConnectorSettings( @@ -161,7 +161,7 @@ class LocalChargePointStatusAura(LocalChargePointStatus): ] ) - def process_message(self, message: str): + def process_message(self, message: str) -> None: parameters = message.split(",") match int(parameters[0]): @@ -195,7 +195,10 @@ def __init__(self, chargepoint: LocalChargePoint) -> None: match self.chargepoint.type: case ChargePointType.HALO: - self.status = LocalChargePointStatusHalo() + self.state = LocalChargePointStatusHalo() case ChargePointType.AURA: - self.status = LocalChargePointStatusAura() + self.state = LocalChargePointStatusAura() + + def process_message(self, message: str) -> None: + self.state.process_message(message) diff --git a/tests/test_local.py b/tests/test_local.py index 4c5de5d..6de06ab 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -20,9 +20,9 @@ def test_local_halo(): client = ChargeAmpsLocalClient(chargepoint=halo) for message in MESSAGES_AURA: - client.status.process_message(message) + client.state.process_message(message) - print(client.status) + print(client.state) def test_local_aura(): @@ -32,6 +32,6 @@ def test_local_aura(): client = ChargeAmpsLocalClient(chargepoint=aura) for message in MESSAGES_AURA: - client.status.process_message(message) + client.state.process_message(message) - print(client.status) + print(client.state)