From: Giorgio Ravera Date: Mon, 25 Aug 2025 20:20:09 +0000 (+0200) Subject: Minor fix to lovelace for fritz X-Git-Url: http://git.giorgioravera.it/?a=commitdiff_plain;h=8c7db13f14adafba861068fcdaf38a5799a90a17;p=homeassistant.git Minor fix to lovelace for fritz --- 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"