1) GLISSEMENT — diagnostic d'abord, et il a donné DEUX réponses. Le geste n'est PAS avalé par le ListView parent : les deux montages du test (section seule / section imbriquée) glissent identiquement. La cause du symptôme était bien que .75 n'a qu'une charge par domaine — rien à réordonner. Mais l'enquête a trouvé un vrai défaut au passage : le centre de la poignée tombait dans le vide de 3 px séparant l'icône de la pastille de rang, et ReorderableDragStartListener défère le test de collision à ses enfants. Une bande morte invisible au milieu d'une poignée qui paraît d'un seul tenant. Corrigé par un Container transparent. Tentative faite et ANNULÉE : rendre les domaines glissables aussi. Deux ReorderableListView imbriqués se disputent le geste et l'extérieur gagne — le glissement des cartes cassait. Les domaines gardent leurs flèches, et une charge seule dans son domaine n'offre plus de prise qui mènerait nulle part (avec l'infobulle qui renvoie au bon geste). Vérifié SUR L'APPAREIL, contre .75, avec les deux charges mises dans le même domaine : [chauffe-eau, pac-terrain] → [pac-terrain, chauffe-eau], brouillon abandonné sans rien écrire. Classement ecs/hvac rétabli ensuite. 2) SÉLECTEUR DE MÉCANISME — actif, et c'était le morceau délicat. LoadConfig est une union discriminée : écrire `adapter` sans nettoyer le reste produit une configuration que la box refuse EN BLOC, et le refus emporte toutes les charges de l'appel. D'où basculerMecanisme(), qui retire les clés du mécanisme quitté et pose celles du nouveau, en récupérant ce qui peut l'être — les deux premiers contacts deviennent SG1/SG2 dans l'encodage standard, les relais gardent leur puissance. Ce qui n'est PAS transposé : l'estimation d'un état SG-Ready n'est pas la puissance d'une résistance. La charge produite est alors incomplète, et c'est voulu — le formulaire réclame plutôt que d'inventer une valeur de plaque. La bascule franchit sameHardware() : confirmation préalable qui annonce la reconstruction et la durée de réarmement (900 s par défaut vers SG-Ready — la valeur d'une PAC réelle, pas celle du banc). Le mode fixed d'etmvariableload reste LISIBLE sans être proposé : bloc « Configuration héritée » en lecture seule, et conversion seulement sur geste explicite, avec le plafond que la déclaration en paliers ne porte pas. Ouvrir l'écran ne convertit personne. 3) CHIP DE DOMAINE — il ne rendait qu'une icône muette : le domaine d'une charge était illisible sur sa carte, alors qu'il décide de son groupe et de son rang. Il porte maintenant son libellé, et sa couleur suit le thème. 4) THÈME — les 11 derniers sites (pas 9) basculés. Trois cas : contexte disponible (main, ac_screen) ; peintre sans contexte, à qui la couleur est passée résolue (energy_flow_widget) ; tables statiques, où la teinte devient nullable et se résout au rendu (categoryInfoMap, favoris). Plus AUCUN jeton hors thème dans lib/. 5) ZONES — non entreprises, comme convenu. Tests 93/93, analyze 0 erreur. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HajXLUczEyZd22JeewRfff
213 lines
8.6 KiB
Dart
213 lines
8.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import '../theme/etm_tokens.dart';
|
|
import 'nymea_models.dart';
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// Catégories affichées dans le Things screen
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
enum ThingCategory {
|
|
energy, // smartmeter, energymeter, powersocket
|
|
solar, // solarinverter, solarpanel
|
|
battery, // battery, energystorage
|
|
evCharger, // evcharger, wallbox
|
|
cars, // evvehicle, electricvehicle + class name "car"/"vehicle"
|
|
hvac, // thermostat, heatingzone, ac, pump
|
|
lighting, // light, dimmablelight, colorlight
|
|
sensors, // sensor, temperaturesensor, humiditysensor, motionsensor
|
|
network, // networkdevice, gateway
|
|
notifications, // pushnotification, email, sms
|
|
media, // mediadevice, mediaplayer
|
|
weather, // weather
|
|
other, // tout le reste
|
|
}
|
|
|
|
class ThingCategoryInfo {
|
|
final ThingCategory category;
|
|
final String label;
|
|
final IconData icon;
|
|
|
|
/// Teinte d'identité de la catégorie, ou `null` pour « **neutre** ».
|
|
///
|
|
/// Une table statique n'a pas de `BuildContext` : une catégorie sans teinte propre ne
|
|
/// peut donc pas y figer un gris, qui dépend du thème. `null` dit « neutre » et
|
|
/// [colorOf] le résout au rendu — c'est ce qui rend ces deux catégories lisibles en
|
|
/// sombre, où le gris clair devenait illisible.
|
|
final Color? color;
|
|
|
|
const ThingCategoryInfo({
|
|
required this.category,
|
|
required this.label,
|
|
required this.icon,
|
|
this.color,
|
|
});
|
|
|
|
/// Teinte effective : celle de la catégorie, ou le gris neutre du thème courant.
|
|
Color colorOf(BuildContext c) => color ?? EtmTokens.mutedOf(c);
|
|
}
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// Mapping interface nymea → catégorie
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
const Map<String, ThingCategory> interfaceToCategoryMap = {
|
|
'smartmeter': ThingCategory.energy,
|
|
'electricmeter': ThingCategory.energy,
|
|
'energymeter': ThingCategory.energy,
|
|
'smartenergymeter': ThingCategory.energy,
|
|
'extendedsmartmeter': ThingCategory.energy,
|
|
'powersocket': ThingCategory.energy,
|
|
'smartplug': ThingCategory.energy,
|
|
'solarinverter': ThingCategory.solar,
|
|
'solarpanel': ThingCategory.solar,
|
|
'inverter': ThingCategory.solar,
|
|
'battery': ThingCategory.battery,
|
|
'energystorage': ThingCategory.battery,
|
|
'batterymonitor': ThingCategory.battery,
|
|
'evcharger': ThingCategory.evCharger,
|
|
'wallbox': ThingCategory.evCharger,
|
|
'evvehicle': ThingCategory.cars,
|
|
'electricvehicle': ThingCategory.cars,
|
|
'electriccar': ThingCategory.cars,
|
|
'vehicle': ThingCategory.cars,
|
|
'thermostat': ThingCategory.hvac,
|
|
'heatingzone': ThingCategory.hvac,
|
|
'ac': ThingCategory.hvac,
|
|
'airconditioner': ThingCategory.hvac,
|
|
'pump': ThingCategory.hvac,
|
|
'heatpump': ThingCategory.hvac,
|
|
'simpleheatpump': ThingCategory.hvac, // interfaces réelles (hems)
|
|
'smartgridheatpump': ThingCategory.hvac,
|
|
'ventilation': ThingCategory.hvac,
|
|
'boiler': ThingCategory.hvac,
|
|
'light': ThingCategory.lighting,
|
|
'dimmablelight': ThingCategory.lighting,
|
|
'colorlight': ThingCategory.lighting,
|
|
'colortemperaturelight': ThingCategory.lighting,
|
|
'sensor': ThingCategory.sensors,
|
|
'temperaturesensor': ThingCategory.sensors,
|
|
'humiditysensor': ThingCategory.sensors,
|
|
'pressuresensor': ThingCategory.sensors,
|
|
'motionsensor': ThingCategory.sensors,
|
|
'doorsensor': ThingCategory.sensors,
|
|
'windowsensor': ThingCategory.sensors,
|
|
'smokesensor': ThingCategory.sensors,
|
|
'co2sensor': ThingCategory.sensors,
|
|
'lightsensor': ThingCategory.sensors,
|
|
'networkdevice': ThingCategory.network,
|
|
'gateway': ThingCategory.network,
|
|
'router': ThingCategory.network,
|
|
'pushnotification': ThingCategory.notifications,
|
|
'notificationservice': ThingCategory.notifications,
|
|
'notification': ThingCategory.notifications,
|
|
'email': ThingCategory.notifications,
|
|
'sms': ThingCategory.notifications,
|
|
'weather': ThingCategory.weather,
|
|
'weatherstation': ThingCategory.weather,
|
|
'mediadevice': ThingCategory.media,
|
|
'mediaplayer': ThingCategory.media,
|
|
};
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// Infos visuelles par catégorie
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
Map<ThingCategory, ThingCategoryInfo> categoryInfoMap = {
|
|
ThingCategory.energy: ThingCategoryInfo(
|
|
category: ThingCategory.energy,
|
|
label: 'Compteurs & Prises',
|
|
icon: Icons.electrical_services_rounded,
|
|
),
|
|
ThingCategory.solar: ThingCategoryInfo(
|
|
category: ThingCategory.solar,
|
|
label: 'Solaire',
|
|
icon: Icons.solar_power_rounded,
|
|
color: EtmTokens.amber,
|
|
),
|
|
ThingCategory.battery: ThingCategoryInfo(
|
|
category: ThingCategory.battery,
|
|
label: 'Stockage',
|
|
icon: Icons.battery_charging_full_rounded,
|
|
color: EtmTokens.green,
|
|
),
|
|
ThingCategory.evCharger: ThingCategoryInfo(
|
|
category: ThingCategory.evCharger,
|
|
label: 'Chargeurs EV',
|
|
icon: Icons.electric_car_rounded,
|
|
color: EtmTokens.blue,
|
|
),
|
|
ThingCategory.cars: ThingCategoryInfo(
|
|
category: ThingCategory.cars,
|
|
label: 'Véhicules',
|
|
icon: Icons.directions_car_rounded,
|
|
color: EtmTokens.blue,
|
|
),
|
|
ThingCategory.hvac: ThingCategoryInfo(
|
|
category: ThingCategory.hvac,
|
|
label: 'Chauffage & Clim',
|
|
icon: Icons.thermostat_rounded,
|
|
color: EtmTokens.orange,
|
|
),
|
|
ThingCategory.lighting: ThingCategoryInfo(
|
|
category: ThingCategory.lighting,
|
|
label: 'Éclairage',
|
|
icon: Icons.lightbulb_rounded,
|
|
color: EtmTokens.amber,
|
|
),
|
|
ThingCategory.sensors: ThingCategoryInfo(
|
|
category: ThingCategory.sensors,
|
|
label: 'Capteurs',
|
|
icon: Icons.sensors_rounded,
|
|
color: EtmTokens.blue,
|
|
),
|
|
ThingCategory.network: ThingCategoryInfo(
|
|
category: ThingCategory.network,
|
|
label: 'Réseau',
|
|
icon: Icons.router_rounded,
|
|
color: Color(0xFF7C4DFF),
|
|
),
|
|
ThingCategory.notifications: ThingCategoryInfo(
|
|
category: ThingCategory.notifications,
|
|
label: 'Notifications',
|
|
icon: Icons.notifications_rounded,
|
|
color: Color(0xFFEC407A),
|
|
),
|
|
ThingCategory.weather: ThingCategoryInfo(
|
|
category: ThingCategory.weather,
|
|
label: 'Météo',
|
|
icon: Icons.wb_cloudy_rounded,
|
|
color: EtmTokens.blue,
|
|
),
|
|
ThingCategory.media: ThingCategoryInfo(
|
|
category: ThingCategory.media,
|
|
label: 'Multimédia',
|
|
icon: Icons.speaker_rounded,
|
|
color: Color(0xFFAB47BC),
|
|
),
|
|
ThingCategory.other: ThingCategoryInfo(
|
|
category: ThingCategory.other,
|
|
label: 'Autres',
|
|
icon: Icons.device_hub_rounded,
|
|
),
|
|
};
|
|
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
// Extension utilitaire sur NymeaThingClass
|
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
|
|
extension ThingClassCategoryExt on NymeaThingClass {
|
|
ThingCategory get category {
|
|
for (final iface in interfaces) {
|
|
final cat = interfaceToCategoryMap[iface.toLowerCase()];
|
|
if (cat != null) return cat;
|
|
}
|
|
// Fallback : nom de classe contient "car" ou "vehicle" → catégorie Cars
|
|
final lower = name.toLowerCase();
|
|
if (lower.contains('car') || lower.contains('vehicle')) {
|
|
return ThingCategory.cars;
|
|
}
|
|
return ThingCategory.other;
|
|
}
|
|
|
|
ThingCategoryInfo get categoryDetails => categoryInfoMap[category]!;
|
|
} |