]> git.giorgioravera.it Git - homeassistant.git/commitdiff
Minor fix to lovelace for fritz
authorGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 25 Aug 2025 20:20:09 +0000 (22:20 +0200)
committerGiorgio Ravera <giorgio.ravera@gmail.com>
Mon, 25 Aug 2025 20:20:09 +0000 (22:20 +0200)
.storage/lovelace.lovelace_devices

index acce0142f8793526cc7910060bfe76ee4ff7c1ce..032a8fcec725a8bcfb320d99016d1de75b82d126 100644 (file)
                                   "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"
                                   "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"