feat(ao-vivo): indicador ao vivo do sensor PIR

Cada disparo do PIR vira um evento SSE 'pir' (mesmo dentro do intervalo do
historico) e o painel mostra 'presenca agora' por 8 s em Ao vivo e no
Historico; /estado inclui o estado do PIR.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
julio
2026-10-06 03:47:11 -03:00
co-authored by Claude Opus 5.5
parent 4b9e805801
commit 6029c79645
7 changed files with 70 additions and 4 deletions
+6 -2
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import {
Brain, Camera, Download, Eye, Hand, History, Palette, PenLine, RefreshCw, Repeat, ScanFace, Settings2, Smile, Sparkles, Video,
Brain, Camera, Download, Eye, Footprints, Hand, History, Palette, PenLine, RefreshCw, Repeat, ScanFace, Settings2, Smile, Sparkles, Video,
} from '@lucide/svelte';
import { onDestroy, onMount } from 'svelte';
import { postar } from '../lib/api';
@@ -12,6 +12,7 @@
import Grupo from '../lib/componentes/Grupo.svelte';
import Interruptor from '../lib/componentes/Interruptor.svelte';
import Linha from '../lib/componentes/Linha.svelte';
import PresencaPir from '../lib/componentes/PresencaPir.svelte';
import RostoPrevia from '../lib/componentes/RostoPrevia.svelte';
import { estado } from '../lib/estado.svelte';
import { Rastreamento } from '../lib/rastreamento.svelte';
@@ -181,7 +182,10 @@
</Grupo>
<Grupo titulo="Acontecimentos">
<Linha icone={History} cor="#34c759" rotulo="Histórico de detecções" detalhe="PIR, movimento e som, com foto" href="#/historico" />
<Linha icone={Footprints} cor="#34c759" rotulo="Sensor de presença (PIR)">
{#snippet acessorio()}<PresencaPir />{/snippet}
</Linha>
<Linha icone={History} cor="#30b0c7" rotulo="Histórico de detecções" detalhe="PIR, movimento e som, com foto" href="#/historico" />
{#if estado.feed.length}
<ol class="feed">
{#each estado.feed.slice(0, 12) as item (item.id)}
+3 -1
View File
@@ -5,6 +5,7 @@
import Interruptor from '../lib/componentes/Interruptor.svelte';
import Linha from '../lib/componentes/Linha.svelte';
import Modal from '../lib/componentes/Modal.svelte';
import PresencaPir from '../lib/componentes/PresencaPir.svelte';
import Slider from '../lib/componentes/Slider.svelte';
import { estado } from '../lib/estado.svelte';
import { historico, TIPOS_EVENTO, urlFoto, type EventoHistorico } from '../lib/historico.svelte';
@@ -33,7 +34,7 @@
const pirTexto = $derived.by(() => {
if (!st) return '';
if (!st.config.pir) return 'Desligado';
if (st.pir.disponivel) return `Pino 11 · ${st.pir.ultimo ? 'último disparo ' + quando(st.pir.ultimo) : 'aguardando presença'}`;
if (st.pir.disponivel) return 'Pino 11 · HC-SR505';
return st.pir.erro || 'Indisponível neste servidor';
});
@@ -57,6 +58,7 @@
<Grupo titulo="Sensores">
<Linha icone={Footprints} cor="#34c759" rotulo="Sensor PIR da placa" detalhe={pirTexto}>
{#snippet acessorio()}
{#if st?.config.pir}<PresencaPir />{/if}
<Interruptor rotulo="Sensor PIR da placa" checked={!!st?.config.pir} disabled={!st} onchange={(v) => historico.configurar({ pir: v })} />
{/snippet}
</Linha>