『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
楼主: crazysiri

[技术探讨] 天气插件 和风 彩云 重构 求组队

[复制链接]

8

主题

116

帖子

509

积分

高级会员

Rank: 4

积分
509
金钱
393
HASS币
0
发表于 2020-8-13 23:57:41 | 显示全部楼层
a4610759 发表于 2020-8-13 21:15
这段代码写在configuration.yaml里。但是重启后在开发者的状态栏里查询不到weather实体。请问我是哪里出错 ...

查询到日志里有错误输出
日志详细信息( ERROR )
Logger: homeassistant.components.weather
Source: custom_components/ha_weather/UBWeatherReader.py:51
Integration: Weather (documentation, issues)
First occurred: 下午11:43:49 (1 occurrences)
Last logged: 下午11:43:49

Error while setting up ha_weather platform for weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/asyncio/coroutines.py", line 124, in coro
    res = func(*args, **kw)
  File "/config/custom_components/ha_weather/weather.py", line 98, in async_setup_platform
    entity = HeFengWeather(hass,name,data)
  File "/config/custom_components/ha_weather/weather.py", line 181, in __init__
    data.reload()
  File "/config/custom_components/ha_weather/weather.py", line 153, in reload
    self.caiyun.load()
  File "/config/custom_components/ha_weather/caiyun.py", line 732, in load
    self._reader.load()
  File "/config/custom_components/ha_weather/UBWeatherReader.py", line 51, in load
    self._originalJson = self._originalJson[key]
KeyError: 'result'
回复

使用道具 举报

15

主题

297

帖子

1501

积分

论坛技术达人

积分
1501
金钱
1199
HASS币
30
 楼主| 发表于 2020-8-15 10:39:02 | 显示全部楼层
a4610759 发表于 2020-8-13 23:57
查询到日志里有错误输出

彩云和和风都得申请,因为我是都申请了,所以这里可能没做判断,读不到彩云的数据肯定报错
回复

使用道具 举报

15

主题

297

帖子

1501

积分

论坛技术达人

积分
1501
金钱
1199
HASS币
30
 楼主| 发表于 2020-8-15 10:49:38 | 显示全部楼层
a4610759 发表于 2020-8-13 19:19
请问是需要在配置目录里面建立一个data的文件是吗??
还有更新策略是增加到automation里面是吗? ...

是在custom_components/ha_weather下建立一个downloads目录,但我记得是自动建立吧
回复

使用道具 举报

8

主题

116

帖子

509

积分

高级会员

Rank: 4

积分
509
金钱
393
HASS币
0
发表于 2020-8-15 20:41:35 | 显示全部楼层
crazysiri 发表于 2020-8-15 10:49
是在custom_components/ha_weather下建立一个downloads目录,但我记得是自动建立吧

好的,多谢指导
回复

使用道具 举报

8

主题

116

帖子

509

积分

高级会员

Rank: 4

积分
509
金钱
393
HASS币
0
发表于 2020-8-17 21:53:12 | 显示全部楼层
crazysiri 发表于 2020-8-15 10:39
彩云和和风都得申请,因为我是都申请了,所以这里可能没做判断,读不到彩云的数据肯定报错 ...

彩云API已添加,也可以下载json文件了,但是还是报错了。您再看一下。
Error while setting up ha_weather platform for weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/asyncio/coroutines.py", line 124, in coro
    res = func(*args, **kw)
  File "/config/custom_components/ha_weather/weather.py", line 98, in async_setup_platform
    entity = HeFengWeather(hass,name,data)
  File "/config/custom_components/ha_weather/weather.py", line 181, in __init__
    data.reload()
  File "/config/custom_components/ha_weather/weather.py", line 154, in reload
    self.hefeng.load(api_type)
  File "/config/custom_components/ha_weather/hefeng.py", line 472, in load
    self.parse()
  File "/config/custom_components/ha_weather/hefeng.py", line 484, in parse
    for item in self._hourly_reader.originalJson['hourly']:
KeyError: 'hourly'
回复

使用道具 举报

15

主题

297

帖子

1501

积分

论坛技术达人

积分
1501
金钱
1199
HASS币
30
 楼主| 发表于 2020-8-25 08:39:30 | 显示全部楼层
a4610759 发表于 2020-8-17 21:53
彩云API已添加,也可以下载json文件了,但是还是报错了。您再看一下。

你看看直接把更新逻辑里的 api_type 变成111111
回复

使用道具 举报

8

主题

116

帖子

509

积分

高级会员

Rank: 4

积分
509
金钱
393
HASS币
0
发表于 2020-8-25 12:27:10 | 显示全部楼层
crazysiri 发表于 2020-8-25 08:39
你看看直接把更新逻辑里的 api_type 变成111111

好的,我再试试
回复

使用道具 举报

8

主题

116

帖子

509

积分

高级会员

Rank: 4

积分
509
金钱
393
HASS币
0
发表于 2020-8-25 12:46:08 | 显示全部楼层
crazysiri 发表于 2020-8-25 08:39
你看看直接把更新逻辑里的 api_type 变成111111
Error while setting up ha_weather platform for weather
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/local/lib/python3.8/asyncio/coroutines.py", line 124, in coro
    res = func(*args, **kw)
  File "/config/custom_components/ha_weather/weather.py", line 97, in async_setup_platform
    data = WeatherData(location,hefengkey,hefengfreekey,caiyunkey,'home',free)
  File "/config/custom_components/ha_weather/weather.py", line 146, in __init__
    self._hefeng = hefeng.HeFengWeather(location,hefengkey,hefengfreekey,save_name_pre=save_name_pre,free=free)
  File "/config/custom_components/ha_weather/hefeng.py", line 412, in __init__
    self.parse()
  File "/config/custom_components/ha_weather/hefeng.py", line 484, in parse
    for item in self._hourly_reader.originalJson['hourly']:
KeyError: 'hourly'

还是一样的。
回复

使用道具 举报

15

主题

297

帖子

1501

积分

论坛技术达人

积分
1501
金钱
1199
HASS币
30
 楼主| 发表于 2020-8-25 22:27:23 来自手机 | 显示全部楼层
a4610759 发表于 2020-8-25 12:46
还是一样的。

重新拉一下代码,我更新了一下看看,好奇怪我这就有数据
回复

使用道具 举报

0

主题

40

帖子

210

积分

论坛积极会员

积分
210
金钱
170
HASS币
0
发表于 2020-8-25 23:55:26 | 显示全部楼层
持续关注大佬动态,现在在用的是免费和风
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-19 07:30 , Processed in 0.056771 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表