Skip to content

Commit 28ada36

Browse files
Remove unused send_msg and send_record functions
Removed unused functions for sending messages and records.
1 parent 57c92f8 commit 28ada36

1 file changed

Lines changed: 7 additions & 50 deletions

File tree

fs/utilitys.py

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
CYAN = '\033[96m'
1313
RESET = '\033[0m'
1414

15-
1615
def sync_time():
1716
print("Sincronizando tiempo NTP...")
1817
try:
@@ -28,97 +27,55 @@ def get_current_time():
2827
current_time = localtime()
2928
return f"{current_time[0]}-{current_time[1]:02}-{current_time[2]:02} {current_time[3]:02}:{current_time[4]:02}:{current_time[5]:02}"
3029

31-
3230
def print_table(temp, humidity_air, light, ph, tds, humidity_soil):
3331
# Encabezado de la tabla
3432
print(f"\n+--------------+------------------------+")
3533
print(f"| " + get_current_time() + " |")
3634
print(f"+--------------+------------------------+")
3735
print(f"| Sensor | Valor |")
3836
print(f"+--------------+------------------------+")
39-
37+
4038
# Fila para temperatura
4139
if temp is not None:
4240
temp_display = f"{RED}{temp:7.2f}°C{RESET:<17}"
4341
else:
4442
temp_display = f"{RED}N/A{RESET:<17}"
4543
print(f"| Temp | {temp_display} |")
46-
44+
4745
# Fila para humedad del aire
4846
if humidity_air is not None:
4947
humidity_air_display = f"{BLUE}{humidity_air:7.2f}%{RESET:<18}"
5048
else:
5149
humidity_air_display = f"{BLUE}N/A{RESET:<18}"
5250
print(f"| Humedad Aire | {humidity_air_display} |")
53-
51+
5452
# Fila para luz
5553
if light is not None:
5654
light_display = f"{YELLOW}{light:7.2f} lux{RESET:<15}"
5755
else:
5856
light_display = f"{YELLOW}N/A{RESET:<15}"
5957
print(f"| Luz | {light_display} |")
60-
58+
6159
# Fila para pH
6260
if ph is not None:
6361
ph_display = f"{GREEN}{ph:7.2f}{RESET:<19}"
6462
else:
6563
ph_display = f"{GREEN}N/A{RESET:<19}"
6664
print(f"| pH | {ph_display} |")
67-
65+
6866
# Fila para TDS
6967
if tds is not None:
7068
tds_display = f"{CYAN}{tds:7.2f} ppm{RESET:<15}"
7169
else:
7270
tds_display = f"{CYAN}N/A{RESET:<15}"
7371
print(f"| TDS | {tds_display} |")
74-
72+
7573
# Fila para humedad del suelo
7674
if humidity_soil is not None:
7775
humidity_soil_display = f"{MAGENTA}{humidity_soil:7.2f}%{RESET:<18}"
7876
else:
7977
humidity_soil_display = f"{MAGENTA}N/A{RESET:<18}"
8078
print(f"| Humedad Suelo| {humidity_soil_display} |")
81-
79+
8280
# Línea de cierre
8381
print(f"+--------------+------------------------+\n")
84-
85-
86-
def send_msg(bot, chat_id, temp, humidity_air, light, ph, tds, humidity_soil):
87-
# Crear mensaje con los datos de los sensores
88-
sensor_data = (
89-
f"*Sensor Data:* \n",
90-
f"*Temp:* {temp:.2f}°C\n" if temp is not None else "*Temp:* N/A\n",
91-
f"*Humedad Aire:* {humidity_air:.2f}%\n" if humidity_air is not None else "*Humedad Aire:* N/A\n",
92-
f"*Luz:* {light:.2f} lux\n" if light is not None else "*Luz:* N/A\n",
93-
f"*pH:* {ph:.2f}\n" if ph is not None else "*pH:* N/A\n",
94-
f"*TDS:* {tds:.2f} ppm\n" if tds is not None else "*TDS:* N/A\n",
95-
f"*Humedad Suelo:* {humidity_soil:.2f}%\n" if humidity_soil is not None else "*Humedad Suelo:* N/A\n"
96-
)
97-
98-
# Unir la lista en una sola cadena
99-
formatted_message = "".join(sensor_data)
100-
101-
try:
102-
bot.send(chat_id, formatted_message)
103-
print("Mensaje enviado correctamente")
104-
except Exception as e:
105-
print(f"Error al enviar el mensaje: {e}")
106-
107-
108-
def send_record(ubot, crop_id, temp, humidity_air, light, ph, tds, humidity_soil):
109-
"""Envía un registro con los datos de sensores a la API SmartPot"""
110-
111-
# Crear las medidas
112-
measures = {
113-
"atmosphere": str(temp),
114-
"brightness": str(light),
115-
"temperature": str(temp),
116-
"ph": str(ph),
117-
"tds": str(tds),
118-
"humidity": str(humidity_air)
119-
}
120-
121-
try:
122-
ubot.create_record(crop_id, measures)
123-
except Exception as e:
124-
print(f"Error al enviar el registro: {e}")

0 commit comments

Comments
 (0)