python reading and sending to influx
This commit is contained in:
parent
863e486944
commit
0576b54da1
@ -95,10 +95,11 @@ def read_temp (ip, port, influx_client, write_api):
|
||||
|
||||
|
||||
|
||||
|
||||
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()
|
||||
@ -114,18 +115,23 @@ if __name__ == "__main__":
|
||||
#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)
|
Loading…
Reference in New Issue
Block a user