Skip to content

Commit

Permalink
fix: precipitation sensor
Browse files Browse the repository at this point in the history
  • Loading branch information
chilikla authored Nov 30, 2024
1 parent b0e30e2 commit d5f8da8
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 20 deletions.
25 changes: 6 additions & 19 deletions custom_components/yerushamayim/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,22 +230,9 @@ def icon(self):
"""Return the icon."""
return "mdi:weather-pouring"

# @property
# def precipitation_probability(self) -> int | None:
# """Return the precipitation probability"""
# try:
# return int(self.coordinator.data.precipitation["precipitation_probability"])
# except (ValueError, KeyError, TypeError):
# return None

# @property
# def extra_state_attributes(self):
# """Return the state attributes with numeric conversions for precipitation."""
# attrs = super().extra_state_attributes
# for key in attrs:
# if key.endswith('_temp') and attrs[key] is not None:
# try:
# attrs[key] = float(attrs[key])
# except (ValueError, TypeError):
# pass
# return attrs
@property
def extra_state_attributes(self):
"""Return the state attributes with numeric conversions for precipitation."""
attrs = super().extra_state_attributes
attrs["precipitation_probability_unit"] = PERCENTAGE
return attrs
1 change: 0 additions & 1 deletion custom_components/yerushamayim/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ async def async_forecast_daily(self) -> list[Forecast] | None:
try:
forecast = [Forecast(
datetime=datetime.now().isoformat(),
condition=self.coordinator.data.status.get("condition"),
native_temperature=float(self.coordinator.data.temperature["temperature"]),
precipitation=float(self.coordinator.data.precipitation["precipitation"]),
precipitation_probability=int(self.coordinator.data.precipitation["precipitation_probability"])
Expand Down

0 comments on commit d5f8da8

Please sign in to comment.