abfrage ob temperatur sich geändert hat

This commit is contained in:
moritz 2024-06-27 12:44:30 +02:00
parent 5741f26926
commit 90b139878d

View file

@ -45,10 +45,28 @@ def insert_data(temp, sensor_id, config):
print(f'Datenbank: {config["host"]}') print(f'Datenbank: {config["host"]}')
if __name__ == '__main__': if __name__ == '__main__':
last_temp_sensor_1 = -300
last_temp_sensor_2 = -300
last_temp_sensor_3 = -300
while True: while True:
if get_temp(0x09) != last_temp_sensor_1:
insert_data(get_temp(0x09), 1, config_cloud) 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(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_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_local)
insert_data(get_temp(0x0b), 3, config_cloud)
last_temp_sensor_3 = get_temp(0x0b)
else:
print("Daten Sensor 3 sind gleichgeblieben")