本帖最后由 LW007 于 2025-7-9 11:46 编辑
qweather-card.js 中的这个代码不能正常运行
<div class="title">${config.name || weather.attributes.city || weather.attributes.friendly_name}</div>
我的显示的是未知,我把${config.name 改为了“555” 显示如附件
还有我看了 weather.py中的代码
if not self._city:
try:
async with session.get(self.geo_url) as response:
geo_data = await response.json()
if 'location' in geo_data and geo_data['location']:
self._city = geo_data['location'][0].get("name", "未知")
_LOGGER.info("[%s]天气所在城市:%s", self._name, self._city)
else:
self._city = "未知"
except (aiohttp.ClientError, ValueError, IndexError, KeyError) as e:
_LOGGER.warning("城市信息API请求失败: %s", str(e))
self._city = "未知"
是不是获取数据不正确哦,按我的理解图片圈的应该会显示城市信息 ,本人小白 请看看咋回事 我觉得正常应该显示的 |