diff --git a/goodgarden.sql b/goodgarden.sql
index c77be7f..c0e33a4 100644
--- a/goodgarden.sql
+++ b/goodgarden.sql
@@ -3,24 +3,24 @@
-- https://www.phpmyadmin.net/
--
-- Host: 127.0.0.1
--- Gegenereerd op: 14 feb 2024 om 14:36
--- Serverversie: 10.4.28-MariaDB
--- PHP-versie: 8.2.4
+-- Gegenereerd op: 20 mrt 2024 om 10:19
+-- Serverversie: 10.4.32-MariaDB
+-- PHP-versie: 8.2.12
+
+DROP DATABASE IF EXISTS goodgarden;
+CREATE DATABASE goodgarden;
+
+USE goodgarden;
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
-
START TRANSACTION;
-
SET time_zone = "+00:00";
-/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */
-;
-/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */
-;
-/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */
-;
-/*!40101 SET NAMES utf8mb4 */
-;
+
+/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
+/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
+/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
+/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `goodgarden`
@@ -33,47 +33,20 @@ SET time_zone = "+00:00";
--
CREATE TABLE `battery_voltage_events` (
- `id` int(10) UNSIGNED NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
+ `id` int(10) UNSIGNED NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Gegevens worden geëxporteerd voor tabel `battery_voltage_events`
--
-INSERT INTO
- `battery_voltage_events` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 1, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 2, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- ),
- (
- 3, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 4, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- ),
- (
- 5, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 6, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- ),
- (
- 7, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 8, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- ),
- (
- 9, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 10, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- );
+INSERT INTO `battery_voltage_events` (`id`, `timestamp`, `gateway_receive_time`, `device`, `value`) VALUES
+(2185, 1710839863, '2024-03-19T09:17:43Z', 256, 4.03663),
+(2186, 1710842346, '2024-03-19T09:59:06Z', 322, 4.08547);
-- --------------------------------------------------------
@@ -82,23 +55,13 @@ VALUES (
--
CREATE TABLE `devices` (
- `id` int(10) UNSIGNED NOT NULL, `serial_number` varchar(255) DEFAULT NULL, `name` varchar(255) DEFAULT NULL, `label` varchar(255) DEFAULT NULL, `last_seen` int(11) DEFAULT NULL, `last_battery_voltage` float DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
-
---
--- Gegevens worden geëxporteerd voor tabel `devices`
---
-
-INSERT INTO
- `devices` (
- `id`, `serial_number`, `name`, `label`, `last_seen`, `last_battery_voltage`
- )
-VALUES (
- 1, '0033889B1BAB1169', 'firefly2_0051', 'The Field', 1707765066, 4.09768
- ),
- (
- 2, '006FE1FC316ED7D8', 'firefly2_0111', 'The Field', 1707764966, 4.10745
- );
+ `id` int(10) UNSIGNED NOT NULL,
+ `serial_number` varchar(255) DEFAULT NULL,
+ `name` varchar(255) DEFAULT NULL,
+ `label` varchar(255) DEFAULT NULL,
+ `last_seen` int(11) DEFAULT NULL,
+ `last_battery_voltage` float DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
@@ -107,89 +70,12 @@ VALUES (
--
CREATE TABLE `fetch` (
- `id` int(10) UNSIGNED NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
-
---
--- Gegevens worden geëxporteerd voor tabel `fetch`
---
-
-INSERT INTO
- `fetch` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 70, 1707851215, '2024-02-13T19:06:55Z', 322, 0.00000
- ),
- (
- 71, 1707851215, '2024-02-13T19:06:55Z', 322, 1.52000
- ),
- (
- 72, 1707851215, '2024-02-13T19:06:55Z', 322, 12.06000
- ),
- (
- 73, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 74, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- ),
- (75, 0, '', 0, 0.00000),
- (76, 0, '', 0, 0.00000),
- (
- 77, 1707844638, '2024-02-13T17:17:18Z', 322, 0.00000
- ),
- (
- 78, 1707851099, '2024-02-13T19:04:59Z', 256, 0.00000
- ),
- (
- 79, 1707844638, '2024-02-13T17:17:18Z', 322, 71.08984
- ),
- (
- 80, 1707851099, '2024-02-13T19:04:59Z', 256, 66.72949
- ),
- (
- 81, 1707851215, '2024-02-13T19:06:55Z', 322, 0.00000
- ),
- (
- 82, 1707851215, '2024-02-13T19:06:55Z', 322, 1.52000
- ),
- (
- 83, 1707851215, '2024-02-13T19:06:55Z', 322, 12.06000
- ),
- (84, 0, '', 0, 0.00000),
- (85, 0, '', 0, 0.00000),
- (
- 86, 1707844638, '2024-02-13T17:17:18Z', 322, 0.00000
- ),
- (
- 87, 1707851099, '2024-02-13T19:04:59Z', 256, 0.00000
- ),
- (
- 88, 1707844638, '2024-02-13T17:17:18Z', 322, 71.08984
- ),
- (
- 89, 1707851099, '2024-02-13T19:04:59Z', 256, 66.72949
- ),
- (
- 90, 1707825721, '2024-02-13T12:02:01Z', 256, 4.09890
- ),
- (
- 91, 1707837460, '2024-02-13T15:17:40Z', 322, 4.10501
- ),
- (92, 0, '', 0, 0.00000),
- (93, 0, '', 0, 0.00000),
- (
- 94, 1707844638, '2024-02-13T17:17:18Z', 322, 0.00000
- ),
- (
- 95, 1707851099, '2024-02-13T19:04:59Z', 256, 0.00000
- ),
- (
- 96, 1707844638, '2024-02-13T17:17:18Z', 322, 71.08984
- ),
- (
- 97, 1707851099, '2024-02-13T19:04:59Z', 256, 66.72949
- );
+ `id` int(10) UNSIGNED NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
@@ -198,23 +84,36 @@ VALUES (
--
CREATE TABLE `par_events` (
- `id` int(10) UNSIGNED NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
+ `id` int(10) UNSIGNED NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+-- --------------------------------------------------------
--
--- Gegevens worden geëxporteerd voor tabel `par_events`
+-- Tabelstructuur voor tabel `planten`
--
-INSERT INTO
- `par_events` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 1, 1707844638, '2024-02-13T17:17:18Z', 322, 0.00000
- ),
- (
- 2, 1707851099, '2024-02-13T19:04:59Z', 256, 0.00000
- );
+CREATE TABLE `planten` (
+ `id` int(20) UNSIGNED NOT NULL,
+ `plant_naam` varchar(255) DEFAULT NULL,
+ `plantensoort` varchar(255) DEFAULT NULL,
+ `plant_geteelt` tinyint(1) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
+
+--
+-- Gegevens worden geëxporteerd voor tabel `planten`
+--
+
+INSERT INTO `planten` (`id`, `plant_naam`, `plantensoort`, `plant_geteelt`) VALUES
+(47, 'Tomaten', 'Groente', 1),
+(49, 'Komkommer', 'Groente', 1),
+(50, 'Appel', 'Fruit', 1),
+(51, 'Sla', 'Groente', 1),
+(52, 'Wietplant', 'Onkruid', 0);
-- --------------------------------------------------------
@@ -223,29 +122,12 @@ VALUES (
--
CREATE TABLE `relative_humidity_events` (
- `id` int(10) UNSIGNED NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
-
---
--- Gegevens worden geëxporteerd voor tabel `relative_humidity_events`
---
-
-INSERT INTO
- `relative_humidity_events` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 3, 1707844638, '2024-02-13T17:17:18Z', 322, 71.08984
- ),
- (
- 4, 1707851099, '2024-02-13T19:04:59Z', 256, 66.72949
- ),
- (
- 5, 1707844638, '2024-02-13T17:17:18Z', 322, 71.08984
- ),
- (
- 6, 1707851099, '2024-02-13T19:04:59Z', 256, 66.72949
- );
+ `id` int(10) UNSIGNED NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
@@ -254,20 +136,12 @@ VALUES (
--
CREATE TABLE `soil_electric_conductivity_events` (
- `id` int(10) UNSIGNED NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
-
---
--- Gegevens worden geëxporteerd voor tabel `soil_electric_conductivity_events`
---
-
-INSERT INTO
- `soil_electric_conductivity_events` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 3, 1707851215, '2024-02-13T19:06:55Z', 322, 0.00000
- );
+ `id` int(10) UNSIGNED NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
@@ -276,20 +150,12 @@ VALUES (
--
CREATE TABLE `soil_relative_permittivity_events` (
- `id` int(10) UNSIGNED NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
-
---
--- Gegevens worden geëxporteerd voor tabel `soil_relative_permittivity_events`
---
-
-INSERT INTO
- `soil_relative_permittivity_events` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 3, 1707851215, '2024-02-13T19:06:55Z', 322, 1.52000
- );
+ `id` int(10) UNSIGNED NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
-- --------------------------------------------------------
@@ -298,20 +164,12 @@ VALUES (
--
CREATE TABLE `soil_temperature_events` (
- `id` int(10) NOT NULL, `timestamp` int(11) DEFAULT NULL, `gateway_receive_time` varchar(50) DEFAULT NULL, `device` int(11) DEFAULT NULL, `value` decimal(10, 5) DEFAULT NULL
-) ENGINE = InnoDB DEFAULT CHARSET = utf8mb4 COLLATE = utf8mb4_general_ci;
-
---
--- Gegevens worden geëxporteerd voor tabel `soil_temperature_events`
---
-
-INSERT INTO
- `soil_temperature_events` (
- `id`, `timestamp`, `gateway_receive_time`, `device`, `value`
- )
-VALUES (
- 3, 1707851215, '2024-02-13T19:06:55Z', 322, 12.06000
- );
+ `id` int(10) NOT NULL,
+ `timestamp` int(11) DEFAULT NULL,
+ `gateway_receive_time` varchar(50) DEFAULT NULL,
+ `device` int(11) DEFAULT NULL,
+ `value` decimal(10,5) DEFAULT NULL
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
--
-- Indexen voor geëxporteerde tabellen
@@ -320,44 +178,79 @@ VALUES (
--
-- Indexen voor tabel `battery_voltage_events`
--
-ALTER TABLE `battery_voltage_events` ADD PRIMARY KEY (`id`);
+ALTER TABLE `battery_voltage_events`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`);
--
-- Indexen voor tabel `devices`
--
-ALTER TABLE `devices` ADD PRIMARY KEY (`id`);
+ALTER TABLE `devices`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `last_seen` (`last_seen`),
+ ADD UNIQUE KEY `last_battery_voltage` (`last_battery_voltage`);
--
-- Indexen voor tabel `fetch`
--
-ALTER TABLE `fetch` ADD PRIMARY KEY (`id`);
+ALTER TABLE `fetch`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`),
+ ADD UNIQUE KEY `value` (`value`);
--
-- Indexen voor tabel `par_events`
--
-ALTER TABLE `par_events` ADD PRIMARY KEY (`id`);
+ALTER TABLE `par_events`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`),
+ ADD UNIQUE KEY `value` (`value`);
+
+--
+-- Indexen voor tabel `planten`
+--
+ALTER TABLE `planten`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `plant_naam` (`plant_naam`);
--
-- Indexen voor tabel `relative_humidity_events`
--
-ALTER TABLE `relative_humidity_events` ADD PRIMARY KEY (`id`);
+ALTER TABLE `relative_humidity_events`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`),
+ ADD UNIQUE KEY `value` (`value`);
--
-- Indexen voor tabel `soil_electric_conductivity_events`
--
ALTER TABLE `soil_electric_conductivity_events`
-ADD PRIMARY KEY (`id`);
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`),
+ ADD UNIQUE KEY `value` (`value`);
--
-- Indexen voor tabel `soil_relative_permittivity_events`
--
ALTER TABLE `soil_relative_permittivity_events`
-ADD PRIMARY KEY (`id`);
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`),
+ ADD UNIQUE KEY `value` (`value`);
--
-- Indexen voor tabel `soil_temperature_events`
--
-ALTER TABLE `soil_temperature_events` ADD PRIMARY KEY (`id`);
+ALTER TABLE `soil_temperature_events`
+ ADD PRIMARY KEY (`id`),
+ ADD UNIQUE KEY `timestamp` (`timestamp`),
+ ADD UNIQUE KEY `gateway_receive_time` (`gateway_receive_time`),
+ ADD UNIQUE KEY `value` (`value`);
--
-- AUTO_INCREMENT voor geëxporteerde tabellen
@@ -367,55 +260,57 @@ ALTER TABLE `soil_temperature_events` ADD PRIMARY KEY (`id`);
-- AUTO_INCREMENT voor een tabel `battery_voltage_events`
--
ALTER TABLE `battery_voltage_events`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 11;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=2189;
--
-- AUTO_INCREMENT voor een tabel `devices`
--
ALTER TABLE `devices`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 3;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=15;
--
-- AUTO_INCREMENT voor een tabel `fetch`
--
ALTER TABLE `fetch`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 98;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=100;
--
-- AUTO_INCREMENT voor een tabel `par_events`
--
ALTER TABLE `par_events`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 3;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7;
+
+--
+-- AUTO_INCREMENT voor een tabel `planten`
+--
+ALTER TABLE `planten`
+ MODIFY `id` int(20) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=53;
--
-- AUTO_INCREMENT voor een tabel `relative_humidity_events`
--
ALTER TABLE `relative_humidity_events`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 7;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=9;
--
-- AUTO_INCREMENT voor een tabel `soil_electric_conductivity_events`
--
ALTER TABLE `soil_electric_conductivity_events`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 4;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
--
-- AUTO_INCREMENT voor een tabel `soil_relative_permittivity_events`
--
ALTER TABLE `soil_relative_permittivity_events`
-MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 4;
+ MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=4;
--
-- AUTO_INCREMENT voor een tabel `soil_temperature_events`
--
ALTER TABLE `soil_temperature_events`
-MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT = 4;
-
+ MODIFY `id` int(10) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=8;
COMMIT;
-/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */
-;
-/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */
-;
-/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */
-;
+/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
+/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
+/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
diff --git a/src/py/static/js/main.js b/src/py/static/js/main.js
index bc89974..ad6370a 100644
--- a/src/py/static/js/main.js
+++ b/src/py/static/js/main.js
@@ -1,7 +1,151 @@
-const { ipcRenderer } = require("electron");
+// const { ipcRenderer } = require("electron");
-document.addEventListener('DOMContentLoaded', () =>
-{
+// document.addEventListener('DOMContentLoaded', () =>
+// {
+// ipcRenderer.send('request-update-temp', ['some', 'arguments']);
+
+// ipcRenderer.on('update-temp-result', (event, newTemperature) => {
+// if (newTemperature === 'error') {
+// console.error('Er is een fout opgetreden bij het ophalen van de nieuwe temperatuur');
+// } else {
+// document.getElementById('bodem-temperatuur').textContent = newTemperature;
+// }
+// });
+
+// });
+
+// function openModal()
+// {
+// const modal = document.getElementById("myModal");
+// const button = document.getElementById("modalButton");
+// const close = document.getElementsByClassName("close")[0];
+
+// // Toon de modal wanneer op de knop wordt geklikt
+// button.onclick = function()
+// {
+// modal.style.display = "block";
+// }
+
+// // Sluit de modal wanneer op het 'sluiten' icoon wordt geklikt
+// close.onclick = function()
+// {
+// modal.style.display = "none";
+// }
+
+// // Sluit de modal wanneer buiten de modal wordt geklikt
+// window.onclick = function(event)
+// {
+// if (event.target == modal)
+// {
+// modal.style.display = "none";
+// }
+// }
+// }
+
+// /**
+// * --- Functie om de grafiek te tekenen. Enigste belangrijke is de eerste 2 "const" arrays "data" & "xLabels".
+// */
+// function drawLineChart()
+// {
+// /*Dit is de data die getoond wordt als "punt" op de grafiek. 20 = y20 / x20, 50 = y50 / x50 enzovoort... De array "data" & "xLabels" moeten beide evenveel array items hebben!!*/
+// const data = [20, 50, 60, 45, 50, 100, 70, 60, 65, 0, 85, 0];
+// const xLabels = ["", "", "", "", "", 6, "", "", "", "", "", 12];
+
+// const yLabels = ["", 20, "", 40, "", 60, "", 80, "", 100]; /*NIET VERANDEREN!!!*/
+
+// const canvas = document.getElementById("myCanvas");
+// const ctx = canvas.getContext("2d");
+
+// ctx.clearRect(0, 0, canvas.width, canvas.height);
+
+// const padding = 35; // Increased padding for Y labels
+// const graphWidth = canvas.width - padding * 2;
+// const graphHeight = canvas.height - padding * 2;
+
+// ctx.beginPath();
+// ctx.moveTo(padding, padding);
+// ctx.lineTo(padding, canvas.height - padding);
+// ctx.lineTo(canvas.width - padding, canvas.height - padding);
+// ctx.stroke();
+
+// // Set the color of the line
+// ctx.strokeStyle = "rgb(143, 188, 143)";
+
+// const xIncrement = graphWidth / (xLabels.length - 1);
+// const yIncrement = graphHeight / (yLabels.length - 1);
+
+// // Plot the data
+// ctx.beginPath();
+// ctx.moveTo(padding, canvas.height - padding - (data[0] / 100) * graphHeight);
+
+// for (let i = 1; i < data.length; i++)
+// {
+// const xPos = padding + i * xIncrement;
+// const yPos = canvas.height - padding - (data[i] / 100) * graphHeight;
+// ctx.lineTo(xPos, yPos);
+// }
+// ctx.stroke();
+
+// // Draw Y labels
+// ctx.fillStyle = "black";
+// ctx.textAlign = "right"; // Align text to the right
+// ctx.textBaseline = "middle"; // Center vertically
+
+// for (let i = 0; i < yLabels.length; i++)
+// {
+// if (yLabels[i] !== "")
+// {
+// const yPos = canvas.height - padding - i * yIncrement;
+// ctx.fillText(yLabels[i], padding - 10, yPos);
+// }
+// }
+
+// // Draw X labels
+// ctx.textAlign = "center"; // Center horizontally for X labels
+// for (let i = 0; i < xLabels.length; i++)
+// {
+// if (xLabels[i] !== "")
+// {
+// const xPos = padding + i * xIncrement;
+// ctx.fillText(xLabels[i], xPos, canvas.height - padding + 20);
+// }
+// }
+// }
+
+// drawLineChart();
+
+// /////////////////////////////////
+
+// // Function to fetch battery data from Flask API
+// function fetchBatteryData() {
+// axios.get('http://127.0.0.1:5000')
+// .then(response => {
+// const batteryData = response.data;
+// updateBatteryData(batteryData);
+// })
+// .catch(error => {
+// console.error('Error fetching battery data:', error);
+// });
+// }
+
+// // Function to update HTML content with battery data
+// function updateBatteryData(batteryData) {
+// document.getElementById('deviceNumber').innerText = batteryData.device;
+// document.getElementById('voltage').innerText = batteryData.value;
+// document.getElementById('time').innerText = batteryData.gateway_receive_time;
+// document.getElementById('tevredenheid').innerText = batteryData.timestamp;
+
+// // Voeg andere eigenschappen toe zoals nodig
+// }
+
+// // Fetch battery data when the page loads
+// fetchBatteryData();
+/////////////////////////////////
+
+const { ipcRenderer } = require("electron");
+const axios = require('axios');
+
+// document.addEventListener('DOMContentLoaded', () => {
ipcRenderer.send('request-update-temp', ['some', 'arguments']);
ipcRenderer.on('update-temp-result', (event, newTemperature) => {
@@ -12,108 +156,145 @@ document.addEventListener('DOMContentLoaded', () =>
}
});
-});
+ // Send a message to the main process to execute the Python script
+ ipcRenderer.send('run-python-script', ['some', 'arguments']);
-function openModal()
-{
- const modal = document.getElementById("myModal");
- const button = document.getElementById("modalButton");
- const close = document.getElementsByClassName("close")[0];
-
- // Toon de modal wanneer op de knop wordt geklikt
- button.onclick = function()
- {
- modal.style.display = "block";
- }
-
- // Sluit de modal wanneer op het 'sluiten' icoon wordt geklikt
- close.onclick = function()
- {
- modal.style.display = "none";
- }
-
- // Sluit de modal wanneer buiten de modal wordt geklikt
- window.onclick = function(event)
- {
- if (event.target == modal)
- {
- modal.style.display = "none";
+ ipcRenderer.on('python-script-response', (event, pythonData) => {
+ if (pythonData === 'error') {
+ console.error('An error occurred while retrieving data from Python');
+ } else {
+ // Update HTML elements with data received from Python
+ document.getElementById('bodem-temperatuur').textContent = pythonData.bodemTemperatuur; // Adjust the property based on your actual Python response
}
- }
-}
+ });
-/**
- * --- Functie om de grafiek te tekenen. Enigste belangrijke is de eerste 2 "const" arrays "data" & "xLabels".
- */
-function drawLineChart()
-{
- /*Dit is de data die getoond wordt als "punt" op de grafiek. 20 = y20 / x20, 50 = y50 / x50 enzovoort... De array "data" & "xLabels" moeten beide evenveel array items hebben!!*/
- const data = [20, 50, 60, 45, 50, 100, 70, 60, 65, 0, 85, 0];
- const xLabels = ["", "", "", "", "", 6, "", "", "", "", "", 12];
-
- const yLabels = ["", 20, "", 40, "", 60, "", 80, "", 100]; /*NIET VERANDEREN!!!*/
+ // Listen for updates to HTML data from the main process
+ ipcRenderer.on('update-html-data', (event, data) => {
+ // Update the HTML with the received data
+ document.getElementById('batteryVoltage').innerText = data.batteryVoltage;
+ // Add similar lines for other data fields
+ });
- const canvas = document.getElementById("myCanvas");
- const ctx = canvas.getContext("2d");
+ // Trigger an event to request data update
+ ipcRenderer.send('request-update-data');
- ctx.clearRect(0, 0, canvas.width, canvas.height);
+ // Function to open the modal
+ function openModal() {
+ const modal = document.getElementById("myModal");
+ const button = document.getElementById("modalButton");
+ const close = document.getElementsByClassName("close")[0];
- const padding = 35; // Increased padding for Y labels
- const graphWidth = canvas.width - padding * 2;
- const graphHeight = canvas.height - padding * 2;
+ // Check if elements are found before attaching events
+ if (modal && button && close) {
+ // Show the modal when the button is clicked
+ button.onclick = function () {
+ modal.style.display = "block";
+ }
- ctx.beginPath();
- ctx.moveTo(padding, padding);
- ctx.lineTo(padding, canvas.height - padding);
- ctx.lineTo(canvas.width - padding, canvas.height - padding);
- ctx.stroke();
+ // Close the modal when the 'close' icon is clicked
+ close.onclick = function () {
+ modal.style.display = "none";
+ }
- // Set the color of the line
- ctx.strokeStyle = "rgb(143, 188, 143)";
-
- const xIncrement = graphWidth / (xLabels.length - 1);
- const yIncrement = graphHeight / (yLabels.length - 1);
-
- // Plot the data
- ctx.beginPath();
- ctx.moveTo(padding, canvas.height - padding - (data[0] / 100) * graphHeight);
-
- for (let i = 1; i < data.length; i++)
- {
- const xPos = padding + i * xIncrement;
- const yPos = canvas.height - padding - (data[i] / 100) * graphHeight;
- ctx.lineTo(xPos, yPos);
- }
- ctx.stroke();
-
- // Draw Y labels
- ctx.fillStyle = "black";
- ctx.textAlign = "right"; // Align text to the right
- ctx.textBaseline = "middle"; // Center vertically
-
- for (let i = 0; i < yLabels.length; i++)
- {
- if (yLabels[i] !== "")
- {
- const yPos = canvas.height - padding - i * yIncrement;
- ctx.fillText(yLabels[i], padding - 10, yPos);
+ // Close the modal when clicked outside the modal
+ window.onclick = function (event) {
+ if (event.target == modal) {
+ modal.style.display = "none";
+ }
+ }
}
}
- // Draw X labels
- ctx.textAlign = "center"; // Center horizontally for X labels
- for (let i = 0; i < xLabels.length; i++)
- {
- if (xLabels[i] !== "")
- {
+ // Call the function to open the modal
+ openModal();
+
+ /**
+ * --- Function to draw the chart. The important arrays are "data" & "xLabels".
+ */
+ function drawLineChart() {
+ const data = [20, 50, 60, 45, 50, 100, 70, 60, 65, 0, 85, 0];
+ const xLabels = ["", "", "", "", "", 6, "", "", "", "", "", 12];
+ const yLabels = ["", 20, "", 40, "", 60, "", 80, "", 100]; /*NIET VERANDEREN!!!*/
+
+ const canvas = document.getElementById("myCanvas");
+ const ctx = canvas.getContext("2d");
+
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
+
+ const padding = 35; // Increased padding for Y labels
+ const graphWidth = canvas.width - padding * 2;
+ const graphHeight = canvas.height - padding * 2;
+
+ ctx.beginPath();
+ ctx.moveTo(padding, padding);
+ ctx.lineTo(padding, canvas.height - padding);
+ ctx.lineTo(canvas.width - padding, canvas.height - padding);
+ ctx.stroke();
+
+ // Set the color of the line
+ ctx.strokeStyle = "rgb(143, 188, 143)";
+
+ const xIncrement = graphWidth / (xLabels.length - 1);
+ const yIncrement = graphHeight / (yLabels.length - 1);
+
+ // Plot the data
+ ctx.beginPath();
+ ctx.moveTo(padding, canvas.height - padding - (data[0] / 100) * graphHeight);
+
+ for (let i = 1; i < data.length; i++) {
const xPos = padding + i * xIncrement;
- ctx.fillText(xLabels[i], xPos, canvas.height - padding + 20);
+ const yPos = canvas.height - padding - (data[i] / 100) * graphHeight;
+ ctx.lineTo(xPos, yPos);
+ }
+ ctx.stroke();
+
+ // Draw Y labels
+ ctx.fillStyle = "black";
+ ctx.textAlign = "right"; // Align text to the right
+ ctx.textBaseline = "middle"; // Center vertically
+
+ for (let i = 0; i < yLabels.length; i++) {
+ if (yLabels[i] !== "") {
+ const yPos = canvas.height - padding - i * yIncrement;
+ ctx.fillText(yLabels[i], padding - 10, yPos);
+ }
+ }
+
+ // Draw X labels
+ ctx.textAlign = "center"; // Center horizontally for X labels
+ for (let i = 0; i < xLabels.length; i++) {
+ if (xLabels[i] !== "") {
+ const xPos = padding + i * xIncrement;
+ ctx.fillText(xLabels[i], xPos, canvas.height - padding + 20);
+ }
}
}
-}
-drawLineChart();
+ // Call the function to draw the line chart
+ drawLineChart();
+ // Function to fetch battery data from Flask API
+ function fetchBatteryData() {
+ axios.get('http://127.0.0.1:5000')
+ .then(response => {
+ const batteryData = response.data;
+ updateBatteryData(batteryData);
+ })
+ .catch(error => {
+ console.error('Error fetching battery data:', error);
+ });
+ }
-/////////////////////////////////
+ // Function to update HTML content with battery data
+ function updateBatteryData(batteryData) {
+ document.getElementById('deviceNumber').innerText = batteryData.device;
+ document.getElementById('voltage').innerText = batteryData.value;
+ document.getElementById('time').innerText = batteryData.gateway_receive_time;
+ document.getElementById('zulu').innerText = batteryData.timestamp;
+ // Voeg andere eigenschappen toe zoals nodig
+ }
+
+ // Fetch battery data when the page loads
+ fetchBatteryData();
+// });
\ No newline at end of file
diff --git a/src/py/static/js/planten.class.js b/src/py/static/js/planten.class.js
index b40d275..fcdcff2 100644
--- a/src/py/static/js/planten.class.js
+++ b/src/py/static/js/planten.class.js
@@ -36,25 +36,25 @@ class PlantGrid {
"id": 3,
"plantNaam": "Appel",
"plantensoort": "Groente",
- "plantGeteelt": 0
+ "plantGeteelt": 1
},
{
"id": 4,
"plantNaam": "KwamKwammer",
"plantensoort": "Groente",
- "plantGeteelt": 1
+ "plantGeteelt": 0
},
{
"id": 5,
"plantNaam": ":p",
"plantensoort": "Groente",
- "plantGeteelt": 1
+ "plantGeteelt": 0
},
{
"id": 6,
"plantNaam": ":3",
"plantensoort": "Groente",
- "plantGeteelt": 1
+ "plantGeteelt": 0
},
{
"id": 7,
@@ -66,13 +66,13 @@ class PlantGrid {
"id": 8,
"plantNaam": "test",
"plantensoort": "Groente",
- "plantGeteelt": 0
+ "plantGeteelt": 1
},
{
"id": 9,
"plantNaam": "yippie",
"plantensoort": "Groente",
- "plantGeteelt": 0
+ "plantGeteelt": 1
}
];
diff --git a/src/py/templates/kas_informatie.html b/src/py/templates/kas_informatie.html
index 62c1487..c41e3ba 100644
--- a/src/py/templates/kas_informatie.html
+++ b/src/py/templates/kas_informatie.html
@@ -25,22 +25,22 @@
+