Compare commits

..

4 Commits

Author SHA1 Message Date
Ninluc c39b811a3c Lower noise buffer for ultrasonic ranger
Build, push image, and notify Watchtower / build-image (push) Successful in 41s
Build, push image, and notify Watchtower / notify (push) Successful in 13s
2026-08-23 11:05:04 +02:00
Ninluc b0a6c4d2ec Bettter safety check 2026-08-23 11:04:38 +02:00
Ninluc 0b1971ed0b Forgot https 2026-08-23 10:00:20 +02:00
Ninluc d6951cbbcf Fix Camera cm per pixels 2026-08-23 10:00:15 +02:00
4 changed files with 32 additions and 24 deletions
+3 -3
View File
@@ -29,10 +29,10 @@ curl -X POST "https://smartwave.matthiasg.dev/alert" \
## Jobs
### Trigger Server CVE Audit
`curl http://smartwave.matthiasg.dev/debug/run-job/server_cve_audit_job`
`curl https://smartwave.matthiasg.dev/debug/run-job/server_cve_audit_job`
### Trigger Client IP Audit
`curl http://smartwave.matthiasg.dev/debug/run-job/client_ip_audit_job`
`curl https://smartwave.matthiasg.dev/debug/run-job/client_ip_audit_job`
### Trigger Telemetry Request
`curl http://smartwave.matthiasg.dev/debug/run-job/request_telemetry_job`
`curl https://smartwave.matthiasg.dev/debug/run-job/request_telemetry_job`
+1 -1
View File
@@ -10,7 +10,7 @@ class MicrowaveDishAnalyzer:
"""
# Constant scale ratio: Centimeters per Pixel.
CM_PER_PIXEL: float = 0.002592593
CM_PER_PIXEL: float = 0.005925926
def __init__(self, cm_per_pixel: Optional[float] = None):
if cm_per_pixel is not None:
+21 -13
View File
@@ -3,34 +3,42 @@ from pydantic import BaseModel, Field
from APIs.aichat import generate
import shared.config as config
class UtensilMaterialCheck(BaseModel):
object_name: str = Field(
description="Name of utensil or container seen (e.g., spoon, fork, tray)."
)
is_metal: bool = Field(
description="True ONLY if the object is made of metal, stainless steel, or aluminum."
)
class DishSafetyResult(BaseModel):
visible_objects: list[str] = Field(
description="List physical container items and utensils visible in the image."
utensils_and_containers: list[UtensilMaterialCheck] = Field(
description="List each visible non-food object and check if it is made of metal."
)
material_analysis: str = Field(
description="Brief description of container material (e.g., standard plastic tray, glass bowl)."
description="Short description of the materials present."
)
detected_hazards: list[str] = Field(
description="List of visually confirmed metal or foil hazards. MUST be empty [] if no metal or foil is present."
description="List objects from utensils_and_containers where is_metal is True."
)
is_safe: bool = Field(
description="Set to True if detected_hazards is empty. Set to False ONLY if metal or aluminum foil is present."
description="True if detected_hazards is completely empty []. False if ANY metal is found."
)
warning_message: str = Field(
description="Short warning if is_safe is False, otherwise an empty string."
description="If is_safe is False, set to 'REMOVE METAL UTENSIL OR FOIL BEFORE MICROWAVING'. Otherwise empty ''."
)
def check_dish_safety(image_path: str) -> dict:
prompt = (
"Analyze this food image for microwave safety.\n\n"
"DEFAULT ASSUMPTION:\n"
"- Assume the dish is SAFE (is_safe = True, detected_hazards = []).\n"
"- Standard food (meat, vegetables, potatoes) and standard containers (black plastic meal trays, plastic bowls, ceramic, glass) are 100% SAFE for microwaves.\n\n"
"STRICT HAZARD RULE:\n"
"- Flag as UNSAFE ONLY if you can literally see actual metal cutlery (metal spoon/fork/knife), aluminum foil packaging, or metal foil trim in the image.\n"
"- Do NOT invent or hallucinate hazards. If you do not see shiny metal or aluminum foil, detected_hazards MUST be an empty list []."
"Analyze this microwave dish image strictly for EQUIPMENT DAMAGE HAZARDS (Metal, Steel, Aluminum Foil).\n\n"
"GOAL:\n"
"Identify if any metallic item (metal spoon, fork, knife, aluminum foil, wire) is inside the dish.\n\n"
"RULES:\n"
"1. Examine all utensils carefully, even in dim lighting or dark spots.\n"
"2. Spoons, forks, and knives are often STAINLESS STEEL / METAL. If a spoon or fork is visible, mark is_metal = True unless it is clearly bright colored plastic.\n"
"3. Ignore chemical or health concerns (plastic cancer risks are IRRELEVANT). Focus ONLY on spark/fire hazards (metal, foil).\n"
"4. If ANY utensil is metal: set is_metal=True, add it to detected_hazards, and set is_safe=False."
)
response_raw = generate(
+6 -6
View File
@@ -817,16 +817,16 @@ async def monitor_dish_height_task():
if dist is not None:
# Hysteresis Thresholds:
# - Must be > 2.5 cm to detect dish insertion
# - Must be < 1.2 cm to detect dish removal
if dist > 2.5:
# - Must be > 1.2 cm to detect dish insertion
# - Must be < 0.8 cm to detect dish removal
if dist > 1.2:
consecutive_present += 1
consecutive_absent = 0
elif dist < 1.2:
elif dist < 0.8:
consecutive_absent += 1
consecutive_present = 0
else:
# Dead-zone (1.2cm to 2.5cm) -> Noise buffer
# Dead-zone (1.2cm to 0.8cm) -> Noise buffer
consecutive_present = 0
consecutive_absent = 0
@@ -848,7 +848,7 @@ async def monitor_dish_height_task():
ir_data_cache.pop(mw_id, None)
ir_data_events.pop(mw_id, None)
await asyncio.sleep(0.3)
await asyncio.sleep(0.7)
# --- BOOTSTRAP ---
async def main():