feat: relay inversé, LED idle solid, luminosité manuelle, auto-flash lux
🚀 Deploy — JH Photomaton / 🔍 Vérification (push) Has been cancelled
🚀 Deploy — JH Photomaton / 🍓 Deploy sur le Pi (push) Has been cancelled

This commit is contained in:
2026-07-17 10:32:43 +02:00
parent 3de55821b7
commit 4b188ce819
8 changed files with 260 additions and 6 deletions
+21
View File
@@ -27,6 +27,9 @@ async def photobooth_webhook(
match event_key:
case "counting":
led.play("countdown", countdown_duration=DEFAULT_COUNTDOWN)
if request.app.state.config.leds.auto_brightness:
pb = request.app.state.photobooth_service
asyncio.create_task(_analyze_ambient_lux(led, pb))
case "capture":
led.play("capture")
@@ -58,3 +61,21 @@ async def _delayed_relay_on(btn, delay: float):
await asyncio.sleep(delay)
if btn:
btn.relay_on()
async def _analyze_ambient_lux(led, pb):
"""Capture une frame du liveview et calcule la luminosite moyenne."""
try:
snapshot = await pb.get_liveview_snapshot()
if not snapshot:
logger.debug("Analyse lux: aucun snapshot disponible")
return
from PIL import Image
import io
img = Image.open(io.BytesIO(snapshot)).convert("L").resize((80, 60))
pixels = list(img.getdata())
avg = sum(pixels) / len(pixels)
led.set_ambient_lux(avg)
logger.info("Luminosite ambiante: %.1f / 255", avg)
except Exception as e:
logger.warning("Analyse lux echouee: %s", e)