Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix for 2024.4 #131

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions custom_components/car_wash/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -16,13 +16,14 @@

from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.components.weather import (
ATTR_FORECAST,
ATTR_FORECAST_CONDITION,
ATTR_FORECAST_PRECIPITATION,
ATTR_FORECAST_TEMP,
ATTR_FORECAST_TEMP_LOW,
ATTR_FORECAST_TIME,
ATTR_WEATHER_TEMPERATURE,
DOMAIN as WEATHER_DOMAIN,
SERVICE_GET_FORECASTS,
)
from homeassistant.const import (
CONF_NAME,
@@ -141,7 +142,9 @@ def sensor_startup(event):
def _temp2c(temperature: Optional[float], temperature_unit: str) -> Optional[float]:
"""Convert weather temperature to Celsius degree."""
if temperature is not None and temperature_unit != UnitOfTemperature.CELSIUS:
temperature = TemperatureConverter.convert(temperature, temperature_unit, UnitOfTemperature.CELSIUS)
temperature = TemperatureConverter.convert(
temperature, temperature_unit, UnitOfTemperature.CELSIUS
)
return temperature

# pylint: disable=too-many-branches,too-many-statements
@@ -157,7 +160,20 @@ async def async_update(self):
tmpu = self.hass.config.units.temperature_unit
temp = wdata.attributes.get(ATTR_WEATHER_TEMPERATURE)
cond = wdata.state
forecast = wdata.attributes.get(ATTR_FORECAST)

daily_response = await self.hass.services.async_call(
WEATHER_DOMAIN,
SERVICE_GET_FORECASTS,
{"entity_id": self._weather_entity, "type": "daily"},
blocking=True,
return_response=True,
)
if (not (isinstance(daily_response, dict))) or (len(daily_response) == 0):
forecast = None
elif "forecast" in daily_response[self._weather_entity]:
forecast = daily_response[self._weather_entity]["forecast"]
else:
forecast = None

if forecast is None:
self._attr_is_on = None
@@ -185,7 +201,7 @@ async def async_update(self):
fc_date = fcast.get(ATTR_FORECAST_TIME)
if isinstance(fc_date, int):
fc_date = dt_util.as_local(
datetime.utcfromtimestamp(fc_date / 1000)
datetime.fromtimestamp(fc_date, tz=datetime.timezone.utc)
).isoformat()
elif isinstance(fc_date, datetime):
fc_date = dt_util.as_local(fc_date).isoformat()