fix(historico): ignora a borda falsa do PIR ao iniciar a leitura do pino
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -185,9 +185,12 @@ class Historico:
|
|||||||
self.processo_pir = subprocess.Popen(['gpiomon', '-c', chip, '-b', 'pull-down', '-e', 'rising', linha],
|
self.processo_pir = subprocess.Popen(['gpiomon', '-c', chip, '-b', 'pull-down', '-e', 'rising', linha],
|
||||||
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE, text=True)
|
||||||
self.pir.update(disponivel=True, erro='')
|
self.pir.update(disponivel=True, erro='')
|
||||||
|
inicio = time.monotonic()
|
||||||
for _ in self.processo_pir.stdout:
|
for _ in self.processo_pir.stdout:
|
||||||
if not self.config['pir']:
|
if not self.config['pir']:
|
||||||
break
|
break
|
||||||
|
if time.monotonic() - inicio < 2: # o pino "assenta" ao ligar o pull-down
|
||||||
|
continue
|
||||||
self.pir['ultimo'] = time.time()
|
self.pir['ultimo'] = time.time()
|
||||||
self.registrar('pir', 'presença')
|
self.registrar('pir', 'presença')
|
||||||
erro = (self.processo_pir.stderr.read() or '').strip()[:200]
|
erro = (self.processo_pir.stderr.read() or '').strip()[:200]
|
||||||
|
|||||||
Reference in New Issue
Block a user