@@ -88,11 +88,12 @@ def update_status(self, minutes_now):
8888 self .soc_kw = self .base .sim_soc_kw
8989 else :
9090 if self .rest_data :
91- self .soc_kw = self .rest_data ['Power' ]['Power' ]['SOC_kWh' ]
92- self .base .log ("Inverter {} SOC_Kwh {}" .format (self .id , self .soc_kw ))
91+ self .soc_kw = self .rest_data ['Power' ]['Power' ]['SOC_kWh' ] * self .base .battery_scaling
9392 else :
9493 self .soc_kw = self .base .get_arg ('soc_kw' , default = 0.0 , index = self .id ) * self .base .battery_scaling
9594
95+ self .base .log ("Inverter {} SOC_Kwh {}" .format (self .id , self .soc_kw ))
96+
9697 # If the battery is being charged then find the charge window
9798 if self .charge_enable_time :
9899 # Find current charge window
@@ -210,20 +211,20 @@ def adjust_battery_target(self, soc):
210211
211212 if current_soc != soc :
212213 self .base .log ("Inverter {} Current charge Limit is {} % and new target is {} %" .format (self .id , current_soc , soc ))
213- entity_soc = self .base .get_entity (self .base .get_arg ('charge_limit' , indirect = False , index = self .id ))
214- if entity_soc :
215- if SIMULATE :
216- self .base .sim_soc = soc
214+ if SIMULATE :
215+ self .base .sim_soc = soc
216+ else :
217+ if self .rest_api :
218+ self .rest_setChargeTarget (soc )
217219 else :
218- if self .rest_api :
219- self .rest_setChargeTarget (soc )
220- else :
220+ entity_soc = self .base .get_entity (self .base .get_arg ('charge_limit' , indirect = False , index = self .id ))
221+ if entity_soc :
221222 entity_soc .call_service ("set_value" , value = soc )
222- if self . base . get_arg ( 'set_soc_notify' , False ) :
223- self .base .call_notify ( 'Predbat : Inverter {} Target SOC has been changed to {} % at {}' .format (self .id , soc , self . base . time_now_str () ))
224- self .base .record_status ( "Inverter {} set soc to {} at {}" . format ( self . id , soc , self . base . time_now_str ()))
225- else :
226- self .base .log ( "WARN: Inverter {} Unable to get entity to set SOC target " .format (self .id ))
223+ else :
224+ self .base .log ( "WARN : Inverter {} Unable to get entity to set SOC target" .format (self .id ))
225+ if self .base .get_arg ( 'set_soc_notify' , False ):
226+ self . base . call_notify ( 'Predbat: Inverter {} Target SOC has been changed to {} % at {}' . format ( self . id , soc , self . base . time_now_str ()))
227+ self .base .record_status ( " Inverter {} set soc to {} at {} " .format (self .id , soc , self . base . time_now_str () ))
227228 else :
228229 self .base .log ("Inverter {} Current SOC is {} already at target" .format (self .id , current_soc ))
229230
0 commit comments