@@ -1073,6 +1073,7 @@ def __init__(self, cmd_arg, sys_config, name, tc_logger):
10731073 self .pwm_max = CONST .PWM_MAX
10741074 self .value = CONST .TEMP_INIT_VAL_DEF
10751075 self .value_acc = self .value * self .input_smooth_level
1076+ self .last_value = self .value
10761077 self .pwm = CONST .PWM_MIN
10771078 self .last_pwm = self .pwm
10781079 self .pwm_hysteresis = int (self .sensors_config .get ("pwm_hyst" , CONST .PWM_HYSTERESIS_DEF ))
@@ -1225,20 +1226,22 @@ def update_value(self, value=None):
12251226
12261227 input_smooth_level defined in sensor configuration
12271228 2. Add hysteresis for value change
1228- if value >= old_value + hysteresis then update old_value to the new
1229- If new change in the same diraction (up or downn) then updating value will be immediatly without hysteresis.
1229+ if value >= prev_value + hysteresis then update prev_value to the new
1230+ If new change in the same direction (up or downn) then updating value will be immediatly without hysteresis.
12301231
12311232 value_hyst defined in sensor configuration
12321233 """
1233- old_value = self .value
1234+ self .last_value = value
1235+ prev_value = self .value
1236+
12341237 # integral filter for soothing temperature change
12351238 self .value_acc -= self .value_acc / self .input_smooth_level
12361239 self .value_acc += value
12371240 self .value = int (round (float (self .value_acc ) / self .input_smooth_level ))
12381241
1239- if self .value > old_value :
1242+ if self .value > prev_value :
12401243 value_trend = 1
1241- elif self .value < old_value :
1244+ elif self .value < prev_value :
12421245 value_trend = - 1
12431246 else :
12441247 value_trend = 0
@@ -1597,7 +1600,7 @@ def get_temp_support_status(self):
15971600 """
15981601 status = True
15991602
1600- if self .value == 0 and self .val_max == 0 and self .val_min == 0 :
1603+ if self .last_value == 0 and self .val_max == 0 and self .val_min == 0 :
16011604 self .log .debug ("Module not supporting temp reading val:{} max:{}" .format (self .value , self .val_max ))
16021605 status = False
16031606
@@ -1628,7 +1631,7 @@ def handle_input(self, thermal_table, flow_dir, amb_tmp):
16281631 self .refresh_attr ()
16291632 self .update_value (value )
16301633
1631- if self .value != 0 :
1634+ if self .get_temp_support_status () :
16321635 if self .value > self .val_max :
16331636 self .log .warn ("{} value({}) more then max({}). Set pwm {}" .format (self .name ,
16341637 self .value ,
0 commit comments