1 Commits
Author SHA1 Message Date
yangchengdong c26474e7b3 deploy 2024-07-19 16:33:23 +08:00
3 changed files with 18 additions and 13 deletions
+1 -1
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.1.6" VERSION = "0.1.7"
VERSION_STORAGE = 1 VERSION_STORAGE = 1
+16 -11
View File
@@ -164,8 +164,7 @@ class StateGridDataClient:
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)) LOGGER.error(api+': '+B);LOGGER.error(json_dumps(A));return B
return B
async def __fetch_safe(C,api,data): async def __fetch_safe(C,api,data):
B=await C.__fetch(api,data) B=await C.__fetch(api,data)
if _H not in B:return B if _H not in B:return B
@@ -271,16 +270,22 @@ class StateGridDataClient:
if _H in B and B[_H]==1 and _A in B and _u in B[_A]: if _H in B and B[_H]==1 and _A in B and _u in B[_A]:
D=B[_A][_u] D=B[_A][_u]
if len(D)!=0:D=D[0];E['ladder']=D if len(D)!=0:D=D[0];E['ladder']=D
async def __get_door_mouth_bill(E,door_account,monthBill): async def __get_door_mouth_bill(F,door_account,monthBill):
O='pointList';H=monthBill;G='quantity';F='priceName';B=door_account;I=datetime.datetime.strptime(H[_AN],'%Y%m');P=f"{I.year}-{I.month:02d}";Q={_A:{_I:configuration[_V][_I],_D:configuration[_V][_D],_T:configuration[_V][_T],_e:configuration[_V][_e],_q:B[_g],_d:B[_U],_Y:B[_Y],_Av:P,_AV:B[_U],_AL:B[_AW],_AI:E.userInfo[_R],_N:'',_L:'',_A4:E.userInfo[_AB],_A3:E.userInfo[_R]},_C:configuration[_V][_C],_E:configuration[_V][_E],_S:B[_U]};C=await E.__fetch(get_door_ladder_api,Q);S=E.handle_request_result_message(_Aw,C) S='pointList';K=monthBill;J='amtList';I='readList';H='quantity';G='priceName';B=door_account;L=datetime.datetime.strptime(K[_AN],'%Y%m');T=f"{L.year}-{L.month:02d}";U={_A:{_I:configuration[_V][_I],_D:configuration[_V][_D],_T:configuration[_V][_T],_e:configuration[_V][_e],_q:B[_g],_d:B[_U],_Y:B[_Y],_Av:T,_AV:B[_U],_AL:B[_AW],_AI:F.userInfo[_R],_N:'',_L:'',_A4:F.userInfo[_AB],_A3:F.userInfo[_R]},_C:configuration[_V][_C],_E:configuration[_V][_E],_S:B[_U]};C=await F.__fetch(get_door_ladder_api,U);W=F.handle_request_result_message(_Aw,C)
if _H in C and C[_H]==1 and _A in C and _u in C[_A]: if _H in C and C[_H]==1 and _A in C and _u in C[_A]:
J=C[_A][_u][0];R=catchFloat(J[O][0]['readList'][0],'activeCount');K=0;L=0;M=0;N=0 D=C[_A][_u][0]
for A in J[O][0]['amtGroupList'][0]['amtList']: if I in D:M=D[I][0]
if A[F]=='':K=catchFloat(A,G) else:M=D[S][0][I][0]
elif A[F]=='':L=catchFloat(A,G) V=catchFloat(M,'activeCount')
elif A[F]=='':M=catchFloat(A,G) if J in D:N=D[J]
elif A[F]=='':N=catchFloat(A,G) else:N=D[S][0]['amtGroupList'][0][J]
D={};D[_AX]=normal_round(R,2);D[_AY]=normal_round(K,2);D[_AZ]=normal_round(L,2);D[_Aa]=normal_round(M,2);D[_Ab]=normal_round(N,2);H[_h]=D O=0;P=0;Q=0;R=0
for A in N:
if A[G]=='':O=catchFloat(A,H)
elif A[G]=='':P=catchFloat(A,H)
elif A[G]=='':Q=catchFloat(A,H)
elif A[G]=='':R=catchFloat(A,H)
E={};E[_AX]=normal_round(V,2);E[_AY]=normal_round(O,2);E[_AZ]=normal_round(P,2);E[_Aa]=normal_round(Q,2);E[_Ab]=normal_round(R,2);K[_h]=E
async def __get_door_daily_bill(B,door_account,year,start_date,end_date): async def __get_door_daily_bill(B,door_account,year,start_date,end_date):
D='sevenEleList';A=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]},_A1:{_R:B.userInfo[_R]},_p:B.token},'params3':{_A:{_A3:B.userInfo[_R],_q:A[_g],_AL:_c,'endTime':end_date,_Y:A[_Y],_Au:year,_AJ:A.get(_U,A.get(_AK,_F)),_N:'',_L:'','startTime':start_date,_A4:B.userInfo[_AB],_D:configuration[_m][_D],_I:configuration[_m][_I],_e:configuration[_m][_e],_d:configuration[_m][_d],_T:configuration[_m][_T]},_C:configuration[_m][_C],_E:configuration[_m][_E],_S:A.get(_U,A.get(_AK,_F))},'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) D='sevenEleList';A=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]},_A1:{_R:B.userInfo[_R]},_p:B.token},'params3':{_A:{_A3:B.userInfo[_R],_q:A[_g],_AL:_c,'endTime':end_date,_Y:A[_Y],_Au:year,_AJ:A.get(_U,A.get(_AK,_F)),_N:'',_L:'','startTime':start_date,_A4:B.userInfo[_AB],_D:configuration[_m][_D],_I:configuration[_m][_I],_e:configuration[_m][_e],_d:configuration[_m][_d],_T:configuration[_m][_T]},_C:configuration[_m][_C],_E:configuration[_m][_E],_S:A.get(_U,A.get(_AK,_F))},'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 C and C[_H]==1 and _A in C and D in C[_A]:A[_A6]=C[_A][D] if _H in C and C[_H]==1 and _A in C and D in C[_A]:A[_A6]=C[_A][D]
+1 -1
View File
@@ -5,5 +5,5 @@
"config_flow": true, "config_flow": true,
"documentation": "https://hassbox.cn/", "documentation": "https://hassbox.cn/",
"iot_class": "cloud_polling", "iot_class": "cloud_polling",
"version": "0.1.6" "version": "0.1.7"
} }