From 0576b54da14fd258fcd45b355417e1fba23835ac Mon Sep 17 00:00:00 2001 From: Eilon Zohar Date: Tue, 22 Jul 2025 13:34:34 +0200 Subject: [PATCH] python reading and sending to influx --- ...data_to_influx.py => temp_hum_to_influx.py} | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) rename In work/Temp. sensors/{phillips_desk_data_to_influx.py => temp_hum_to_influx.py} (87%) diff --git a/In work/Temp. sensors/phillips_desk_data_to_influx.py b/In work/Temp. sensors/temp_hum_to_influx.py similarity index 87% rename from In work/Temp. sensors/phillips_desk_data_to_influx.py rename to In work/Temp. sensors/temp_hum_to_influx.py index 4e7aa84..6d1dcc0 100644 --- a/In work/Temp. sensors/phillips_desk_data_to_influx.py +++ b/In work/Temp. sensors/temp_hum_to_influx.py @@ -92,13 +92,14 @@ def read_temp (ip, port, influx_client, write_api): return data.decode().strip() + if __name__ == "__main__": influx_client, write_api = init_influxdb(URL, TOKEN, ORG) - setup_logger ("PhillipsDeskTemp.") - logging.info ("Reading the temperature on Phillip's desk") + setup_logger ("FerDy_exp_table_Temp.") + logging.info ("Reading the temperature on exp. table in FerDy") with socket.socket (socket.AF_INET, socket.SOCK_STREAM) as s: s.bind ((ip, port)) s.listen() @@ -113,19 +114,24 @@ if __name__ == "__main__": message = data.decode().strip() #T = read_temp (ip, port, influx_client, write_api) + - if (message is not None and temp_or_hum == "T"): + if (message is not None and temp_or_hum == "T" and message <= "9" and message >= "0"): + #if type (message) != int: + # continue print (str (datetime.now () )[:19] + ": Temp is " + message) T = float (message) - p1 = influxdb_client.Point ("FerDy").tag("Climate_control", "temperature").field ("temp_Eilons_desk", T) + p1 = influxdb_client.Point ("FerDy").tag("Climate_control", "temperature").field ("temp_exp_table", T) temp_or_hum = "a" influx_client, write_api = write_data_to_influxDB (influx_client, write_api, p1) time.sleep (update_interval/2) - elif (message is not None and temp_or_hum == "H"): + elif (message is not None and temp_or_hum == "H" and message <= "9" and message >= "0"): + # if type (message) != int: + # continue print (str (datetime.now () )[:19] + ": humidity is " + message) H = float (message) - p1 = influxdb_client.Point ("FerDy").tag("Climate_control", "humidity").field ("hum_Eilons_desk", H) + p1 = influxdb_client.Point ("FerDy").tag("Climate_control", "humidity").field ("hum_exp_table", H) temp_or_hum = "a" influx_client, write_api = write_data_to_influxDB (influx_client, write_api, p1) time.sleep (update_interval/2)