Fix weather entities reverting to daily forecast (#1402)

This commit is contained in:
Nigel Rook
2025-11-29 15:47:04 +00:00
committed by GitHub
parent 3b25d47bc7
commit 341cdb47ab

View File

@@ -388,11 +388,12 @@ class LuiPagesGen(object):
entityTypePanel = "text" entityTypePanel = "text"
unit = get_attr_safe(entity, "temperature_unit", "") unit = get_attr_safe(entity, "temperature_unit", "")
rt = None rt = None
index = item.stype
if type(item.stype) == str and ":" in item.stype and len(item.stype.split(":")) == 2: if type(item.stype) == str and ":" in item.stype and len(item.stype.split(":")) == 2:
spintstr = item.stype.split(":") spintstr = item.stype.split(":")
rt = spintstr[0] rt = spintstr[0]
item.stype = int(spintstr[1]) index = int(spintstr[1])
if type(item.stype) == int: if type(index) == int:
bits = get_attr_safe(entity, "supported_features", 0b0) bits = get_attr_safe(entity, "supported_features", 0b0)
if not rt: if not rt:
rt = "daily" rt = "daily"
@@ -407,8 +408,8 @@ class LuiPagesGen(object):
"weather/get_forecasts", target={"entity_id": entityId}, service_data={"type": rt} "weather/get_forecasts", target={"entity_id": entityId}, service_data={"type": rt}
) )
forecast = results.get("result", {}).get("response", {}).get(entityId, {}).get('forecast') or entity.attributes.get('forecast', []) forecast = results.get("result", {}).get("response", {}).get(entityId, {}).get('forecast') or entity.attributes.get('forecast', [])
if len(forecast) >= item.stype: if len(forecast) >= index:
day_forecast = forecast[item.stype] day_forecast = forecast[index]
fdate = dp.parse(day_forecast['datetime']) fdate = dp.parse(day_forecast['datetime'])
global babel_spec global babel_spec
if babel_spec is not None: if babel_spec is not None: