lumnik. / scénarios Tous les scénarios · English

Lyon tire 18,7 kW la nuit et seule sa responsable est alertée

Objectif Être alerté quand un site fermé consomme au-delà de son seuil de nuit, sans alerter les sites où cette charge est normale.

Trois compteurs publient leur puissance sur Kafka à 23 h 15. Un registre CSV dit ce qu'est chaque site.

sites.csv
site_id,site_name,activity,night_baseline_kw,night_alert_kw,energy_owner,owner_email,tariff,context
SITE-LYON,Lyon Assembly Plant,Industrial assembly,4,10,Elodie Martin,elodie.martin@example.test,Peak and off-peak,Production must be stopped after 22:00
SITE-OFFICE,Paris Operations Office,Office,1,3,Karim Benali,karim.benali@example.test,Commercial standard,Only network and security systems stay powered
SITE-LAB,Grenoble Materials Laboratory,Research laboratory,28,40,Dr. Maya Laurent,maya.laurent@example.test,Research continuity,Climate chambers run continuously overnight
calibration.jsonl
{"reading_id":"CAL-LYON","meter_id":"MTR-042","site_id":"SITE-LYON","measured_at":"2026-10-15T17:00:00Z","power_kw":7.2,"period":"OPEN"}
{"reading_id":"CAL-OFFICE","meter_id":"MTR-101","site_id":"SITE-OFFICE","measured_at":"2026-10-15T17:00:00Z","power_kw":2.4,"period":"OPEN"}
{"reading_id":"CAL-LAB","meter_id":"MTR-207","site_id":"SITE-LAB","measured_at":"2026-10-15T17:00:00Z","power_kw":31.0,"period":"OPEN"}
manifests/30-enriched-reading.yaml
kind: Entityname: ScenarioEnergyReadingNdescription: "A live electricity reading enriched with the site's operating context."match: [reading_id]scopes: [energy]columns:  reading_id: { label: "Reading" }  meter_id: { label: "Meter" }  site_id: { label: "Site code" }  site_name: { label: "Site" }  power_kw: { label: "Power (kW)" }  period: { label: "Operating period" }  night_alert_kw: { label: "Night alert threshold (kW)" }  energy_owner: { label: "Energy owner" }  owner_email: { label: "Owner email" }  context: { label: "Operating context" }sources:  - table: t_scenario_energy_readings_n    map:      reading_id: reading_id      meter_id: meter_id      site_id: site_id      measured_at: measured_at      power_kw: power_kw      period: periodjoins:  - table: t_scenario_energy_sites_n    from: site_id    to: site_id    map:      site_name: site_name      activity: activity      night_baseline_kw: night_baseline_kw      night_alert_kw: night_alert_kw      energy_owner: energy_owner      owner_email: owner_email      tariff: tariff      context: context
manifests/40-factory-policy.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata:  name: scenario-energy-factory-nspec:  scope: energy  on:    event: data.row.changed    table: connector.t_scenario_energy_readings_n  when:    - site_id=SITE-LYON    - period=CLOSED    - power_kw>10  emit:    type: decision.energy-after-hours-factory-n    message: "Meter {meter_id} at {site_id}: {power_kw} kW while the site is closed"
manifests/41-office-policy.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata:  name: scenario-energy-office-nspec:  scope: energy  on:    event: data.row.changed    table: connector.t_scenario_energy_readings_n  when:    - site_id=SITE-OFFICE    - period=CLOSED    - power_kw>3  emit:    type: decision.energy-after-hours-office-n    message: "Meter {meter_id} at {site_id}: {power_kw} kW while the office is closed"
manifests/42-laboratory-policy.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata:  name: scenario-energy-laboratory-nspec:  scope: energy  on:    event: data.row.changed    table: connector.t_scenario_energy_readings_n  when:    - site_id=SITE-LAB    - period=CLOSED    - power_kw>40  emit:    type: decision.energy-after-hours-laboratory-n    message: "Meter {meter_id} at {site_id}: {power_kw} kW above the laboratory night policy"
after-hours.jsonl
{"reading_id":"NIGHT-LYON-1","meter_id":"MTR-042","site_id":"SITE-LYON","measured_at":"2026-10-15T23:15:00Z","power_kw":18.7,"period":"CLOSED"}
{"reading_id":"NIGHT-OFFICE-1","meter_id":"MTR-101","site_id":"SITE-OFFICE","measured_at":"2026-10-15T23:15:00Z","power_kw":0.8,"period":"CLOSED"}
{"reading_id":"NIGHT-LAB-1","meter_id":"MTR-207","site_id":"SITE-LAB","measured_at":"2026-10-15T23:15:00Z","power_kw":28.4,"period":"CLOSED"}
$ lm entity get ScenarioEnergyReadingE --filter reading_id=NIGHT-LAB-1 -o json
[
  {
    "reading_id": "NIGHT-LAB-1",
    "meter_id": "MTR-207",
    "site_id": "SITE-LAB",
    "measured_at": "2026-10-15T23:15:00Z",
    "power_kw": "28.4",
    "period": "CLOSED",
    "site_name": "Grenoble Materials Laboratory",
    "activity": "Research laboratory",
    "night_baseline_kw": "28",
    "night_alert_kw": "40",
    "energy_owner": "Dr. Maya Laurent",
    "owner_email": "maya.laurent@example.test",
    "tariff": "Research continuity",
    "context": "Climate chambers run continuously overnight",
    "_conflicts": "{}"
  }
]
recovery.jsonl
{"reading_id":"NIGHT-LYON-2","meter_id":"MTR-042","site_id":"SITE-LYON","measured_at":"2026-10-15T23:30:00Z","power_kw":3.9,"period":"CLOSED"}

