Made some scripts to send snapshots from ip-cameras to telegram or via email or both. May be it will be useful for somebody. It was made with help of AI so...
And I'm on Win so all pathes are for win and not tested on unix.
Features:
- easy to add or remove cameras
- for TG you can specify socks5 proxy - the global setting
- for TG - silent mode - local setting for each script
- for email - one global recipient and you can add more recipients localy in each script
Requirements:
Git for windows - for win users
Python 3.8+
Curl 8.4+
So... unzip attachment to Domoticz\scripts\dzVents\ so it will looks like Domoticz\scripts\dzVents\tg_email_notify\....
Check files for your own settings:
- sendtoemail.lua - only path to email_debug.log
- email_config.lua - settings for email account (the same as in Dz.settings)
- sendToTelegram.lua -settings for Telegram
- create user variable 'socksEnabled' type string and value 0 - needed parameter
Usage:
Code: Select all
-- =============================================
-- 3. Cameras table
-- =============================================
local cameras = {
{
url = "http://192.168.0.87/cgi-bin/snapshot.cgi",
caption = "Camera 1", -- any string
folder = "C:/Domoticz/screensfromcams/camDvorMelni4naya/" -- any folder you want the same or different for each camera
},
{
url = "http://192.168.0.97/image.jpg",
caption = "camera 2",
folder = "C:/Domoticz/screensfromcams/camVorotaMelni4naya/"
},
{
url = "http://192.168.0.93/webcapture.jpg?command=snap&channel=0",
caption = "Camera 3",
folder = "C:/Domoticz/screensfromcams/camMelni4yayaVpered/"
}
}
-- =============================================
-- NEDEED VARIABLES Don't remove!! :
-- =============================================
local current_date_time = os.date("%Y-%m-%d_%H-%M-%S")
local deviceName = string.gsub(string.match(debug.getinfo(1, 'S').short_src, "[^/]+$"), '.lua', '') or 'Unknown'
-- =============================================
-- SAVING SNAPSHOTS:
-- =============================================
local snapshots = require("tg_email_notify/prepare_snapshots")
snapshots.prepare_snapshots(domoticz, cameras, current_date_time)
-- =============================================
-- SENDING TO TG
-- check Domoticz\scripts\dzVents\tg_email_notify\sendtotg.lua for settins
-- =============================================
local sendToTg = require("tg_email_notify/sendtotg")
local silentMode = 'true' -- or false
sendToTg.sendToTelegram(
domoticz,
cameras,
current_date_time,
silentMode
)
-- =============================================
-- SENDING TO EMAIL
-- check Domoticz\scripts\dzVents\tg_email_notify\email_config.lua for settins
-- =============================================
local emailConfig = require("tg_email_notify/email_config")
local emailModule = require("tg_email_notify/sendtoemail")
local recipients = domoticz.variables('deltaChatMy').value --..','..'[email protected]' -- one or several
emailModule.sendToEmail(
domoticz,
cameras,
emailConfig,
recipients,
deviceName,
current_date_time
)