Temperature Alert
Build, push image, and notify Watchtower / build-image (push) Successful in 1m17s
Build, push image, and notify Watchtower / notify (push) Successful in 16s

This commit is contained in:
2026-08-17 13:04:35 +02:00
parent 01eccf47c6
commit 83b269cc88
7 changed files with 93 additions and 30 deletions
+5 -2
View File
@@ -20,10 +20,12 @@ class AlertManager:
self.alerts.clear()
class Alert:
def __init__(self, alertType: "AlertType", message: str):
def __init__(self, alertType: "AlertType", message: str, redistributed: bool = False, small_message: str = None):
self.alertType = alertType
self.message = message
self.small_message = small_message
self.timestamp = time.time()
self.redistributed = redistributed
def to_dict(self):
return {
@@ -44,4 +46,5 @@ class Alert:
return alert
class AlertType:
COOKING_SAFETY = "COOKING_SAFETY"
COOKING_SAFETY = "COOKING_SAFETY"
TEMPERATURE_ALERT = "TEMPERATURE_ALERT"
+3 -1
View File
@@ -1,6 +1,7 @@
# Debugging and others
DEBUG=True
DEBUG_DANGEROUS_AREA=False
DEBUG_TEMPERATURE_ALERT=True
# LoRa
LORA_HEARTBEAT_INTERVAL = 30
@@ -19,8 +20,9 @@ MQTT_HELLO_INTERVAL = 30
# Microwave Model
COOKING_COMPARTMENT_HEIGHT = 30 # cm
BUZZER_ACTIVATED = False
MAX_ALLOWED_TEMPERATURE_TECHNICAL_COMPARTMENT = 70
MAX_ALLOWED_TEMPERATURE_COOKING_COMPARTMENT = 200
# TELEMETRY
TELEMETRY_SEND_INTERVAL = 3
+5 -3
View File
@@ -33,10 +33,11 @@ class MicrowaveState:
if config.DEBUG:
assert new_state in (
MicrowaveState.IDLE,
MicrowaveState.ANALYZING,
MicrowaveState.ANALYZING,
MicrowaveState.WAITING_FOR_CLOUD,
MicrowaveState.COOKING,
MicrowaveState.DONE
MicrowaveState.DONE,
MicrowaveState.ALERT,
), f"Invalid state: {new_state}"
if self.state != new_state:
@@ -90,4 +91,5 @@ class MicrowaveState:
ANALYZING = "ANALYZING" # Reading sensors & waiting for IR
WAITING_FOR_CLOUD = "WAITING_FOR_CLOUD" # Waiting for API parameters
COOKING = "COOKING" # Microwave is active
DONE = "DONE" # Finished/Stopped, waiting for dish removal
DONE = "DONE" # Finished/Stopped, waiting for dish removal
ALERT = "ALERT" # Alert state, waiting for user action
+7 -2
View File
@@ -69,17 +69,22 @@ def telemetry_payload(device_id, microwave_states, button_state, cloud_alert, gp
"logs": logs
})
def lora_new_alert(alert: Alert):
def lora_new_alert(alert: Alert, with_message=False):
try:
from shared.lora_device import LoraCommands
except ImportError:
pass # No need
return {
payload = {
"action": LoraCommands.NEW_ALERT,
"alert_type": alert.alertType
}
if with_message:
payload["alert_message"] = alert.message
return payload
def lora_microwave_state(state: str):
try:
from shared.lora_device import LoraCommands