Limites

  • Une politique ne voit que les colonnes de la lecture Kafka : le responsable et le contexte, venus du CSV, ne peuvent pas entrer dans le message de décision en v1.
  • Le destinataire est une règle statique pour ce type de décision ; lumnik ne lit pas l'adresse dans l'entité.
  • lumnik compare une mesure à un seuil déclaré ; il ne diagnostique pas la cause. period=CLOSED vient de la source.
  • Grafana interroge postgres toutes les 5 secondes ; ce n'est pas du streaming.
  • Données synthétiques.

Énergie · trois sites

À 23 h 15, une usine fermée consomme.

Lyon tire 18,7 kW.

Au même moment, le laboratoire de Grenoble tire 28,4 kW.

Sites fictifs · données synthétiques

Le problème

Le même chiffre ne dit pas la même chose partout.

  • Le compteur envoie un code de site et des kW.
  • Le registre CSV dit le type de site et son seuil de nuit.
  • Aucun des deux ne sait qu'un seuil est dépassé.

Rien n'est modifié

Les compteurs, Kafka et le fichier restent en place.

  • Le producteur Kafka ne change pas.
  • Le registre CSV reste à sa place.
  • Aucune application à développer.

Ce qu'il a fallu écrire

when:
  - site_id=SITE-LYON
  - period=CLOSED
  - power_kw>10

Un seuil de nuit par site.

Le scénario complet tient en 6 fichiers de déclaration, 110 lignes.

Ce que reçoit la responsable

Un email, pour Lyon seulement.

Email à Elodie Martin
Meter MTR-042 at SITE-LYON: 18.7 kW while the site is closed

Message réel, rejeu du 3 novembre 2026.

Le silence aussi est une réponse

Le laboratoire tourne toute la nuit.

  • 28,4 kW, pour un seuil de 40 kW.
  • Ses chambres climatiques ne s'arrêtent pas.
  • Aucune décision, aucun email.

La limite

lumnik compare une mesure à un seuil déclaré.

  • Il ne dit pas pourquoi Lyon consomme.
  • « Site fermé » vient de la source, pas d'un calendrier.
  • Le responsable vient du CSV, pas du message.

Essayer

Le scénario se rejoue de bout en bout.

Kafka, CSV, entité, politiques, email et Grafana: chaque étape est publiée avec sa sortie.

Ce scénario demande lumnik Pro.

Voir l'offre →