Skip to content

Commit

Permalink
Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mschlenstedt committed Jul 18, 2024
1 parent 028450f commit f13d4e4
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions mqtt_io/modules/sensor/flowsensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def reset_count(self) -> None:
"""Reset pulse count."""
self.count = 0

def flow_rate(self, sample_window: int) -> float:
def flow_rate(self, sample_window: int, factor: float) -> float:
"""Return flow rate in liters per minute.
From YF-S201 manual:
Expand All @@ -71,11 +71,11 @@ def flow_rate(self, sample_window: int) -> float:
sample_window is in seconds, so hz is pulse_count / sample_window
"""
hertz = self.count / sample_window
return hertz / sens_conf["factor"]
return hertz / factor

def get_value(self, interval: int) -> float:
def get_value(self, interval: int, factor: float) -> float:
"""Return flow rate in L/min over interval seconds and reset count."""
flow_rate = self.flow_rate(interval)
flow_rate = self.flow_rate(interval,factor)
self.reset_count()
return flow_rate

Expand Down Expand Up @@ -117,4 +117,4 @@ def setup_sensor(self, sens_conf: ConfigType) -> None:
self.sensors[sensor.name] = sensor

def get_value(self, sens_conf: ConfigType) -> SensorValueType:
return self.sensors[sens_conf["name"]].get_value(sens_conf["interval"])
return self.sensors[sens_conf["name"]].get_value(sens_conf["interval"],sens_conf["factor"])

0 comments on commit f13d4e4

Please sign in to comment.