From 8c7db13f14adafba861068fcdaf38a5799a90a17 Mon Sep 17 00:00:00 2001 From: Giorgio Ravera Date: Mon, 25 Aug 2025 22:20:09 +0200 Subject: [PATCH] Minor fix to lovelace for fritz --- .storage/lovelace.lovelace_devices | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.storage/lovelace.lovelace_devices b/.storage/lovelace.lovelace_devices index acce0142..032a8fce 100644 --- a/.storage/lovelace.lovelace_devices +++ b/.storage/lovelace.lovelace_devices @@ -415,7 +415,7 @@ "type": "custom:button-card", "template": "template_device_generic_state", "entity": "sensor.fritz_box_7530_ax_ultimo_riavvio", - "label": "[[[\n const eventTime = new Date(entity.state);\n const now = new Date();\n const diffMin = Math.floor((now - eventTime) / 60000);\n return `${diffMin} minuti fa`;\n]]]\n", + "label": "[[[\n const eventTime = new Date(entity.state);\n const now = new Date();\n const diffMs = now - eventTime;\n \n const diffMin = Math.floor(diffMs / 60000);\n const diffHrs = Math.floor(diffMs / 3600000);\n const diffDays = Math.floor(diffMs / 86400000);\n \n let timeAgo;\n \n if (diffMin < 60) {\n timeAgo = `${diffMin} minuti fa`;\n } else if (diffHrs < 24) {\n timeAgo = `${diffHrs} ore fa`;\n } else {\n timeAgo = `${diffDays} giorni fa`;\n }\n \n return timeAgo;\n]]]\n", "show_state": false, "show_label": true, "name": "Ultimo Riavvio" @@ -491,7 +491,7 @@ "type": "custom:button-card", "template": "template_device_generic_state", "entity": "sensor.fritz_box_7590_ultimo_riavvio", - "label": "[[[\n const eventTime = new Date(entity.state);\n const now = new Date();\n const diffMin = Math.floor((now - eventTime) / 60000);\n return `${diffMin} minuti fa`;\n]]]\n", + "label": "[[[\n const eventTime = new Date(entity.state);\n const now = new Date();\n const diffMs = now - eventTime;\n \n const diffMin = Math.floor(diffMs / 60000);\n const diffHrs = Math.floor(diffMs / 3600000);\n const diffDays = Math.floor(diffMs / 86400000);\n \n let timeAgo;\n \n if (diffMin < 60) {\n timeAgo = `${diffMin} minuti fa`;\n } else if (diffHrs < 24) {\n timeAgo = `${diffHrs} ore fa`;\n } else {\n timeAgo = `${diffDays} giorni fa`;\n }\n \n return timeAgo;\n]]]\n", "show_state": false, "show_label": true, "name": "Ultimo Riavvio" -- 2.47.3