Skip to content

Commit

Permalink
Do not report a thermistor warning every interval
Browse files Browse the repository at this point in the history
  • Loading branch information
albireox committed Sep 20, 2024
1 parent 3502702 commit 1430067
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## Next version

### ✨ Improved

* Do not report a thermistor warning every interval.


## 0.1.2 - 2024-09-18

### 🚀 New
Expand Down
17 changes: 13 additions & 4 deletions src/lvmcryo/handlers/thermistor.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,9 @@ async def start_monitoring(self):
# is not providing new data.
alert_seconds = int(10 * self.monitoring_interval)

# Number of seconds since the last issued warnings.
last_warned = -1

while True:
await asyncio.sleep(self.monitoring_interval)

Expand Down Expand Up @@ -239,10 +242,16 @@ async def start_monitoring(self):
never_seen = last_seen <= 0 and elapsed_running > alert_seconds

if is_late or never_seen:
self.log.warning(
f"No data from the thermistor {self.channel} "
f"in the last {last_seen_elapsed} seconds."
)
# Issue a warning the first time this happens
# and then every 30 seconds.
if last_warned == -1 or last_warned > 30:
self.log.warning(
f"No data from the thermistor {self.channel} "
f"in the last {last_seen_elapsed:.1f} seconds."
)
last_warned = 0
else:
last_warned += self.monitoring_interval

self.valve_handler.log.debug(
f"Thermistor {self.channel} has been active for more than "
Expand Down

0 comments on commit 1430067

Please sign in to comment.