From d9ebc51e71c39f7b856897b9831d3c3bf4545a01 Mon Sep 17 00:00:00 2001 From: dadaloop82 Date: Sat, 23 May 2026 14:38:01 +0000 Subject: [PATCH] fix: ha_sensor JOIN products for name/unit columns (was HTTP 500) --- api/index.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/api/index.php b/api/index.php index 560edda..39bee37 100644 --- a/api/index.php +++ b/api/index.php @@ -1388,9 +1388,12 @@ function haInventorySensor(PDO $db): void { // Expiring items details $expiringItems = $db->query( - "SELECT name, quantity, unit, expiry_date FROM inventory - WHERE quantity > 0 AND expiry_date IS NOT NULL AND expiry_date BETWEEN date('now') AND date('now', '+7 days') - ORDER BY expiry_date ASC LIMIT 10" + "SELECT p.name, i.quantity, p.unit, i.expiry_date + FROM inventory i + JOIN products p ON p.id = i.product_id + WHERE i.quantity > 0 AND i.expiry_date IS NOT NULL + AND i.expiry_date BETWEEN date('now') AND date('now', '+7 days') + ORDER BY i.expiry_date ASC LIMIT 10" )->fetchAll(PDO::FETCH_ASSOC); $stateValue = match($sensor) {