Kilometrage des vehicules : releves km, km par kWh, capacite estimee (tables, vues, Grafana, formulaire HA)

This commit is contained in:
Tallagrand Thierry
2026-10-04 00:44:24 +02:00
parent fb2f43cc88
commit 24bdbf9fd4
7 changed files with 1110 additions and 1 deletions

View File

@@ -579,6 +579,557 @@
"show": false
}
}
},
{
"type": "xychart",
"pluginVersion": "11.3.0",
"title": "Kilometres contre kWh : le nuage des trajets",
"description": "Un point = l'intervalle entre deux releves du compteur d'un vehicule. kWh consommes = kWh livres par la borne entre les deux releves + (niveau au 1er - niveau au 2nd) x capacite. Les droites sont les references donnees par le proprietaire (JEEP 50 km, VW 42 km, ZERO 200 km pour une charge pleine). Sous la droite : on a roule moins loin par kWh (conduite, froid, chauffage — ou batterie qui s'use). Les intervalles d'une hybride finis batterie vide sont ecartes (km essence possibles).",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"gridPos": {
"x": 0,
"y": 24,
"w": 14,
"h": 11
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"format": "table",
"rawQuery": true,
"editorMode": "code",
"rawSql": "WITH i AS (SELECT * FROM km_intervalle WHERE statut = 'valide'),\ncap AS (SELECT DISTINCT ON (vehicule) capacite_kwh AS c FROM releve_km\n WHERE capacite_kwh > 0 ORDER BY vehicule, ts DESC),\nx AS (SELECT round(kwh_consommes::numeric, 2)::float8 AS x, vehicule, km_parcourus::float8 AS km FROM i\n UNION ALL SELECT 0, NULL, NULL\n UNION ALL SELECT c::float8, NULL, NULL FROM cap)\nSELECT x AS \"kWh consommes\",\n CASE WHEN vehicule = 'JEEP' THEN km END AS \"JEEP\",\n CASE WHEN vehicule = 'VW' THEN km END AS \"VW\",\n CASE WHEN vehicule = 'ZERO' THEN km END AS \"ZERO\",\n round((x * (SELECT autonomie_ref_km / capacite_kwh FROM releve_km\n WHERE vehicule = 'JEEP' AND capacite_kwh > 0 AND autonomie_ref_km > 0 ORDER BY ts DESC LIMIT 1))::numeric, 1)::float8 AS \"Reference JEEP\",\n round((x * (SELECT autonomie_ref_km / capacite_kwh FROM releve_km\n WHERE vehicule = 'VW' AND capacite_kwh > 0 AND autonomie_ref_km > 0 ORDER BY ts DESC LIMIT 1))::numeric, 1)::float8 AS \"Reference VW\",\n round((x * (SELECT autonomie_ref_km / capacite_kwh FROM releve_km\n WHERE vehicule = 'ZERO' AND capacite_kwh > 0 AND autonomie_ref_km > 0 ORDER BY ts DESC LIMIT 1))::numeric, 1)::float8 AS \"Reference ZERO\"\nFROM x ORDER BY 1"
}
],
"fieldConfig": {
"defaults": {
"unit": "lengthkm",
"color": {
"mode": "palette-classic"
},
"custom": {
"show": "points",
"pointSize": {
"fixed": 10
},
"pointShape": "circle",
"lineWidth": 1,
"fillOpacity": 60
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "JEEP"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "VW"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "blue"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "ZERO"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Reference JEEP"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
},
{
"id": "custom.show",
"value": "lines"
},
{
"id": "custom.lineStyle",
"value": {
"fill": "dash",
"dash": [
10,
10
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Reference VW"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "blue"
}
},
{
"id": "custom.show",
"value": "lines"
},
{
"id": "custom.lineStyle",
"value": {
"fill": "dash",
"dash": [
10,
10
]
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "Reference ZERO"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
},
{
"id": "custom.show",
"value": "lines"
},
{
"id": "custom.lineStyle",
"value": {
"fill": "dash",
"dash": [
10,
10
]
}
}
]
}
]
},
"options": {
"mapping": "manual",
"series": [
{
"frame": {
"matcher": {
"id": "byIndex",
"options": 0
}
},
"x": {
"matcher": {
"id": "byName",
"options": "kWh consommes"
}
},
"y": {
"matcher": {
"id": "byName",
"options": "JEEP"
}
}
},
{
"frame": {
"matcher": {
"id": "byIndex",
"options": 0
}
},
"x": {
"matcher": {
"id": "byName",
"options": "kWh consommes"
}
},
"y": {
"matcher": {
"id": "byName",
"options": "VW"
}
}
},
{
"frame": {
"matcher": {
"id": "byIndex",
"options": 0
}
},
"x": {
"matcher": {
"id": "byName",
"options": "kWh consommes"
}
},
"y": {
"matcher": {
"id": "byName",
"options": "ZERO"
}
}
},
{
"frame": {
"matcher": {
"id": "byIndex",
"options": 0
}
},
"x": {
"matcher": {
"id": "byName",
"options": "kWh consommes"
}
},
"y": {
"matcher": {
"id": "byName",
"options": "Reference JEEP"
}
}
},
{
"frame": {
"matcher": {
"id": "byIndex",
"options": 0
}
},
"x": {
"matcher": {
"id": "byName",
"options": "kWh consommes"
}
},
"y": {
"matcher": {
"id": "byName",
"options": "Reference VW"
}
}
},
{
"frame": {
"matcher": {
"id": "byIndex",
"options": 0
}
},
"x": {
"matcher": {
"id": "byName",
"options": "kWh consommes"
}
},
"y": {
"matcher": {
"id": "byName",
"options": "Reference ZERO"
}
}
}
],
"legend": {
"showLegend": true,
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single",
"sort": "none"
}
}
},
{
"type": "table",
"title": "Les intervalles entre releves",
"description": "Tous les intervalles, y compris ceux ecartes du nuage, avec la raison. « niveau manquant » : redonner le releve avec le niveau (« JEEP 112694 km 54 % »).",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"format": "table",
"rawQuery": true,
"editorMode": "code",
"rawSql": "SELECT vehicule AS \"Vehicule\",\n to_char(debut AT TIME ZONE 'Europe/Paris', 'Dy DD/MM HH24:MI') AS \"Du\",\n to_char(fin AT TIME ZONE 'Europe/Paris', 'Dy DD/MM HH24:MI') AS \"Au\",\n km_parcourus AS \"km\",\n round(kwh_charges::numeric, 2) AS \"kWh borne\",\n niveau_debut || ' -> ' || niveau_fin || ' %' AS \"Niveau\",\n round(kwh_consommes::numeric, 2) AS \"kWh consommes\",\n round(km_par_kwh::numeric, 1) AS \"km/kWh\",\n round(km_par_kwh_ref::numeric, 1) AS \"Reference\",\n statut AS \"Statut\"\nFROM km_intervalle ORDER BY fin DESC"
}
],
"gridPos": {
"x": 14,
"y": 24,
"w": 10,
"h": 11
},
"fieldConfig": {
"defaults": {
"custom": {
"align": "left",
"cellOptions": {
"type": "auto"
},
"filterable": true
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "kWh borne"
},
"properties": [
{
"id": "unit",
"value": "kwatth"
}
]
},
{
"matcher": {
"id": "byName",
"options": "kWh consommes"
},
"properties": [
{
"id": "unit",
"value": "kwatth"
}
]
}
]
},
"options": {
"showHeader": true,
"cellHeight": "sm",
"footer": {
"show": false
}
}
},
{
"type": "timeseries",
"title": "Capacite estimee des batteries (usure)",
"description": "Un point = un branchement ou le niveau a ete donne et la charge menee au plein (ou suivie d'un releve « debranche a NN % ») : capacite = kWh livres par la borne depuis le branchement / part manquante. Ce sont des kWh AU COMPTEUR (pertes du chargeur comprises). Une pente descendante sur des mois = usure de la batterie. Le niveau saisi est un entier : sur une petite charge, 1 point d'erreur pese lourd.",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"format": "time_series",
"rawQuery": true,
"editorMode": "code",
"rawSql": "SELECT debranche AS time,\n CASE WHEN vehicule = 'JEEP' THEN capacite_kwh END AS \"JEEP\",\n CASE WHEN vehicule = 'VW' THEN capacite_kwh END AS \"VW\",\n CASE WHEN vehicule = 'ZERO' THEN capacite_kwh END AS \"ZERO\"\nFROM capacite_estimee WHERE capacite_kwh IS NOT NULL AND $__timeFilter(debranche)\nORDER BY 1"
}
],
"gridPos": {
"x": 0,
"y": 35,
"w": 14,
"h": 9
},
"fieldConfig": {
"defaults": {
"unit": "kwatth",
"color": {
"mode": "palette-classic"
},
"custom": {
"lineWidth": 2,
"fillOpacity": 8,
"showPoints": "always",
"spanNulls": false,
"axisBorderShow": false,
"gradientMode": "opacity",
"drawStyle": "points",
"pointSize": 10
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "JEEP"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "green"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "VW"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "blue"
}
}
]
},
{
"matcher": {
"id": "byName",
"options": "ZERO"
},
"properties": [
{
"id": "color",
"value": {
"mode": "fixed",
"fixedColor": "purple"
}
}
]
}
]
},
"options": {
"legend": {
"displayMode": "list",
"placement": "bottom",
"showLegend": true,
"calcs": []
},
"tooltip": {
"mode": "multi",
"sort": "desc"
}
}
},
{
"type": "table",
"title": "Les releves du compteur",
"description": "Releves recus par WhatsApp (concierge) ou par le tableau EVCS Master. Un releve fait au branchement est date du branchement : le compteur n'avance pas pendant la charge.",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"targets": [
{
"refId": "A",
"datasource": {
"type": "grafana-postgresql-datasource",
"uid": "evcs-pg"
},
"format": "table",
"rawQuery": true,
"editorMode": "code",
"rawSql": "SELECT to_char(ts AT TIME ZONE 'Europe/Paris', 'Dy DD/MM HH24:MI') AS \"Quand\",\n vehicule AS \"Vehicule\", km AS \"Compteur\",\n coalesce(niveau_pct || ' %', '?') AS \"Niveau\", source AS \"Source\"\nFROM releve_km ORDER BY ts DESC"
}
],
"gridPos": {
"x": 14,
"y": 35,
"w": 10,
"h": 9
},
"fieldConfig": {
"defaults": {
"custom": {
"align": "left",
"cellOptions": {
"type": "auto"
},
"filterable": true
}
},
"overrides": [
{
"matcher": {
"id": "byName",
"options": "Compteur"
},
"properties": [
{
"id": "unit",
"value": "lengthkm"
}
]
}
]
},
"options": {
"showHeader": true,
"cellHeight": "sm",
"footer": {
"show": false
}
}
}
]
}