Skip to content

Commit

Permalink
sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jschlyter committed Jun 28, 2024
1 parent 69e01b4 commit 5e22894
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
17 changes: 10 additions & 7 deletions chargeamps/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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]):
Expand All @@ -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(
Expand Down Expand Up @@ -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]):
Expand Down Expand Up @@ -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)
8 changes: 4 additions & 4 deletions tests/test_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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)

0 comments on commit 5e22894

Please sign in to comment.