# Agent App — `etm_powersync_app` > Lire aussi le `CLAUDE.md` du dossier parent avant de commencer. --- ## Mon rôle Interface utilisateur Flutter du HEMS ETM-PowerSync. Je communique **exclusivement via JSON-RPC nymea port 4444**. Le gating des features par tier est géré visuellement ici, mais la source de vérité du tier est dans `powersync-optimizer`. --- ## Stack technique | Élément | Valeur | |---|---| | Flutter SDK | ^3.11.0 | | State management | `provider ^6.1.2` — `NymeaService` (ChangeNotifier) | | Navigation | `go_router ^14.6.3` — ShellRoute + 25+ routes | | Transport | WebSocket port 4444 / TCP brut port 2222 | | Graphiques | `fl_chart ^0.70.2` | | Persistance | `shared_preferences ^2.3.2` | | Sécurité installateur | `crypto ^3.0.6` (PIN SHA-256) | --- ## 🔴 Bug critique — à corriger en priorité absolue ```dart // ❌ FAUX — ne déclenche pas le SmartChargingManager nymeaService.call('Energy.SetChargingMode', {'mode': 'pv'}); // ✅ CORRECT — appelle vraiment le plugin ETM nymeaService.call('EnergyPlugin.SetChargingInfo', { 'chargingInfo': { 'evChargerId': chargerId, 'mode': 'Eco', // Eco | EcoWithMinCurrent | Normal // EcoWithTargetTime | EcoMinWithTargetTime 'minCurrent': 6, // requis pour EcoWithMinCurrent/* 'targetSoc': 80, // requis pour *WithTargetTime 'endTime': null, // requis pour *WithTargetTime } }); ``` ### Modes UI EV — 3 boutons + option deadline ``` [PV] [Min+PV] [Boost] ↓ Option deadline ? → afficher champs SOC cible + heure d'arrivée PV → mode: Eco Min+PV → mode: EcoWithMinCurrent, minCurrent: 6 Boost → mode: Normal PV + deadline → mode: EcoWithTargetTime, targetSoc, endTime Min+PV+deadline → mode: EcoMinWithTargetTime, minCurrent, targetSoc, endTime ``` --- ## APIs JSON-RPC consommées ### `Energy.*` — nymea-experience-plugin-energy | Méthode | Usage | Tier | |---|---|---| | `GetPowerBalance` | Dashboard temps réel | Community | | `GetPowerBalanceLogs(sampleRate, from, to)` | Historique — envoyer les bons `from/to` pour 90j | Community | | `GetThingPowerLogs(sampleRate, thingIds[], from, to)` | Historique par device | Community | | `SetRootMeter(rootMeterThingId)` | Config installateur | Community | ### `EnergyPlugin.*` — powersync-energy-plugin-etm | Méthode | Usage | Tier | |---|---|---| | `GetChargingInfos(evChargerId)` | Lire config EV | Community | | `SetChargingInfo(chargingInfo)` | **⚠️ CORRECTION CRITIQUE** | Community | | `GetChargingSchedules(evChargerId)` | Planning EV | Community | | `GetAvailableSpotMarketProviders()` | Liste providers | Community | | `SetSpotMarketConfiguration(enabled, providerId)` | Config tarif dynamique | Predict AI | | `GetSpotMarketScoreEntries(date)` | Cotations aWATTar | Predict AI | | `SetPhasePowerLimit(Uint)` | Config installateur | Community | | `SetAcquisitionTolerance(Double)` | Seuil surplus | Community | ### `AirConditioning.*` — nymea-experience-plugin-airconditioning | Méthode | Usage | Tier | |---|---|---| | `GetZones` | Afficher zones PAC/thermostat | Auto | | `SetZoneSetpointOverride` | Pilotage manuel | Auto | | `SetZoneWeekSchedule` | Planning 7 jours | Auto | ### `Rules.*` — nymea core | Méthode | Usage | Tier | |---|---|---| | `GetRules` | Lecture automatisations | Community | | `AddRule` | Créer règle HP/HC, surplus → relais | Community | | `RemoveRule / EditRule` | Gérer règles | Community | --- ## État des écrans | Écran | État | Action requise | |---|---|---| | Dashboard (Sankey + EV card) | ✅ | Corriger API EV + brancher notifications | | EnergyScreen (4 onglets) | ✅ | Ajouter sélecteur plage 90j | | ThingsScreen + ThingDetail | ✅ | — | | FavoritesScreen | ✅ | Persister dans SharedPreferences | | InstallerMode (PIN SHA-256) | ✅ | — | | RoleConfigFlow wizard | ⚠️ Stub | Brancher sur vrais RPC | | TariffScreen | ⚠️ Stub | Brancher `SetSpotMarketConfiguration` | | SchedulerScreen | ⚠️ Stub | Brancher `GetChargingSchedules` | | TimelineScreen | ⚠️ Stub | Brancher scheduler réel | | AirConditioning zones | ❌ Absent | Créer (Auto) | | Rules UI (automatisations) | ❌ Absent | Créer (Community) | | DeveloperScreen | ❌ Vide | Créer | | AboutScreen | ❌ Vide | Créer | --- ## Persistance — tout doit survivre au redémarrage | Donnée | État | Action | |---|---|---| | Adresse serveur, PIN, préférences UI | ✅ SharedPreferences | — | | `RoleAssignments` | ❌ Mémoire | Persister SharedPreferences | | `FavoriteWidgets` | ❌ Mémoire | Persister SharedPreferences | | `TariffConfig` / `HcHpConfig` | ❌ Mémoire | Persister SharedPreferences | | `SchedulerConfig` | ❌ Mémoire | Persister SharedPreferences | --- ## Feature gating par tier ```dart // TierProvider — à créer, lit le tier depuis le plugin via RPC // En attendant : valeur par défaut 'community' if (tierProvider.tier >= Tier.auto) { // afficher feature Auto } // Utiliser pro_lock_badge.dart (déjà présent) pour verrouiller visuellement ``` ### Features par tier | Feature | Community | Auto | Predict AI | |---|---|---|---| | Dashboard temps réel | ✅ | ✅ | ✅ | | Config EV (SetChargingInfo) | ✅ | ✅ | ✅ | | Tarif HP/HC statique | ✅ | ✅ | ✅ | | UI automatisations (Rules.*) | ✅ | ✅ | ✅ | | Historique 90 jours | 🔒 | ✅ | ✅ | | Wizard onboarding | 🔒 | ✅ | ✅ | | Zones PAC/ECS (AirConditioning.*) | 🔒 | ✅ | ✅ | | Prévision solaire Open-Meteo | 🔒 | ✅ | ✅ | | Notifications d'anomalies | 🔒 | ✅ | ✅ | | Accès distant sécurisé | 🔒 | ✅ | ✅ | | Tarifs dynamiques aWATTar | 🔒 | 🔒 | ✅ | | Accès fonctionnalités beta | 🔒 | 🔒 | ✅ | --- ## Thème — utiliser `app_theme.dart` systématiquement ```dart primaryGreen solarYellow gridGray homeBlue batteryGreen boostRed pvGreen minPvBlue accentTeal ``` --- ## Règles de modification - Tout nouvel écran → valider maquette avec Patrick avant de coder - Tout nouvel appel RPC → vérifier dans `INTERFACE.md` que la méthode existe - Ne jamais appeler `Energy.SetChargingMode` pour piloter un EV - Toujours tester la persistance : killer l'app et vérifier que les données survivent - Flavors à configurer : `com.etm-powersync.community` / `.auto` / `.predictai`