1 Commits
Author SHA1 Message Date
HassBox 45d9570f5e deploy 2024-06-14 21:11:09 +08:00
8 changed files with 443 additions and 473 deletions
@@ -139,6 +139,7 @@ class OptionsFlowHandler(config_entries.OptionsFlow):
else: else:
self.data_client.refresh_interval = int(user_input['refresh_interval']) self.data_client.refresh_interval = int(user_input['refresh_interval'])
self.data_client.is_debug = user_input['is_debug'] self.data_client.is_debug = user_input['is_debug']
await self.data_client.save_data()
return self.async_create_entry( return self.async_create_entry(
title="国家电网", title="国家电网",
data={} data={}
+2 -2
View File
@@ -1,4 +1,4 @@
DOMAIN = 'state_grid' DOMAIN = "state_grid"
PACKAGE_NAME = "custom_components.state_grid" PACKAGE_NAME = "custom_components.state_grid"
VERSION = "0.0.5" VERSION = "0.1.2"
VERSION_STORAGE = 1 VERSION_STORAGE = 1
+239 -215
View File
@@ -1,97 +1,97 @@
_Al='queryYear' _Al='constType'
_Ak='provinceCode' _Ak='queryYear'
_Aj='sceneType' _Aj='provinceCode'
_Ai='consNoSrc' _Ai='access_token'
_Ah='access_token' _Ah='businessType'
_Ag='businessType' _Ag='qrCodeSerial'
_Af='qrCodeSerial' _Af='redirect_url'
_Ae='redirect_url' _Ae='_access_token'
_Ad='_access_token' _Ad='refresh_interval'
_Ac='refresh_interval' _Ac='doorAccountDict'
_Ab='doorAccountDict' _Ab='refreshToken'
_Aa='refreshToken' _Aa='accessToken'
_AZ='accessToken' _AZ='/osg-web0004/member/c24/f01'
_AY='/osg-web0004/member/c24/f01' _AY='BCP_00026'
_AX='BCP_00026' _AX='serviceCode_smt'
_AW='serviceCode_smt' _AW='WEBA10070900'
_AV='WEBA10070900' _AV='serviceType'
_AU='serviceType' _AU='jM_custType'
_AT='jM_custType' _AT='jM_busiTypeCode'
_AS='jM_busiTypeCode' _AS='doorNumberManeger'
_AR='consType' _AR='month'
_AQ='constType' _AQ='consType'
_AP='powerUserList' _AP='userAccountId'
_AO='publicKey' _AO='powerUserList'
_AN='WEBA10070800' _AN='publicKey'
_AM='timeDay' _AM='WEBA10070800'
_AL='WEBA10070700' _AL='timeDay'
_AK='0101143' _AK='WEBA10070700'
_AJ='channelNo' _AJ='channelNo'
_AI='latestBillMonth' _AI='monthBillList'
_AH='yearTotalCost' _AH='yearTotalCost'
_AG='userAccountId' _AG='provinceId'
_AF='0000' _AF='proCode'
_AE='refresh_token' _AE='loginAccount'
_AD='skey' _AD='0000'
_AC='userInfo' _AC='refresh_token'
_AB='0101046' _AB='skey'
_AA='proCode' _AA='userInfo'
_A9='loginAccount' _A9='0101046'
_A8='keyCode' _A8='list'
_A7='querytypeCode' _A7='userName'
_A6='01010049' _A6='acctId'
_A5='doorNumberManeger' _A5='keyCode'
_A4='monthBillList' _A4='querytypeCode'
_A3='accountBalance' _A3='01010049'
_A2='list' _A2='account'
_A1='userName' _A1='account_balance'
_A0='acctId' _A0='resultCode'
_z='resultCode' _z='quInfo'
_y='quInfo' _y='BCP_000026'
_x='BCP_000026' _x='app'
_w='app' _w='WEBALIPAY_01'
_v='WEBALIPAY_01' _v='order'
_u='order' _u='state_grid'
_t='state_grid' _t='latestBillMonth'
_s=False _s='consNo_dst'
_r='authFlag' _r='consNo'
_q='09' _q=True
_p='0101183' _p='authFlag'
_o='stepelect' _o='09'
_n='account' _n='0101183'
_m='consNo_dst' _m='stepelect'
_l='token' _l='daily_bill_list'
_k='0101154' _k='token'
_j='getday' _j=False
_i='consNo' _i='0101154'
_h='bizrt' _h='getday'
_g='clearCache' _g='bizrt'
_f='timestamp' _f='clearCache'
_e='errmsg' _e='orgNo'
_d='promotCode' _d='timestamp'
_c='01' _c='promotCode'
_b='SGAPP' _b='errmsg'
_a='devciceId' _a='01'
_Z='devciceIp' _Z='SGAPP'
_Y='orgNo' _Y='devciceId'
_X='tenant' _X='devciceIp'
_W='member' _W='proNo'
_V='daily_bill_list' _V='tenant'
_U='proNo' _U='member'
_T='promotType' _T='promotType'
_S='target' _S='userId'
_R='userId' _R='target'
_Q='srvrt' _Q='srvrt'
_P='subBusiTypeCode' _P='subBusiTypeCode'
_O='serCat' _O='serialNo'
_N='serialNo' _N='serCat'
_M='0902' _M='srvCode'
_L='srvCode' _L='0902'
_K='uscInfo' _K='uscInfo'
_J=None _J='busiTypeCode'
_I='busiTypeCode' _I='channelCode'
_H='code' _H='code'
_G='channelCode' _G=None
_F='1' _F='1'
_E='source' _E='source'
_D='funcCode' _D='funcCode'
@@ -102,9 +102,9 @@ import json,time,aiohttp,urllib.parse,datetime
from.utils.logger import LOGGER from.utils.logger import LOGGER
from.utils.store import async_save_to_store from.utils.store import async_save_to_store
from.utils.crypt import a,b,c,d,e from.utils.crypt import a,b,c,d,e
configuration={_K:{_U:_L,_X:'',_Y:'',_V:_u},_E:_Z,_R:'32101',_I:_L,_AJ:_L,'toPublish':_a,'siteId':'2012000000033700',_M:'',_O:'',_D:'',_C:{_v:_i,'uploadPic':'0101296','pauseSCode':'0101250','pauseTCode':'0101251','listconsumers':'0101093','messageList':'0101343','submit':'0101003','sbcMsg':'0101210','powercut':'0104514','BkAuth01':'f15','BkAuth02':'f18','BkAuth03':'f02','BkAuth04':'f17','BkAuth05':'f05','BkAuth06':'f16','BkAuth07':'f01','BkAuth08':'f03'},'electricityArchives':{'servicecode':'0104505',_E:_L},'subscriptionList':{_M:'APP_SGPMS_05_030',_O:'22',_I:_L,_D:'22',_R:'-1'},'userInformation':{_C:'01008183',_E:_Z},'userInform':{_C:_n,_E:_Z},'elesum':{_I:_L,_D:_w,_c:_F,_T:_F,_C:'0101143',_E:_x},_A2:{_I:_L,_D:'WEBA1007200'},_AS:{_E:_L,_R:'-1',_I:_o,_AJ:_o,_C:_A3,_D:'WEBA40050000',_K:{_U:_L,_X:'',_Y:'',_V:_u}},'doorAuth':{_E:_Z,_C:'f04'},'xinZ':{_N:'101',_AT:'101','fJ_busiTypeCode':'102',_AU:'03','fJ_custType':'02',_AV:_a,_P:'',_D:_AK,_v:_i,_E:_Z,_A4:_F},'onedo':{_C:_A9,_E:_Z,_D:_AK,'queryType':'03'},'xinHuTongDian':{_N:'110',_J:'211',_P:'21102',_D:'WEBA10071200',_I:_L,_E:_o,_C:_n},'company':{_N:'104',_D:_AK,_AV:'02',_A4:_F,_p:_F,_E:_Z,_v:_i},'charge':{_I:_o,_D:'WEBA10071300',_AJ:'0901',_N:'102',_AU:_a,_AT:'102'},'other':{_I:_o,_D:'WEBA10079700',_N:'129',_J:'999',_P:'21501',_C:_y,_M:'',_O:''},'vatchange':{'submit':'0101003',_J:'320',_P:'',_N:'115',_D:'WEBA10074000',_p:_F},'bill':{_f:_F,_D:_w,_T:_F,_C:_y},_m:{_I:_L,_D:_w,_T:_F,_f:_o,_C:_y,_E:_x},_h:{_I:_L,_f:'11',_D:_w,_c:_F,_T:_F,_C:_y,_E:_x},'mouthOut':{_I:_L,_f:'11',_D:_w,_c:_F,_T:_F,_C:_y,_E:_x},'meter':{_N:'114',_J:'304',_D:'WEBA10071000',_P:'',_C:_A9,_O:''},'complaint':{_J:'005','srvMode':_L,'anonymousFlag':'0','replyMode':_a,'retvisitFlag':_a},'report':{_J:'006'},'tradewinds':{_J:'019'},'somesay':{_J:'091'},'faultrepair':{_D:_AW,_C:_n,_N:'111',_J:'001',_P:'21505'},'electronicInvoice':{_N:'105',_J:'0'},'rename':{_C:_A9,_D:'WEBA10076100',_J:'210',_N:'109',_p:_F,'gh_busiTypeCode':'211','gh_subusi':'21101',_O:'',_M:''},'pause':{_P:'',_C:_A3,_D:'WEBA10073600',_N:'107',_J:'203','jr_busi':'201',_O:'',_M:''},'capacityRecovery':{_C:_A3,_E:_Z,_M:'',_O:'',_D:'WEBA10073700','busiTypeCode_stop':'204','busiTypeCode_less':'202',_J:'202',_P:'',_N:'108',_AL:'5',_p:_F},'electricityPriceChange':{_C:_n,_J:'215',_P:'21502',_N:'113',_p:_F,_AL:'15',_D:'WEBA10073900WEB',_M:'',_O:''},'electricityPriceStrategyChange':{_C:'01008183',_J:'215',_P:'21506',_N:'160',_D:'WEBV00000517WEB',_M:'',_O:''},'eemandValueAdjustment':{_C:_n,_M:'',_O:'',_N:'112',_D:'WEBA10073800',_J:'215',_P:'21504',_p:_F,_AL:'5','getMonthServiceCode':_A9},'businessProgress':{_C:_n,_M:_a,_D:'WEB01'},'increase':{_E:_Z,_O:'',_M:'',_AX:_A3,_C:_i,_v:_i,_D:_AM,_A4:_F,_N:'106',_J:'111',_P:''},'fjincrea':{_N:'105',_J:'110',_P:'',_E:_Z,_D:_AM,_O:'',_M:'',_AX:_A3,_C:_i,_v:_i,_A4:_F},'persIncrea':{_N:'105',_J:'109',_v:_i,_P:'',_E:_Z,_D:_AM,_A4:_F},'fgdChange':{_C:_n,_M:_a,_I:_o,_D:_AW,_J:'215',_P:'21505',_N:'111',_p:_F},'createOrder':{_I:_L,_D:_w,_M:'BCP_000001','chargeMode':'02','conType':_a,'bizTypeId':'BT_ELEC'},'largePopulation':{_J:'383',_D:'WEBA10076800',_P:'',_M:'',_T:'',_c:'',_I:'0901',_N:'383',_C:'',_O:''},'biaoJiCode':{_C:'0104507',_E:'1704',_I:'1704'},'twoGuar':{_J:'402',_P:'40201',_D:'web_twoGuar'},'electTrend':{_C:_AY,_I:_L},'emergency':{_C:_AY,_D:'A10000000',_I:_L},'infoPublic':{_C:'2545454',_E:_x}}
appKey='3def6c365d284881bf1a9b2b502ee68c' appKey='3def6c365d284881bf1a9b2b502ee68c'
appSecret='ab7357dae64944a197ace37398897f64' appSecret='ab7357dae64944a197ace37398897f64'
configuration={_K:{_W:_M,_Z:'',_a:'',_X:_t},_E:_b,_S:'32101',_G:_M,_AJ:_M,'toPublish':_c,'siteId':'2012000000033700',_L:'',_N:'',_D:'',_C:{_u:_k,'uploadPic':'0101296','pauseSCode':'0101250','pauseTCode':'0101251','listconsumers':'0101093','messageList':'0101343','submit':'0101003','sbcMsg':'0101210','powercut':'0104514','BkAuth01':'f15','BkAuth02':'f18','BkAuth03':'f02','BkAuth04':'f17','BkAuth05':'f05','BkAuth06':'f16','BkAuth07':'f01','BkAuth08':'f03'},'electricityArchives':{'servicecode':'0104505',_E:_M},'subscriptionList':{_L:'APP_SGPMS_05_030',_N:'22',_G:_M,_D:'22',_S:'-1'},'userInformation':{_C:'01008183',_E:_b},'userInform':{_C:_p,_E:_b},'elesum':{_G:_M,_D:_v,_d:_F,_T:_F,_C:_AK,_E:_w},_n:{_G:_M,_D:'WEBA1007200'},_A5:{_E:_M,_S:'-1',_G:_q,_AJ:_q,_C:_A6,_D:'WEBA40050000',_K:{_W:_M,_Z:'',_a:'',_X:_t}},'doorAuth':{_E:_b,_C:'f04'},'xinZ':{_O:'101',_AS:'101','fJ_busiTypeCode':'102',_AT:'03','fJ_custType':'02',_AU:_c,_P:'',_D:_AL,_u:_k,_E:_b,_A7:_F},'onedo':{_C:_AB,_E:_b,_D:_AL,'queryType':'03'},'xinHuTongDian':{_O:'110',_I:'211',_P:'21102',_D:'WEBA10071200',_G:_M,_E:_q,_C:_p},'company':{_O:'104',_D:_AL,_AU:'02',_A7:_F,_r:_F,_E:_b,_u:_k},'charge':{_G:_q,_D:'WEBA10071300',_AJ:'0901',_O:'102',_AT:_c,_AS:'102'},'other':{_G:_q,_D:'WEBA10079700',_O:'129',_I:'999',_P:'21501',_C:_x,_L:'',_N:''},'vatchange':{'submit':'0101003',_I:'320',_P:'',_O:'115',_D:'WEBA10074000',_r:_F},'bill':{_g:_F,_D:_v,_T:_F,_C:_x},_o:{_G:_M,_D:_v,_T:_F,_g:_q,_C:_x,_E:_w},_j:{_G:_M,_g:'11',_D:_v,_d:_F,_T:_F,_C:_x,_E:_w},'mouthOut':{_G:_M,_g:'11',_D:_v,_d:_F,_T:_F,_C:_x,_E:_w},'meter':{_O:'114',_I:'304',_D:'WEBA10071000',_P:'',_C:_AB,_N:''},'complaint':{_I:'005','srvMode':_M,'anonymousFlag':'0','replyMode':_c,'retvisitFlag':_c},'report':{_I:'006'},'tradewinds':{_I:'019'},'somesay':{_I:'091'},'faultrepair':{_D:_AV,_C:_p,_O:'111',_I:'001',_P:'21505'},'electronicInvoice':{_O:'105',_I:'0'},'rename':{_C:_AB,_D:'WEBA10076100',_I:'210',_O:'109',_r:_F,'gh_busiTypeCode':'211','gh_subusi':'21101',_N:'',_L:''},'pause':{_P:'',_C:_A6,_D:'WEBA10073600',_O:'107',_I:'203','jr_busi':'201',_N:'',_L:''},'capacityRecovery':{_C:_A6,_E:_b,_L:'',_N:'',_D:'WEBA10073700','busiTypeCode_stop':'204','busiTypeCode_less':'202',_I:'202',_P:'',_O:'108',_AM:'5',_r:_F},'electricityPriceChange':{_C:_p,_I:'215',_P:'21502',_O:'113',_r:_F,_AM:'15',_D:'WEBA10073900WEB',_L:'',_N:''},'electricityPriceStrategyChange':{_C:'01008183',_I:'215',_P:'21506',_O:'160',_D:'WEBV00000517WEB',_L:'',_N:''},'eemandValueAdjustment':{_C:_p,_L:'',_N:'',_O:'112',_D:'WEBA10073800',_I:'215',_P:'21504',_r:_F,_AM:'5','getMonthServiceCode':_AB},'businessProgress':{_C:_p,_L:_c,_D:'WEB01'},'increase':{_E:_b,_N:'',_L:'',_AW:_A6,_C:_k,_u:_k,_D:_AN,_A7:_F,_O:'106',_I:'111',_P:''},'fjincrea':{_O:'105',_I:'110',_P:'',_E:_b,_D:_AN,_N:'',_L:'',_AW:_A6,_C:_k,_u:_k,_A7:_F},'persIncrea':{_O:'105',_I:'109',_u:_k,_P:'',_E:_b,_D:_AN,_A7:_F},'fgdChange':{_C:_p,_L:_c,_G:_q,_D:_AV,_I:'215',_P:'21505',_O:'111',_r:_F},'createOrder':{_G:_M,_D:_v,_L:'BCP_000001','chargeMode':'02','conType':_c,'bizTypeId':'BT_ELEC'},'largePopulation':{_I:'383',_D:'WEBA10076800',_P:'',_L:'',_T:'',_d:'',_G:'0901',_O:'383',_C:'',_N:''},'biaoJiCode':{_C:'0104507',_E:'1704',_G:'1704'},'twoGuar':{_I:'402',_P:'40201',_D:'web_twoGuar'},'electTrend':{_C:_AX,_G:_M},'emergency':{_C:_AX,_D:'A10000000',_G:_M},'infoPublic':{_C:'2545454',_E:_w}}
baseApi='https://www.95598.cn/api' baseApi='https://www.95598.cn/api'
get_request_key_api='/oauth2/outer/c02/f02' get_request_key_api='/oauth2/outer/c02/f02'
get_qr_code_api='/osg-open-uc0001/member/c8/f24' get_qr_code_api='/osg-open-uc0001/member/c8/f24'
@@ -120,51 +120,64 @@ get_door_number_api='/osg-open-uc0001/member/c9/f02'
get_door_balance_api='/osg-open-bc0001/member/c05/f01' get_door_balance_api='/osg-open-bc0001/member/c05/f01'
get_door_bill_api='/osg-open-bc0001/member/c01/f02' get_door_bill_api='/osg-open-bc0001/member/c01/f02'
get_door_ladder_api='/osg-open-bc0001/member/c04/f03' get_door_ladder_api='/osg-open-bc0001/member/c04/f03'
getJiaoFeiRecordApi=_AY getJiaoFeiRecordApi=_AZ
get_door_daily_bill_api=_AY get_door_daily_bill_api=_AZ
sessionIdControlApiList=[get_qr_code_api,get_qr_code_status_api,get_qr_code_token_api,send_code_api,code_login_api] sessionIdControlApiList=[get_qr_code_api,get_qr_code_status_api,get_qr_code_token_api,send_code_api,code_login_api]
keyCodeControlApiList=[get_qr_code_status_api,get_qr_code_token_api,send_code_api,code_login_api,getCertificationApi,get_request_authorize_api,get_web_token_api,refresh_web_token_api,get_door_number_api,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api] keyCodeControlApiList=[get_qr_code_status_api,get_qr_code_token_api,send_code_api,code_login_api,getCertificationApi,get_request_authorize_api,get_web_token_api,refresh_web_token_api,get_door_number_api,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api]
authControlApiList=[get_door_number_api,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api] authControlApiList=[get_door_number_api,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api]
tControlApiList=[getCertificationApi,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api] tControlApiList=[getCertificationApi,get_door_balance_api,get_door_bill_api,get_door_ladder_api,getJiaoFeiRecordApi,get_door_daily_bill_api]
def json_dumps(data):return json.dumps(data,separators=(',',':'),ensure_ascii=_s) def json_dumps(data):return json.dumps(data,separators=(',',':'),ensure_ascii=_j)
def normal_round(num,ndigits=0):
A=ndigits
if A==0:return int(num+.5)
else:B=10**A;return int(num*B+.5)/B
def catchFloat(data,key): def catchFloat(data,key):
if key in data: if key in data:
try:return float(data[key]) try:return normal_round(float(data[key]),2)
except:return 0 except:return 0
else:return 0 else:return 0
class StateGridDataClient: class StateGridDataClient:
hass=_J;session=_J;keyCode=_J;publicKey=_J;need_login=_s;phone=_J;codeKey=_J;serialNo=_J;qrCodeSerial=_J;userInfo=_J;accountInfo=_J;powerUserList=_J;doorAccountDict={};cookie=[];timestamp=int(time.time()*1000);accessToken=_J;refreshToken=_J;token=_J;expirationDate=_J;refresh_interval=12;is_debug=_s hass=_G;session=_G;keyCode=_G;publicKey=_G;need_login=_j;phone=_G;codeKey=_G;serialNo=_G;qrCodeSerial=_G;userInfo=_G;accountInfo=_G;powerUserList=_G;doorAccountDict={};cookie=[];timestamp=int(time.time()*1000);accessToken=_G;refreshToken=_G;token=_G;expirationDate=_G;refresh_interval=6;is_debug=_j
def __init__(A,hass,config=_J): def __init__(A,hass,config=_G):
B=config;A.hass=hass;C=aiohttp.TCPConnector(ssl=_s);D=aiohttp.CookieJar(quote_cookie=True);A.session=aiohttp.ClientSession(cookie_jar=D,connector=C) B=config;A.hass=hass;C=aiohttp.TCPConnector(ssl=_j);D=aiohttp.CookieJar(quote_cookie=_q);A.session=aiohttp.ClientSession(cookie_jar=D,connector=C)
if B is not _J: if B is not _G:
try:A.keyCode=B[_A8];A.publicKey=B[_AO];A.accessToken=B[_AZ];A.refreshToken=B[_Aa];A.token=B[_l];A.userInfo=B[_AC];A.powerUserList=B[_AP];A.doorAccountDict=B[_Ab];A.refresh_interval=B[_Ac];A.is_debug=B['is_debug'] try:A.keyCode=B[_A5];A.publicKey=B[_AN];A.accessToken=B[_Aa];A.refreshToken=B[_Ab];A.token=B[_k];A.userInfo=B[_AA];A.powerUserList=B[_AO];A.doorAccountDict=B[_Ac];A.refresh_interval=B[_Ad];A.is_debug=B['is_debug']
except Exception as E:LOGGER.error(E) except Exception as E:LOGGER.error(E)
async def save_data(A):B={};B[_A8]=A.keyCode;B[_AO]=A.publicKey;B[_AZ]=A.accessToken;B[_Aa]=A.refreshToken;B[_l]=A.token;B[_AC]=A.userInfo;B[_AP]=A.powerUserList;B[_Ab]=A.doorAccountDict;B[_Ac]=A.refresh_interval;B['is_debug']=A.is_debug;await async_save_to_store(A.hass,'state_grid.config',B) async def save_data(A):B={};B[_A5]=A.keyCode;B[_AN]=A.publicKey;B[_Aa]=A.accessToken;B[_Ab]=A.refreshToken;B[_k]=A.token;B[_AA]=A.userInfo;B[_AO]=A.powerUserList;B[_Ac]=A.doorAccountDict;B[_Ad]=A.refresh_interval;B['is_debug']=A.is_debug;await async_save_to_store(A.hass,'state_grid.config',B)
def encrypt_post_data(A,data):B={_Ad:A.accessToken[len(A.accessToken)//2:]if A.accessToken else'','_t':A.token[len(A.token)//2:]if A.token else'','_data':data,_f:A.timestamp};return A.encrypt_wapper_data(B) def encrypt_post_data(A,data):B={_Ae:A.accessToken[len(A.accessToken)//2:]if A.accessToken else'','_t':A.token[len(A.token)//2:]if A.token else'','_data':data,_d:A.timestamp};return A.encrypt_wapper_data(B)
def encrypt_wapper_data(A,data):B=a(json_dumps(data),A.keyCode);return{_A:B+c(B+str(A.timestamp)),_AD:d(A.keyCode,A.publicKey),_f:str(A.timestamp)} def encrypt_wapper_data(A,data):B=a(json_dumps(data),A.keyCode);return{_A:B+c(B+str(A.timestamp)),_AB:d(A.keyCode,A.publicKey),_d:str(A.timestamp)}
def handle_request_result_message(E,api,result): def handle_request_result_message(E,api,result):
D='message';C='resultMessage';A=result;B=_J D='message';C='resultMessage';A=result;B=_G
if _A in A and _Q in A[_A]and C in A[_A][_Q]:B=A[_A][_Q][C] if _A in A and _Q in A[_A]and C in A[_A][_Q]:B=A[_A][_Q][C]
elif _Q in A and C in A[_Q]:B=A[_Q][C] elif _Q in A and C in A[_Q]:B=A[_Q][C]
elif D in A:B=A[D] elif D in A:B=A[D]
else:B=json_dumps(A) else:B=json_dumps(A)
if E.is_debug:LOGGER.error(api+': '+B);LOGGER.error(json_dumps(A)) if E.is_debug:LOGGER.error(api+': '+B);LOGGER.error(json_dumps(A))
return B return B
async def fetch(B,api,data,header=_J): async def __fetch_safe(C,api,data):
B=await C.__fetch(api,data)
if _H not in B:return B
A=B[_H]
if 10015==A or 10108==A or 10009==A or 10207==A or 10005==A or 10010==A or 30010==A or 10002==A:
await C.__refresh_token()
if C.need_login is _q:return B
else:return await C.__fetch(api,data)
else:return B
async def __fetch(B,api,data,header=_G):
T='encryptData';S='464606a4-184c-4beb-b442-2ab7761d0796';R='key_code';Q='state';P='sign';O='grant_type';N='application/json;charset=UTF-8';M='Content-Type';L=header;K='client_secret';I='client_id';E=api;B.timestamp=int(time.time()*1000);D=B.timestamp T='encryptData';S='464606a4-184c-4beb-b442-2ab7761d0796';R='key_code';Q='state';P='sign';O='grant_type';N='application/json;charset=UTF-8';M='Content-Type';L=header;K='client_secret';I='client_id';E=api;B.timestamp=int(time.time()*1000);D=B.timestamp
if B.keyCode is _J:B.keyCode=e(32,16,2) if B.keyCode is _G:B.keyCode=e(32,16,2)
F=B.keyCode;G={'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.36','Accept':N,M:N,'version':'1.0',_E:'0901',_f:str(D),'wsgwType':'web','appKey':appKey};A=data F=B.keyCode;G={'User-Agent':'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Mobile Safari/537.36','Accept':N,M:N,'version':'1.0',_E:'0901',_d:str(D),'wsgwType':'web','appKey':appKey};A=data
if E==get_request_key_api:A={I:appKey,K:appSecret};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AD:d(F,'042BC7AD510BF9793B7744C8854C56A8C95DD1027EE619247A332EC6ED5B279F435A23D62441FE861F4B0C963347ECD5792F380B64CA084BE8BE41151F8B8D19C8'),I:appKey,_f:str(D)} if E==get_request_key_api:A={I:appKey,K:appSecret};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AB:d(F,'042BC7AD510BF9793B7744C8854C56A8C95DD1027EE619247A332EC6ED5B279F435A23D62441FE861F4B0C963347ECD5792F380B64CA084BE8BE41151F8B8D19C8'),I:appKey,_d:str(D)}
elif E==get_qr_code_api:A={_Ad:'','_t':'','_data':A,_f:D} elif E==get_qr_code_api:A={_Ae:'','_t':'','_data':A,_d:D}
elif E==get_request_authorize_api: elif E==get_request_authorize_api:
A={I:appKey,'response_type':_H,_Ae:'/test',_f:D,'rsi':B.token};A=urllib.parse.urlencode(A);G[M]='application/x-www-form-urlencoded; charset=UTF-8';G[_A8]=F A={I:appKey,'response_type':_H,_Af:'/test',_d:D,'rsi':B.token};A=urllib.parse.urlencode(A);G[M]='application/x-www-form-urlencoded; charset=UTF-8';G[_A5]=F
async with B.session.post(baseApi+E,data=A,headers=G)as J:B.session.cookie_jar.update_cookies(J.cookies);C=await J.json();C=b(C[_A],B.token);C=json.loads(C);return C async with B.session.post(baseApi+E,data=A,headers=G)as J:B.session.cookie_jar.update_cookies(J.cookies);C=await J.json();C=b(C[_A],B.token);C=json.loads(C);return C
elif E==get_web_token_api:A={O:'authorization_code',P:c(appKey+str(D)),K:appSecret,Q:S,R:F,I:appKey,_f:D,_H:A[_H]};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AD:d(F,B.publicKey),_f:str(D)} elif E==get_web_token_api:A={O:'authorization_code',P:c(appKey+str(D)),K:appSecret,Q:S,R:F,I:appKey,_d:D,_H:A[_H]};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AB:d(F,B.publicKey),_d:str(D)}
elif E==refresh_web_token_api:A={O:_AE,P:c(appKey+str(D)),K:appSecret,Q:S,R:F,I:appKey,_f:D,_AE:B.refreshToken};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AD:d(F,B.publicKey),_f:str(D)};E=get_web_token_api elif E==refresh_web_token_api:A={O:_AC,P:c(appKey+str(D)),K:appSecret,Q:S,R:F,I:appKey,_d:D,_AC:B.refreshToken};H=a(json_dumps(A),F);A={_A:H+c(H+str(D)),_AB:d(F,B.publicKey),_d:str(D)};E=get_web_token_api
else:A=B.encrypt_post_data(A) else:A=B.encrypt_post_data(A)
if L is not _J:G.update(L) if L is not _G:G.update(L)
if E in sessionIdControlApiList:G['sessionId']='web'+str(D) if E in sessionIdControlApiList:G['sessionId']='web'+str(D)
if E in keyCodeControlApiList:G[_A8]=F if E in keyCodeControlApiList:G[_A5]=F
if E in authControlApiList:G['Authorization']='Bearer '+B.accessToken[:len(B.accessToken)//2] if E in authControlApiList:G['Authorization']='Bearer '+B.accessToken[:len(B.accessToken)//2]
if E in tControlApiList:G['t']=B.token[:len(B.token)//2] if E in tControlApiList:G['t']=B.token[:len(B.token)//2]
async with B.session.post(baseApi+E,json=A,headers=G)as J: async with B.session.post(baseApi+E,json=A,headers=G)as J:
@@ -174,72 +187,74 @@ class StateGridDataClient:
if T in C:C=b(C[T],F);C=json.loads(C) if T in C:C=b(C[T],F);C=json.loads(C)
return C return C
async def __get_request_key(A): async def __get_request_key(A):
A.keyCode=_J;B=await A.fetch(get_request_key_api,{});C=A.handle_request_result_message('get_request_key_api',B) A.keyCode=_G;B=await A.__fetch(get_request_key_api,{});C=A.handle_request_result_message('get_request_key_api',B)
if B[_H]==_F:A.keyCode=B[_A][_A8];A.publicKey=B[_A][_AO];return{_B:0} if B[_H]==_F:A.keyCode=B[_A][_A5];A.publicKey=B[_A][_AN];return{_B:0}
return{_B:1,_e:C} return{_B:1,_b:C}
async def __get_qr_code(B): async def __get_qr_code(B):
C={_K:{_Z:'',_X:_t,_W:_M,_a:''},_y:{'optType':_c,_N:e(28,10,1)}};A=await B.fetch(get_qr_code_api,C);D=B.handle_request_result_message('get_qr_code_api',A) C={_K:{_X:'',_V:_u,_U:_L,_Y:''},_z:{'optType':_a,_O:e(28,10,1)}};A=await B.__fetch(get_qr_code_api,C);D=B.handle_request_result_message('get_qr_code_api',A)
if A[_H]==1: if A[_H]==1:
if A[_A]and A[_A][_Q]and A[_A][_Q][_z]==_AF:B.qrCodeSerial=A[_A][_h][_Af];E=A[_A][_h]['qrCode'];return{_B:0,_A:E} if A[_A]and A[_A][_Q]and A[_A][_Q][_A0]==_AD:B.qrCodeSerial=A[_A][_g][_Ag];E=A[_A][_g]['qrCode'];return{_B:0,_A:E}
return{_B:1,_e:D} return{_B:1,_b:D}
async def __get_qr_code_status(B): async def __get_qr_code_status(B):
C={_h:{_Af:B.qrCodeSerial}};D={_l:'98'+e(10,10,1)};A=await B.fetch(get_qr_code_status_api,C,D);E=B.handle_request_result_message('get_qr_code_status_api',A) C={_g:{_Ag:B.qrCodeSerial}};D={_k:'98'+e(10,10,1)};A=await B.__fetch(get_qr_code_status_api,C,D);E=B.handle_request_result_message('get_qr_code_status_api',A)
if _H in A and A[_H]==1: if _H in A and A[_H]==1:
if _A in A and A[_A]!='null':B.token=A[_A];return{_B:0} if _A in A and A[_A]!='null':B.token=A[_A];return{_B:0}
else:return{_B:1,_e:'未使用网上国网 App 扫码或确认登录'} else:return{_B:1,_b:'未使用网上国网 App 扫码或确认登录'}
return{_B:1,_e:E} return{_B:1,_b:E}
async def __get_qr_code_token(B): async def __get_qr_code_token(B):
C={_K:{_X:_t,_W:_M,'isEncrypt':True},_l:B.token};A=await B.fetch(get_qr_code_token_api,C);D=B.handle_request_result_message('get_qr_code_token_api',A) C={_K:{_V:_u,_U:_L,'isEncrypt':_q},_k:B.token};A=await B.__fetch(get_qr_code_token_api,C);D=B.handle_request_result_message('get_qr_code_token_api',A)
if _Q in A and _z in A[_Q]and A[_Q][_z]==_AF:B.userInfo=A[_h][_AC];return{_B:0} if _Q in A and _A0 in A[_Q]and A[_Q][_A0]==_AD:B.userInfo=A[_g][_AA];return{_B:0}
return{_B:1,_e:D} return{_B:1,_b:D}
async def __send_code(B,phone): async def __send_code(B,phone):
C=phone;B.phone=C;D={_K:{_Z:'',_X:_t,_W:_M,_a:''},_y:{'sendType':'0',_n:C,_Ag:'login','accountType':''},'Channels':'web'};A=await B.fetch(send_code_api,D);E=B.handle_request_result_message('send_code_api',A) C=phone;B.phone=C;D={_K:{_X:'',_V:_u,_U:_L,_Y:''},_z:{'sendType':'0',_A2:C,_Ah:'login','accountType':''},'Channels':'web'};A=await B.__fetch(send_code_api,D);E=B.handle_request_result_message('send_code_api',A)
if A[_H]==1: if A[_H]==1:
if A[_A]and A[_A][_Q]and A[_A][_Q][_z]==_AF:B.codeKey=A[_A][_h]['codeKey'];return{_B:0} if A[_A]and A[_A][_Q]and A[_A][_Q][_A0]==_AD:B.codeKey=A[_A][_g]['codeKey'];return{_B:0}
return{_B:1,_e:E} return{_B:1,_b:E}
async def __verfiy_code(A,code): async def __verfiy_code(A,code):
C={_K:{_Z:'',_X:_t,_W:_M,_a:''},_y:{_n:A.phone,_Ag:'login',_H:code,'optSys':'ios','pushId':'00000','codeKey':A.codeKey},'Channels':'web'};B=await A.fetch(code_login_api,C);D=A.handle_request_result_message('code_login_api',B) C={_K:{_X:'',_V:_u,_U:_L,_Y:''},_z:{_A2:A.phone,_Ah:'login',_H:code,'optSys':'ios','pushId':'00000','codeKey':A.codeKey},'Channels':'web'};B=await A.__fetch(code_login_api,C);D=A.handle_request_result_message('code_login_api',B)
if _Q in B and _z in B[_Q]and B[_Q][_z]==_AF:A.token=B[_h][_l];A.userInfo=B[_h][_AC][0];return{_B:0} if _Q in B and _A0 in B[_Q]and B[_Q][_A0]==_AD:A.token=B[_g][_k];A.userInfo=B[_g][_AA][0];return{_B:0}
return{_B:1,_e:D} return{_B:1,_b:D}
async def __get_request_authorize(B): async def __get_request_authorize(B):
A=await B.fetch(get_request_authorize_api,{});E=B.handle_request_result_message('get_request_authorize_api',A) A=await B.__fetch(get_request_authorize_api,{});E=B.handle_request_result_message('get_request_authorize_api',A)
if _H in A and A[_H]==_F:C=A[_A][_Ae];D=C.rfind('code=');B.authorizeCode=C[D+5:D+5+32];return{_B:0} if _H in A and A[_H]==_F:C=A[_A][_Af];D=C.rfind('code=');B.authorizeCode=C[D+5:D+5+32];return{_B:0}
return{_B:1,_e:E} return{_B:1,_b:E}
async def __get_web_token(A): async def __get_web_token(A):
C={_H:A.authorizeCode};B=await A.fetch(get_web_token_api,C);D=A.handle_request_result_message('get_web_token_api',B) C={_H:A.authorizeCode};B=await A.__fetch(get_web_token_api,C);D=A.handle_request_result_message('get_web_token_api',B)
if _H in B and B[_H]==_F:A.accessToken=B[_A][_Ah];A.refreshToken=B[_A][_AE];return{_B:0} if _H in B and B[_H]==_F:A.accessToken=B[_A][_Ai];A.refreshToken=B[_A][_AC];return{_B:0}
return{_B:1,_e:D} return{_B:1,_b:D}
async def __refresh_web_token(B): async def __refresh_web_token(B):
A=await B.fetch(refresh_web_token_api,{});C=B.handle_request_result_message('refresh_web_token_api',A) A=await B.__fetch(refresh_web_token_api,{});C=B.handle_request_result_message('refresh_web_token_api',A)
if _H in A and A[_H]==_F:B.accessToken=A[_A][_Ah];B.refreshToken=A[_A][_AE];return{_B:0} if _H in A and A[_H]==_F:B.accessToken=A[_A][_Ai];B.refreshToken=A[_A][_AC];return{_B:0}
return{_B:1,_e:C} return{_B:1,_b:C}
async def __get_door_number(B): async def __get_door_number(C):
C={_C:configuration[_C],_E:configuration[_E],_S:configuration[_S],_K:{_W:configuration[_A5][_K][_W],_Z:configuration[_A5][_K][_Z],_a:configuration[_A5][_K][_a],_X:configuration[_A5][_K][_X]},_y:{_R:B.userInfo[_R]},_l:B.token};A=await B.fetch(get_door_number_api,C);D=B.handle_request_result_message('get_door_number_api',A) A=configuration[_AS];D={_C:A[_C],_E:A[_E],_R:A[_R],_K:{_U:A[_K][_U],_X:A[_K][_X],_Y:A[_K][_Y],_V:A[_K][_V]},_z:{_S:C.userInfo[_S]},_k:C.token};B=await C.__fetch_safe(get_door_number_api,D);E=C.handle_request_result_message('get_door_number_api',B)
if _H in A and A[_H]==1 and _A in A and _h in A[_A]:B.powerUserList=A[_A][_h][_AP];return{_B:0} if _H in B and B[_H]==1 and _A in B and _g in B[_A]:C.powerUserList=B[_A][_g][_AO];return{_B:0}
return{_B:1,_e:D} return{_B:1,_b:E}
async def __get_door_balance(C,door_account): async def __get_door_balance(B,door_account):
A=door_account;E={_A:{_L:'',_N:'',_G:configuration[_n][_G],_D:configuration[_n][_D],_A0:C.userInfo[_R],_A1:C.userInfo[_A9],_T:_F,_d:_F,_AG:C.userInfo[_R],_A2:[{_Ai:A[_m],_AA:A[_U],_Aj:A[_AQ],_i:A[_i],_Y:A[_Y]}]},_C:_AK,_E:configuration[_E],_S:A[_U]};B=await C.fetch(get_door_balance_api,E);C.handle_request_result_message('get_door_balance_api',B) A=door_account;E={_A:{_M:'',_O:'',_I:configuration[_A2][_I],_D:configuration[_A2][_D],_A6:B.userInfo[_S],_A7:B.userInfo.get(_AE,B.userInfo.get('nickname',_G)),_T:_F,_c:_F,_AP:B.userInfo[_S],_A8:[{'consNoSrc':A[_s],_AF:A.get(_W,A.get(_AG,_G)),'sceneType':A.get('consSortCode',A.get('elecTypeCode',_G)),_r:A[_r],_e:A[_e]}]},_C:'0101143',_E:configuration[_E],_R:A.get(_W,A.get(_AG,_G))};C=await B.__fetch_safe(get_door_balance_api,E);B.handle_request_result_message('get_door_balance_api',C)
if _H in B and B[_H]==1 and _A in B and _A2 in B[_A]: if _H in C and C[_H]==1 and _A in C and _A8 in C[_A]:
D=B[_A][_A2] D=C[_A][_A8]
if len(D)!=0:A[_A3]=D[0] if len(D)!=0:A[_A1]=D[0]
async def __get_door_bill(C,door_account,year): async def __get_door_bill(C,door_account,year):
F='dataInfo';D='mothEleList';A=door_account;E={_A:{_L:'',_N:'',_G:configuration[_n][_G],_D:configuration[_n][_D],_A0:C.userInfo[_R],_A1:C.userInfo[_A9],_T:_F,_d:_F,_AG:C.userInfo[_R],_A2:[{_Ai:A[_m],_AA:A[_U],_Aj:A['consSortCode'],_i:A[_i],_Y:A[_Y]}]},_C:_AK,_E:configuration[_E],_S:A[_U]};E={_A:{_A0:C.userInfo[_R],_G:configuration[_G],_g:'11',_AR:A[_AQ],_D:'ALIPAY_01',_Y:A[_Y],_AA:A[_U],_d:_F,_T:_F,_N:'',_L:'',_A1:'',_Ak:A[_U],_AG:C.userInfo[_R],_i:A[_i],_Al:year},_C:_x,_E:_w,_S:A[_U]};B=await C.fetch(get_door_bill_api,E);C.handle_request_result_message('get_door_bill_api',B) E='dataInfo';D='mothEleList';B=door_account;F={_A:{_A6:C.userInfo[_S],_I:configuration[_I],_f:'11',_AQ:B[_Al],_D:'ALIPAY_01',_e:B[_e],_AF:B[_W],_c:_F,_T:_F,_O:'',_M:'',_A7:'',_Aj:B[_W],_AP:C.userInfo[_S],_r:B[_r],_Ak:year},_C:_y,_E:_x,_R:B[_W]};A=await C.__fetch_safe(get_door_bill_api,F);C.handle_request_result_message('get_door_bill_api',A)
if _H in B and B[_H]==1 and _A in B: if _H in A and A[_H]==1 and _A in A:
if F in B[_A]:A[_AH]=B[_A][F] if E in A[_A]:B[_AH]=A[_A][E]
if D in B[_A]:A[_A4]=B[_A][D];A[_AI]=B[_A][D][-1]['month'] if D in A[_A]:
B[_AI]=A[_A][D]
if len(A[_A][D])!=0:B[_t]=A[_A][D][-1]
async def __get_door_ladder(B,door_account,month): async def __get_door_ladder(B,door_account,month):
F='ladder_flag';E=month;A=door_account;G=A[_m];H={_A:{_G:configuration[_o][_G],_D:configuration[_o][_D],_T:configuration[_o][_T],_g:configuration[_o][_g],_i:A[_m],_d:A[_U],_Y:A[_Y],'queryDate':E,_Ak:A[_U],_AR:A[_AQ],_AG:B.userInfo[_R],_N:'',_L:'',_A1:B.userInfo[_A9],_A0:B.userInfo[_R]},_C:configuration[_o][_C],_E:configuration[_o][_E],_S:A[_U]};C=await B.fetch(get_door_ladder_api,H);I=B.handle_request_result_message('get_door_ladder_api',C) F='ladder_flag';E=month;A=door_account;G=A[_s];H={_A:{_I:configuration[_m][_I],_D:configuration[_m][_D],_T:configuration[_m][_T],_f:configuration[_m][_f],_r:A[_s],_c:A[_W],_e:A[_e],'queryDate':E,_Aj:A[_W],_AQ:A[_Al],_AP:B.userInfo[_S],_O:'',_M:'',_A7:B.userInfo[_AE],_A6:B.userInfo[_S]},_C:configuration[_m][_C],_E:configuration[_m][_E],_R:A[_W]};C=await B.__fetch(get_door_ladder_api,H);I=B.handle_request_result_message('get_door_ladder_api',C)
if _H in C and C[_H]==1 and _A in C and _A2 in C[_A]: if _H in C and C[_H]==1 and _A in C and _A8 in C[_A]:
D=C[_A][_A2] D=C[_A][_A8]
if len(D)!=0: if len(D)!=0:
D=D[0];D['month']=E D=D[0];D[_AR]=E
if D['electricParticulars']['levelFlag']=='2':A[F]=1 if D['electricParticulars']['levelFlag']=='2':A[F]=1
else:A[F]=0 else:A[F]=0
B.doorAccountDict[G]['ladder']=D B.doorAccountDict[G]['ladder']=D
async def __get_door_daily_bill(A,door_account,year,start_date,end_date): async def __get_door_daily_bill(B,door_account,year,start_date,end_date):
D='sevenEleList';C=door_account;E={'params1':{_C:configuration[_C],_E:configuration[_E],_S:configuration[_S],_K:{_W:configuration[_K][_W],_Z:configuration[_K][_Z],_a:configuration[_K][_a],_X:configuration[_K][_X]},_y:{_R:A.userInfo[_R]},_l:A.token},'params3':{_A:{_A0:A.userInfo[_R],_i:C[_m],_AR:_c,'endTime':end_date,_Y:C[_Y],_Al:year,_AA:C[_U],_N:'',_L:'','startTime':start_date,_A1:A.userInfo[_A9],_D:configuration[_j][_D],_G:configuration[_j][_G],_g:configuration[_j][_g],_d:configuration[_j][_d],_T:configuration[_j][_T]},_C:configuration[_j][_C],_E:configuration[_j][_E],_S:C[_U]},'params4':'010103'};B=await A.fetch(get_door_daily_bill_api,E);F=A.handle_request_result_message('get_door_daily_bill_api',B) D='sevenEleList';A=door_account;E={'params1':{_C:configuration[_C],_E:configuration[_E],_R:configuration[_R],_K:{_U:configuration[_K][_U],_X:configuration[_K][_X],_Y:configuration[_K][_Y],_V:configuration[_K][_V]},_z:{_S:B.userInfo[_S]},_k:B.token},'params3':{_A:{_A6:B.userInfo[_S],_r:A[_s],_AQ:_a,'endTime':end_date,_e:A[_e],_Ak:year,_AF:A.get(_W,A.get(_AG,_G)),_O:'',_M:'','startTime':start_date,_A7:B.userInfo[_AE],_D:configuration[_h][_D],_I:configuration[_h][_I],_f:configuration[_h][_f],_c:configuration[_h][_c],_T:configuration[_h][_T]},_C:configuration[_h][_C],_E:configuration[_h][_E],_R:A.get(_W,A.get(_AG,_G))},'params4':'010103'};C=await B.__fetch_safe(get_door_daily_bill_api,E);F=B.handle_request_result_message('get_door_daily_bill_api',C)
if _H in B and B[_H]==1 and _A in B and D in B[_A]:C[_V]=B[_A][D] if _H in C and C[_H]==1 and _A in C and D in C[_A]:A[_l]=C[_A][D]
async def __get_door_pay_record(A,door_account):B=door_account;D=B[_m];C={'params1':{_C:configuration[_C],_E:configuration[_E],_S:configuration[_S],_K:{_W:configuration[_K][_W],_Z:configuration[_K][_Z],_a:configuration[_K][_a],_X:configuration[_K][_X]},_y:{_R:A.userInfo[_R]},_l:A.token},'params3':{_A:{_A0:A.userInfo[_R],'bgnPayDate':'2023-04-24',_G:configuration[_G],_i:B[_m],'endPayDate':'2024-04-24',_D:'webALIPAY_01','number':100,_Y:B[_Y],'page':_F,_AA:B[_U],_d:_F,_T:_F,_N:'',_L:'',_A1:A.userInfo[_A9]},_C:'0101051',_E:_c,_S:B[_U]},'params4':'010104'};E=await A.fetch(getJiaoFeiRecordApi,C) async def __get_door_pay_record(A,door_account):B=door_account;D=B[_s];C={'params1':{_C:configuration[_C],_E:configuration[_E],_R:configuration[_R],_K:{_U:configuration[_K][_U],_X:configuration[_K][_X],_Y:configuration[_K][_Y],_V:configuration[_K][_V]},_z:{_S:A.userInfo[_S]},_k:A.token},'params3':{_A:{_A6:A.userInfo[_S],'bgnPayDate':'2023-04-24',_I:configuration[_I],_r:B[_s],'endPayDate':'2024-04-24',_D:'webALIPAY_01','number':100,_e:B[_e],'page':_F,_AF:B[_W],_c:_F,_T:_F,_O:'',_M:'',_A7:A.userInfo[_AE]},_C:'0101051',_E:_a,_R:B[_W]},'params4':'010104'};E=await A.__fetch(getJiaoFeiRecordApi,C)
async def get_qr_code(B): async def get_qr_code(B):
A=await B.__get_request_key() A=await B.__get_request_key()
if _B in A and A[_B]!=0:return A if _B in A and A[_B]!=0:return A
@@ -267,65 +282,74 @@ class StateGridDataClient:
if _B in A and A[_B]!=0:return A if _B in A and A[_B]!=0:return A
A=await B.__get_door_number() A=await B.__get_door_number()
if _B in A and A[_B]!=0:return A if _B in A and A[_B]!=0:return A
B.need_login=_s;await B.save_data();return{_B:0,_A:B.powerUserList} B.need_login=_j;await B.save_data();return{_B:0,_A:B.powerUserList}
async def refresh_data(B,setup=_s): async def __refresh_token(A):
n='daily_t_ele_num';m='daily_n_ele_num';l='daily_v_ele_num';k='daily_p_ele_num';j='daily_ele_num';i='last_month_ele_cost';h='last_month_ele_num';g='year_ele_cost';f='year_ele_num';e='monthEleNum';d='thisTPq';c='thisNPq';b='thisVPq';a='thisPPq';R='ladder_level_num';Q='ladder_level';L='balance';K='%Y%m%d';J='day';H='dayElePq' B=await A.__get_request_key()
if B.need_login is True:LOGGER.error('国家电网需要重新登录!');return if _B in B and B[_B]!=0:return
o=setup or int(time.time()*1000)-B.timestamp>B.refresh_interval*3600*1000 B=await A.__refresh_web_token()
if o is _s:return if _B in B and B[_B]==0:A.need_login=_j;await A.save_data()
D=await B.__get_door_number() else:A.need_login=_q;LOGGER.error('国家电网刷新 Token 失败')
if _B in D and D[_B]!=0: async def refresh_data(C,setup=_j):
LOGGER.warning('刷新 Token');D=await B.__get_request_key() l='last_month_ele_cost';k='monthEleNum';j='year_ele_cost';i='thisTPq';h='thisNPq';g='thisVPq';f='thisPPq';e='refresh_time';U=setup;T='ladder_level_num';S='ladder_level';R='last_month_ele_num';Q='year_ele_num';L='%Y%m%d';K='day';I='dayElePq';H='balance'
if _B in D and D[_B]!=0:return if U is _q:
D=await B.__refresh_web_token() V=await C.__get_door_number()
if _B in D and D[_B]==0:await B.save_data() if _B in V and V[_B]!=0:C.need_login=_q
else:B.need_login=True;LOGGER.error('刷新 Token 失败');return if C.need_login is _q:
D=await B.__get_door_number() if C.powerUserList is not _G:
if _B in D and D[_B]!=0:B.need_login=True;LOGGER.error('重新请求失败');return for A in C.get_door_account_list():A[e]='刷新 Token 失败,需重新登录!'
M=datetime.datetime.now();I=M-datetime.timedelta(days=1);p=f"{I.year}-{I.month:02d}-{I.day:02d}";N=I-datetime.timedelta(days=40);q=f"{N.year}-{N.month:02d}-{N.day:02d}" LOGGER.error('国家电网需要重新登录!');return
for A in B.powerUserList: m=U or int(time.time()*1000)-C.timestamp>C.refresh_interval*3600*1000
r=A[_m];B.doorAccountDict[r]=A;await B.__get_door_balance(A);await B.__get_door_daily_bill(A,M.year,q,p);O=A[_V][0] if m is _j:return
try:float(O[H]) M=datetime.datetime.now();J=M-datetime.timedelta(days=1);n=f"{J.year}-{J.month:02d}-{J.day:02d}";N=J-datetime.timedelta(days=40);o=f"{N.year}-{N.month:02d}-{N.day:02d}"
except:A[_V].pop(0) for A in C.powerUserList:
O=A[_V][0];E=datetime.datetime.strptime(O[J],K);S=0;T=0;U=0;V=0;W=0 p=A[_s];C.doorAccountDict[p]=A;await C.__get_door_balance(A)
for C in A[_V]: if _A1 in A:
G=datetime.datetime.strptime(C[J],K) q=catchFloat(A[_A1],'estiAmt');W=catchFloat(A[_A1],'prepayBal');r=catchFloat(A[_A1],'sumMoney')
if W==0:A[H]=r
else:A[H]=W-q
X=catchFloat(A[_A1],'historyOwe')
if X>0:A[H]=-X
else:LOGGER.error('国家电网账户余额获取失败!')
if H not in A:A[H]=0
await C.__get_door_daily_bill(A,M.year,o,n)
if _l not in A:LOGGER.error('国家电网无法获取日用电数据!');return
O=0
for Y in range(10):
D=A[_l][Y]
try:float(D[I]);break
except:O=O+1
for Y in range(O):A[_l].pop(0)
D=A[_l][0];E=datetime.datetime.strptime(D[K],L);A['daily_ele_num']=catchFloat(D,I);A['daily_p_ele_num']=catchFloat(D,f);A['daily_v_ele_num']=catchFloat(D,g);A['daily_n_ele_num']=catchFloat(D,h);A['daily_t_ele_num']=catchFloat(D,i);Z=0;a=0;b=0;c=0;d=0
for B in A[_l]:
G=datetime.datetime.strptime(B[K],L)
if G.month!=E.month:break if G.month!=E.month:break
S+=catchFloat(C,H);T+=catchFloat(C,a);U+=catchFloat(C,b);V+=catchFloat(C,c);W+=catchFloat(C,d) Z+=catchFloat(B,I);a+=catchFloat(B,f);b+=catchFloat(B,g);c+=catchFloat(B,h);d+=catchFloat(B,i)
P=E-datetime.timedelta(days=E.day);X=f"{P.year}-{P.month:02d}" A['month_ele_num']=normal_round(Z,2);A['month_p_ele_num']=normal_round(a,2);A['month_v_ele_num']=normal_round(b,2);A['month_n_ele_num']=normal_round(c,2);A['month_t_ele_num']=normal_round(d,2);P=E-datetime.timedelta(days=E.day);s=f"{P.year}-{P.month:02d}"
if _AI not in A or A[_AI]!=X:await B.__get_door_bill(A,P.year);await B.__get_door_ladder(A,X) if _t not in A or A[_t][_AR]!=s:await C.__get_door_bill(A,P.year)
s=datetime.datetime.strptime(A[_AI],'%Y%m') if _t not in A:LOGGER.error('国家电网无法获取年度用电数据!');return
if s.month==12: if _AH in A:A[Q]=catchFloat(A[_AH],'totalEleNum');A[j]=catchFloat(A[_AH],'totalEleCost')
if Q not in A:A[Q]=0;A[j]=0
if _AI in A:A[R]=catchFloat(A[_t],k);A[l]=catchFloat(A[_t],'monthEleCost')
if R not in A:A[R]=0;A[l]=0
t=datetime.datetime.strptime(A[_t][_AR],'%Y%m')
if t.month==12:
F=0 F=0
for C in A[_V]: for B in A[_l]:
G=datetime.datetime.strptime(C[J],K) G=datetime.datetime.strptime(B[K],L)
if G.month!=12:break if G.month!=12:break
F+=catchFloat(C,H) F+=catchFloat(B,I)
else: else:
F=0 F=0
for C in A[_A4]:F+=catchFloat(C,e) for B in A[_AI]:F+=catchFloat(B,k)
t=len(A[_A4]) u=len(A[_AI])
for C in A[_V]: for B in A[_l]:
G=datetime.datetime.strptime(C[J],K) G=datetime.datetime.strptime(B[K],L)
if G.month<=t:break if G.month<=u:break
F+=catchFloat(C,H) F+=catchFloat(B,I)
if F<=2760:A[Q]='第一阶梯';A[R]=1 if F<=2760:A[S]='第一阶梯';A[T]=1
elif F<=4800:A[Q]='第二阶梯';A[R]=2 elif F<=4800:A[S]='第二阶梯';A[T]=2
else:A[Q]='第三阶梯';A[R]=3 else:A[S]='第三阶梯';A[T]=3
if _A3 in A: A['daily_lasted_date']=f"{E.year}-{E.month:02d}-{E.day:02d}";A[e]=datetime.datetime.strftime(M,'%Y-%m-%d %H:%M:%S')
u=catchFloat(A[_A3],'estiAmt');Y=catchFloat(A[_A3],'prepayBal');v=catchFloat(A[_A3],'sumMoney') await C.save_data()
if Y==0:A[L]=v def get_door_account_list(A):return list(A.doorAccountDict.values())
else:A[L]=Y-u
Z=catchFloat(A[_A3],'historyOwe')
if Z>0:A[L]=-Z
else:A[L]=0
if _AH in A:A[f]=catchFloat(A[_AH],'totalEleNum');A[g]=catchFloat(A[_AH],'totalEleCost')
else:A[f]=0;A[g]=0
if _A4 in A:A[h]=catchFloat(A[_A4][-1],e);A[i]=catchFloat(A[_A4][-1],'monthEleCost')
else:A[h]=0;A[i]=0
if _V in A:A[j]=catchFloat(A[_V][0],H);A[k]=catchFloat(A[_V][0],a);A[l]=catchFloat(A[_V][0],b);A[m]=catchFloat(A[_V][0],c);A[n]=catchFloat(A[_V][0],d)
else:A[j]=0;A[k]=0;A[l]=0;A[m]=0;A[n]=0
A['month_ele_num']=S;A['month_p_ele_num']=T;A['month_v_ele_num']=U;A['month_n_ele_num']=V;A['month_t_ele_num']=W;A['daily_lasted_date']=f"{E.year}-{E.month:02d}-{E.day:02d}";A['refresh_time']=datetime.datetime.strftime(M,'%Y-%m-%d %H:%M:%S')
await B.save_data()
async def get_door_account_list(A):return list(A.doorAccountDict.values())
def get_door_account(A):return A.doorAccountDict def get_door_account(A):return A.doorAccountDict
+2 -2
View File
@@ -3,7 +3,7 @@
"name": "国家电网", "name": "国家电网",
"codeowners": ["@hassbox"], "codeowners": ["@hassbox"],
"config_flow": true, "config_flow": true,
"documentation": "https://github.com/hass-box/state-grid", "documentation": "https://hassbox.cn/",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"version": "0.0.5" "version": "0.1.2"
} }
+125 -138
View File
@@ -2,13 +2,11 @@ from homeassistant.components.sensor import (
DOMAIN as SENSOR_DOMAIN, DOMAIN as SENSOR_DOMAIN,
SensorDeviceClass, SensorDeviceClass,
SensorEntity, SensorEntity,
SensorEntityDescription,
SensorStateClass, SensorStateClass,
) )
from homeassistant.config_entries import ConfigEntry from homeassistant.config_entries import ConfigEntry
from homeassistant.const import UnitOfEnergy from homeassistant.const import UnitOfEnergy
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.device_registry import DeviceEntryType
from homeassistant.helpers.entity_platform import AddEntitiesCallback from homeassistant.helpers.entity_platform import AddEntitiesCallback
from homeassistant.helpers.update_coordinator import CoordinatorEntity from homeassistant.helpers.update_coordinator import CoordinatorEntity
@@ -18,132 +16,118 @@ from .const import DOMAIN, VERSION
from .data_client import StateGridDataClient from .data_client import StateGridDataClient
from .coordinator import StateGridCoordinator from .coordinator import StateGridCoordinator
CURRENCY_YUAN = "" UNIT_DU = ""
UNIT_YUAN = ""
ENTITY_ID_SENSOR_FORMAT = SENSOR_DOMAIN + ".state_grid_" ENTITY_ID_SENSOR_FORMAT = SENSOR_DOMAIN + ".state_grid_"
SENSOR_TYPES = ( SENSOR_TYPES = [
SensorEntityDescription( {
key="balance", "key":"balance",
translation_key="balance", "name": "账户余额",
native_unit_of_measurement=CURRENCY_YUAN, "unit_of_measurement": UNIT_YUAN,
device_class=SensorDeviceClass.MONETARY, "native_unit_of_measurement": UNIT_YUAN
state_class=SensorStateClass.TOTAL },
), {
SensorEntityDescription( "key": "year_ele_num",
key="year_ele_num", "name": "年度累计用电",
translation_key="year_ele_num", "unit_of_measurement": UNIT_DU,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "native_unit_of_measurement": UNIT_DU
device_class=SensorDeviceClass.ENERGY, },
state_class=SensorStateClass.TOTAL {
), "key": "year_ele_cost",
SensorEntityDescription( "name": "年度累计电费",
key="year_ele_cost", "unit_of_measurement": UNIT_YUAN,
translation_key="year_ele_cost", "native_unit_of_measurement": UNIT_YUAN
native_unit_of_measurement=CURRENCY_YUAN, },
device_class=SensorDeviceClass.MONETARY, {
state_class=SensorStateClass.TOTAL "key": "last_month_ele_num",
), "name": "上个月用电",
SensorEntityDescription( "unit_of_measurement": UNIT_DU,
key="last_month_ele_num", "native_unit_of_measurement": UNIT_DU
translation_key="last_month_ele_num", },
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, {
device_class=SensorDeviceClass.ENERGY, "key": "last_month_ele_cost",
state_class=SensorStateClass.TOTAL "name": "上个月电费",
), "unit_of_measurement": UNIT_YUAN,
SensorEntityDescription( "native_unit_of_measurement": UNIT_YUAN
key="last_month_ele_cost", },
translation_key="last_month_ele_cost", {
native_unit_of_measurement=CURRENCY_YUAN, "key": "month_ele_num",
device_class=SensorDeviceClass.MONETARY, "name": "当月累计用电",
state_class=SensorStateClass.TOTAL "unit_of_measurement": UNIT_DU,
), "native_unit_of_measurement": UNIT_DU
SensorEntityDescription( },
key="month_ele_num", {
translation_key="month_ele_num", "key": "month_p_ele_num",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "name": "当月累计峰用电",
device_class=SensorDeviceClass.ENERGY, "unit_of_measurement": UNIT_DU,
state_class=SensorStateClass.TOTAL "native_unit_of_measurement": UNIT_DU
), },
SensorEntityDescription( {
key="month_p_ele_num", "key": "month_v_ele_num",
translation_key="month_p_ele_num", "name": "当月累计谷用电",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "unit_of_measurement": UNIT_DU,
device_class=SensorDeviceClass.ENERGY, "native_unit_of_measurement": UNIT_DU
state_class=SensorStateClass.TOTAL },
), {
SensorEntityDescription( "key": "month_n_ele_num",
key="month_v_ele_num", "name": "当月累计平用电",
translation_key="month_v_ele_num", "unit_of_measurement": UNIT_DU,
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "native_unit_of_measurement": UNIT_DU
device_class=SensorDeviceClass.ENERGY, },
state_class=SensorStateClass.TOTAL {
), "key": "month_t_ele_num",
SensorEntityDescription( "name": "当月累计尖用电",
key="month_n_ele_num", "unit_of_measurement": UNIT_DU,
translation_key="month_n_ele_num", "native_unit_of_measurement": UNIT_DU
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, },
device_class=SensorDeviceClass.ENERGY, {
state_class=SensorStateClass.TOTAL "key": "daily_ele_num",
), "name": "日总用电",
SensorEntityDescription( "unit_of_measurement": UNIT_DU,
key="month_t_ele_num", "native_unit_of_measurement": UNIT_DU
translation_key="month_t_ele_num", },
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, {
device_class=SensorDeviceClass.ENERGY, "key": "daily_p_ele_num",
state_class=SensorStateClass.TOTAL "name": "日峰用电",
), "unit_of_measurement": UNIT_DU,
SensorEntityDescription( "native_unit_of_measurement": UNIT_DU
key="daily_ele_num", },
translation_key="daily_ele_num", {
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "key": "daily_v_ele_num",
device_class=SensorDeviceClass.ENERGY, "name": "日谷用电",
state_class=SensorStateClass.TOTAL "unit_of_measurement": UNIT_DU,
), "native_unit_of_measurement": UNIT_DU
SensorEntityDescription( },
key="daily_p_ele_num", {
translation_key="daily_p_ele_num", "key": "daily_n_ele_num",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "name": "日平用电",
device_class=SensorDeviceClass.ENERGY, "unit_of_measurement": UNIT_DU,
state_class=SensorStateClass.TOTAL "native_unit_of_measurement": UNIT_DU
), },
SensorEntityDescription( {
key="daily_v_ele_num", "key": "daily_t_ele_num",
translation_key="daily_v_ele_num", "name": "日尖用电",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, "unit_of_measurement": UNIT_DU,
device_class=SensorDeviceClass.ENERGY, "native_unit_of_measurement": UNIT_DU
state_class=SensorStateClass.TOTAL },
), {
SensorEntityDescription( "key": "daily_lasted_date",
key="daily_n_ele_num", "name": "日最新用电日期"
translation_key="daily_n_ele_num", },
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR, {
device_class=SensorDeviceClass.ENERGY, "key": "refresh_time",
state_class=SensorStateClass.TOTAL "name": "最近刷新时间"
), }
SensorEntityDescription( ]
key="daily_t_ele_num",
translation_key="daily_t_ele_num",
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
device_class=SensorDeviceClass.ENERGY,
state_class=SensorStateClass.TOTAL
),
SensorEntityDescription(
key="daily_lasted_date",
translation_key="daily_lasted_date"
),
SensorEntityDescription(
key="refresh_time",
translation_key="refresh_time"
)
)
SENSOR_TYPES_FOR_LADDER = ( SENSOR_TYPES_FOR_LADDER = [
SensorEntityDescription( {
key="ladder_level", "key": "ladder_level",
translation_key="ladder_level" "name": "当前阶梯"
), },
) ]
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback hass: HomeAssistant, entry: ConfigEntry, async_add_entities: AddEntitiesCallback
@@ -151,42 +135,45 @@ async def async_setup_entry(
coordinator = StateGridCoordinator(hass) coordinator = StateGridCoordinator(hass)
await coordinator.async_config_entry_first_refresh() await coordinator.async_config_entry_first_refresh()
data_client: StateGridDataClient = hass.data[DOMAIN] data_client: StateGridDataClient = hass.data[DOMAIN]
door_account_list = await data_client.get_door_account_list() door_account_list = data_client.get_door_account_list()
for door_account in door_account_list: for door_account in door_account_list:
async_add_entities( async_add_entities(
[StateGridSensor(door_account, description, entry.entry_id, coordinator) for description in SENSOR_TYPES] [StateGridSensor(door_account, sensor_type, entry.entry_id, coordinator) for sensor_type in SENSOR_TYPES]
) )
# if door_account["ladder_flag"] == 1: # if door_account["ladder_flag"] == 1:
# async_add_entities( # async_add_entities(
# StateGridSensor(door_account, description, entry.entry_id) # StateGridSensor(door_account, sensor_type, entry.entry_id)
# for description in SENSOR_TYPES_FOR_LADDER # for sensor_type in SENSOR_TYPES_FOR_LADDER
# ) # )
class StateGridSensor(CoordinatorEntity[StateGridCoordinator], SensorEntity): class StateGridSensor(CoordinatorEntity[StateGridCoordinator], SensorEntity):
_attr_has_entity_name = True _attr_has_entity_name = True
entity_description: SensorEntityDescription
def __init__( def __init__(
self, door_account, entity_description: SensorEntityDescription, entry_id: str, coordinator: StateGridCoordinator, self, door_account, sensor_type, entry_id: str, coordinator: StateGridCoordinator,
) -> None: ) -> None:
super().__init__(coordinator) super().__init__(coordinator)
self.entity_description = entity_description
self.door_account = door_account self.door_account = door_account
self.entity_id = SENSOR_DOMAIN + ".state_grid" + "_" + door_account["consNo_dst"] + "_" + entity_description.key self.sensor_type = sensor_type
self._attr_translation_key = entity_description.key self.entity_id = SENSOR_DOMAIN + ".state_grid" + "_" + door_account["consNo_dst"] + "_" + sensor_type["key"]
self._attr_unique_id = entry_id + "-" + door_account["consNo_dst"] + "-" + entity_description.key self._attr_name = sensor_type["name"]
self._attr_unique_id = entry_id + "-" + door_account["consNo_dst"] + "-" + sensor_type["key"]
if "native_unit_of_measurement" in sensor_type:
self._attr_native_unit_of_measurement = sensor_type["native_unit_of_measurement"]
self._attr_device_info = { self._attr_device_info = {
"name": door_account["elecAddr_dst"], "name": door_account["elecAddr_dst"],
"identifiers": {(DOMAIN, door_account["consNo_dst"])}, "identifiers": {(DOMAIN, door_account["consNo_dst"])},
"sw_version": VERSION, "sw_version": VERSION,
"manufacturer": "HassBox", "manufacturer": "HassBox",
"model": "户号:" + door_account["consName_dst"] + " - " + door_account["consNo_dst"], "model": "户号:" + door_account["consName_dst"] + " - " + door_account["consNo_dst"]
"entry_type": DeviceEntryType.SERVICE,
} }
@property @property
def native_value(self): def native_value(self):
data = self.coordinator.data[self.door_account["consNo_dst"]] data = self.coordinator.data[self.door_account["consNo_dst"]]
return data[self.entity_description.key] return data[self.sensor_type["key"]]
-58
View File
@@ -70,63 +70,5 @@
"get_qr_code_error": "{errmsg}", "get_qr_code_error": "{errmsg}",
"check_qr_code_error": "{errmsg}" "check_qr_code_error": "{errmsg}"
} }
},
"entity": {
"sensor": {
"balance": {
"name": "账户余额"
},
"year_ele_num": {
"name": "年度累计用电"
},
"year_ele_cost": {
"name": "年度累计电费"
},
"last_month_ele_num": {
"name": "上个月用电"
},
"last_month_ele_cost": {
"name": "上个月电费"
},
"month_ele_num": {
"name": "当月累计用电"
},
"month_p_ele_num": {
"name": "当月累计峰用电"
},
"month_v_ele_num": {
"name": "当月累计谷用电"
},
"month_n_ele_num": {
"name": "当月累计平用电"
},
"month_t_ele_num": {
"name": "当月累计尖用电"
},
"daily_ele_num": {
"name": "日总用电"
},
"daily_p_ele_num": {
"name": "日峰用电"
},
"daily_v_ele_num": {
"name": "日谷用电"
},
"daily_n_ele_num": {
"name": "日平用电"
},
"daily_t_ele_num": {
"name": "日尖用电"
},
"daily_lasted_date": {
"name": "最新日用电日期"
},
"ladder_level": {
"name": "当前阶梯"
},
"refresh_time": {
"name": "最近刷新时间"
}
}
} }
} }
@@ -0,0 +1,74 @@
{
"config": {
"flow_title": "国家电网",
"step": {
"user": {
"title": "国家电网",
"description": "集成国家电网可以选择网上国网 App 扫码登录或短信验证码登录。如登录异常,可至 **HassBox全屋智能** 微信公众号联系客服。"
},
"code_login": {
"title": "短信验证码登录",
"description": "手机号需先在网上电网 App 注册并绑定户号",
"data": {
"phone": "请输入手机号"
}
},
"verfiy_code": {
"title": "短信验证码登录",
"data": {
"code": "请输入验证码"
}
},
"check_qr_code": {
"title": "网上国网 App 扫码登录",
"description": "\n {qr_image} \n\n\n 请使用 网上国网 App 扫码登录,确认登录后再点击提交。"
}
},
"abort": {
"single_instance_allowed": "该集成已经配置过了,且只能配置一次。若要重新配置,请先删除旧集成。",
"get_qr_code_error": "{errmsg}",
"check_qr_code_error": "{errmsg}"
}
},
"options": {
"step": {
"debug": {
"title": "国家电网",
"description": "国家电网当日用电等数据一般隔天才会刷新,且各地区时间不一,可根据情况适当调整接口轮询间隔。",
"data": {
"refresh_interval": "轮询间隔",
"is_debug": "调试模式"
},
"data_description": {
"is_debug": "打开调试开关后,将会打印所有请求日志。可在[配置]-[系统]-[日志]中查看。\n如需反馈异常,可至 **HassBox全屋智能** 微信公众号联系客服。"
}
},
"user": {
"title": "重新登录国家电网",
"description": "刷新 Token 异常,需重新登录。\n如需反馈异常,可至 **HassBox全屋智能** 微信公众号联系客服。"
},
"code_login": {
"title": "短信验证码登录",
"description": "手机号需先在网上电网 App 注册并绑定户号",
"data": {
"phone": "请输入手机号"
}
},
"verfiy_code": {
"title": "短信验证码登录",
"data": {
"code": "请输入验证码"
}
},
"check_qr_code": {
"title": "网上国网 App 扫码登录",
"description": "\n {qr_image} \n\n\n 请使用 网上国网 App 扫码登录,确认登录后再点击提交。"
}
},
"abort": {
"single_instance_allowed": "该集成已经配置过了,且只能配置一次。若要重新配置,请先删除旧集成。",
"get_qr_code_error": "{errmsg}",
"check_qr_code_error": "{errmsg}"
}
}
}
@@ -70,63 +70,5 @@
"get_qr_code_error": "{errmsg}", "get_qr_code_error": "{errmsg}",
"check_qr_code_error": "{errmsg}" "check_qr_code_error": "{errmsg}"
} }
},
"entity": {
"sensor": {
"balance": {
"name": "账户余额"
},
"year_ele_num": {
"name": "年度累计用电"
},
"year_ele_cost": {
"name": "年度累计电费"
},
"last_month_ele_num": {
"name": "上个月用电"
},
"last_month_ele_cost": {
"name": "上个月电费"
},
"month_ele_num": {
"name": "当月累计用电"
},
"month_p_ele_num": {
"name": "当月累计峰用电"
},
"month_v_ele_num": {
"name": "当月累计谷用电"
},
"month_n_ele_num": {
"name": "当月累计平用电"
},
"month_t_ele_num": {
"name": "当月累计尖用电"
},
"daily_ele_num": {
"name": "日总用电"
},
"daily_p_ele_num": {
"name": "日峰用电"
},
"daily_v_ele_num": {
"name": "日谷用电"
},
"daily_n_ele_num": {
"name": "日平用电"
},
"daily_t_ele_num": {
"name": "日尖用电"
},
"daily_lasted_date": {
"name": "最新日用电日期"
},
"ladder_level": {
"name": "当前阶梯"
},
"refresh_time": {
"name": "最近刷新时间"
}
}
} }
} }