@@ -22,12 +22,12 @@ def __init__(self, hass, my_api):
2222 self .team = my_api .data ['team' ]
2323
2424
25- def __get_url (self , operation , value ):
25+ def xx__get_url (self , operation , value ):
2626 with open (operation + ".txt" , 'r' ) as fson :
2727 rj = json .load (fson )
2828 return rj
2929
30- def xx__get_url (self , operation , value ):
30+ def __get_url (self , operation , value ):
3131 try :
3232 main_url = 'https://datalake-prod2018.rbfa.be/graphql'
3333 url = '{}?operationName={}&variables={{"{}":"{}","language":"nl"}}&extensions={{"persistedQuery":{{"version":1,"sha256Hash":"{}"}}}}' .format (
@@ -37,7 +37,6 @@ def xx__get_url(self, operation, value):
3737 value ,
3838 HASHES [operation ]
3939 )
40- # _LOGGER.debug(url)
4140 response = requests .get (url )
4241 if response .status_code != 200 :
4342 _LOGGER .debug ('Invalid response from server for collection data' )
@@ -95,6 +94,13 @@ async def update(self, my_api):
9594 else :
9695 self .show_ranking = True
9796
97+ if 'show_referee' in my_api .options :
98+ self .show_referee = my_api .options ['show_referee' ]
99+ elif 'show_referee' in my_api .data :
100+ self .show_referee = my_api .data ['show_referee' ]
101+ else :
102+ self .show_referee = True
103+
98104 self .collections = [];
99105 _LOGGER .debug ('duration: %r' , self .duration )
100106 _LOGGER .debug ('show ranking: %r' , self .show_ranking )
@@ -111,7 +117,6 @@ async def update(self, my_api):
111117 previous = None
112118
113119 self .collections = []
114- ranking = []
115120 referee = None
116121
117122 for item in r ['data' ]['teamCalendar' ]:
@@ -124,10 +129,11 @@ async def update(self, my_api):
124129 match ['postalCode' ],
125130 match ['city' ],
126131 )
127- officials = r ['data' ]['matchDetail' ]['officials' ]
128- for x in officials :
129- if x ['function' ] == 'referee' :
130- referee = f"{ x ['firstName' ]} { x ['lastName' ]} "
132+ if self .show_referee :
133+ officials = r ['data' ]['matchDetail' ]['officials' ]
134+ for x in officials :
135+ if x ['function' ] == 'referee' :
136+ referee = f"{ x ['firstName' ]} { x ['lastName' ]} "
131137 else :
132138 location = None
133139
@@ -169,7 +175,8 @@ async def update(self, my_api):
169175 }
170176 if self .show_ranking :
171177 await self .get_ranking ('upcoming' )
172- await self .get_ranking ('lastmatch' )
178+ if previous != None :
179+ await self .get_ranking ('lastmatch' )
173180
174181 summary = '[' + item ['state' ] + '] ' + item ['homeTeam' ]['name' ] + ' - ' + item ['awayTeam' ]['name' ]
175182 description = item ['series' ]['name' ]
@@ -216,4 +223,4 @@ async def get_ranking (self, tag):
216223 if rank ['teamId' ] == self .matchdata [tag ]['hometeamid' ]:
217224 self .matchdata [tag ]['hometeamposition' ] = rank ['position' ]
218225 if rank ['teamId' ] == self .matchdata [tag ]['awayteamid' ]:
219- self .matchdata [tag ]['awayteamposition' ] = rank ['position' ]
226+ self .matchdata [tag ]['awayteamposition' ] = rank ['position' ]
0 commit comments