Skip to content

Commit

Permalink
Update sensor.py
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinebou12 authored Mar 2, 2024
1 parent 529e097 commit 5fb6b28
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions custom_components/renpho/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@ def unit(self) -> str:
"""Return the unit of the sensor."""
if self._unit_of_measurement == MASS_POUNDS and self._unit == MASS_KILOGRAM:
return MASS_POUNDS
return MASS_KILOGRAMS
else:
return MASS_KILOGRAM
return self._unit

@property
def category(self) -> str:
Expand All @@ -156,7 +158,7 @@ async def async_update(self) -> None:
)

if metric_value is not None:
self._state = round(metric_value * KG_TO_LBS, 2) if self._unit_of_measurement == MASS_POUNDS else round(metric_value, 2)
self._state = round(metric_value * KG_TO_LBS, 2) if self._unit_of_measurement == MASS_POUNDS and self._unit == MASS_KILOGRAMS else round(metric_value, 2)
self._timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
_LOGGER.info(f"Successfully updated {self._name} for metric type {self._metric}")
else:
Expand Down

0 comments on commit 5fb6b28

Please sign in to comment.