@@ -1584,22 +1584,23 @@ def treat_address(self, data: dict[str, Any], regs: list[int], idx: int, descr:
15841584 return_value = round (val * descr .scale * read_scale , descr .rounding )
15851585 except Exception :
15861586 return_value = val # probably a REGISTER_WORDS instance
1587- if descr .native_unit_of_measurement == UnitOfFrequency .HERTZ :
1587+ native_unit = getattr (descr , "native_unit_of_measurement" , None )
1588+ if native_unit == UnitOfFrequency .HERTZ :
15881589 min_val = getattr (descr , "min_value" , 20 )
15891590 max_val = getattr (descr , "max_value" , 80 )
1590- if descr . native_unit_of_measurement == PERCENTAGE :
1591+ if native_unit == PERCENTAGE :
15911592 min_val = getattr (descr , "min_value" , 0 )
15921593 max_val = getattr (descr , "max_value" , 100 )
1593- elif descr . native_unit_of_measurement == UnitOfTemperature .CELSIUS :
1594+ elif native_unit == UnitOfTemperature .CELSIUS :
15941595 min_val = getattr (descr , "min_value" , - 100 )
15951596 max_val = getattr (descr , "max_value" , 200 )
1596- elif descr . native_unit_of_measurement == UnitOfPower .KILO_WATT :
1597+ elif native_unit == UnitOfPower .KILO_WATT :
15971598 min_val = getattr (descr , "min_value" , - self .inverterPowerKw * 2 )
15981599 max_val = getattr (descr , "max_value" , + self .inverterPowerKw * 2 )
1599- elif descr . native_unit_of_measurement == UnitOfElectricCurrent .AMPERE :
1600+ elif native_unit == UnitOfElectricCurrent .AMPERE :
16001601 min_val = getattr (descr , "min_value" , - self .inverterPowerKw * 2 )
16011602 max_val = getattr (descr , "max_value" , + self .inverterPowerKw * 2 )
1602- elif descr . native_unit_of_measurement == UnitOfElectricPotential .VOLT :
1603+ elif native_unit == UnitOfElectricPotential .VOLT :
16031604 min_val = getattr (descr , "min_value" , 0 )
16041605 max_val = getattr (descr , "max_value" , 2000 )
16051606 else :
0 commit comments