Skip to content

Commit

Permalink
Merge pull request #49 from figorr/figorr-patch-1
Browse files Browse the repository at this point in the history
Merging this now!
  • Loading branch information
barleybobs authored Feb 26, 2024
2 parents d5a8565 + 2d1af86 commit 7ba6126
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions custom_components/ecowater_softener/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@
from homeassistant.helpers.typing import StateType
from homeassistant.helpers.update_coordinator import CoordinatorEntity
from homeassistant.const import (
VOLUME_LITERS,
VOLUME_GALLONS,
TIME_DAYS,
UnitOfVolume,
UnitOfTime,
PERCENTAGE,
)

Expand Down Expand Up @@ -80,7 +79,7 @@ class EcowaterSensorEntityDescription(SensorEntityDescription):
key=DAYS_UNTIL_OUT_OF_SALT,
name="Days until out of salt",
icon="mdi:calendar",
native_unit_of_measurement=TIME_DAYS,
native_unit_of_measurement=UnitOfTime.DAYS,
),
EcowaterSensorEntityDescription(
key=RECHARGE_ENABLED,
Expand Down Expand Up @@ -137,9 +136,9 @@ def __init__(
def native_unit_of_measurement(self) -> StateType:
if self.entity_description.key.startswith('water'):
if self.coordinator.data['water_units'].lower() == 'liters':
return VOLUME_LITERS
return UnitOfVolume.LITERS
elif self.coordinator.data['water_units'].lower() == 'gallons':
return VOLUME_GALLONS
return UnitOfVolume.GALLONS
elif self.entity_description.native_unit_of_measurement != None:
return self.entity_description.native_unit_of_measurement

Expand Down

0 comments on commit 7ba6126

Please sign in to comment.