summaryrefslogtreecommitdiff
path: root/src/esp32cam_capture_diff_node.py
diff options
context:
space:
mode:
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')