File tree Expand file tree Collapse file tree 2 files changed +6
-7
lines changed
custom_components/solaredge_modbus_multi Expand file tree Collapse file tree 2 files changed +6
-7
lines changed Original file line number Diff line number Diff line change @@ -10,18 +10,18 @@ def watts_to_kilowatts(value):
1010def parse_modbus_string (s : str ) -> str :
1111 return s .decode (encoding = "utf-8" , errors = "ignore" ).replace ("\x00 " , "" ).rstrip ()
1212
13- def update_accum (self , raw : int , current : int ) -> None :
13+ def update_accum (self , accum_value : int ) -> None :
1414
1515 if self .last is None :
1616 self .last = 0
1717
18- if not raw > 0 :
18+ if not accum_value > 0 :
1919 raise ValueError (f"update_accum must be non-zero value." )
2020
21- if current >= self .last :
21+ if accum_value >= self .last :
2222 # doesn't account for accumulator rollover, but it would probably take
2323 # several decades to roll over to 0 so we'll worry about it later
24- self .last = current
25- return current
24+ self .last = accum_value
25+ return accum_value
2626 else :
2727 raise ValueError (f"update_accum must be an increasing value." )
Original file line number Diff line number Diff line change @@ -839,10 +839,9 @@ def native_value(self):
839839
840840 else :
841841 value = scale_factor (self ._platform .decoded_model [model_key ], self ._platform .decoded_model ['AC_Energy_WH_SF' ])
842- value_kw = watts_to_kilowatts (value )
843842
844843 try :
845- return update_accum (self , value , value_kw )
844+ return watts_to_kilowatts ( update_accum (self , value ) )
846845 except :
847846 return None
848847
You can’t perform that action at this time.
0 commit comments