home / sensor

Menu
  • Dashboards

Fridge Temperature Rising

Five-minute windows where average temperature rises for three consecutive periods.

Custom SQL query returning 5 rows (hide)

WITH buckets AS (
  SELECT
    strftime('%Y-%m-%d %H:', recorded_at) || printf('%02d', (CAST(strftime('%M', recorded_at) AS INTEGER) / 5) * 5) AS window_start,
    AVG(temperature_c) AS avg_temperature_c
  FROM sensor_log
  GROUP BY 1
), trends AS (
  SELECT
    window_start,
    avg_temperature_c,
    LAG(avg_temperature_c, 1) OVER (ORDER BY window_start) AS prev_avg_temperature_c,
    LAG(avg_temperature_c, 2) OVER (ORDER BY window_start) AS prev2_avg_temperature_c
  FROM buckets
)
SELECT
  window_start,
  ROUND(avg_temperature_c, 2) AS avg_temperature_c,
  ROUND(avg_temperature_c - prev_avg_temperature_c, 2) AS delta_from_previous_c
FROM trends
WHERE prev2_avg_temperature_c IS NOT NULL
  AND avg_temperature_c > prev_avg_temperature_c
  AND prev_avg_temperature_c > prev2_avg_temperature_c
ORDER BY window_start DESC;

Edit SQL

This data as json, CSV

window_startavg_temperature_cdelta_from_previous_c
2026-03-04 09:45 5.5 0.13
2026-03-04 09:40 5.38 0.57
2026-03-04 09:35 4.8 0.77
2026-03-04 08:40 6.01 0.25
2026-03-04 08:35 5.76 0.52
Powered by Datasette · Queries took 1.725ms