diff --git a/README.md b/README.md index 83496aa..dc95fc4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Ohme EV Charger for Home Assistant -A basic integration for interacting with Ohme EV Chargers. +An integration for interacting with Ohme EV Chargers. This is an unofficial integration. I have no affiliation with Ohme besides owning one of their EV chargers. diff --git a/custom_components/ohme/number.py b/custom_components/ohme/number.py index efee03b..20c8906 100644 --- a/custom_components/ohme/number.py +++ b/custom_components/ohme/number.py @@ -193,7 +193,6 @@ def native_value(self): class PriceCapNumber(NumberEntity): _attr_name = "Price Cap" - _attr_native_unit_of_measurement = "p" _attr_device_class = NumberDeviceClass.MONETARY _attr_mode = NumberMode.BOX _attr_native_step = 0.1 @@ -230,6 +229,19 @@ async def async_set_native_value(self, value: float) -> None: await asyncio.sleep(1) await self.coordinator.async_refresh() + @property + def native_unit_of_measurement(self): + if self.coordinator.data is None: + return None + + penny_unit = { + "GBP": "p", + "EUR": "c" + } + currency = self.coordinator.data["userSettings"].get("currencyCode", "XXX") + + return penny_unit.get(currency, f"{currency}/100") + @property def icon(self): """Icon of the sensor."""