Règlages des SMS
This commit is contained in:
3
.idea/misc.xml
generated
3
.idea/misc.xml
generated
@@ -7,4 +7,7 @@
|
||||
<component name="PyPackaging">
|
||||
<option name="earlyReleasesAsUpgrades" value="true" />
|
||||
</component>
|
||||
<component name="PythonCompatibilityInspectionAdvertiser">
|
||||
<option name="version" value="3" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -103,7 +103,7 @@ def insert_gyro_log(lieu: str, etat: str, topic: str, payload_raw: str,
|
||||
try:
|
||||
cur = cnx.cursor()
|
||||
cur.execute(
|
||||
"INSERT INTO `Gyro` (Lieu, Sonde, Etat, Date, Topic, Payload, QoS, Retained) "
|
||||
"INSERT INTO Sondes.Gyro (Lieu, Sonde, Etat, Date, Topic, Payload, QoS, Retained) "
|
||||
"VALUES (%s, %s, %s, %s, %s, %s, %s, %s)",
|
||||
(
|
||||
lieu,
|
||||
@@ -124,7 +124,7 @@ def insert_gyro_log(lieu: str, etat: str, topic: str, payload_raw: str,
|
||||
cnx.close()
|
||||
|
||||
def should_insert_gyro(lieu: str, etat: str, sonde: str = "Gyro") -> bool:
|
||||
sql = "SELECT Etat FROM `Gyro` WHERE Lieu=%s AND Sonde=%s ORDER BY Date DESC LIMIT 1"
|
||||
sql = "SELECT Etat FROM Sondes.Gyro WHERE Lieu=%s AND Sonde=%s ORDER BY Date DESC LIMIT 1"
|
||||
cnx = get_db()
|
||||
try:
|
||||
cur = cnx.cursor()
|
||||
@@ -170,7 +170,7 @@ def lire_cfg_chambres(site: str):
|
||||
"""
|
||||
sql = """
|
||||
SELECT Sonde, Temp_Max, Etat, En_entretien
|
||||
FROM Chambres_froides
|
||||
FROM Sondes.Chambres_froides
|
||||
WHERE Lieu=%s
|
||||
"""
|
||||
cnx = get_db()
|
||||
@@ -208,7 +208,7 @@ def compute_site_alarm(last_values: list[dict], cfg: dict[str, dict], hysteresis
|
||||
def lire_seuils_depuis_db(site: str):
|
||||
sql = """
|
||||
SELECT Sonde, Temp_Max
|
||||
FROM Chambres_froides
|
||||
FROM Sondes.Chambres_froides
|
||||
WHERE Lieu=%s AND Etat='ON'
|
||||
"""
|
||||
cnx = get_db()
|
||||
@@ -791,7 +791,8 @@ class GyroPulseController:
|
||||
log.info("Gyro → ON déclenché par %s: %.2f > %.2f (mode %s)",
|
||||
s, t, se, "CONTINU" if os.getenv("GYRO_MODE_CONTINUOUS","1")=="1" else "PULSE")
|
||||
# SMS alerte immédiat
|
||||
self._send_alert_sms(trigger)
|
||||
if os.getenv("ALERT_INTERNAL_SMS_ENABLED", "0") == "1":
|
||||
self._send_alert_sms(trigger)
|
||||
|
||||
elif self.state == _GyroState.PULSE_ON:
|
||||
if not active:
|
||||
@@ -802,7 +803,8 @@ class GyroPulseController:
|
||||
self._normal_count = 0
|
||||
log.info("Gyro → OFF (retour à la normale confirmé)")
|
||||
# SMS OK immédiat
|
||||
self._send_ok_sms_from_last_trigger()
|
||||
if os.getenv("ALERT_OK_SMS_GYRO", "0") == "1":
|
||||
self._send_ok_sms_from_last_trigger()
|
||||
else:
|
||||
self._normal_count = 0
|
||||
if os.getenv("GYRO_MODE_CONTINUOUS", "1") != "1":
|
||||
|
||||
@@ -170,7 +170,7 @@ def lire_cfg_chambres(site: str):
|
||||
"""
|
||||
sql = """
|
||||
SELECT Sonde, Temp_Max, Etat, En_entretien
|
||||
FROM Chambres_froides
|
||||
FROM Sondes.Chambres_froides
|
||||
WHERE Lieu=%s
|
||||
"""
|
||||
cnx = get_db()
|
||||
@@ -208,7 +208,7 @@ def compute_site_alarm(last_values: list[dict], cfg: dict[str, dict], hysteresis
|
||||
def lire_seuils_depuis_db(site: str):
|
||||
sql = """
|
||||
SELECT Sonde, Temp_Max
|
||||
FROM Chambres_froides
|
||||
FROM Sondes.Chambres_froides
|
||||
WHERE Lieu=%s AND Etat='ON'
|
||||
"""
|
||||
cnx = get_db()
|
||||
@@ -789,9 +789,10 @@ class GyroPulseController:
|
||||
if trigger:
|
||||
s, t, se = trigger
|
||||
log.info("Gyro → ON déclenché par %s: %.2f > %.2f (mode %s)",
|
||||
s, t, se, "CONTINU" if os.getenv("GYRO_MODE_CONTINUOUS","1")=="1" else "PULSE")
|
||||
# SMS alerte immédiat
|
||||
self._send_alert_sms(trigger)
|
||||
s, t, se, "CONTINU" if os.getenv("GYRO_MODE_CONTINUOUS", "1") == "1" else "PULSE")
|
||||
# SMS alerte immédiat (optionnel)
|
||||
if os.getenv("ALERT_INTERNAL_SMS_ENABLED", "0") == "1":
|
||||
self._send_alert_sms(trigger)
|
||||
|
||||
elif self.state == _GyroState.PULSE_ON:
|
||||
if not active:
|
||||
@@ -802,7 +803,8 @@ class GyroPulseController:
|
||||
self._normal_count = 0
|
||||
log.info("Gyro → OFF (retour à la normale confirmé)")
|
||||
# SMS OK immédiat
|
||||
self._send_ok_sms_from_last_trigger()
|
||||
if os.getenv("ALERT_OK_SMS_GYRO", "0") == "1":
|
||||
self._send_ok_sms_from_last_trigger()
|
||||
else:
|
||||
self._normal_count = 0
|
||||
if os.getenv("GYRO_MODE_CONTINUOUS", "1") != "1":
|
||||
|
||||
@@ -12,7 +12,10 @@ import pandas as pd
|
||||
pd.set_option('future.no_silent_downcasting', True)
|
||||
import streamlit as st
|
||||
from contextlib import closing
|
||||
from dotenv import load_dotenv
|
||||
from dotenv import find_dotenv, load_dotenv
|
||||
env_file = find_dotenv(usecwd=True)
|
||||
if env_file:
|
||||
load_dotenv(env_file)
|
||||
from fpdf import FPDF
|
||||
|
||||
# =========================================================
|
||||
@@ -45,7 +48,7 @@ def fetch_gyro(site: str):
|
||||
"""Retourne (etat, ts) depuis la vue v_gyro_last pour le site donné."""
|
||||
q = """
|
||||
SELECT Etat, `Date`
|
||||
FROM v_gyro_last
|
||||
FROM Sondes.v_gyro_last
|
||||
WHERE Lieu = %s AND Sonde = 'Gyro'
|
||||
ORDER BY `Date` DESC
|
||||
LIMIT 1
|
||||
|
||||
Reference in New Issue
Block a user