@@ -747,8 +747,14 @@ async def get_scheduler(self, deviceSN):
747747 result = await self .request_get (GET_SCHEDULER , datain = {"deviceSN" : deviceSN }, post = True )
748748 if result :
749749 self .fdpwr_max [deviceSN ] = result .get ("properties" , {}).get ("fdpwr" , {}).get ("range" , {}).get ("max" , 8000 )
750+ # XXX: Fox seems to be have an issue with FD Power max value, no maximum is listed but the default fdPwr listed in disabled groups seems to be the max so find that
751+ for group in result .get ("groups" , []):
752+ if group .get ("enable" , 1 ) == 0 :
753+ self .fdpwr_max [deviceSN ] = group .get ("fdPwr" , self .fdpwr_max [deviceSN ])
754+ break
755+
750756 self .fdsoc_min [deviceSN ] = result .get ("properties" , {}).get ("fdsoc" , {}).get ("range" , {}).get ("min" , 10 )
751- self .log ("Fox: Fetched schedule got {}" .format (result ))
757+ self .log ("Fox: Fetched schedule got {} fdPwr max {} fdSoc min {} " .format (result , self . fdpwr_max [ deviceSN ], self . fdsoc_min [ deviceSN ] ))
752758 self .device_scheduler [deviceSN ] = result
753759 return result
754760 return {}
@@ -853,21 +859,21 @@ async def request_get_func(self, path, post=False, datain=None):
853859 self .failures_total += 1
854860 if errno in [40400 , 41200 , 41201 , 41202 , 41203 , 41935 , 44098 ]:
855861 # Rate limiting so wait up to 31 seconds
856- self .log ("Info: Fox: Rate limiting or comms issue detected, waiting..." )
862+ self .log (f "Info: Fox: Rate limiting or comms issue detected { msg } : { errno } , waiting..." )
857863 await asyncio .sleep (random .random () * 30 + 1 )
858864 return None , True
859865 elif errno in [40402 ]:
860866 # Out of API calls for today
861- self .log ("Warn: Fox: Has run out of API calls for today, sleeping..." )
867+ self .log (f "Warn: Fox: Has run out of API calls for today { msg } : { errno } , sleeping..." )
862868 await asyncio .sleep (5 * 60 )
863869 return None , False
864870 elif errno in [44096 ]:
865871 # Unsupported function code
866- self .log ("Warn: Fox: Unsupported function code {} from {}" . format ( errno , url ) )
872+ self .log (f "Warn: Fox: Unsupported function code { msg } : { errno } from { url } " )
867873 return None , False
868874 elif errno in [40257 ]:
869875 # Invalid parameter
870- self .log ("Warn: Fox: Invalid parameter {} from {} message {}" . format ( errno , url , msg ) )
876+ self .log (f "Warn: Fox: Invalid parameter { msg } : { errno } from { url } " )
871877 return None , False
872878 else :
873879 self .log ("Warn: Fox: Error {} from {} message {}" .format (errno , url , msg ))
@@ -1283,12 +1289,16 @@ async def test_fox_api(api_key):
12831289
12841290 # Create FoxAPI instance with a lambda that returns the API key
12851291 fox_api = FoxAPI (api_key , False , mock_base )
1286- # device_List = await fox_api.get_device_list()
1287- # print(f"Device List: {device_List}")
1292+ device_List = await fox_api .get_device_list ()
1293+ print (f"Device List: { device_List } " )
12881294 # await fox_api.start()
1289- # res = await fox_api.get_device_settings(sn)
1290- # res = await fox_api.get_battery_charging_time(sn)
1291- # res = await fox_api.get_scheduler(sn)
1295+ res = await fox_api .get_device_settings (sn )
1296+ print (res )
1297+ res = await fox_api .get_battery_charging_time (sn )
1298+ print (res )
1299+ res = await fox_api .get_scheduler (sn )
1300+ print (res )
1301+ return 1
12921302 # res = await fox_api.compute_schedule(sn)
12931303 # res = await fox_api.publish_data()
12941304 # res = await fox_api.set_device_setting(sn, "dummy", 42)
@@ -1301,13 +1311,13 @@ async def test_fox_api(api_key):
13011311 new_slot = {}
13021312 new_slot ["enable" ] = 1
13031313 new_slot ["workMode" ] = "ForceDischarge"
1304- new_slot ["startHour" ] = 23
1314+ new_slot ["startHour" ] = 11
13051315 new_slot ["startMinute" ] = 30
1306- new_slot ["endHour" ] = 23
1307- new_slot ["endMinute" ] = 59
1308- new_slot ["fdSoc" ] = 10
1309- new_slot ["fdPwr" ] = 10500
1310- new_slot ["minSocOnGrid" ] = 10
1316+ new_slot ["endHour" ] = 12
1317+ new_slot ["endMinute" ] = 00
1318+ new_slot ["fdSoc" ] = 20
1319+ new_slot ["fdPwr" ] = 4000
1320+ new_slot ["minSocOnGrid" ] = 20
13111321 new_slot2 = {}
13121322 new_slot2 ["enable" ] = 1
13131323 new_slot2 ["workMode" ] = "ForceCharge"
@@ -1319,10 +1329,9 @@ async def test_fox_api(api_key):
13191329 new_slot2 ["fdPwr" ] = 8000
13201330 new_slot2 ["minSocOnGrid" ] = 100
13211331
1322- new_schedule = fox_api .validate_schedule ([new_slot2 , new_slot ])
1332+ new_schedule = fox_api .validate_schedule ([new_slot ])
13231333 print ("Validated schedule" )
13241334 print (new_schedule )
1325- return 0
13261335
13271336 print ("Sending: {}" .format (new_schedule ))
13281337 res = await fox_api .set_scheduler (sn , new_schedule )
0 commit comments