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

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

[经验分享] Deprecated

  [复制链接]

0

主题

2

帖子

47

积分

新手上路

Rank: 1

积分
47
金钱
45
HASS币
0
发表于 2022-12-17 21:16:04 | 显示全部楼层
本帖最后由 DEEaka 于 2022-12-17 21:26 编辑

大佬。出错了咋办。户号是我手动处理掉的。
conts.py改过了,还是这样
2022-12-17 21:02:05  [INFO    ] ---- Webdriver initialized.
2022-12-17 21:02:28  [INFO    ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-12-17 21:02:34  [INFO    ] ---- get all user id: ['户号1', '户号2', '户号3', '户号4', '户号5', '户号6', '户号7']
2022-12-17 21:02:43  [INFO    ] ---- Get electricity charge balance for 户号1 successfully, balance is -35.94 CNY.
2022-12-17 21:02:46  [INFO    ] ---- Get electricity charge balance for 户号2 successfully, balance is -35.38 CNY.
2022-12-17 21:03:06  [ERROR   ] ---- Webdriver quit abnormly, reason: Message: no such element: Unable to locate element: {"method":"css selector","selector":".num"}
  (Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x560f462d77f9 <unknown>
#1 0x560f462773b3 <unknown>
#2 0x560f45fbf016 <unknown>
#3 0x560f45ff381e <unknown>
#4 0x560f460298fb <unknown>
#5 0x560f46016ded <unknown>
#6 0x560f460279e1 <unknown>
#7 0x560f46016c93 <unknown>
#8 0x560f45fe8ce4 <unknown>
#9 0x560f45fea4d2 <unknown>
#10 0x560f462a3542 <unknown>
#11 0x560f462b2ce7 <unknown>
#12 0x560f462b29e4 <unknown>
#13 0x560f462b713a <unknown>
#14 0x560f462b35b9 <unknown>
#15 0x560f46298e00 <unknown>
#16 0x560f462ca5d2 <unknown>
#17 0x560f462ca778 <unknown>
#18 0x560f462e2a1f <unknown>
#19 0x7f87b7a26fa3 start_thread
#20 0x7f87b6c7d06f clone
. 1 retry times left.
Traceback (most recent call last):
  File "/app/data_fetcher.py", line 30, in fetch
    return self._fetch()
  File "/app/data_fetcher.py", line 53, in _fetch
    balance_list = self._get_electric_balances(driver, user_id_list)
  File "/app/data_fetcher.py", line 126, in _get_electric_balances
    balance = self._get_eletric_balance(driver)
  File "/app/data_fetcher.py", line 183, in _get_eletric_balance
    balance = driver.find_element(By.CLASS_NAME,"num").text
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 856, in find_element
    return self.execute(Command.FIND_ELEMENT, {
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/webdriver.py", line 429, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python3.8/site-packages/selenium/webdriver/remote/errorhandler.py", line 243, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".num"}
  (Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x560f462d77f9 <unknown>
#1 0x560f462773b3 <unknown>
#2 0x560f45fbf016 <unknown>
#3 0x560f45ff381e <unknown>
#4 0x560f460298fb <unknown>
#5 0x560f46016ded <unknown>
#6 0x560f460279e1 <unknown>
#7 0x560f46016c93 <unknown>
#8 0x560f45fe8ce4 <unknown>
#9 0x560f45fea4d2 <unknown>
#10 0x560f462a3542 <unknown>
#11 0x560f462b2ce7 <unknown>
#12 0x560f462b29e4 <unknown>
#13 0x560f462b713a <unknown>
#14 0x560f462b35b9 <unknown>
#15 0x560f46298e00 <unknown>
#16 0x560f462ca5d2 <unknown>
#17 0x560f462ca778 <unknown>
#18 0x560f462e2a1f <unknown>
#19 0x7f87b7a26fa3 start_thread
#20 0x7f87b6c7d06f clone

2022-12-17 21:03:47  [INFO    ] ---- Webdriver initialized.
2022-12-17 21:04:09  [INFO    ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-12-17 21:04:14  [INFO    ] ---- get all user id: ['户号1', '户号2', '户号3', '户号4', '户号5', '户号6', '户号7']
2022-12-17 21:04:24  [INFO    ] ---- Get electricity charge balance for 户号1 successfully, balance is -35.94 CNY.
2022-12-17 21:04:27  [INFO    ] ---- Get electricity charge balance for 户号2 successfully, balance is -35.38 CNY.
2022-12-17 21:04:47  [ERROR   ] ---- state-refresh task failed, reason is Message: no such element: Unable to locate element: {"method":"css selector","selector":".num"}
  (Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x556380ca47f9 <unknown>
#1 0x556380c443b3 <unknown>
#2 0x55638098c016 <unknown>
#3 0x5563809c081e <unknown>
#4 0x5563809f68fb <unknown>
#5 0x5563809e3ded <unknown>
#6 0x5563809f49e1 <unknown>
#7 0x5563809e3c93 <unknown>
#8 0x5563809b5ce4 <unknown>
#9 0x5563809b74d2 <unknown>
#10 0x556380c70542 <unknown>
#11 0x556380c7fce7 <unknown>
#12 0x556380c7f9e4 <unknown>
#13 0x556380c8413a <unknown>
#14 0x556380c805b9 <unknown>
#15 0x556380c65e00 <unknown>
#16 0x556380c975d2 <unknown>
#17 0x556380c97778 <unknown>
#18 0x556380cafa1f <unknown>
#19 0x7f43b248afa3 start_thread
#20 0x7f43b16e106f clone


回复

使用道具 举报

1

主题

30

帖子

159

积分

注册会员

Rank: 2

积分
159
金钱
129
HASS币
0
发表于 2022-12-20 17:33:06 | 显示全部楼层
浙江杭州 可以用吗
回复

使用道具 举报

19

主题

190

帖子

1300

积分

金牌会员

Rank: 6Rank: 6

积分
1300
金钱
1110
HASS币
0
发表于 2022-12-24 21:58:04 | 显示全部楼层

X

本帖最后由 xfyisheng 于 2022-12-24 22:29 编辑

stdout: 2022-12-24 21:39:49  [INFO    ] ---- Homeassistant REST API invoke, POST on http://192.168.2.2:8123/api/stat ... y_95598_1459296XXX. response[201]: b'{"entity_id":"sensor.electricity_95598_1459296XXX","state":"104.49","attributes":{"unit_of_measurement":"CNY","is_pay":"\xe9\xa2\x84\xe8\xae\xa1\xe5\x8f\xaf\xe7\x94\xa8\xe5\xa4\xa9\xe6\x95\xb0","last_electricity_usage":6.54,"yearly_electricity_usage":"2089","yearly_electricity_charge":"1243.58","update_time":"2022-12-24 21:39:49"},"last_changed":"2022-12-24T13:39:49.733019+00:00","last_updated":"2022-12-24T13:39:49.733019+00:00","context":{"id":"01GN25RYV4EJXS63S4SNNM0NAT","parent_id":null,"user_id":"9423f5d9b5184c039a0a5890c06e4f38"}}'
stdout: 2022-12-24 21:39:49  [INFO    ] ---- Homeassistant REST API invoke, POST on http://192.168.2.2:8123/api/stat ... y_95598_1459303XXX. response[201]: b'{"entity_id":"sensor.electricity_95598_1459303XXX","state":"184.3","attributes":{"unit_of_measurement":"CNY","is_pay":"\xe9\xa2\x84\xe8\xae\xa1\xe5\x8f\xaf\xe7\x94\xa8\xe5\xa4\xa9\xe6\x95\xb0","last_electricity_usage":8.57,"yearly_electricity_usage":"4473","yearly_electricity_charge":"2963.06","update_time":"2022-12-24 21:39:49"},"last_changed":"2022-12-24T13:39:49.742029+00:00","last_updated":"2022-12-24T13:39:49.742029+00:00","context":{"id":"01GN25RYVDVX276BKSRC59TMPB","parent_id":null,"user_id":"9423f5d9b5184c039a0a5890c06e4f38"}}'
stdout: 2022-12-24 21:39:49  [INFO    ] ---- state-refresh task run successfully!

yearly_electricity_charge_1459296XX_entity 显示未知
electricity_charge_balance_1459303XXX_entity 显示未知
yearly_electricity_usage_1459296XXX_entity 显示未知
last_electricity_usage_1459303XXX_entity 显示未知
回复

使用道具 举报

77

主题

1391

帖子

2万

积分

元老级技术达人

积分
24293
金钱
22862
HASS币
290
发表于 2022-12-24 22:51:31 | 显示全部楼层
本帖最后由 dscao 于 2022-12-24 22:53 编辑
xfyisheng 发表于 2022-12-24 21:58
stdout: 2022-12-24 21:39:49   ---- Homeassistant REST API invoke, POST on http://192.168.2.2:8123/ap ...

sensor.electricity_95598_1459296XXX  
sensor.electricity_95598_1459303XXX
日志显示的很清楚,数据全在这两个实体里面,需要的自己用模板转化一下单独实体。因你这个用了修改的版本。
回复

使用道具 举报

19

主题

190

帖子

1300

积分

金牌会员

Rank: 6Rank: 6

积分
1300
金钱
1110
HASS币
0
发表于 2022-12-24 22:59:04 | 显示全部楼层
dscao 发表于 2022-12-24 22:51
sensor.electricity_95598_1459296XXX  
sensor.electricity_95598_1459303XXX
日志显示的很清楚,数据全 ...

谢谢额,修改好了
回复

使用道具 举报

0

主题

7

帖子

32

积分

新手上路

Rank: 1

积分
32
金钱
25
HASS币
0
发表于 2022-12-26 14:57:54 | 显示全部楼层
本帖最后由 styleyuan 于 2022-12-26 15:12 编辑

2022-12-26 14:38:39 [INFO ] ---- Homeassistant REST API invoke, POST on http://192.168.31.216:8123/api/states/sensor.electricity_95598. response[201]: b'{"entity_id":"sensor.electricity_95598","state":"33.6","attributes":{"unit_of_measurement":"CNY","is_pay":"\xe5\xbd\x93\xe6\x9c\x9f\xe5\xb7\xb2\xe7\xbb\x93\xe6\xb8\x85","last_electricity_usage":18.76,"yearly_electricity_usage":"277","yearly_electricity_charge":"161","update_time":"2022-12-26 14:38:39"},"last_changed":"2022-12-26T06:38:39.509662+00:00","last_updated":"2022-12-26T06:38:39.509662+00:00","context":{"id":"01GN6JF6WN8RAHDX7VA294TAWR","parent_id":null,"user_id":"46fff1899b394ac8b666cabc7c71155a"}}'

大佬能帮我看下吗?我的实体只显示一个上次的金额,其他都不显示,怎么能显示4个属性
回复

使用道具 举报

77

主题

1391

帖子

2万

积分

元老级技术达人

积分
24293
金钱
22862
HASS币
290
发表于 2022-12-26 23:31:56 | 显示全部楼层
本帖最后由 dscao 于 2022-12-27 19:39 编辑
styleyuan 发表于 2022-12-26 14:57
2022-12-26 14:38:39  ---- Homeassistant REST API invoke, POST on http://192.168.31.216:8123/api/stat ...

用的是docker的吧,看一下这里的文档吧:https://hub.docker.com/r/dscao/sgcc_electricity
回复

使用道具 举报

0

主题

29

帖子

207

积分

中级会员

Rank: 3Rank: 3

积分
207
金钱
178
HASS币
0
发表于 2022-12-27 09:10:23 | 显示全部楼层
小白看完一脸懵,我是docker安装的homeassistant,看完也没明白到底怎么操作。。。。
回复

使用道具 举报

3

主题

118

帖子

843

积分

高级会员

Rank: 4

积分
843
金钱
725
HASS币
0
发表于 2022-12-29 11:56:44 | 显示全部楼层
louis_lee 发表于 2022-12-13 00:00
cool,我postman上已经模拟跑通了,但最后没有码下来。主要是国网内部大佬指出,每个省都有一个加盐方式 ...

大佬,我现在提示这个错误,重新编译也没行,在add-on接入
Home Assistant 2022.12.6
Supervisor 2022.12.1
Operating System 9.4
前端版本: 20221213.0 - latest

#20 0x7f5041b1806f clone
2022-12-29 10:23:22  [INFO    ] ---- Webdriver initialized.
2022-12-29 10:23:29  [INFO    ] ---- Login successfully on https://www.95598.cn/osgweb/login
2022-12-29 10:23:31  [INFO    ] ---- get all user id: ['56XXXXXXXX', '56XXXXXXXX', '56XXXXXXXX']
2022-12-29 10:23:34  [INFO    ] ---- Get electricity charge balance for 56XXXXXXXX successfully, balance is 261.74 CNY.
2022-12-29 10:23:36  [INFO    ] ---- Get electricity charge balance for 56XXXXXXXX successfully, balance is 514.66 CNY.
2022-12-29 10:23:37  [INFO    ] ---- Get electricity charge balance for 56XXXXXXXX successfully, balance is 207.43 CNY.
2022-12-29 10:23:40  [INFO    ] ---- Get year power consumption for 56XXXXXXXX successfully, usage is 1151 kwh, yealrly charge is 509.43 CNY
2022-12-29 10:23:41  [INFO    ] ---- Get daily power consumption for 56XXXXXXXX successfully, usage is 2.61 kwh.
2022-12-29 10:24:02  [ERROR   ] ---- state-refresh task failed, reason is Message: no such element: Unable to locate element: {"method":"css selector","selector":".total"}
  (Session info: headless chrome=90.0.4430.212)
Stacktrace:
#0 0x562a938d67f9 <unknown>
#1 0x562a938763b3 <unknown>
#2 0x562a935be016 <unknown>
#3 0x562a935f281e <unknown>
#4 0x562a936288fb <unknown>
#5 0x562a93615ded <unknown>
#6 0x562a936269e1 <unknown>
#7 0x562a93615c93 <unknown>
#8 0x562a935e7ce4 <unknown>
#9 0x562a935e94d2 <unknown>
#10 0x562a938a2542 <unknown>
#11 0x562a938b1ce7 <unknown>
#12 0x562a938b19e4 <unknown>
#13 0x562a938b613a <unknown>
#14 0x562a938b25b9 <unknown>
#15 0x562a93897e00 <unknown>
#16 0x562a938c95d2 <unknown>
#17 0x562a938c9778 <unknown>
#18 0x562a938e1a1f <unknown>
#19 0x7fb4cd83dfa3 start_thread
#20 0x7fb4cca9406f clone
回复

使用道具 举报

3

主题

118

帖子

843

积分

高级会员

Rank: 4

积分
843
金钱
725
HASS币
0
发表于 2022-12-29 11:57:46 | 显示全部楼层
DEEaka 发表于 2022-12-17 21:16
大佬。出错了咋办。户号是我手动处理掉的。
conts.py改过了,还是这样

朋友 ,你的这个问题解决了吗?我现在跟报一样的错误
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-23 09:45 , Processed in 0.118701 second(s), 30 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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