summaryrefslogtreecommitdiff
path: root/src/esp32cam_capture_diff_node.py
diff options
context:
space:
mode:
authorEvgeny Zinoviev <me@ch1p.io>2022-06-17 00:33:19 +0300
committerEvgeny Zinoviev <me@ch1p.io>2022-06-17 00:43:26 +0300
commit58a4a28f588fe2645ee06a17718767775584becb (patch)
treecb5ca52e2fb642ee0b39b29aa7892765cb9dfa82 /src/esp32cam_capture_diff_node.py
parentfa97ccaa64e1819af3296e95dcbe10fa1c6c788d (diff)
refactor telegram message reporting
Diffstat (limited to 'src/esp32cam_capture_diff_node.py')
-rwxr-xr-xsrc/esp32cam_capture_diff_node.py12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/esp32cam_capture_diff_node.py b/src/esp32cam_capture_diff_node.py
index 38cb5b2..4363e9e 100755
--- a/src/esp32cam_capture_diff_node.py
+++ b/src/esp32cam_capture_diff_node.py
@@ -3,6 +3,7 @@ import asyncio
import logging
import os.path
import tempfile
+import home.telegram.aio as telegram
from home.config import config
from home.camera.esp32 import WebClient
@@ -53,12 +54,19 @@ class ESP32CamCaptureDiffNode:
self.nextpic = 1 if self.nextpic == 2 else 2
if not self.first:
- score = await pyssim(filename, os.path.join(self.directory, self.getfilename()))
- logger.debug(f'pyssim: diff={score}')
+ second_filename = os.path.join(self.directory, self.getfilename())
+ score = await pyssim(filename, second_filename)
+ logger.debug(f'pyssim: score={score}')
if score < config['pyssim']['threshold']:
logger.info(f'score = {score}, informing central server')
send_datagram(stringify([config['node']['name'], 2]), self.server_addr)
+ # send to telegram
+ if 'telegram' in config:
+ await telegram.send_message(f'pyssim: score={score}')
+ await telegram.send_photo(filename)
+ await telegram.send_photo(second_filename)
+
self.first = False
logger.debug('capture: done')