hassio 0.92.2版本运行padavan老毛子插件出错,下面是log:
2019-05-02 18:26:46 INFO (SyncWorker_2) [custom_components.padavan.device_tracker] padavan 开始获取无线客户端数据
2019-05-02 18:26:46 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/homeassistant/components/device_tracker/__init__.py", line 703, in async_device_tracker_scan
found_devices = await scanner.async_scan_devices()
File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/padavan/device_tracker.py", line 82, in scan_devices
self._update_info()
File "/config/custom_components/padavan/device_tracker.py", line 139, in _update_info
hostdict=findhostname(res_host)
File "/config/custom_components/padavan/device_tracker.py", line 223, in findhostname
exec('ipmonitor={}'.format(page),_scp)
File "<string>", line 1, in <module>
NameError: name 'null' is not defined
解决办法:
是findhostname函数出错,执行exec('ipmonitor={}'.format(page),_scp) 有问题。
注释掉下面两行
exec('ipmonitor={}'.format(page),_scp)
for i in _scp['ipmonitor']:
新增下面两行
_scp = json.loads(page)
for i in _scp:
完整的函数,参考下面:
def findhostname(z):
_scp={}
hostinfo={}
page=re.findall(r'ipmonitor = (.+?);',z,flags=re.S)
if page:
page=page[0]
# exec('ipmonitor={}'.format(page),_scp)
# for i in _scp['ipmonitor']:
_scp = json.loads(page)
for i in _scp:
hostinfo[i[1]]=i[2]
return hostinfo
else:return {}
PS:由于插件一直在检测,config下面的home-assistant.log日志一直在疯涨,太占空间了,
建议把126行的_LOGGER.info("gocloud 开始获取无线客户端数据")改成_LOGGER.debug("gocloud 开始获取无线客户端数据")
或者直接注释掉。
|