From 7d0df80c086ba67675e2420437749d1fbd4b4225 Mon Sep 17 00:00:00 2001 From: WebSpider Date: Thu, 31 Oct 2024 14:10:12 +0100 Subject: [PATCH] Fix value of charge_type sensor (#152) * Fix value of sensor when charge_type is None * Add translation for charge_type states --- custom_components/myskoda/sensor.py | 3 ++- custom_components/myskoda/translations/en.json | 7 ++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/custom_components/myskoda/sensor.py b/custom_components/myskoda/sensor.py index 15b4810..d6184b5 100644 --- a/custom_components/myskoda/sensor.py +++ b/custom_components/myskoda/sensor.py @@ -250,7 +250,8 @@ class ChargeType(ChargingSensor): @property def native_value(self) -> str | None: # noqa: D102 if status := self._status(): - return str(status.charge_type).lower() + if status.charge_type: + return str(status.charge_type).lower() class ChargingState(ChargingSensor): diff --git a/custom_components/myskoda/translations/en.json b/custom_components/myskoda/translations/en.json index e52d06f..962f2f6 100644 --- a/custom_components/myskoda/translations/en.json +++ b/custom_components/myskoda/translations/en.json @@ -99,7 +99,12 @@ "name": "Mileage" }, "charge_type": { - "name": "Charge Type" + "name": "Charge Type", + "state": { + "ac": "AC", + "dc": "DC", + "off": "OFF" + } }, "remaining_charging_time": { "name": "Remaining Charging Time"