reset inverter state on close

- workaround which reset the inverter status to
  offline when the inverter has a very low
  output power on connection close
This commit is contained in:
Stefan Allius
2024-07-24 22:36:51 +02:00
parent 7f81799dd9
commit 387c014763

View File

@@ -143,6 +143,14 @@ class SolarmanV5(Message):
'''
def close(self) -> None:
logging.debug('Solarman.close()')
if self.server_side:
# set inverter state to offline, if output power is very low
logging.debug('close power: '
f'{self.db.get_db_value(Register.OUTPUT_POWER, -1)}')
if self.db.get_db_value(Register.OUTPUT_POWER, 999) < 2:
self.db.set_db_def_value(Register.INVERTER_STATUS, 0)
self.new_data['env'] = True
# we have references to methods of this class in self.switch
# so we have to erase self.switch, otherwise this instance can't be
# deallocated by the garbage collector ==> we get a memory leak