From 90b139878d3a696868ff8b6e31d64f6dd91fd666 Mon Sep 17 00:00:00 2001 From: moritz Date: Thu, 27 Jun 2024 12:44:30 +0200 Subject: [PATCH] =?UTF-8?q?abfrage=20ob=20temperatur=20sich=20ge=C3=A4nder?= =?UTF-8?q?t=20hat?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Pi-py-Code/protocoll.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/Pi-py-Code/protocoll.py b/Pi-py-Code/protocoll.py index d8da85e..c1f058a 100644 --- a/Pi-py-Code/protocoll.py +++ b/Pi-py-Code/protocoll.py @@ -45,10 +45,28 @@ def insert_data(temp, sensor_id, config): print(f'Datenbank: {config["host"]}') if __name__ == '__main__': + last_temp_sensor_1 = -300 + last_temp_sensor_2 = -300 + last_temp_sensor_3 = -300 + while True: - insert_data(get_temp(0x09), 1, config_cloud) - insert_data(get_temp(0x0a), 2, config_cloud) - insert_data(get_temp(0x0b), 3, config_cloud) - insert_data(get_temp(0x09), 1, config_local) - insert_data(get_temp(0x0a), 2, config_local) - insert_data(get_temp(0x0b), 3, config_local) + if get_temp(0x09) != last_temp_sensor_1: + insert_data(get_temp(0x09), 1, config_cloud) + insert_data(get_temp(0x09), 1, config_local) + last_temp_sensor_1 = get_temp(0x09) + else: + print("Daten Sensor 1 sind gleichgeblieben") + + if get_temp(0x0a) != last_temp_sensor_2: + insert_data(get_temp(0x0a), 2, config_local) + insert_data(get_temp(0x0a), 2, config_cloud) + last_temp_sensor_2 = get_temp(0x0a) + else: + print("Daten Sensor 2 sind gleichgeblieben") + + if get_temp(0x0b) != last_temp_sensor_3: + insert_data(get_temp(0x0b), 3, config_local) + insert_data(get_temp(0x0b), 3, config_cloud) + last_temp_sensor_3 = get_temp(0x0b) + else: + print("Daten Sensor 3 sind gleichgeblieben")