commit 93409b6f71e704b9fd0774bec0d4ac052e5e1c33 Author: Anismahi Date: Mon Mar 9 13:58:12 2026 +0100 Initial commit diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..ae0901d Binary files /dev/null and b/.DS_Store differ diff --git a/index.html b/index.html new file mode 100644 index 0000000..71f2787 --- /dev/null +++ b/index.html @@ -0,0 +1,133 @@ + + + + + + + Station Solaire | Dashboard PRO + + + + + + + + + + + +
+
+ +
+
+
+
+ Météo & Env. +
+ +
+ Via API Web + (Serveur) +
+ +
+

--°C

+ En + attente... +
+
+
+ +
+ Capteur Local + (DHT11) +
+
+

--

+

Temp

+
+
+

--

+

Hum

+
+
+
+ + +
+
+
+ +
+
+
+
Production Solaire
+
+
+ Espace Étudiant + 1 +
+
+
+
+
+ +
+
+
+
État Batterie
+
+
+ Espace Étudiant + 2 +
+
+
+
+
+ +
+
+
+
Administration
+
+
+ Espace Étudiant + 4 +
+
+
+
+
+ +
+
+ + + + + \ No newline at end of file diff --git a/schema/.DS_Store b/schema/.DS_Store new file mode 100644 index 0000000..ffe63e4 Binary files /dev/null and b/schema/.DS_Store differ diff --git a/schema/schemaprojet/.DS_Store b/schema/schemaprojet/.DS_Store new file mode 100644 index 0000000..8cb89dd Binary files /dev/null and b/schema/schemaprojet/.DS_Store differ diff --git a/schema/schemaprojet/Capture d’écran 2026-03-08 à 09.26.45.png b/schema/schemaprojet/Capture d’écran 2026-03-08 à 09.26.45.png new file mode 100644 index 0000000..f7a38fe Binary files /dev/null and b/schema/schemaprojet/Capture d’écran 2026-03-08 à 09.26.45.png differ diff --git a/schema/schemaprojet/Capture d’écran 2026-03-08 à 09.27.01.png b/schema/schemaprojet/Capture d’écran 2026-03-08 à 09.27.01.png new file mode 100644 index 0000000..da22cfb Binary files /dev/null and b/schema/schemaprojet/Capture d’écran 2026-03-08 à 09.27.01.png differ diff --git a/schema/schemaprojet/schema_echocharge.jpg b/schema/schemaprojet/schema_echocharge.jpg new file mode 100644 index 0000000..f1d84a9 Binary files /dev/null and b/schema/schemaprojet/schema_echocharge.jpg differ diff --git a/script.js b/script.js new file mode 100644 index 0000000..02da469 --- /dev/null +++ b/script.js @@ -0,0 +1,115 @@ +// --- VARIABLES D'ÉTAT --- +let isOnline = true; +let lastHeartbeat = Date.now(); +const TIMEOUT_MS = 5000; // 5 secondes pour les tests + +// --- ÉLÉMENTS DU DOM --- +const statusDot = document.getElementById('system-status'); +const statusText = document.getElementById('status-text'); + +const tempEl = document.getElementById('temp-val'); +const humEl = document.getElementById('hum-val'); + +const apiTempEl = document.getElementById('api-temp'); +const apiDescEl = document.getElementById('api-desc'); +const apiIconEl = document.getElementById('api-icon'); + +// ================================================================= +// --- NOUVEAU : GESTION DE LA VRAIE API MÉTÉO (OPEN-METEO) --- +// ================================================================= + +// 1. Traduction des codes météo de l'API en Icônes et Textes +function getWeatherDetails(code) { + if (code === 0) return { desc: "Dégagé", icon: "bi-brightness-high", color: "text-warning" }; + if (code === 1 || code === 2 || code === 3) return { desc: "Nuageux", icon: "bi-cloud", color: "text-light" }; + if (code >= 45 && code <= 48) return { desc: "Brouillard", icon: "bi-cloud-haze", color: "text-secondary" }; + if (code >= 51 && code <= 67) return { desc: "Pluie", icon: "bi-cloud-rain", color: "text-info" }; + if (code >= 71 && code <= 77) return { desc: "Neige", icon: "bi-cloud-snow", color: "text-white" }; + if (code >= 95) return { desc: "Orage", icon: "bi-cloud-lightning", color: "text-danger" }; + return { desc: "Inconnu", icon: "bi-thermometer", color: "text-muted" }; +} + +// 2. Fonction qui va chercher les données sur Internet +async function fetchRealWeather() { + try { + // --- METS LES COORDONNÉES DE TA VILLE ICI --- + const lat = 48.8566; // Latitude (Ex: Paris) + const lon = 2.3522; // Longitude (Ex: Paris) + + // L'URL magique de l'API Open-Meteo + const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}¤t=temperature_2m,weather_code`; + + // On lance la requête + const response = await fetch(url); + const data = await response.json(); // On convertit la réponse en JSON + + // On extrait la température et le code météo + const temp = data.current.temperature_2m; + const code = data.current.weather_code; + + // On récupère la bonne icône et le bon texte + const weather = getWeatherDetails(code); + + // On met à jour l'interface HTML ! + apiTempEl.innerText = temp + "°C"; + apiDescEl.innerText = weather.desc; + apiIconEl.className = "bi " + weather.icon + " " + weather.color + " display-4 me-3"; + + } catch (error) { + console.error("Erreur avec l'API Météo:", error); + apiDescEl.innerText = "Erreur Web"; + apiIconEl.className = "bi bi-wifi-off text-danger display-4 me-3"; + } +} + +// ================================================================= + +// --- FONCTION DE MISE À JOUR DES DONNÉES LOCALES (Ton DHT11) --- +function fetchLocalData() { + if (!isOnline) return; + + // Simulation de ton capteur DHT11 local + tempEl.innerText = (22 + (Math.random() * 2 - 1)).toFixed(1); + humEl.innerText = Math.floor(45 + Math.random() * 5); + + lastHeartbeat = Date.now(); +} + +// --- FONCTION WATCHDOG (LE HEARTBEAT) --- +function checkSystemStatus() { + if (Date.now() - lastHeartbeat > TIMEOUT_MS) { + statusDot.className = "status-dot rounded-circle pulse-offline"; + statusText.innerText = "HORS LIGNE"; + statusText.style.color = "#ef4444"; + } else { + statusDot.className = "status-dot rounded-circle pulse-online"; + statusText.innerText = "EN LIGNE"; + statusText.style.color = "#e2e8f0"; + } +} + +// --- LANCEMENT DES PROGRAMMES --- + +// 1. Lancer la météo Web une première fois tout de suite +fetchRealWeather(); + +// 2. Les boucles automatiques +setInterval(fetchLocalData, 3000); // Mise à jour de ton capteur local toutes les 3s +setInterval(checkSystemStatus, 1000); // Surveillance de la connexion + +// ATTENTION: On ne met à jour la météo Web que toutes les 15 minutes (900 000 ms) +// pour ne pas saturer l'API gratuite et se faire bloquer ! +setInterval(fetchRealWeather, 900000); + +// --- GESTION DU BOUTON DE TEST --- +document.getElementById('btn-test').addEventListener('click', function () { + isOnline = !isOnline; + if (isOnline) { + this.innerHTML = ' Simuler Coupure'; + this.classList.replace('btn-outline-success', 'btn-outline-danger'); + lastHeartbeat = Date.now(); + } else { + this.innerHTML = ' Rétablir Connexion'; + this.classList.replace('btn-outline-danger', 'btn-outline-success'); + } +}); \ No newline at end of file diff --git a/style.css b/style.css new file mode 100644 index 0000000..ea6e33e --- /dev/null +++ b/style.css @@ -0,0 +1,81 @@ +/* --- COULEURS GLOBALES ET THEME SOMBRE --- */ +body { + background-color: #0f172a; + color: #e2e8f0; +} + +.navbar { + background-color: #1e293b !important; + border-bottom: 1px solid #334155; +} + +/* --- DESIGN DES WIDGETS (CARTES) --- */ +.card { + background-color: #1e293b; + border: 1px solid #334155; + min-height: 320px; + box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5); +} + +.card-meteo { + border-top: 4px solid #38bdf8; +} + +.card-solaire { + border-top: 4px solid #fbbf24; +} + +.card-batterie { + border-top: 4px solid #34d399; +} + +.card-admin { + border-top: 4px solid #f87171; +} + +/* --- ANIMATION DU HEARTBEAT --- */ +.status-dot { + width: 14px; + height: 14px; + display: inline-block; +} + +.pulse-online { + background-color: #22c55e; + box-shadow: 0 0 12px #22c55e; + animation: pulse-green 2s infinite; +} + +.pulse-offline { + background-color: #ef4444; + box-shadow: 0 0 15px #ef4444; +} + +@keyframes pulse-green { + 0% { + transform: scale(0.95); + box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7); + } + + 70% { + transform: scale(1); + box-shadow: 0 0 0 10px rgba(34, 197, 94, 0); + } + + 100% { + transform: scale(0.95); + box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); + } +} + +/* --- TYPOGRAPHIE ET ELEMENTS VISUELS --- */ +.data-value { + color: #e0f2fe; + text-shadow: 0 0 10px rgba(56, 189, 248, 0.3); +} + +.placeholder-box { + border: 2px dashed #475569; + background-color: #0f172a; + color: #94a3b8; +} \ No newline at end of file