File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
custom_components/enphase_envoy Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -176,6 +176,11 @@ def parse_devicedata(data):
176176 return idd
177177
178178
179+ def read_file_as_bytes (filename ):
180+ with open (filename , "rb" ) as f :
181+ return f .read ()
182+
183+
179184class EnvoyReaderError (Exception ):
180185 pass
181186
@@ -1335,9 +1340,9 @@ async def set_grid_profile(self, profile_id):
13351340 async def upload_grid_profile (self , file ):
13361341 if self .endpoint_installer_agf is not None :
13371342 formatted_url = ENDPOINT_URL_INSTALLER_AGF_UPLOAD_PROFILE .format (self .host )
1338- resp = await self . _async_post (
1339- formatted_url , files = { "file" : open ( file , "rb" )}
1340- )
1343+ loop = asyncio . get_running_loop ()
1344+ content = await loop . run_in_executor ( None , read_file_as_bytes , file )
1345+ resp = await self . _async_post ( formatted_url , files = { "file" : content } )
13411346 message = resp .json ().get ("message" )
13421347 if message != "success" :
13431348 raise EnvoyError (f"Failed uploading grid profile: { message } " )
You can’t perform that action at this time.
0 commit comments