first commit
This commit is contained in:
5
AcerManon.sh
Executable file
5
AcerManon.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
lockfile-create "/tmp/AcerManon.lockfile"
|
||||
/usr/bin/rsync -arvlp --bwlimit=1000 --size-only --exclude videos --exclude AppData --exclude Downloads --exclude Music /media/Acer/admin/ /media/MEMUP/AcerManon/ >/tmp/sync.log 2>/tmp/sync.err
|
||||
lockfile-remove "/tmp/AcerManon.lockfile"
|
||||
5
AkhesaSouti.sh
Executable file
5
AkhesaSouti.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
lockfile-create "/tmp/AkhesaSouti.lockfile"
|
||||
/usr/bin/rsync -arvlp --bwlimit=1000 --size-only --exclude videos --exclude AppData --exclude Downloads --exclude Music /media/Akhesa/Souti/ /media/MEMUP/AkhesaSouti/ >/tmp/sync.log 2>/tmp/sync.err
|
||||
lockfile-remove "/tmp/AkhesaSouti.lockfile"
|
||||
5
AkhesaTheo.sh
Executable file
5
AkhesaTheo.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
lockfile-create "/tmp/AkhesaTheo.lockfile"
|
||||
/usr/bin/rsync -arvlp --bwlimit=1000 --size-only --exclude videos --exclude AppData --exclude Downloads --exclude Music /media/Akhesa/Théo/ /media/MEMUP/AkhesaTheo/ >/tmp/sync.log 2>/tmp/sync.err
|
||||
lockfile-remove "/tmp/AkhesaTheo.lockfile"
|
||||
BIN
Blender/sheepit-client-6.2020.0.jar
Normal file
BIN
Blender/sheepit-client-6.2020.0.jar
Normal file
Binary file not shown.
18
Hackintosh.sh
Executable file
18
Hackintosh.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
|
||||
lockfile-create "/tmp/Hackintosh.lockfile"
|
||||
if [ $( mount | grep Hackintosh | wc -l ) == 0 ] ;
|
||||
then
|
||||
sshfs souti@192.168.1.26:/Volumes/Data/ /media/Hackintosh/
|
||||
fi
|
||||
|
||||
if [ $( mount | grep Hackintosh | wc -l ) == 1 ] ;
|
||||
then
|
||||
rsync -rvl --size-only /media/WDBlue/Musique/ /media/Hackintosh/Musique/
|
||||
rsync -rvl --size-only /media/WDBlue/SeriesTV/ /media/Hackintosh/SeriesTV/
|
||||
#rsync -rvl --progress --size-only /media/WDBlue/StockagePhoto/ /media/Hackintosh/StockagePhoto/
|
||||
rsync -rvl --size-only /media/WDBlue/films/ /media/Hackintosh/films/
|
||||
fi
|
||||
|
||||
# /usr/bin/rsync -arvlp --bwlimit=1000 --size-only --exclude videos --exclude AppData --exclude Downloads --exclude Music /media/Acer/admin/ /media/MEMUP/AcerManon/ >/tmp/sync.log 2>/tmp/sync.err
|
||||
lockfile-remove "/tmp/Hackintosh.lockfile"
|
||||
2
JSON_POUR_UNDERGROUND.sh
Normal file
2
JSON_POUR_UNDERGROUND.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
wget -O - http://api.wunderground.com/api/48a08328a93a18a1/conditions/q/pws:ISAINTGR13.json
|
||||
|
||||
7
Musique.sh
Normal file
7
Musique.sh
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
mount -t cifs //musique.home/sdcard/Musique /mnt/Musique -o username=souti,password=setaou,rw,uid=$(id -u),gid=$(id -g)
|
||||
|
||||
for dir in mp3 flac Classique Clips Concerts "Chansons Francaises"; do
|
||||
rsync -aprvhu --size-only --delete "/media/WDBlue/Musique/$dir" /mnt/Musique
|
||||
done
|
||||
37
MySerial.py
Normal file
37
MySerial.py
Normal file
@@ -0,0 +1,37 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import serial
|
||||
import string
|
||||
import re # Matches
|
||||
import os
|
||||
|
||||
test=serial.Serial("/dev/ttyACM0",9600)
|
||||
test.open()
|
||||
onSort = False
|
||||
try:
|
||||
while not onSort:
|
||||
line = test.readline()
|
||||
sp = line.split(' ')
|
||||
result = bool('fumee' in line)
|
||||
if result:
|
||||
print(line)
|
||||
print(sp[0])
|
||||
print(sp[1])
|
||||
print(sp[2])
|
||||
#print(line[6:9])
|
||||
#print(line[14:18])
|
||||
#print(line[24:26])
|
||||
spCo = sp[0].split('=')
|
||||
spButane = sp[1].split('=')
|
||||
spPhoto = sp[2].split('=')[1].split('\r')
|
||||
#print(spPhoto[1].split('\r'))
|
||||
os.system("curl \"http://localhost:81/json.htm?type=command¶m=udevice&idx=110&nvalue=" + spCo[1] + "\"")
|
||||
os.system("curl \"http://localhost:81/json.htm?type=command¶m=udevice&idx=109&nvalue=" + spButane[1] + "\"")
|
||||
os.system("curl \"http://localhost:81/json.htm?type=command¶m=udevice&idx=107&svalue=" + spPhoto[0] + "\"")
|
||||
onSort = True
|
||||
|
||||
except KeyboardInterrupt:
|
||||
pass # do cleanup here
|
||||
|
||||
test.close()
|
||||
|
||||
5
PhilaeHome.sh
Executable file
5
PhilaeHome.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
lockfile-create "/tmp/PhilaeHome.lockfile"
|
||||
/usr/bin/rsync -arvlp --bwlimit=1000 --size-only --delete-during --exclude Téléchargements --exclude videos --exclude .arduino15 --exclude Downloads --exclude Music /media/WDBlue/PhilaeHome/* /home/souti/ >/tmp/sync.log 2>/tmp/sync.err
|
||||
lockfile-remove "/tmp/PhilaeHome.lockfile"
|
||||
19
Surveillance.sh
Executable file
19
Surveillance.sh
Executable file
@@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
|
||||
WATCH_DIRS=("mp3" "flac" "Classique" "Clips" "Concerts" "Chansons Francaises") # Répertoire à surveiller
|
||||
#SCRIPT="/opt/domoticz/scripts/Musique.sh" # Script à exécuter
|
||||
|
||||
mount -t cifs //musique.home/sdcard/Musique /mnt/Musique -o username=souti,password=setaou,rw,uid=$(id -u),gid=$(id -g)
|
||||
|
||||
|
||||
for dir in "${WATCH_DIRS[@]}"; do
|
||||
inotifywait -m -e create,modify,delete,move "/media/WDBlue/Musique/$dir" |
|
||||
while read -r directory events filename; do
|
||||
echo "Changement détecté dans $directory : $events sur $filename"
|
||||
#bash "$SCRIPT" "$directory" "$filename" "$events"
|
||||
lockfile-create "/tmp/synchro.lockfile"
|
||||
rsync -aprvhu --size-only "$directory/" "/mnt/Musique/$dir/" > "/tmp/synch_directory"
|
||||
lockfile-remove "/tmp/synchro.lockfile"
|
||||
done &
|
||||
done
|
||||
|
||||
10
_domoticz_main
Normal file
10
_domoticz_main
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
startup_path=$1
|
||||
hardware_id=$2
|
||||
device_id=$3
|
||||
status=$4
|
||||
status2=$5
|
||||
devname=$6
|
||||
|
||||
echo "startup_path=${startup_path}, hardware_id=${hardware_id}, device_id=${device_id}, status=${status}, status2=${status2}, devname=${devname}"
|
||||
10
_domoticz_main.bat
Normal file
10
_domoticz_main.bat
Normal file
@@ -0,0 +1,10 @@
|
||||
@echo off
|
||||
set startup_path=%1
|
||||
set hardware_id=%2
|
||||
set device_id=%3
|
||||
set status=%4
|
||||
set status2=%5
|
||||
set devname=%6
|
||||
|
||||
:: %startup_path% %hardware_id% %device_id% %status% %status2% %devname%
|
||||
|
||||
17
backup/domoticz
Executable file
17
backup/domoticz
Executable file
@@ -0,0 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
service domoticz.sh stop
|
||||
|
||||
cd /opt/domoticz/
|
||||
#tar -czf /tmp/domoticz.tgz .
|
||||
tar --exclude="./backups" -czf /tmp/domoticz.tgz .
|
||||
#tar -cz --exclude="./backups" -f /tmp/domoticz.tgz .
|
||||
|
||||
cp /tmp/domoticz.tgz /media/WDBlue/backup/ImagesMyPi/domoticz"$(date '+%Y-%m-%d')".tgz
|
||||
#scp /tmp/domoticz.tgz pi@volumio2:/media/WDRed/backup/
|
||||
|
||||
service domoticz.sh start
|
||||
|
||||
#rm /tmp/domoticz.tgz
|
||||
|
||||
|
||||
8
backup/domoticzOpt
Executable file
8
backup/domoticzOpt
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /opt/domoticz;
|
||||
/bin/tar cvzf /tmp/opt.tgz *;
|
||||
/bin/cp /tmp/opt.tgz /media/Backup/domoticz/domoticz"$(date '+%Y-%m-%d')".tgz;
|
||||
|
||||
|
||||
|
||||
7
backup/domoticzScripts
Executable file
7
backup/domoticzScripts
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /opt/domoticz/scripts/;
|
||||
/bin/tar cvzf /tmp/scriptsDomoticz.tgz *;
|
||||
/bin/cp /tmp/scriptsDomoticz.tgz /media/Backup/domoticz/scriptsDomoticz"$(date '+%Y-%m-%d')".tgz;
|
||||
|
||||
|
||||
7
backup/domoticzWww
Executable file
7
backup/domoticzWww
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
cd /var/www/;
|
||||
/bin/tar cvzf /tmp/varwww.tgz *;
|
||||
/bin/cp /tmp/varwww.tgz /media/Backup/domoticz/varwww"$(date '+%Y-%m-%d')".tgz;
|
||||
|
||||
|
||||
2
backup/exclude.txt
Normal file
2
backup/exclude.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
domoticz
|
||||
domoticz*.db*
|
||||
7
backup/octoprint
Executable file
7
backup/octoprint
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
tar czf /tmp/octoprint.tgz /opt/OctoPrint/*
|
||||
|
||||
cp /tmp/octoprint.tgz /media/WDBlue/backup/ImagesMyPi/octoprint"$(date '+%Y-%m-%d')".tgz
|
||||
|
||||
tar cvzf /media/WDBlue/backup/ImageMyPi/klipper_configurated"$(date '+%Y-%m-%d')".tgz /home/souti/klipper /home/souti/klippy-env /home/souti/printer.cfg
|
||||
5
backup/saveOctoprint.sh
Executable file
5
backup/saveOctoprint.sh
Executable file
@@ -0,0 +1,5 @@
|
||||
#!/bin/bash
|
||||
|
||||
/bin/tar -cvzf /media/WDBlue/backup/ImagesMyPi/Octoprint"$(date '+%Y-%m-%d')".tgz /home/souti/OctoPrint/*
|
||||
/bin/tar -cvzf /media/WDBlue/backup/ImagesMyPi/saveOctoprintData"$(date '+%Y-%m-%d')".tgz --exclude=uploads --exclude=logs /home/souti/.octoprint/
|
||||
/bin/tar -cvzf /media/WDBlue/backup/ImagesMyPi/saveOctoprint2Data"$(date '+%Y-%m-%d')".tgz --exclude=uploads --exclude=logs /home/souti/.octoprint2/
|
||||
3
backupOctprint.sh
Normal file
3
backupOctprint.sh
Normal file
@@ -0,0 +1,3 @@
|
||||
!/bin/bash
|
||||
|
||||
tar cvz --exclude=uploads --exclude=logs -f /media/WDBlue/backup/saveOctoprint"$(date '+%H')".tgz /home/souti/.octoprint/
|
||||
13
banned.sh
Executable file
13
banned.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
#var=`/usr/bin/fail2ban-client status sshd |grep "Total banned"|awk -F":" '{print $2}'`
|
||||
|
||||
# remove leading whitespace characters
|
||||
#banned="${var#"${var%%[![:space:]]*}"}"
|
||||
|
||||
banned=`/usr/sbin/iptables -L -n --line|/bin/grep REJECT|wc -l`
|
||||
json="http://localhost:81/json.htm?type=command¶m=udevice&idx=700&svalue=$banned"
|
||||
echo $json
|
||||
|
||||
curl -s -i -H "Accept: application/json" $json
|
||||
echo $banned;
|
||||
43
batterie.py
Normal file
43
batterie.py
Normal file
@@ -0,0 +1,43 @@
|
||||
import curses
|
||||
import json
|
||||
import requests
|
||||
|
||||
# URL de l'API
|
||||
url = "http://192.168.1.18/getData"
|
||||
|
||||
def fetch_data(url):
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
return {}
|
||||
|
||||
def display_data(screen, data):
|
||||
screen.clear()
|
||||
|
||||
rows, cols = screen.getmaxyx()
|
||||
|
||||
# Clés et valeurs
|
||||
keys = list(data.keys())
|
||||
values = list(data.values())
|
||||
|
||||
# Largeur des colonnes
|
||||
col_width = max(len(key) for key in keys) + 2 # Largeur de la colonne des clés
|
||||
col_width_value = max(len(str(value)) for value in values) + 2 # Largeur de la colonne des valeurs
|
||||
|
||||
for idx, (key, value) in enumerate(data.items()):
|
||||
key_str = f"{key}:"
|
||||
value_str = str(value)
|
||||
screen.addstr(idx, 0, key_str.ljust(col_width))
|
||||
screen.addstr(idx, col_width, value_str.ljust(col_width_value))
|
||||
|
||||
screen.refresh()
|
||||
|
||||
def main(screen):
|
||||
data = fetch_data(url)
|
||||
display_data(screen, data)
|
||||
screen.getch()
|
||||
|
||||
if __name__ == "__main__":
|
||||
curses.wrapper(main)
|
||||
|
||||
74
batterie2.py
Normal file
74
batterie2.py
Normal file
@@ -0,0 +1,74 @@
|
||||
import curses
|
||||
import json
|
||||
import requests
|
||||
import time
|
||||
|
||||
# URL de l'API
|
||||
url = "http://192.168.1.59/getData"
|
||||
excluded_keys = {"FW", "PID", "SER#", "TENSIONS", "OR", "HSDS", "XY_ON", "XY_AV", "XY_AC", "XY_AW", "CONS"}
|
||||
|
||||
def fetch_data(url):
|
||||
response = requests.get(url)
|
||||
if response.status_code == 200:
|
||||
return response.json()
|
||||
else:
|
||||
return {}
|
||||
|
||||
def display_headers(screen, keys, max_width):
|
||||
screen.clear()
|
||||
for idx, key in enumerate(keys):
|
||||
if idx * max_width < curses.COLS:
|
||||
try:
|
||||
screen.addstr(0, idx * max_width, key.ljust(max_width)[:max_width], curses.color_pair(1))
|
||||
except curses.error:
|
||||
pass
|
||||
screen.refresh()
|
||||
|
||||
def display_data(screen, data, keys, line, max_width):
|
||||
for idx, key in enumerate(keys):
|
||||
if idx * max_width < curses.COLS:
|
||||
value_str = str(data.get(key, ""))
|
||||
if key == "PPV" and float(value_str) > 0:
|
||||
color = curses.color_pair(3) # Red background for PPV > 0
|
||||
else:
|
||||
color = curses.color_pair(2) # Default color
|
||||
screen.addstr(line, idx * max_width, value_str.ljust(max_width)[:max_width], color)
|
||||
|
||||
screen.refresh()
|
||||
|
||||
def main(screen):
|
||||
curses.curs_set(0) # Hide the cursor
|
||||
screen.nodelay(True) # Don't block waiting for user input
|
||||
# Initialize colors
|
||||
curses.start_color()
|
||||
curses.init_pair(1, curses.COLOR_WHITE, curses.COLOR_BLUE) # Header color
|
||||
curses.init_pair(2, curses.COLOR_BLACK, curses.COLOR_CYAN) # Data color
|
||||
curses.init_pair(3, curses.COLOR_RED, curses.COLOR_CYAN) # PPV > 0 color
|
||||
|
||||
keys = None
|
||||
max_width = 9 # Maximum width for each column
|
||||
|
||||
line = 1
|
||||
while True:
|
||||
data = fetch_data(url)
|
||||
if line == 1: #keys is None:
|
||||
keys = [key for key in data.keys() if key not in excluded_keys]
|
||||
display_headers(screen, keys, max_width)
|
||||
|
||||
try:
|
||||
display_data(screen, data, keys, line, max_width)
|
||||
except curses.error:
|
||||
line = 0
|
||||
screen.clear()
|
||||
pass
|
||||
|
||||
line += 1
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
if screen.getch() != -1:
|
||||
break
|
||||
|
||||
if __name__ == "__main__":
|
||||
curses.wrapper(main)
|
||||
|
||||
96
buienradar_rain.pl
Normal file
96
buienradar_rain.pl
Normal file
@@ -0,0 +1,96 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
use strict;
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Cookies;
|
||||
|
||||
my $lat=50.22041;
|
||||
my $long=5.89744;
|
||||
my $domoticz_ip="127.0.0.1";
|
||||
my $domoticz_port="8080";
|
||||
my $domoticz_sensor_idx="2442";
|
||||
my $duration=15;
|
||||
|
||||
my @user_agents = (
|
||||
'Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)'
|
||||
);
|
||||
|
||||
my $ua = LWP::UserAgent->new(
|
||||
#Set agent name, we are not a script! :)
|
||||
agent => $user_agents[rand @user_agents],
|
||||
cookie_jar => HTTP::Cookies->new(),
|
||||
);
|
||||
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
|
||||
|
||||
my $startTime=($hour*60)+$min;
|
||||
my $endTime=$startTime+$duration;
|
||||
|
||||
my $url = "http://gps.buienradar.nl/getrr.php?lat=$lat&lon=$long";
|
||||
my $response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
# hmm, let's retry
|
||||
$response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
# still no luck; sleep and retry
|
||||
sleep 1;
|
||||
$response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
print "Could not connect to buienradar.nl.\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $data = $response->content;
|
||||
|
||||
unless ($data =~ /\A((\d{3})?\|\d{2}:\d{2}\r?\n)+\z/) {
|
||||
print "Could not parse the data returned by buienradar.nl.\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $total_rain_predictions=0;
|
||||
my $total_rain_values=0;
|
||||
|
||||
while ($data =~ s/\A(\d{3})?\|(\d{2}:\d{2})\r?\n//) {
|
||||
my ($value, $mtime) = ($1, $2);
|
||||
|
||||
if (defined $value) {
|
||||
|
||||
my @hour_min = split(':', $mtime);
|
||||
my $mhour = $hour_min[0];
|
||||
my $mmin = $hour_min[1];
|
||||
my $calc_time=($mhour*60)+$mmin;
|
||||
if (($calc_time>=$startTime)&&($calc_time<=$endTime)) {
|
||||
$value =~ s/\A0+(\d)/$1/;
|
||||
$total_rain_predictions+=$value;
|
||||
$total_rain_values+=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $result = "0.0";
|
||||
|
||||
if ($total_rain_values!=0) {
|
||||
my $rain_0_100=($total_rain_predictions/$total_rain_values)*0.392156862745098;
|
||||
$result = sprintf("%.2f", $rain_0_100);
|
||||
}
|
||||
|
||||
$url = "http://$domoticz_ip:$domoticz_port/json.htm?type=command¶m=udevice&idx=$domoticz_sensor_idx&nvalue=0&svalue=$result";
|
||||
$response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
print "Error sending data to domoticz!\n";
|
||||
exit 0;
|
||||
}
|
||||
$data = $response->content;
|
||||
|
||||
if (index($data, "\"OK\"") == -1) {
|
||||
print "Error sending data to domoticz!\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
print "OK, precip=$result\n";
|
||||
123
buienradar_rain_example.pl
Normal file
123
buienradar_rain_example.pl
Normal file
@@ -0,0 +1,123 @@
|
||||
#!/usr/bin/perl -w
|
||||
|
||||
=head1 buienradar_rain.pl
|
||||
|
||||
Installation:
|
||||
|
||||
Perl, you need to install the LWP module:
|
||||
sudo apt-get install libjson-perl
|
||||
|
||||
In Domoticz create a Dummy Percentage sensor.
|
||||
Next go to the Devices overview, and write down the 'idx' value of the sensor.
|
||||
|
||||
Copy this file to another location and edit the setting below to match your situation.
|
||||
|
||||
cp /home/pi/domoticz/scripts/buienradar_rain_example.pl /home/pi/domoticz/buienradar_rain.pl
|
||||
nano /home/pi/domoticz/buienradar_rain.pl
|
||||
|
||||
Next add a Crontab rule:
|
||||
|
||||
crontab -e
|
||||
|
||||
Add the following line at the end:
|
||||
|
||||
*/5 * * * * perl /home/pi/domoticz/buienradar_rain.pl
|
||||
|
||||
In 5 minutes, the sensor should work
|
||||
|
||||
=cut
|
||||
|
||||
use strict;
|
||||
use LWP::UserAgent;
|
||||
use HTTP::Cookies;
|
||||
|
||||
my $lat=50.22041;
|
||||
my $long=5.89744;
|
||||
my $domoticz_ip="127.0.0.1";
|
||||
my $domoticz_port="8080";
|
||||
my $domoticz_sensor_idx="2442";
|
||||
my $duration=15;
|
||||
|
||||
my @user_agents = (
|
||||
'Mozilla/4.0 (compatible; MSIE 4.01; Windows 98)'
|
||||
);
|
||||
|
||||
my $ua = LWP::UserAgent->new(
|
||||
#Set agent name, we are not a script! :)
|
||||
agent => $user_agents[rand @user_agents],
|
||||
cookie_jar => HTTP::Cookies->new(),
|
||||
);
|
||||
|
||||
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
|
||||
|
||||
my $startTime=($hour*60)+$min;
|
||||
my $endTime=$startTime+$duration;
|
||||
|
||||
my $url = "http://gps.buienradar.nl/getrr.php?lat=$lat&lon=$long";
|
||||
my $response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
# hmm, let's retry
|
||||
$response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
# still no luck; sleep and retry
|
||||
sleep 1;
|
||||
$response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
print "Could not connect to buienradar.nl.\n";
|
||||
exit 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $data = $response->content;
|
||||
|
||||
unless ($data =~ /\A((\d{3})?\|\d{2}:\d{2}\r?\n)+\z/) {
|
||||
print "Could not parse the data returned by buienradar.nl.\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
my $total_rain_predictions=0;
|
||||
my $total_rain_values=0;
|
||||
|
||||
while ($data =~ s/\A(\d{3})?\|(\d{2}:\d{2})\r?\n//) {
|
||||
my ($value, $mtime) = ($1, $2);
|
||||
|
||||
if (defined $value) {
|
||||
|
||||
my @hour_min = split(':', $mtime);
|
||||
my $mhour = $hour_min[0];
|
||||
my $mmin = $hour_min[1];
|
||||
my $calc_time=($mhour*60)+$mmin;
|
||||
if (($calc_time>=$startTime)&&($calc_time<=$endTime)) {
|
||||
$value =~ s/\A0+(\d)/$1/;
|
||||
$total_rain_predictions+=$value;
|
||||
$total_rain_values+=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $result = "0.0";
|
||||
|
||||
if ($total_rain_values!=0) {
|
||||
my $rain_0_100=($total_rain_predictions/$total_rain_values)*0.392156862745098;
|
||||
$result = sprintf("%.2f", $rain_0_100);
|
||||
}
|
||||
|
||||
$url = "http://$domoticz_ip:$domoticz_port/json.htm?type=command¶m=udevice&idx=$domoticz_sensor_idx&nvalue=0&svalue=$result";
|
||||
$response = $ua->get($url);
|
||||
|
||||
unless ($response->is_success) {
|
||||
print "Error sending data to domoticz!\n";
|
||||
exit 0;
|
||||
}
|
||||
$data = $response->content;
|
||||
|
||||
if (index($data, "\"OK\"") == -1) {
|
||||
print "Error sending data to domoticz!\n";
|
||||
exit 0;
|
||||
}
|
||||
|
||||
print "OK, precip=$result\n";
|
||||
148
cal_action.py
Normal file
148
cal_action.py
Normal file
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
|
||||
# il faut le module requests
|
||||
# sudo pip install requests
|
||||
|
||||
|
||||
# on lit le fichier genere par getgoovlecal.py
|
||||
# dans le calendrier google on fait soit
|
||||
# idx=etat (14=On ou 44=Off)
|
||||
#
|
||||
# ou idx1;idx2;idx3=etat
|
||||
# 25/01/15 correction pour mode debug qui lance la cde alors que le mode ss debug non
|
||||
# 25/01/15 mode auth pour identification Domoticz
|
||||
|
||||
|
||||
|
||||
import time
|
||||
import os
|
||||
import requests
|
||||
from requests.auth import HTTPBasicAuth
|
||||
import csv
|
||||
from collections import namedtuple
|
||||
from datetime import datetime
|
||||
|
||||
############# Parametres #################################
|
||||
|
||||
# fichier et chemin pour agenda
|
||||
rep="/var/tmp/"
|
||||
file="googlecal.txt"
|
||||
|
||||
# seuil pour declemecnhemnt des actions
|
||||
# c'est la tolerance autour de l'heure prevue par rapport a l'heure exacte
|
||||
# cest a dire que X secondes AVANT l heure prevue on declenche
|
||||
seuil=10
|
||||
|
||||
#a cause du declenchelent de crontab qui a lieu entre 0 et 5sec apres l'heure prevue
|
||||
# un crontab programme toutes les minutes peut se declencher a 1min0sec, 1min1sec ,1min2sec ... 1min5sec
|
||||
# donc on gere un seuil de X secondes APRES l'heure prevue
|
||||
# si declenchement tt les minutes dans crontab
|
||||
# si le seuil est a 10 sec
|
||||
# l'action pourra se declencher 1O secondes avant
|
||||
# et si c'est croontab qui declcenche on laisse 10 secondes APRES
|
||||
|
||||
|
||||
#debug = 1 on affiche les chaines de caracteres recues
|
||||
debug=1
|
||||
|
||||
|
||||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# les parametres de Domoticz
|
||||
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
domoticz_ip='localhost'
|
||||
domoticz_port='81'
|
||||
user='souti'
|
||||
password='setaou'
|
||||
|
||||
# l URL Domoticz est construite dans maj_switch pour allumer/eteidndre
|
||||
# avec les bouts ci dessous
|
||||
json_url1='/json.htm?type=command¶m=switchlight&idx='
|
||||
json_url2='&switchcmd='
|
||||
json_url3='&level=0'
|
||||
|
||||
# fin du parametrage #
|
||||
############### fin des parametres #############################
|
||||
|
||||
def maj_switch(idx,etat):
|
||||
|
||||
#/json.htm?type=command¶m=switchlight&idx=&switchcmd=&level=0
|
||||
|
||||
requete='http://'+domoticz_ip+':'+domoticz_port+json_url1+idx+json_url2+etat+json_url3
|
||||
r=requests.get (requete,auth=HTTPBasicAuth(user,password))
|
||||
if debug!=0:
|
||||
print "______________________________________________________________"
|
||||
print ""
|
||||
print ("URL= :",requete)
|
||||
print (" le serveur Domoticz dit : ",r)
|
||||
print ""
|
||||
print "###############################################################"
|
||||
|
||||
def debugmode():
|
||||
print ""
|
||||
print "###############################################################"
|
||||
print ""
|
||||
print ("le fichier dit que l'action ",r.action,"debute a ",r.heuredeb,"le :",r.datedeb)
|
||||
print ("heure declenchement ",heure_action)
|
||||
print ("il est ",present)
|
||||
print ("difference en secondes",diffsecondes)
|
||||
print ""
|
||||
print ""
|
||||
|
||||
# main #
|
||||
|
||||
reader = csv.reader(open(rep+file),delimiter='\t')
|
||||
rec=namedtuple('rec','datedeb heuredeb datefin heurefin action')
|
||||
|
||||
for r in map(rec._make,reader):
|
||||
date_action=r.datedeb+" "+r.heuredeb
|
||||
heure_action= datetime.strptime(date_action,"%Y-%m-%d %H:%M")
|
||||
present=datetime.now()
|
||||
diffsecondes=(heure_action-present).seconds
|
||||
# diffsecondes=4
|
||||
if (diffsecondes < seuil or (diffsecondes> 86400-seuil and diffsecondes <86400)):
|
||||
if debug!=0:
|
||||
debugmode()
|
||||
todo=r.action.split("=")
|
||||
idx=todo[0]
|
||||
etat=todo[1].capitalize()
|
||||
|
||||
if ";" in idx:
|
||||
#print "multiples idx"
|
||||
midx=idx.split(";")
|
||||
for each_idx in midx:
|
||||
print (" IDX : ",each_idx)
|
||||
if (etat=="On" or etat=="Off"):
|
||||
if debug!=0:
|
||||
print ""
|
||||
print "ok actions a faire"
|
||||
print ("idx=",each_idx)
|
||||
print ("etat=",etat)
|
||||
print ""
|
||||
|
||||
maj_switch(each_idx,etat)
|
||||
|
||||
else:
|
||||
if (etat=="On" or etat=="Off"):
|
||||
if debug!=0:
|
||||
print ""
|
||||
print "ok actions a faire"
|
||||
print ("idx=",idx)
|
||||
print ("etat=",etat)
|
||||
print ""
|
||||
|
||||
maj_switch(idx,etat)
|
||||
|
||||
else:
|
||||
if debug!=0:
|
||||
print "Rien a faire /nothing to do/wir haben nichts damit zu tun"
|
||||
debugmode()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
11
cam.sh
Executable file
11
cam.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=1148
|
||||
|
||||
movies=`find /media/WDBlue/motion/CAM1/*.avi -mmin -2|wc -l`
|
||||
echo $movies
|
||||
curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$IDX&nvalue=0&svalue=$movies" &
|
||||
|
||||
exit 0
|
||||
10
changevol.sh
Executable file
10
changevol.sh
Executable file
@@ -0,0 +1,10 @@
|
||||
#!/bin/bash
|
||||
|
||||
#sleep 1
|
||||
|
||||
value=`curl "http://localhost:81/json.htm?type=devices&rid=202" 2>/dev/null|grep \"Level\"|awk -F: '{print $2}' |awk -F, '{print $1}'`
|
||||
|
||||
|
||||
/opt/domoticz/scripts/vol $value
|
||||
|
||||
#return $value
|
||||
45
check.sh
Executable file
45
check.sh
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/bash
|
||||
# Script qui vérifie l'état de domoticz et qui relance si off
|
||||
|
||||
PATH=/opt/domoticz/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
|
||||
|
||||
now=$(date) #récupération de la date et heure pour les logs
|
||||
echo $now
|
||||
#Récupération du retour de la commande de status
|
||||
domoticz=$(/usr/sbin/service domoticz.sh status |egrep "inactive|failed" |wc -l)
|
||||
echo "statut domoticz" $domoticz
|
||||
|
||||
#grep "Error: RFLink: TX time out..." /var/log/domoticz.log |tail -n 1|cut -c 1-16
|
||||
#status=$(/usr/sbin/service domoticz.sh status) #On le lance
|
||||
|
||||
#echo $domoticz $status
|
||||
rflink=$(tail -n5000 /var/log/domoticz.log|grep -y "RFXCOM: Unhandled switch command" |wc -l)
|
||||
rflink2=$(tail -n5000 /var/log/domoticz.log|grep -y "RFXCOM: TX time out..." |wc -l)
|
||||
#rflink2=$(grep -y "Error: RFLink: TX time out..." /var/log/domoticz.log |wc -l)
|
||||
echo "Unhandled switch" $rflink
|
||||
echo "Time out" $rflink2
|
||||
|
||||
if [ "$domoticz" -ge "1" ] # Si le service n'est pas lancé
|
||||
then
|
||||
relance=$(/usr/sbin/service domoticz.sh restart) #On le lance
|
||||
echo "$now >> relance : $relance" #On log la lancement
|
||||
else
|
||||
echo "$now >> Domoticz lancé" #On log l'état normal
|
||||
fi
|
||||
|
||||
if [ "$rflink" -ge "1" ] # Si le service n'est pas lancé
|
||||
then
|
||||
cat /dev/null > /var/log/domoticz.log
|
||||
relance=$(/usr/sbin/service domoticz.sh restart) #On le lance
|
||||
echo "$now >> relance : $relance" #On log la lancement
|
||||
fi
|
||||
|
||||
if [ "$rflink2" -ge "1" ] # Si le service n'est pas lancé
|
||||
then
|
||||
cat /dev/null > /var/log/domoticz.log
|
||||
relance=$(/usr/sbin/service domoticz.sh restart) #On le lance
|
||||
echo "$now >> relance rflink : $relance" #On log la lancement
|
||||
fi
|
||||
|
||||
exit 0
|
||||
|
||||
13
check_RFXCOM.sh
Executable file
13
check_RFXCOM.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=330
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/lib/
|
||||
cnt=`tail -n50000 /var/log/domoticz.log |grep -y "Error: RFXCOM: TX time out"|wc -l`
|
||||
|
||||
if [ "cnt" -gt 0 ]; then
|
||||
service domoticz restart
|
||||
fi
|
||||
|
||||
exit 0
|
||||
13
clamscan.sh
Executable file
13
clamscan.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=330
|
||||
|
||||
nice -n 10 clamscan -r -i --max-filesize=100M --exclude "\.(CR2|TIF|tif|img|IMG|mp4|mp3|mov|flv|mkv|avi|AVI|MKV|MP4|MP3|MOV|mpg|MPG|jpg|JPG|nfo|png|PNG|html|htm|HTM|HTML|idx|gif|txt|TXT)$" --cross-fs=no /home/souti/ >/tmp/clamscanMEMUP.txt
|
||||
|
||||
virus=`cat /tmp/clamscanMEMUP.txt |grep FOUND|wc -l`
|
||||
|
||||
curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$IDX&nvalue=0&svalue=$virus" &
|
||||
|
||||
exit 0
|
||||
13
clamscanWDBlue.sh
Executable file
13
clamscanWDBlue.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="192.168.1.3" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=331
|
||||
|
||||
nice -n 0 clamscan -r -i --max-filesize=100M --exclude "\.(CR2|cr2|info|xmp|java|class|o|epub|xml|vdi|log|img|IMG|flac|mp4|mp3|mov|flv|mkv|avi|AVI|MKV|MP4|MP3|MOV|mpg|MPG|jpg|JPG|nfo|png|PNG|html|htm|HTM|HTML|idx|gif|txt|TXT|java|php|htm|html)$" --cross-fs=no /media/Backup/ >/tmp/clamscanWDBlue.txt
|
||||
|
||||
virus=`cat /tmp/clamscanWDBlue.txt |grep FOUND|wc -l`
|
||||
|
||||
curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$IDX&nvalue=0&svalue=$virus" &
|
||||
|
||||
exit 0
|
||||
15
clamscandomoticz.sh
Executable file
15
clamscandomoticz.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=330
|
||||
|
||||
lockfile-create --lock-name "/tmp/clamscandomoticz.lockfile"
|
||||
nice -n 12 clamscan -r -i --max-filesize=100M --exclude "\.(CR2|TIF|tif|img|IMG|mp4|mp3|mov|flv|mkv|avi|AVI|MKV|MP4|MP3|MOV|mpg|MPG|jpg|JPG|nfo|png|PNG|html|htm|HTM|HTML|idx|gif|txt|TXT)$" --cross-fs=no /opt/domoticz/ >/tmp/clamscanDomoticz.txt
|
||||
|
||||
virus=`cat /tmp/clamscanDomoticz.txt |grep FOUND|wc -l`
|
||||
|
||||
curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$IDX&nvalue=0&svalue=$virus" &
|
||||
|
||||
lockfile-remove --lock-name "/tmp/clamscandomoticz.lockfile"
|
||||
exit 0
|
||||
15
clamscanfulldomoticz.sh
Executable file
15
clamscanfulldomoticz.sh
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=330
|
||||
|
||||
lockfile-create --lock-name "/tmp/clamscanfulldomoticz.lockfile"
|
||||
nice -n 12 clamscan -r -i --max-filesize=10M --exclude=/media --exclude "\.(CR2|TIF|tif|img|IMG|mp4|mp3|mov|flv|mkv|avi|AVI|MKV|MP4|MP3|MOV|mpg|MPG|jpg|JPG|nfo|png|PNG|html|htm|HTM|HTML|idx|gif|txt|TXT)$" --cross-fs=no / >/tmp/clamscanFullDomoticz.txt
|
||||
|
||||
virus=`cat /tmp/clamscanFullDomoticz.txt |grep FOUND|wc -l`
|
||||
|
||||
curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$IDX&nvalue=0&svalue=$virus" &
|
||||
lockfile-remove --lock-name "/tmp/clamscanfulldomoticz.lockfile"
|
||||
|
||||
exit 0
|
||||
13
clamscanpath.sh
Executable file
13
clamscanpath.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=330
|
||||
|
||||
nice -n 10 clamscan -r -i --max-filesize=100M --exclude "\.(CR2|TIF|tif|img|IMG|mp4|mp3|mov|flv|mkv|avi|AVI|MKV|MP4|MP3|MOV|mpg|MPG|jpg|JPG|nfo|png|PNG|html|htm|HTM|HTML|idx|gif|txt|TXT)$" --cross-fs=no $1 >/tmp/clamscanpath.txt
|
||||
|
||||
virus=`cat /tmp/clamscanpath.txt |grep FOUND|wc -l`
|
||||
|
||||
#curl -y 1 -s "http://$DOMO_IP:$DOMO_PORT/json.htm?type=command¶m=udevice&idx=$IDX&nvalue=0&svalue=$virus" &
|
||||
|
||||
exit 0
|
||||
227
crontab.bak
Normal file
227
crontab.bak
Normal file
@@ -0,0 +1,227 @@
|
||||
# DO NOT EDIT THIS FILE - edit the master and reinstall.
|
||||
# (/tmp/crontab.v3hKb5/crontab installed on Wed May 20 23:29:42 2020)
|
||||
# (Cron version -- $Id: crontab.c,v 2.13 1994/01/17 03:20:37 vixie Exp $)
|
||||
# Edit this file to introduce tasks to be run by cron.
|
||||
#
|
||||
# Each task to run has to be defined through a single line
|
||||
# indicating with different fields when the task will be run
|
||||
# and what command to run for the task
|
||||
#
|
||||
# To define the time you can provide concrete values for
|
||||
# minute (m), hour (h), day of month (dom), month (mon),
|
||||
# and day of week (dow) or use '*' in these fields (for 'any').#
|
||||
# Notice that tasks will be started based on the cron's system
|
||||
# daemon's notion of time and timezones.
|
||||
#
|
||||
# Output of the crontab jobs (including errors) is sent through
|
||||
# email to the user the crontab file belongs to (unless redirected).
|
||||
#
|
||||
# For example, you can run a backup of all your user accounts
|
||||
# at 5 a.m every week with:
|
||||
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
|
||||
#
|
||||
# For more information see the manual pages of crontab(5) and cron(8)
|
||||
#
|
||||
# m h dom mon dow command
|
||||
|
||||
# Edit this file to introduce tasks to be run by cron.
|
||||
#
|
||||
# Each task to run has to be defined through a single line
|
||||
# indicating with different fields when the task will be run
|
||||
# and what command to run for the task
|
||||
#
|
||||
# To define the time you can provide concrete values for
|
||||
# minute (m), hour (h), day of month (dom), month (mon),
|
||||
# and day of week (dow) or use '*' in these fields (for 'any').#
|
||||
# Notice that tasks will be started based on the cron's system
|
||||
# daemon's notion of time and timezones.
|
||||
#
|
||||
# Output of the crontab jobs (including errors) is sent through
|
||||
# email to the user the crontab file belongs to (unless redirected).
|
||||
#
|
||||
# For example, you can run a backup of all your user accounts
|
||||
# at 5 a.m every week with:
|
||||
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
|
||||
#
|
||||
# For more information see the manual pages of crontab(5) and cron(8)
|
||||
#
|
||||
# m h dom mon dow command
|
||||
MAILTO=""
|
||||
|
||||
#0 21 15 * * tar czf /tmp/sketch.tgz /home/souti/Arduino/*; cp /tmp/sketch.tgz /media/WDBlue/backup/; cp /tmp/sketch.tgz /home/souti/Google\ Drive/
|
||||
#30 21 10 * * tar czf /tmp/arduino-1.6.0.tgz /home/souti/Téléchargements/arduino-1.6.0/*; cp /tmp/arduino-1.6.0.tgz /home/souti/Google\ Drive/; mv /tmp/arduino-1.6.0.tgz /media/WDBlue/backup/
|
||||
#35 21 5 * * tar czf /tmp/arduino-1.6.5.tgz /home/souti/Téléchargements/arduino-1.6.5/*; cp /tmp/arduino-1.6.5.tgz /home/souti/Google\ Drive/; mv /tmp/arduino-1.6.5.tgz /media/WDBlue/backup/
|
||||
#05 12 1 * * cp /media/WDBlue/backup/scriptsDomoticz.tgz /home/souti/Google\ Drive/
|
||||
|
||||
0 20 20 * * rsync -arvl --size-only --bwlimit=100 /media/WDBlue/Documents /home/souti/Dropbox
|
||||
|
||||
#30 20 * * * tar czf /home/souti/Google\ Drive/Arduino.tgz /home/souti/Arduino/*
|
||||
|
||||
#0 20 * * * tar czf /tmp/document.tgz /home/souti/Dropbox; cp /tmp/document.tgz /home/souti/Google\ Drive/
|
||||
|
||||
#Synchro Clips
|
||||
#0 09 * * * rsync -arvl --size-only --bwlimit=100 /home/souti/Musique/Clips/ /media/WDBlue/Musique/Clips/
|
||||
|
||||
#0 11 * * * rsync -arvl --size-only --bwlimit=100 /home/souti/Musique/Concerts/ /media/WDBlue/Musique/Concerts/
|
||||
|
||||
#0 12 * * * rsync -arvl --size-only --delete-during /media/Philae/Impression3D /media/WDBlue/
|
||||
#41 18 * * * rsync -arvl --size-only --delete-during --exclude=".*" /home/souti/ /media/WDBlue/Home_Souti_Akhenaton
|
||||
|
||||
#*/30 * * * * scp -r souti@philae:/var/www/html/PhpTest/* /home/souti/scripts/Php/
|
||||
#5 0 * * * rsync -arvl --size-only /media/WDBlue/Musique/ /media/MEMUP/Musique/
|
||||
|
||||
#Update Clamav (Anti virus)
|
||||
0 13 * * 3 /usr/bin/freshclam >> /var/log/resul_freshclam.txt
|
||||
|
||||
# Scan (Anti virus)
|
||||
#0 12 * * 1 clamscan -r /home/pi --cross-fs=no --detect-pua=yes >/tmp/clamscan.txt
|
||||
0 13 * * 2 /opt/domoticz/scripts/clamscan.sh
|
||||
0 13 * * 1 /opt/domoticz/scripts/clamscanWDBlue.sh
|
||||
|
||||
10 14 * * * /opt/domoticz/scripts/prestashop.sh
|
||||
# Pas besoin de le faire toutes les heures actuellement
|
||||
10 12 * * * /opt/domoticz/scripts/prestashopHourly.sh
|
||||
|
||||
20 20 * * * /bin/tar cvzf /media/WDBlue/backup/ImagesMyPi/Octoprint"$(date '+%Y-%m-%d')".tgz /home/souti/OctoPrint/*
|
||||
30 20 * * * /bin/tar cvz --exclude=uploads --exclude=logs -f /tmp/saveOctoprintData"$(date '+%H-%m-%d')".tgz /home/souti/.octoprint/
|
||||
40 20 * * * /bin/tar cvz --exclude=uploads --exclude=logs -f /tmp/saveOctoprint2Data"$(date '+%H-%m-%d')".tgz /home/souti/.octoprint2/
|
||||
|
||||
# Mount Hackintosh
|
||||
#*/5 * * * * mount_afp afp://souti:setaou@Hackintosh.home/Data/ /media/Hackintosh/ -o user=souti
|
||||
#0 22 * * * rsync -arvl --size-only /media/WDBlue/Musique/ /media/Hackintosh/Musique/
|
||||
#0 22 * * * rsync -arvl --size-only /media/WDBlue/SeriesTV/ /media/Hackintosh/SeriesTV/
|
||||
#0 23 * * * rsync -arvl --size-only /media/WDBlue/StockagePhoto/ /media/Hackintosh/StockagePhoto/
|
||||
#0 04 * * * rsync -arvl --size-only /media/WDBlue/films/ /media/Hackintosh/films/
|
||||
|
||||
#0 16 * * * rsync -aP --size-only /media/Backup/backup/ /media/WDBlue/backup/
|
||||
|
||||
#epure all files
|
||||
0 19 5 * * cd /media/WDBlue/backup;bash epureall.sh
|
||||
|
||||
|
||||
# DOMOTICZ
|
||||
# Récpératin qualité de l'air rennes
|
||||
#1 */4 * * * php /opt/domoticz/scripts/qualiteAir.php
|
||||
|
||||
*/5 * * * * php /opt/domoticz/scripts/suncalc.php
|
||||
|
||||
# Récupération Gaz 2 et Photo par les logs serial
|
||||
#* * * * * python /opt/domoticz/scripts/MySerial.py
|
||||
|
||||
# Géneration des images de la terre et de la lune
|
||||
#0/10 * * * * /opt/domoticz/www/templates/xplanet/xplanet_cloud.sh
|
||||
|
||||
# Synchronisation de la musique sur WDRed
|
||||
#42 0 * * * rsync -rltzuv --size-only --del /media/WDBlue/Musique /media/DATA/
|
||||
#0 13 * * * rsync -arvl /media/DATA/backup/ /media/WDBlue/
|
||||
|
||||
# Backup du serveur domoticz
|
||||
0 2 * * * /opt/domoticz/scripts/backup/domoticz
|
||||
0 3 * * * /opt/domoticz/scripts/backup/octoprint
|
||||
|
||||
# Recopie de la sauvegarde de raspbmc sur wdred
|
||||
#0 3 * * * scp /media/WDBlue/backup/raspbmc.img /media/WDRed/backup/
|
||||
|
||||
# Récupération agenda domoticz sur google
|
||||
#remplace par un script lua 0 */2 * * * python /opt/domoticz/scripts/getgooglecal.py
|
||||
|
||||
# Toutes les 10 minutes scan du fichier généré au-dessus pour lancement d'actions
|
||||
#remplace par un script lua */5 * * * * python /opt/domoticz/scripts/cal_action.py
|
||||
|
||||
# Script Jeedom lancé toutes les minutes ?? WTF
|
||||
#* * * * * su --shell=/bin/bash - www-data -c '/usr/bin/php /usr/share/nginx/www/jeedom/core/php/jeeCron.php' >> /dev/null 2>&1
|
||||
|
||||
# Script pour récupérer la température et l'humidité du Digispark
|
||||
#*/10 * * * * /opt/domoticz/scripts/hum.sh
|
||||
|
||||
#Masse grasse JD
|
||||
0 */4 * * * /opt/domoticz/scripts/withings.sh
|
||||
|
||||
#Update Domoticz & alerte
|
||||
#0 1 */7 * * /opt/domoticz/scripts/update.sh
|
||||
|
||||
# read values on i2c
|
||||
*/5 * * * * /opt/domoticz/scripts/i2cs2.py >/var/log/i2c.log
|
||||
|
||||
# Count banned ips
|
||||
*/10 * * * * /opt/domoticz/scripts/banned.sh
|
||||
|
||||
# Sauvegarde home pi
|
||||
#0 12 * * * tar cvzf /tmp/script.tgz --exclude '.*' --exclude '*.o' --exc$
|
||||
#30 14 * * * /etc/backup/domoticzScripts
|
||||
#45 14 * * * /etc/backup/domoticzOpt
|
||||
#00 15 * * * /etc/backup/domoticzWww
|
||||
#0 0 * * * /usr/bin/rsync -rvl --size-only /home/pi/ /media/Backup/domot$
|
||||
|
||||
|
||||
#Ping pour garder la connexion réseau (Autre moyen ?)
|
||||
#*/5 * * * * ping -c 10 192.168.0.1 2>/dev/null |grep rtt >/tmp/ping
|
||||
|
||||
#*/5 * * * * mount /media/WDBlue 2>/dev/null
|
||||
#*/5 * * * * mount /media/WDGreen 2>/dev/null
|
||||
#*/5 * * * * mount /media/DATA 2>/dev/null
|
||||
#*/5 * * * * mount /media/Backup 2>/dev/null
|
||||
#*/5 * * * * mount /media/Musique 2>/dev/null
|
||||
#*/5 * * * * mount /media/MEMUP 2>/dev/null
|
||||
|
||||
# Check que domoticz tourne toujours
|
||||
* * * * * /opt/domoticz/scripts/check.sh >>/tmp/check.log
|
||||
|
||||
# Etat de la route
|
||||
#*/10 8,17 * * * /opt/domoticz/scripts/infotrafic.sh
|
||||
#0 8,17 * * 1,2,3,4,5 /opt/domoticz/scripts/radars.sh
|
||||
|
||||
|
||||
# Etat pollen
|
||||
#10 8 * * 1 /opt/domoticz/scripts/infoPollen.sh
|
||||
|
||||
# Suppression des logs
|
||||
0 10 * * * cd /var/log/; rm *.gz;
|
||||
15 * * * * rm -rf /var/log/*.1
|
||||
|
||||
# *.[1234567890] *.log *.err syslog* samba/* faillog *.error *.old 2>/dev$
|
||||
|
||||
#Redemarrage DOMOTICZ
|
||||
0 0 * * * service domoticz.sh restart
|
||||
|
||||
#Test ligne
|
||||
10 */2 * * * /opt/domoticz/scripts/debit.sh
|
||||
|
||||
#Test ping Livebox
|
||||
* * * * * /opt/domoticz/scripts/livebox2.sh
|
||||
* * * * * /opt/domoticz/scripts/livebox.sh
|
||||
|
||||
#Update Clamav (Anti virus)
|
||||
0 13 * * 3 /usr/bin/freshclam >> /var/log/resul_freshclam.txt
|
||||
|
||||
# Scan (Anti virus)
|
||||
#0 12 * * 1 clamscan -r /home/pi --cross-fs=no --detect-pua=yes >/tmp/cl$
|
||||
0 1 * * * /opt/domoticz/scripts/clamscandomoticz.sh
|
||||
#0 3 * * * /opt/domoticz/scripts/clamscanfulldomoticz.sh
|
||||
|
||||
# Logwatch
|
||||
57 8 * * * /opt/domoticz/scripts/logwatch.sh
|
||||
|
||||
#* * * * * ping -c 4 orangepizero
|
||||
|
||||
# Luminosite camera
|
||||
#5 * * * * /usr/bin/python /opt/domoticz/scripts/lum.py
|
||||
|
||||
# Epuration backup
|
||||
27 7 */3 * * /media/WDBlue/backup/epureAll.sh
|
||||
|
||||
# Extinction imprimante
|
||||
*/10 0-6 * * * /opt/domoticz/scripts/octoprintStatus.sh >>/tmp/status.log
|
||||
*/10 0-6 * * * /opt/domoticz/scripts/octoprint2Status.sh >>/tmp/status2.log
|
||||
|
||||
# Synchronisation home philae sur Akhenaton
|
||||
0 20 * * * /opt/domoticz/scripts/PhilaeHome.sh
|
||||
|
||||
@reboot sh /opt/domoticz/scripts/mplayer.sh
|
||||
@reboot /opt/ympd/ympd -w 9292
|
||||
|
||||
# Sauvegarde AcerManon
|
||||
40 */3 * * 6,0 /opt/domoticz/scripts/AcerManon.sh
|
||||
10 */3 * * 5 /opt/domoticz/scripts/AkhesaSouti.sh
|
||||
40 */3 * * 5 /opt/domoticz/scripts/AkhesaTheo.sh
|
||||
|
||||
13
curl.sh
Executable file
13
curl.sh
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/bin/bash
|
||||
|
||||
DOMO_IP="localhost" # Domoticz IP Address
|
||||
DOMO_PORT="81" # Domoticz Port
|
||||
IDX=330
|
||||
|
||||
curl_count=`ps ax |grep curl|wc -l`
|
||||
|
||||
if [ "$curl_count" -gt 6 ]; then
|
||||
killall curl
|
||||
fi
|
||||
|
||||
exit 0
|
||||
30
debit.py
Executable file
30
debit.py
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: latin-1 -*-
|
||||
|
||||
#sudo apt-get install python-pip
|
||||
#sudo pip install speedtest-cli
|
||||
#speedtest-cli --list |grep France <== Recherche serveur le plus proche
|
||||
|
||||
import subprocess as sub
|
||||
import os
|
||||
|
||||
f = os.popen('speedtest --share --simple')
|
||||
#f = open('/tmp/speedtest')
|
||||
valeurvariable = f.read()
|
||||
|
||||
liste = str(valeurvariable)
|
||||
columns2 = liste.split(' ')
|
||||
columns = [i for i in columns2 if i != '']
|
||||
|
||||
ping = str(columns[1])
|
||||
download = str(columns[3])
|
||||
upload = str(columns[5])
|
||||
|
||||
url='curl -y 2 "http://localhost:81/json.htm?type=command¶m=udevice&idx=323&nvalue=0&svalue='+ping+'"'
|
||||
url1='curl -y 2 "http://localhost:81/json.htm?type=command¶m=udevice&idx=325&nvalue=0&svalue='+download+'"'
|
||||
url2='curl -y 2 "http://localhost:81/json.htm?type=command¶m=udevice&idx=324&nvalue=0&svalue='+upload+'"'
|
||||
|
||||
os.system(url)
|
||||
os.system(url1)
|
||||
os.system(url2)
|
||||
|
||||
7
debit.sh
Executable file
7
debit.sh
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/bin/bash
|
||||
# Script qui vérifie l'état de domoticz et qui relance si off
|
||||
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/lib/
|
||||
/usr/bin/python /opt/domoticz/scripts/debit.py
|
||||
|
||||
|
||||
93
digiterm
Executable file
93
digiterm
Executable file
@@ -0,0 +1,93 @@
|
||||
#!/usr/bin/env ruby
|
||||
$:.unshift File.dirname(__FILE__) + "/../lib"
|
||||
require 'digiusb'
|
||||
require 'colored'
|
||||
require 'io/console'
|
||||
|
||||
if ARGV.include? '--help' or ARGV.include? '-h'
|
||||
puts "Usage:"
|
||||
puts " digiterm [options]"
|
||||
puts " digiterm [options] [device name]"
|
||||
puts
|
||||
puts " Options:"
|
||||
puts " --raw Disable ansi colouring and other friendly decorations."
|
||||
puts " Useful for using as subprocess from another programming language."
|
||||
puts " --no-wait Don't loop and wait for a digispark - return immediately if no"
|
||||
puts " device is found."
|
||||
puts " --no-info Don't write out any status information to standard error output"
|
||||
exit
|
||||
end
|
||||
|
||||
raw_mode = ARGV.include?("--raw")
|
||||
device_name = if ARGV.empty? or ARGV.last.start_with?("--")
|
||||
false
|
||||
else
|
||||
ARGV.last
|
||||
end
|
||||
no_stderr = ARGV.include?("--no-info")
|
||||
|
||||
|
||||
$stderr.puts "Looking for Digispark running DigiUSB...".blue unless no_stderr
|
||||
|
||||
sleep 0.5 until DigiUSB.sparks(device_name).length > 0 unless ARGV.include? '--no-wait'
|
||||
spark = DigiUSB.sparks(device_name).last
|
||||
|
||||
unless spark
|
||||
$stderr.puts "No device found".white_on_red unless no_stderr
|
||||
exit 1
|
||||
end
|
||||
|
||||
$stderr.puts "Attached to #{spark.inspect.green}".blue unless no_stderr
|
||||
$stderr.puts "Type control + c to exit".blue unless no_stderr
|
||||
|
||||
i = 0
|
||||
begin
|
||||
loop do
|
||||
char = spark.getc
|
||||
if char != ""
|
||||
if raw_mode
|
||||
print char
|
||||
else
|
||||
print char.green
|
||||
end
|
||||
if char == "@"
|
||||
loop do
|
||||
char = spark.getc
|
||||
if char == ""
|
||||
exit 0
|
||||
end
|
||||
spark.putc char
|
||||
end
|
||||
end
|
||||
else
|
||||
sleep 1.0 / 30.0
|
||||
i = i + 1
|
||||
if i > 30
|
||||
spark.putc "\n"
|
||||
i = 0
|
||||
end
|
||||
#$stderr.puts "s" # newline
|
||||
end
|
||||
|
||||
begin
|
||||
char = IO.console.read_nonblock(1)
|
||||
spark.putc char
|
||||
rescue Errno::EAGAIN
|
||||
end
|
||||
end
|
||||
rescue LIBUSB::ERROR_PIPE, LIBUSB::ERROR_NO_DEVICE
|
||||
unless no_stderr
|
||||
$stderr.puts "" # newline
|
||||
$stderr.puts "Digispark disconnected".white_on_red unless no_stderr
|
||||
end
|
||||
exit 2
|
||||
rescue DigiUSB::ErrorCrashed
|
||||
unless no_stderr
|
||||
$stderr.puts "" # newline
|
||||
$stderr.puts "Digispark has crashed".white_on_red
|
||||
$stderr.puts " >> Probably need to call DigiUSB.refresh() more frequently in Digispark Program".blue
|
||||
end
|
||||
exit 3
|
||||
rescue Interrupt
|
||||
$stderr.puts "" unless no_stderr
|
||||
end
|
||||
9
digiterm.sh
Executable file
9
digiterm.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
|
||||
./digiterm --raw --no-info >/tmp/digiterm.tmp
|
||||
|
||||
temp=`cat /tmp/digiterm.tmp |awk -F "," '{ print $2 }'|awk -F "@" '{print $1}'`
|
||||
hum=`cat /tmp/digiterm.tmp |awk -F "," '{ print $1 }'|awk -F "#" '{print $2}'`
|
||||
|
||||
echo $temp "--" $hum
|
||||
|
||||
105
domoticz.conf
Normal file
105
domoticz.conf
Normal file
@@ -0,0 +1,105 @@
|
||||
# Domoticz configuration file
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# HTTP Listen address (default ::/0.0.0.0)
|
||||
# http_address=::
|
||||
|
||||
# HTTP Listen port (default 8080, use 0 to disable HTTP)
|
||||
# http_port=8080
|
||||
|
||||
# HTTPS Listen address (default ::/0.0.0.0)
|
||||
# ssl_address=::
|
||||
|
||||
# HTTPS Listen port (default 443, use 0 to disable HTTP)
|
||||
# ssl_port=443
|
||||
|
||||
# HTTPS root folder location
|
||||
# http_root=/opt/domoticz/www
|
||||
|
||||
# Web root path (for instance mydomoticz, Domoticz url will become https://127.0.0.1:8080/mydomoticz/)
|
||||
# web_root=mydomoticz
|
||||
|
||||
# Compression mode (on = always compress [default], off = always decompress, static = no processing but try precompressed first)
|
||||
# www_compress_mode=on
|
||||
|
||||
# Disable appcache, usefull for gui development
|
||||
# cache=no
|
||||
|
||||
# In case you forgot your admin username/password, remove the comment below.
|
||||
# Do not forget to comment when you have reset your password!
|
||||
# reset_password=yes
|
||||
|
||||
# SSL certificate file
|
||||
# ssl_cert=/opt/domoticz/server_cert.pem
|
||||
|
||||
# SSL certificate key file (could also point to SSL certificate file if it contains the key)
|
||||
# ssl_key=/opt/domoticz/server_cert.key
|
||||
|
||||
# SSL Diffie-Hellman (DH) file (could also point to SSL certificate file if it contains the DH)
|
||||
# ssl_dhparam=/opt/domoticz/server_cert.dh
|
||||
|
||||
# SSL password (to access to server private key in certificatee)
|
||||
# ssl_pass=secret
|
||||
|
||||
# SSL method (Supported methods are: tlsv1, tlsv1_server, sslv23, sslv23_server, tlsv11, tlsv11_server, tlsv12, tlsv12_server)
|
||||
# ssl_method=sslv23
|
||||
|
||||
# SSL options (default is 'efault_workarounds,no_sslv2,no_sslv3,no_tlsv1,no_tlsv1_1,single_dh_use)
|
||||
# ssl_options=default_workarounds,no_sslv2,no_sslv3,no_tlsv1,no_tlsv1_1,single_dh_use'
|
||||
|
||||
# Log file (for example /var/log/domoticz.log)
|
||||
# log_file=/var/log/domoticz.log
|
||||
|
||||
# Log level (combination of: normal,status,error,debug)
|
||||
# loglevel=normal,status,error
|
||||
|
||||
# Debug level (When debug level enabled, combination of: normal,hardware,received,webserver,eventsystem,python,thread_id
|
||||
# debuglevel=normal,hardware
|
||||
|
||||
# Disable timestamps in the log (useful with syslog, etc.)
|
||||
# notimestamps=yes
|
||||
|
||||
# Enable syslog as log system, specify level: user, daemon, local0 .. local7
|
||||
# syslog=user
|
||||
|
||||
# Database
|
||||
# dbase_file=/opt/domoticz/domoticz.db
|
||||
|
||||
# Startup delay, time the daemon will pause before launching
|
||||
# startup_delay=0
|
||||
|
||||
# Disable update checking
|
||||
# updates=no
|
||||
|
||||
# Enable PHP calls/pages, you need to have installed php-cgi
|
||||
# php_cgi_path=/usr/bin/php-cgi
|
||||
|
||||
# Application path (folder where domoticz is installed in)
|
||||
# app_path=/opt/domoticz
|
||||
|
||||
# User data path (where backups and scripts are installed)
|
||||
# userdata_path=/opt/domoticz
|
||||
|
||||
# Run as daemon (default when launched as service)
|
||||
# daemon=yes
|
||||
|
||||
# Daemon Name
|
||||
# daemon_name=domoticz
|
||||
|
||||
# Daemon PID file
|
||||
# pidfile=/var/run/domoticz.pid
|
||||
|
||||
# Launch browser (Windows only, starts a browser at startup)
|
||||
# launch_browser=yes
|
||||
50
download_update.sh
Executable file
50
download_update.sh
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/bin/sh
|
||||
cd $1
|
||||
|
||||
lowercase(){
|
||||
echo "$1" | sed "y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/"
|
||||
}
|
||||
|
||||
OS=`lowercase \`uname -s\``
|
||||
# KERNEL=`uname -r`
|
||||
MACH=`uname -m`
|
||||
if [ ${MACH} = "armv6l" ]
|
||||
then
|
||||
MACH="armv7l"
|
||||
fi
|
||||
|
||||
CHANNEL="stable"
|
||||
if [ "$2" = "/beta" ]; then
|
||||
CHANNEL="beta"
|
||||
fi
|
||||
|
||||
archive_file="http://www.domoticz.com/download.php?channel=${CHANNEL}&type=release&system=${OS}&machine=${MACH}"
|
||||
checksum_file="http://www.domoticz.com/download.php?channel=${CHANNEL}&type=checksum&system=${OS}&machine=${MACH}"
|
||||
|
||||
# Download checksum
|
||||
wget -q "${checksum_file}" -O update.tgz.sha256sum
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Error downloading checksum file!...";
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Download archive file
|
||||
wget -q "${archive_file}" -O update.tgz
|
||||
if [ $? -ne 0 ]
|
||||
then
|
||||
echo "Error downloading archive file!...";
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check archive
|
||||
if [ -f update.tgz.sha256sum ];
|
||||
then
|
||||
#Check archive against checksum!
|
||||
valid=$(LC_ALL=C sha256sum -c update.tgz.sha256sum | grep update.tgz | cut -d':' -f2 | tr -d ' ')
|
||||
if [ $valid != "OK" ]
|
||||
then
|
||||
echo "Archive checksum mismatch !";
|
||||
exit 1;
|
||||
fi
|
||||
fi
|
||||
8
dzVents/.gitignore
vendored
Normal file
8
dzVents/.gitignore
vendored
Normal file
@@ -0,0 +1,8 @@
|
||||
# Created by .ignore support plugin (hsz.mobi)
|
||||
/domoticzData.lua
|
||||
scripts/*.lua
|
||||
data/*.lua
|
||||
generated_scripts/*.lua
|
||||
!/runtime/tests/data/README.md
|
||||
/runtime/tests/data/__data_global_data.lua
|
||||
/runtime/tests/data/__data_script1.lua
|
||||
1
dzVents/data/README.md
Normal file
1
dzVents/data/README.md
Normal file
@@ -0,0 +1 @@
|
||||
This folder will contains the data files for scripts. If a script uses the `data` section then dzVents stores the persistent data in this folder. If a script doesn't seem to work properly with regards to the persistent data, then you can remove the corresponding data file here.
|
||||
4
dzVents/dumps/.gitignore
vendored
Normal file
4
dzVents/dumps/.gitignore
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# Ignore everything in this directory
|
||||
*
|
||||
# Except this file
|
||||
!.gitignore
|
||||
18
dzVents/dzVents_settings_example.lua
Normal file
18
dzVents/dzVents_settings_example.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
--[[
|
||||
Log level = 1: Errors
|
||||
Log level = 1.5: Errors + info about the execution of individual scripts and a dump of the commands sent back to Domoticz
|
||||
Log level = 2: Errors + info
|
||||
Log level = 3: Debug info + Errors + Info (can be a lot!!!)
|
||||
Log level = 0: As silent as possible
|
||||
|
||||
About the fetch interval: there's no need to have a short interval in normal
|
||||
situations. dzVents will only use it for battery level and some other information
|
||||
that doesn't change very often.
|
||||
]]--
|
||||
return {
|
||||
['Domoticz ip'] = '10.0.0.8',
|
||||
['Domoticz port'] = '8080',
|
||||
['Fetch interval'] = 'every 30 minutes', -- see readme for timer settings
|
||||
['Enable http fetch'] = true, -- only works on linux systems
|
||||
['Log level'] = 2
|
||||
}
|
||||
22
dzVents/examples/calc temp delta.lua
Normal file
22
dzVents/examples/calc temp delta.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
--[[
|
||||
Assume you have two temperature sensors and a third dummy sensor that should be the
|
||||
difference of these two sensors (e.g. you want to see the difference between water temperature
|
||||
going into a radiator and the temperature of the water going out of it
|
||||
]]--
|
||||
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {'every 5 minutes'}
|
||||
},
|
||||
execute = function(domoticz)
|
||||
local inTemp = domoticz.devices('Temp in').temperature
|
||||
local outTemp = domoticz.devices('Temp out').temperature
|
||||
local delta = outTemp - inTemp -- how much did the temperature drop?
|
||||
|
||||
-- update the dummy sensor
|
||||
domoticz.devices('Delta temp').updateTemperature(delta)
|
||||
|
||||
end
|
||||
}
|
||||
37
dzVents/examples/check battery levels.lua
Normal file
37
dzVents/examples/check battery levels.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
local BATTERY_THRESHOLD = 10
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'every hour'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz)
|
||||
|
||||
local message = ''
|
||||
|
||||
-- first filter on low battery level
|
||||
local lowOnBat = domoticz.devices().filter(function(device)
|
||||
|
||||
local level = device.batteryLevel -- level is 0-100
|
||||
return (level ~= nil and -- not all devices have this attribute
|
||||
level <= BATTERY_THRESHOLD)
|
||||
|
||||
end)
|
||||
|
||||
-- then loop over the results
|
||||
lowOnBat.forEach(function(lowDevice)
|
||||
|
||||
message = message .. 'Device ' ..
|
||||
lowDevice.name .. ' is low on batteries (' .. tostring(lowDevice.batteryLevel) .. '), '
|
||||
|
||||
end)
|
||||
|
||||
if (message ~= '') then
|
||||
domoticz.notify('Low battery warning', message, domoticz.PRIORITY_NORMAL)
|
||||
domoticz.log('Low battery warning: ' .. message, domoticz.LOG_ERROR)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
36
dzVents/examples/check dead devices by desc.lua
Normal file
36
dzVents/examples/check dead devices by desc.lua
Normal file
@@ -0,0 +1,36 @@
|
||||
--Check dead device using their description
|
||||
--This allow to configure device to be checked directly in domoticz GUI by accessing to device details and add "CDA:<delayInMinute>"
|
||||
--You have to active http fetching !
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'every 60 minutes'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz)
|
||||
local message=""
|
||||
|
||||
domoticz.devices().forEach(function(device)
|
||||
if (device.description ~= nil) then
|
||||
_, _, threshold = string.find(device.description,"CDA:(%d+)")
|
||||
if (threshold ~= nil) then
|
||||
local name = device.name
|
||||
local minutes = domoticz.devices(name).lastUpdate.minutesAgo
|
||||
if ( minutes > tonumber(threshold)) then
|
||||
message = message .. 'Device ' ..
|
||||
name .. ' seems to be dead. No heartbeat for at least ' ..
|
||||
minutes .. ' minutes.\r'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end)
|
||||
|
||||
if (message ~= "") then
|
||||
domoticz.notify('Dead devices', message, domoticz.PRIORITY_HIGH)
|
||||
domoticz.log('Dead devices found: ' .. message, domoticz.LOG_ERROR)
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
37
dzVents/examples/check dead devices.lua
Normal file
37
dzVents/examples/check dead devices.lua
Normal file
@@ -0,0 +1,37 @@
|
||||
|
||||
local devicesToCheck = {
|
||||
{ ['name'] = 'Sensor1', ['threshold'] = 30 },
|
||||
{ ['name'] = 'Sensor2', ['threshold'] = 30 },
|
||||
{ ['name'] = 'Bathroom temperature', ['threshold'] = 20 }
|
||||
}
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'every 5 minutes'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz)
|
||||
|
||||
local message = ""
|
||||
|
||||
for i, deviceToCheck in pairs(devicesToCheck) do
|
||||
local name = deviceToCheck['name']
|
||||
local threshold = deviceToCheck['threshold']
|
||||
local minutes = domoticz.devices(name).lastUpdate.minutesAgo
|
||||
|
||||
if ( minutes > threshold) then
|
||||
message = message .. 'Device ' ..
|
||||
name .. ' seems to be dead. No heartbeat for at least ' ..
|
||||
minutes .. ' minutes.\r'
|
||||
end
|
||||
end
|
||||
|
||||
if (message ~= "") then
|
||||
domoticz.email('Dead devices', message, 'me@address.nl')
|
||||
domoticz.log('Dead devices found: ' .. message, domoticz.LOG_ERROR)
|
||||
end
|
||||
end
|
||||
}
|
||||
|
||||
22
dzVents/examples/external_light.lua
Normal file
22
dzVents/examples/external_light.lua
Normal file
@@ -0,0 +1,22 @@
|
||||
-- External light
|
||||
-- turn lights on at sunset and back off at sunrise
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
timer = {
|
||||
'at sunset',
|
||||
'at sunrise'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, timer)
|
||||
-- external light switch name
|
||||
local external_light = domoticz.devices('External light')
|
||||
|
||||
if (timer.trigger == 'at sunset') then
|
||||
external_light.switchOn()
|
||||
else
|
||||
external_light.switchOff()
|
||||
end
|
||||
end
|
||||
}
|
||||
23
dzVents/examples/fake presence.lua
Normal file
23
dzVents/examples/fake presence.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
-- example script to fake the presence of people being at home
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
timer = {
|
||||
'at sunset',
|
||||
'at 23:30'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, timer)
|
||||
|
||||
if (timer.trigger == 'at sunset') then
|
||||
domoticz.devices('mySwitch').switchOn()
|
||||
domoticz.devices('anotherSwitch').dimTo(40)
|
||||
-- add whatever you want
|
||||
else
|
||||
-- switch off at a random moment after 23:30
|
||||
domoticz.devices('mySwitch').switchOff().withinMin(60)
|
||||
domoticz.devices('anotherSwitch').switchOff().withinMin(60)
|
||||
end
|
||||
end
|
||||
}
|
||||
27
dzVents/examples/garage door.lua
Normal file
27
dzVents/examples/garage door.lua
Normal file
@@ -0,0 +1,27 @@
|
||||
--[[
|
||||
|
||||
From the domoticz examples online:
|
||||
http://www.domoticz.com/wiki/Event_script_examples
|
||||
|
||||
Send a warning when the garage door has been open for more than 10 minutes
|
||||
|
||||
]]
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'every minute',
|
||||
}
|
||||
},
|
||||
execute = function(domoticz)
|
||||
|
||||
local door = domoticz.devices('Garage door')
|
||||
|
||||
if (door.state == 'Open' and door.lastUpdate.minutesAgo > 10) then
|
||||
domoticz.notify('Garage door alert',
|
||||
'The garage door has been open for more than 10 minutes!',
|
||||
domoticz.PRIORITY_HIGH)
|
||||
end
|
||||
end
|
||||
}
|
||||
23
dzVents/examples/generic.lua
Normal file
23
dzVents/examples/generic.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
-- See README.md for instructions
|
||||
|
||||
return {
|
||||
active = false, -- set to true to activate this script
|
||||
on = {
|
||||
'My switch', -- name of the device
|
||||
'My sensor_Temperature', -- better not use but check device.attributeIsChanged('temperature')
|
||||
'My sensor',
|
||||
258, -- index of the device
|
||||
['timer'] = 'every minute', -- see readme for more options and schedules
|
||||
'PIR_*', -- triggers for all devices which name begins with PIR_
|
||||
},
|
||||
|
||||
execute = function(domoticz, mySwitch) -- see readme for what you get
|
||||
-- see readme for the entire domoticz object tree
|
||||
-- mySwitch is a Device object with all the properties of the device that was updated
|
||||
-- unless this is a timer script, then there is not second parameter to this execute function
|
||||
|
||||
if (mySwitch.state == 'On') then
|
||||
domoticz.notify('Hey!', 'I am on!', domoticz.PRIORITY_NORMAL)
|
||||
end
|
||||
end
|
||||
}
|
||||
19
dzVents/examples/get sensor values.lua
Normal file
19
dzVents/examples/get sensor values.lua
Normal file
@@ -0,0 +1,19 @@
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
devices = {
|
||||
'My sensor'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, mySensor)
|
||||
|
||||
if (mySensor.temperature > 50) then
|
||||
domoticz.notify('Hey!', 'The house might be on fire!!',
|
||||
domoticz.PRIORITY_EMERGENCY,
|
||||
domoticz.SOUND_SIREN)
|
||||
domoticz.log('Fire alert', domoticz.LOG_ERROR)
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
|
||||
25
dzVents/examples/intruder alert.lua
Normal file
25
dzVents/examples/intruder alert.lua
Normal file
@@ -0,0 +1,25 @@
|
||||
return {
|
||||
|
||||
active = true,
|
||||
|
||||
on = {
|
||||
devices = {
|
||||
'PIR_*' -- all my motion detectors' name start with PIR_
|
||||
}
|
||||
},
|
||||
|
||||
execute = function(domoticz, detector)
|
||||
|
||||
if (detector.state == 'Motion' and domoticz.security ~= domoticz.SECURITY_DISARMED) then
|
||||
-- o dear
|
||||
|
||||
domoticz.setScene('intruder alert', 'On')
|
||||
|
||||
-- send notification
|
||||
domoticz.notify('Security breach', '',
|
||||
domoticz.PRIORITY_EMERGENCY,
|
||||
domoticz.SOUND_SIREN)
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
72
dzVents/examples/leak_detection.lua
Normal file
72
dzVents/examples/leak_detection.lua
Normal file
@@ -0,0 +1,72 @@
|
||||
-- Water leak detection
|
||||
--
|
||||
-- assumptions:
|
||||
-- need 2 devices :
|
||||
-- a Water Flow devices name "Water_Flow"
|
||||
-- a Dummy Device type percentage "Leakage_Percent"
|
||||
--
|
||||
-- 1 / leakage "open valve"
|
||||
-- Every minute if a non-zero water flow is present, it increments a counter (Leakage_Percent)
|
||||
-- If the water flow is zero is that it leaks more continuously.
|
||||
-- A notification can be put on "Leakage_Percent" if >80% (80% = 80 minutes of continuous flow)
|
||||
--
|
||||
-- 2 / "micro continuous flow" (drip)
|
||||
-- in 24 hours one must have at least 2 hours without flow (detection 0.5 liters / hour is 4.5m3 / year)
|
||||
-- if not, "Leakage_Percent" is forced at 100%.
|
||||
|
||||
local FLOW_DEVICE = 'Water_Flow' -- Flow device
|
||||
local LEAK_DEVICE = 'Leakage_Percent' -- percent dummy device
|
||||
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'every minute'
|
||||
}
|
||||
},
|
||||
data = {
|
||||
time_0_flow = { initial = 0 },
|
||||
total_time = { initial = 0 },
|
||||
},
|
||||
execute = function(domoticz)
|
||||
-- Flow in liter/minute
|
||||
local flow = tonumber(domoticz.devices(FLOW_DEVICE).rawData[1])
|
||||
-- Dummy device in %
|
||||
local leakage = domoticz.devices(LEAK_DEVICE)
|
||||
local time_with_flow = tonumber(leakage.rawData[1])
|
||||
local new_time_with_flow = time_with_flow
|
||||
|
||||
-- 1 / leakage "open valve"
|
||||
if (flow > 0) then
|
||||
domoticz.data.time_0_flow = 0 -- there is a flow
|
||||
new_time_with_flow = new_time_with_flow + 1 -- time with flow
|
||||
if (new_time_with_flow > 100) then
|
||||
new_time_with_flow = 100
|
||||
end
|
||||
else
|
||||
new_time_with_flow = 0
|
||||
domoticz.data.time_0_flow = domoticz.data.time_0_flow + 1 -- time without flow
|
||||
end
|
||||
|
||||
-- 2 / flight type "micro continuous flow" (drip)
|
||||
domoticz.data.total_time = domoticz.data.total_time + 1 -- time without since last 2 hours with no flow
|
||||
|
||||
if (domoticz.data.time_0_flow > 120) then
|
||||
-- 2 hours with no flow
|
||||
domoticz.data.total_time = 0
|
||||
elseif (domoticz.data.total_time > (60*24)) then
|
||||
-- 24 heures since last 2 hours with no flow
|
||||
new_time_with_flow = 100
|
||||
end
|
||||
-- log
|
||||
domoticz.log(new_time_with_flow .. ' minutes with flow ')
|
||||
domoticz.log(domoticz.data.time_0_flow .. ' minutes without flow ')
|
||||
domoticz.log(domoticz.data.total_time .. ' minutes without 2hrs without flow ')
|
||||
|
||||
-- update dummy device %
|
||||
if (time_with_flow ~= new_time_with_flow) then
|
||||
leakage.update(0,new_time_with_flow)
|
||||
end
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
-- this script can be used in conjunction with the System-alive checker plug-in.
|
||||
-- the plugin pings a list of devices and creates switches for these devices
|
||||
-- the reason for this script is to not treat devices as dead immediately after they
|
||||
-- do not respond. More often than not, the second ping atempt does work. So only
|
||||
-- if the device has been not responding for a while AFTER it is been presumed dead
|
||||
-- then this script will notify you
|
||||
|
||||
-- put the names of these switches in the devicesToCheck list
|
||||
-- you may have to tweak the THRESHOLD depending on the check interval
|
||||
|
||||
|
||||
|
||||
|
||||
local THRESHOLD = 5 -- minutes
|
||||
local devicesToCheck = {'ESP8266 CV', 'ESP8266 ManCave', 'ESP8266 Watermeter'}
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
devices = {
|
||||
devicesToCheck
|
||||
},
|
||||
timer = {
|
||||
'every 5 minutes'
|
||||
}
|
||||
},
|
||||
data = {
|
||||
notified = { initial = {} }
|
||||
},
|
||||
execute = function(domoticz, item, triggerInfo)
|
||||
|
||||
if (item.isTimer) then
|
||||
|
||||
-- check all devices that are off and have not been updated in the past 5 minutes and have not been notified for
|
||||
for index, deviceName in pairs(devicesToCheck) do
|
||||
|
||||
local device = domoticz.devices(deviceName)
|
||||
|
||||
if (device.state == 'Off' and
|
||||
device.lastUpdate.minutesAgo >= THRESHOLD and
|
||||
domoticz.data.notified[deviceName] == false) then
|
||||
|
||||
domoticz.notify(deviceName .. ' is not responding anymore.',' ',domoticz.PRIORITY_HIGH)
|
||||
|
||||
-- make sure we only notify once for this device in this case
|
||||
domoticz.data.notified[deviceName] = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
else
|
||||
-- it is the device that was triggered
|
||||
domoticz.data.notified[item.name] = false
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
23
dzVents/examples/only run script when button pressed.lua
Normal file
23
dzVents/examples/only run script when button pressed.lua
Normal file
@@ -0,0 +1,23 @@
|
||||
return {
|
||||
|
||||
-- create a function for the active key, when the switch in Domoticz
|
||||
-- called 'script_blabla' is active, then the script is executed.
|
||||
|
||||
-- Note: keep this function really light weight because it is ALWAYS
|
||||
-- executed in every cycle, even when 'My switch' hasn't changed!!
|
||||
|
||||
active = function(domoticz)
|
||||
return (domoticz.devices('script_blabla').state == 'On')
|
||||
end,
|
||||
|
||||
on = {
|
||||
devices = {
|
||||
'My switch'
|
||||
}
|
||||
},
|
||||
|
||||
execute = function(domoticz, mySwitch)
|
||||
-- do some weird complicated stuff
|
||||
-- that takes quite some processing time ;-)
|
||||
end
|
||||
}
|
||||
100
dzVents/examples/plant watering notification.lua
Normal file
100
dzVents/examples/plant watering notification.lua
Normal file
@@ -0,0 +1,100 @@
|
||||
--[[
|
||||
This script can be used to get notification message when plant sensor exceed specified tresholds.
|
||||
It is specifically build to be used with the Xiaomi Mi Flora (https://www.domoticz.com/wiki/Mi_Flora_Bluetooth_LE), but can also be used with similar sensors
|
||||
|
||||
For the script to work correctly it is recommended your device names have the following convention:
|
||||
|
||||
Mi Flora - #0 Moisture
|
||||
Mi Flora - #0 Conductivity
|
||||
Mi Flora - #1 Moisture
|
||||
etc. etc.
|
||||
|
||||
This is the default device naming when Mi Flora plugin creates devices.
|
||||
|
||||
If you have another naming you need to adjust settings below.
|
||||
]]--
|
||||
|
||||
local configuration = {
|
||||
-- Define the different sensorTypes you want to get notified of
|
||||
sensorTypes = {
|
||||
moisture = {
|
||||
name = 'Moisture', -- Specify substring of name to match ie. "Mi Flora - #1 Moisture"
|
||||
property = 'percentage' -- property of dzVents device object to use
|
||||
},
|
||||
fertility = {
|
||||
name = 'Conductivity',
|
||||
property = 'percentage'
|
||||
}
|
||||
},
|
||||
|
||||
-- Define the plant names and the tresholds (min, max) per sensor below
|
||||
sensor0 = {
|
||||
plant = "Calamondin",
|
||||
tresholds = {
|
||||
moisture = {30, 60},
|
||||
fertility = {350, 2000}
|
||||
}
|
||||
},
|
||||
sensor1 = {
|
||||
plant = "Red pepper",
|
||||
tresholds = {
|
||||
moisture = {15, 60},
|
||||
fertility = {350, 2000}
|
||||
}
|
||||
},
|
||||
sensor2 = {
|
||||
plant = "Strawberries",
|
||||
tresholds = {
|
||||
moisture = {15, 60},
|
||||
fertility = {350, 2000}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
devices = {
|
||||
'Mi Flora*'
|
||||
}
|
||||
},
|
||||
logging = {
|
||||
level = domoticz.LOG_DEBUG
|
||||
},
|
||||
execute = function(domoticz, device)
|
||||
|
||||
local sensorNumber = string.match(device.name, "#(%d+)")
|
||||
local configKey = 'sensor' .. sensorNumber
|
||||
|
||||
if (configuration[configKey] == nil) then
|
||||
domoticz.log('No configuration defined for sensor #' .. sensorNumber, domoticz.LOG_INFO)
|
||||
return
|
||||
end
|
||||
|
||||
local sensorConfig = configuration[configKey]
|
||||
local tresholds = sensorConfig.tresholds
|
||||
local plantName = sensorConfig.plant
|
||||
|
||||
local function checkSensorTresholds(sensorType, notification)
|
||||
local sensorTypeConfig = configuration.sensorTypes[sensorType]
|
||||
if (tresholds[sensorType] == nil or not string.match(device.name, sensorTypeConfig.name)) then
|
||||
domoticz.log(string.format('No tresholds configured for sensor #%d or name does not match' , sensorNumber), domoticz.LOG_DEBUG)
|
||||
return
|
||||
end
|
||||
|
||||
local value = device[sensorTypeConfig.property]
|
||||
if (value < tresholds[sensorType][1] or value > tresholds[sensorType][2]) then
|
||||
notification = string.format(notification, plantName)
|
||||
notification = notification .. ' | ' .. string.format('%s = %d', sensorType, value)
|
||||
domoticz.notify('Plants', notification)
|
||||
domoticz.log(string.format('#%d %s exceeded', sensorNumber, sensorType), domoticz.LOG_DEBUG)
|
||||
else
|
||||
domoticz.log(string.format('#%d %s ok', sensorNumber, sensorType), domoticz.LOG_DEBUG)
|
||||
end
|
||||
end
|
||||
|
||||
checkSensorTresholds('moisture', '%s needs watering')
|
||||
checkSensorTresholds('fertility', '%s needs fertilization')
|
||||
|
||||
end
|
||||
}
|
||||
24
dzVents/examples/random night light.lua
Normal file
24
dzVents/examples/random night light.lua
Normal file
@@ -0,0 +1,24 @@
|
||||
local RANDOM_DELAY_MINS = 30
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'at sunset',
|
||||
'at 01:00'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz)
|
||||
|
||||
if (domoticz.security ~= domoticz.SECURITY_DISARMED) then
|
||||
|
||||
local light = domoticz.devices('Window light')
|
||||
|
||||
if (not light.bState) then -- i.e. state == 'On'
|
||||
light.switchOn().withinMin(RANDOM_DELAY_MINS)
|
||||
else
|
||||
light.switchOff().withinMin(RANDOM_DELAY_MINS)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
}
|
||||
14
dzVents/examples/respond to switch.lua
Normal file
14
dzVents/examples/respond to switch.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
devices = {
|
||||
'My switch'
|
||||
}
|
||||
},
|
||||
|
||||
execute = function(domoticz, mySwitch)
|
||||
if (mySwitch.state == 'On') then
|
||||
domoticz.notify('Hey!', 'I am on!', domoticz.PRIORITY_NORMAL)
|
||||
end
|
||||
end
|
||||
}
|
||||
20
dzVents/examples/schedule fish pond pump.lua
Normal file
20
dzVents/examples/schedule fish pond pump.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
['timer'] = {
|
||||
'at 8:30 on mon,tue,wed,thu,fri',
|
||||
'at 17:30 on mon,tue,wed,thu,fri',
|
||||
|
||||
-- weeekends are different
|
||||
'at sunset on sat, sun',
|
||||
'at sunrise on sat, sun'
|
||||
}
|
||||
},
|
||||
|
||||
execute = function(domoticz)
|
||||
|
||||
local pump = domoticz.devices('Pond')
|
||||
pump.toggleSwitch()
|
||||
|
||||
end
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
-- assumptions:
|
||||
-- the setpoint is set by a selector dummy device where the values are numeric temperatures
|
||||
-- but you can easily change it to a setpoint device
|
||||
|
||||
local BOILER_DEVICE = 'Boiler' -- switch device
|
||||
local SETPOINT_DEVICE = 'Setpoint' -- selector dummy device
|
||||
local TEMPERATURE_SENSOR = 'Temperature'
|
||||
local HYSTERESIS = 0.5 -- temp has to drop this value below setpoint before boiler is on again
|
||||
local SMOOTH_FACTOR = 3
|
||||
local LOGGING = true
|
||||
|
||||
return {
|
||||
on = {
|
||||
['timer'] = {
|
||||
'every minute',
|
||||
},
|
||||
devices = {
|
||||
TEMPERATURE_SENSOR,
|
||||
SETPOINT_DEVICE
|
||||
}
|
||||
},
|
||||
data = {
|
||||
temperatureReadings = { history = true, maxItems = SMOOTH_FACTOR }
|
||||
},
|
||||
active = true,
|
||||
execute = function(domoticz, item)
|
||||
|
||||
local avgTemp
|
||||
local temperatureReadings = domoticz.data.temperatureReadings
|
||||
local sensor = domoticz.devices(TEMPERATURE_SENSOR)
|
||||
local current = sensor.temperature
|
||||
local boiler = domoticz.devices(BOILER_DEVICE)
|
||||
local setpoint = domoticz.devices(SETPOINT_DEVICE)
|
||||
|
||||
-- first check if the sensor got a new reading or the setpoint was changed:
|
||||
if (item.isDevice) then
|
||||
|
||||
if (sensor.changed) then
|
||||
-- sensor just reported a new reading
|
||||
-- add it to the readings table
|
||||
|
||||
if (current ~= 0 and current ~= nil) then
|
||||
temperatureReadings.add(current)
|
||||
else
|
||||
-- no need to be here, weird state detected
|
||||
domoticz.log('Strange sensor reading.. skiping', domoticz.LOG_ERROR)
|
||||
return
|
||||
end
|
||||
|
||||
elseif (domoticz.devices(SETPOINT_DEVICE).changed) then
|
||||
-- a new setpoint was set
|
||||
if LOGGING then domoticz.log('Setpoint was set to ' .. item.state) end
|
||||
else
|
||||
-- no business here, bail out...
|
||||
return
|
||||
end
|
||||
end
|
||||
|
||||
-- now determine what to do
|
||||
if (setpoint.state == nil or setpoint.state == 'Off') then
|
||||
boiler.switchOff()
|
||||
return -- we're done here
|
||||
end
|
||||
|
||||
local setpointValue = tonumber(setpoint.state)
|
||||
|
||||
-- determine at which temperature the boiler should be
|
||||
-- switched on
|
||||
local switchOnTemp = setpointValue - HYSTERESIS
|
||||
|
||||
-- don't use the current reading but average it out over
|
||||
-- the past <SMOOTH_FACTOR> readings (data smoothing) to get rid of noise, wrong readings etc
|
||||
local avgTemp = temperatureReadings.avg(1, SMOOTH_FACTOR, current) -- fallback to current when history is empty
|
||||
|
||||
if LOGGING then
|
||||
domoticz.log('Average: ' .. avgTemp, domoticz.LOG_INFO)
|
||||
domoticz.log('Setpoint: ' .. setpointValue, domoticz.LOG_INFO)
|
||||
domoticz.log('Current boiler state: ' .. boiler.state, domoticz.LOG_INFO)
|
||||
domoticz.log('Switch-on temperature: ' .. switchOnTemp, domoticz.LOG_INFO)
|
||||
end
|
||||
|
||||
if (avgTemp >= setpointValue and boiler.state == 'On') then
|
||||
if LOGGING then domoticz.log('Target temperature reached, boiler off') end
|
||||
boiler.switchOff()
|
||||
end
|
||||
|
||||
if (avgTemp < setpointValue and boiler.state == 'Off') then
|
||||
if (avgTemp < switchOnTemp) then
|
||||
if LOGGING then domoticz.log('Heating is required, boiler switched on') end
|
||||
boiler.switchOn()
|
||||
else
|
||||
if LOGGING then domoticz.log('Average temperature below setpoint but within hysteresis range, waiting for temperature to drop to ' .. switchOnTemp) end
|
||||
end
|
||||
end
|
||||
end
|
||||
}
|
||||
132
dzVents/examples/sunscreen.lua
Normal file
132
dzVents/examples/sunscreen.lua
Normal file
@@ -0,0 +1,132 @@
|
||||
-- Define all the sensors which needs to be considered for the sunscreen to close
|
||||
local sensors = {
|
||||
temperature = {
|
||||
active = true,
|
||||
device = 'Temperature',
|
||||
closeRule = function(device)
|
||||
return device.temperature <= 15
|
||||
end
|
||||
},
|
||||
wind = {
|
||||
active = true,
|
||||
device = 'Wind',
|
||||
closeRule = function(device)
|
||||
return device.speed >= 50 or device.gust >= 150
|
||||
end
|
||||
},
|
||||
rain = {
|
||||
active = true,
|
||||
device = 'Rain',
|
||||
closeRule = function(device)
|
||||
return device.rainRate > 0
|
||||
end
|
||||
},
|
||||
rainExpected = {
|
||||
active = false,
|
||||
device = 'Rain expected', -- This needs to be a virtual sensor of type 'percentage'
|
||||
closeRule = function(device)
|
||||
return device.percentage > 15
|
||||
end
|
||||
},
|
||||
uv = {
|
||||
active = true,
|
||||
device = 'UV',
|
||||
closeRule = function(device)
|
||||
return device.uv <= 3
|
||||
end
|
||||
},
|
||||
lux = {
|
||||
active = false,
|
||||
device = 'Lux',
|
||||
closeRule = function(device)
|
||||
return device.lux <= 500
|
||||
end
|
||||
}
|
||||
}
|
||||
|
||||
-- Define the name of your sunscreen device
|
||||
local sunscreenDevice = 'Sunscreen'
|
||||
|
||||
-- Enable dry run mode to test the sunscreen script without actually activating the sunscreen
|
||||
local dryRun = false
|
||||
|
||||
-- Define the name of a virtual switch which you can use to disable the sunscreen automation script
|
||||
-- Set to false to disable this feature
|
||||
local manualOverrideSwitch = false
|
||||
|
||||
-- Minutes to wait after a sunscreen close before opening it again.
|
||||
local timeBetweenOpens = 10
|
||||
|
||||
return {
|
||||
active = true,
|
||||
on = {
|
||||
timer = {'every minute'}
|
||||
},
|
||||
logging = {
|
||||
level = domoticz.LOG_DEBUG,
|
||||
marker = 'Sunscreen'
|
||||
},
|
||||
execute = function(domoticz)
|
||||
|
||||
local function switchOn(sunscreen, message)
|
||||
if (sunscreen.state == 'Closed') then
|
||||
if (not dryRun) then
|
||||
sunscreen.switchOn()
|
||||
domoticz.notify('Sunscreen', message)
|
||||
end
|
||||
domoticz.log(message, domoticz.LOG_INFO)
|
||||
end
|
||||
end
|
||||
|
||||
local function switchOff(sunscreen, message)
|
||||
if (sunscreen.state == 'Open') then
|
||||
if (not dryRun) then
|
||||
sunscreen.switchOff()
|
||||
domoticz.notify('Sunscreen', message)
|
||||
end
|
||||
domoticz.log(message, domoticz.LOG_INFO)
|
||||
end
|
||||
end
|
||||
|
||||
if (manualOverrideSwitch and domoticz.devices(manualOverrideSwitch).state == 'On') then
|
||||
domoticz.log('Automatic sunscreen script is manually disabled', domoticz.LOG_DEBUG)
|
||||
return
|
||||
end
|
||||
|
||||
local sunscreen = domoticz.devices(sunscreenDevice)
|
||||
|
||||
-- Sunscreen must always be up during nighttime
|
||||
if (domoticz.time.isNightTime) then
|
||||
switchOff(sunscreen, 'Closing sunscreen, It is night')
|
||||
return
|
||||
end
|
||||
|
||||
-- Check all sensor tresholds and if any exeeded close sunscreen
|
||||
for sensorType, sensor in pairs(sensors) do
|
||||
|
||||
if (sensor['active'] == true) then
|
||||
|
||||
local device = domoticz.devices(sensor['device'])
|
||||
local closeRule = sensor['closeRule']
|
||||
|
||||
domoticz.log('Checking sensor: ' .. sensorType, domoticz.LOG_DEBUG)
|
||||
|
||||
if (closeRule(device)) then
|
||||
|
||||
switchOff(sunscreen, sensorType .. ' treshold exceeded, Sunscreen up')
|
||||
|
||||
domoticz.log(sensorType .. ' treshold exceeded', domoticz.LOG_DEBUG)
|
||||
-- Return early when we exeed any tresholds
|
||||
return
|
||||
end
|
||||
else
|
||||
domoticz.log('Sensor not active skipping: ' .. sensorType, domoticz.LOG_DEBUG)
|
||||
end
|
||||
end
|
||||
|
||||
-- All tresholds OK, sunscreen may be lowered
|
||||
if (sunscreen.lastUpdate.minutesAgo > timeBetweenOpens) then
|
||||
switchOn(sunscreen, 'Sun is shining, all thresholds OK, lowering sunscreen')
|
||||
end
|
||||
end
|
||||
}
|
||||
119
dzVents/examples/templates/All.lua
Normal file
119
dzVents/examples/templates/All.lua
Normal file
@@ -0,0 +1,119 @@
|
||||
-- Check the wiki for dzVents
|
||||
-- remove what you don't need
|
||||
return {
|
||||
|
||||
-- optional active section,
|
||||
-- when left out the script is active
|
||||
-- note that you still have to check this script
|
||||
-- as active in the side panel
|
||||
active = {
|
||||
|
||||
true, -- either true or false, or you can specify a function
|
||||
|
||||
--function(domoticz)
|
||||
-- return true/false
|
||||
--end
|
||||
},
|
||||
-- trigger
|
||||
-- can be a combination:
|
||||
on = {
|
||||
|
||||
-- device triggers
|
||||
devices = {
|
||||
-- scripts is executed if the device that was updated matches with one of these triggers
|
||||
'device name', -- device name
|
||||
'abc*', -- triggers for all devices which name begins with abc
|
||||
258, -- id
|
||||
},
|
||||
|
||||
-- timer riggers
|
||||
timer = {
|
||||
-- timer triggers.. if one matches with the current time then the script is executed
|
||||
'at 13:45',
|
||||
'at 18:37',
|
||||
'every 3 minutes on mon,tue,fri at 16:00-15:00',
|
||||
function(domoticz)
|
||||
-- return true or false
|
||||
end
|
||||
},
|
||||
|
||||
-- user variable triggers
|
||||
variables = {
|
||||
'myUserVariable'
|
||||
},
|
||||
|
||||
-- security triggers
|
||||
security = {
|
||||
domoticz.SECURITY_ARMEDAWAY,
|
||||
domoticz.SECURITY_ARMEHOME,
|
||||
},
|
||||
|
||||
-- scene triggers
|
||||
scenes = {
|
||||
'myScene'
|
||||
},
|
||||
|
||||
-- group triggers
|
||||
groups = {
|
||||
'myGroup'
|
||||
},
|
||||
|
||||
-- http http responses
|
||||
httpResponses = {
|
||||
'some callback string'
|
||||
},
|
||||
|
||||
-- system events
|
||||
system = {
|
||||
'start',
|
||||
'stop',
|
||||
'manualBackupFinished',
|
||||
'dailyBackupFinished',
|
||||
'hourlyBackupFinished',
|
||||
'monthlyBackupFinished'
|
||||
},
|
||||
|
||||
customEvents = {
|
||||
'myCustomEvent'
|
||||
}
|
||||
},
|
||||
|
||||
-- persistent data
|
||||
-- see documentation about persistent variables
|
||||
data = {
|
||||
myVar = { initial = 5 },
|
||||
myHistoryVar = { maxItems = 10 },
|
||||
},
|
||||
|
||||
-- custom logging level for this script
|
||||
logging = {
|
||||
level = domoticz.LOG_DEBUG,
|
||||
marker = "Cool script"
|
||||
},
|
||||
|
||||
-- actual event code
|
||||
-- the second parameter is depending on the trigger
|
||||
-- when it is a device change, the second parameter is the device object
|
||||
-- similar for variables, scenes and groups and httpResponses
|
||||
-- inspect the type like: triggeredItem.isDevice
|
||||
execute = function(domoticz, triggeredItem, info)
|
||||
--[[
|
||||
|
||||
The domoticz object holds all information about your Domoticz system. E.g.:
|
||||
|
||||
local myDevice = domoticz.devices('myDevice')
|
||||
local myVariable = domoticz.variables('myUserVariable')
|
||||
local myGroup = domoticz.groups('myGroup')
|
||||
local myScene = domoticz.scenes('myScene')
|
||||
|
||||
The device object is the device that was triggered due to the device in the 'on' section above.
|
||||
]] --
|
||||
|
||||
-- example
|
||||
|
||||
if (triggerdItem.active) then -- state == 'On'
|
||||
triggerdItem.switchOff().afterMin(2) -- if it is a switch
|
||||
domoticz.notify('Light info', 'The light ' .. triggerdItem.name .. ' will be switched off soon')
|
||||
end
|
||||
end
|
||||
}
|
||||
18
dzVents/examples/templates/Bare.lua
Normal file
18
dzVents/examples/templates/Bare.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
return {
|
||||
on = {
|
||||
devices = {},
|
||||
timer = {},
|
||||
variables = {},
|
||||
scenes = {},
|
||||
groups = {},
|
||||
security = {},
|
||||
httpResponses = {},
|
||||
customEvents = {},
|
||||
system = {},
|
||||
},
|
||||
data = {},
|
||||
logging = {},
|
||||
execute = function(domoticz, triggeredItem)
|
||||
|
||||
end
|
||||
}
|
||||
20
dzVents/examples/templates/CustomEvents.lua
Normal file
20
dzVents/examples/templates/CustomEvents.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
return {
|
||||
on = {
|
||||
timer = {
|
||||
'every 5 minutes' -- just an example to trigger the event
|
||||
},
|
||||
customEvents = {
|
||||
'MyEvent' -- event triggered by emitEvent
|
||||
}
|
||||
},
|
||||
data = {},
|
||||
logging = {},
|
||||
execute = function(domoticz, triggeredItem)
|
||||
if (triggeredItem.isCustomEvent) then
|
||||
domoticz.utils._.print(triggeredItem.data)
|
||||
else
|
||||
-- second parameter can be anything, number, string, boolean or table
|
||||
domoticz.emitEvent('MyEvent', 'Some data')
|
||||
end
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/Device.lua
Normal file
10
dzVents/examples/templates/Device.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
devices = {
|
||||
'myDevice'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, device)
|
||||
domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/Group.lua
Normal file
10
dzVents/examples/templates/Group.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
groups = {
|
||||
'myGroup'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, group)
|
||||
domoticz.log('Group ' .. group.name .. ' was changed', domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
38
dzVents/examples/templates/HTTPRequest.lua
Normal file
38
dzVents/examples/templates/HTTPRequest.lua
Normal file
@@ -0,0 +1,38 @@
|
||||
return {
|
||||
on = {
|
||||
timer = {
|
||||
'every 5 minutes' -- just an example to trigger the request
|
||||
},
|
||||
httpResponses = {
|
||||
'trigger' -- must match with the callback passed to the openURL command
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, item)
|
||||
|
||||
if (item.isTimer) then
|
||||
domoticz.openURL({
|
||||
url = 'http://somedomain/someAPI?param=1',
|
||||
method = 'GET',
|
||||
callback = 'trigger', -- see httpResponses above.
|
||||
})
|
||||
end
|
||||
|
||||
if (item.isHTTPResponse) then
|
||||
|
||||
if (item.ok) then
|
||||
if (item.isJSON) then
|
||||
|
||||
local someValue = item.json.someValue -- just an example
|
||||
|
||||
-- update some device in Domoticz
|
||||
domoticz.devices('myTextDevice').updateText(someValue)
|
||||
end
|
||||
else
|
||||
domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
|
||||
domoticz.log(item, domoticz.LOG_ERROR)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/Scene.lua
Normal file
10
dzVents/examples/templates/Scene.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
scenes = {
|
||||
'myScene'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, scene)
|
||||
domoticz.log('Scene ' .. scene.name .. ' was changed', domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/Security.lua
Normal file
10
dzVents/examples/templates/Security.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
security = {
|
||||
domoticz.SECURITY_ARMEDAWAY,
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, security)
|
||||
domoticz.log('Security was triggered by ' .. security.trigger, domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
17
dzVents/examples/templates/System.lua
Normal file
17
dzVents/examples/templates/System.lua
Normal file
@@ -0,0 +1,17 @@
|
||||
return {
|
||||
on = {
|
||||
system = {
|
||||
'start',
|
||||
'stop',
|
||||
'manualBackupFinished',
|
||||
'dailyBackupFinished',
|
||||
'hourlyBackupFinished',
|
||||
'monthlyBackupFinished'
|
||||
}
|
||||
},
|
||||
data = {},
|
||||
logger = {},
|
||||
execute = function(domoticz, triggeredItem)
|
||||
domoticz.log('Domoticz has started')
|
||||
end
|
||||
}
|
||||
50
dzVents/examples/templates/Timer.lua
Normal file
50
dzVents/examples/templates/Timer.lua
Normal file
@@ -0,0 +1,50 @@
|
||||
return {
|
||||
on = {
|
||||
timer = {
|
||||
'every minute', -- causes the script to be called every minute
|
||||
'every other minute', -- minutes: xx:00, xx:02, xx:04, ..., xx:58
|
||||
'every <xx> minutes', -- starting from xx:00 triggers every xx minutes (0 > xx < 60)
|
||||
'every hour', -- 00:00, 01:00, ..., 23:00 (24x per 24hrs)
|
||||
'every other hour', -- 00:00, 02:00, ..., 22:00 (12x per 24hrs)
|
||||
'every <xx> hours', -- starting from 00:00, triggers every xx hours (0 > xx < 24)
|
||||
'at 13:45', -- specific time
|
||||
'at *:45', -- every 45th minute in the hour
|
||||
'at 15:*', -- every minute between 15:00 and 16:00
|
||||
'at 12:45-21:15', -- between 12:45 and 21:15. You cannot use '*'!
|
||||
'at 19:30-08:20', -- between 19:30 and 8:20 then next day
|
||||
'at 13:45 on mon,tue', -- at 13:45 only on Monday en Tuesday (english)
|
||||
'every hour on sat', -- you guessed it correctly
|
||||
'at sunset', -- uses sunset/sunrise info from Domoticz
|
||||
'at sunrise',
|
||||
'at sunset on sat,sun',
|
||||
'xx minutes before sunset',
|
||||
'xx minutes after sunset',
|
||||
'xx minutes before sunrise',
|
||||
'xx minutes after sunrise', -- guess ;-)
|
||||
'between aa and bb', -- aa/bb can be a time stamp like 15:44
|
||||
-- aa/bb can be sunrise/sunset
|
||||
-- aa/bb can be 'xx minutes before/after
|
||||
-- sunrise/sunset'
|
||||
'at nighttime', -- between sunset and sunrise
|
||||
'at daytime', -- between sunrise and sunset
|
||||
'at civildaytime', -- between civil twilight start and civil twilight end
|
||||
'at civilnighttime', -- between civil twilight end and civil twilight start
|
||||
'at daytime on mon,tue', -- between sunrise and sunset only on monday and tuesday
|
||||
|
||||
-- or if you want to go really wild:
|
||||
'at nighttime at 21:32-05:44 every 5 minutes on sat, sun',
|
||||
'every 10 minutes between 20 minutes before sunset and 30 minutes after sunrise on mon,fri,tue',
|
||||
|
||||
-- or just do it yourself:
|
||||
function(domoticz)
|
||||
-- you can use domoticz.time to get the current time
|
||||
-- note that this function is called every minute!
|
||||
-- custom code that either returns true or false
|
||||
return true
|
||||
end,
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, timer)
|
||||
domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
11
dzVents/examples/templates/UserVariable.lua
Normal file
11
dzVents/examples/templates/UserVariable.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
on = {
|
||||
variables = {
|
||||
'myUserVariable'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, variable)
|
||||
domoticz.log('Variable ' .. variable.name .. ' was changed', domoticz.LOG_INFO)
|
||||
-- code
|
||||
end
|
||||
}
|
||||
16
dzVents/examples/templates/bare.lua
Normal file
16
dzVents/examples/templates/bare.lua
Normal file
@@ -0,0 +1,16 @@
|
||||
return {
|
||||
on = {
|
||||
devices = {},
|
||||
timer = {},
|
||||
variables = {},
|
||||
scenes = {},
|
||||
groups = {},
|
||||
security = {},
|
||||
httpResponses = {}
|
||||
},
|
||||
data = {},
|
||||
logger = {},
|
||||
execute = function(domoticz, triggeredItem)
|
||||
|
||||
end
|
||||
}
|
||||
105
dzVents/examples/templates/complete.lua
Normal file
105
dzVents/examples/templates/complete.lua
Normal file
@@ -0,0 +1,105 @@
|
||||
-- Check the wiki for dzVents
|
||||
-- remove what you don't need
|
||||
return {
|
||||
|
||||
-- optional active section,
|
||||
-- when left out the script is active
|
||||
-- note that you still have to check this script
|
||||
-- as active in the side panel
|
||||
active = {
|
||||
|
||||
true, -- either true or false, or you can specify a function
|
||||
|
||||
--function(domoticz)
|
||||
-- return true/false
|
||||
--end
|
||||
}
|
||||
-- trigger
|
||||
-- can be a combination:
|
||||
on = {
|
||||
|
||||
-- device triggers
|
||||
devices = {
|
||||
-- scripts is executed if the device that was updated matches with one of these triggers
|
||||
'device name', -- device name
|
||||
'abc*', -- triggers for all devices which name begins with abc
|
||||
258, -- id
|
||||
},
|
||||
|
||||
-- timer riggers
|
||||
timer = {
|
||||
-- timer triggers.. if one matches with the current time then the script is executed
|
||||
'at 13:45',
|
||||
'at 18:37',
|
||||
'every 3 minutes on mon,tue,fri at 16:00-15:00',
|
||||
function(domoticz)
|
||||
-- return true or false
|
||||
end
|
||||
},
|
||||
|
||||
-- user variable triggers
|
||||
variables = {
|
||||
'myUserVariable'
|
||||
},
|
||||
|
||||
-- security triggers
|
||||
security = {
|
||||
domoticz.SECURITY_ARMEDAWAY,
|
||||
domoticz.SECURITY_ARMEHOME,
|
||||
},
|
||||
|
||||
-- scene triggers
|
||||
scenes = {
|
||||
'myScene'
|
||||
},
|
||||
|
||||
-- group triggers
|
||||
groups = {
|
||||
'myGroup'
|
||||
},
|
||||
|
||||
-- http http responses
|
||||
httpResponses = {
|
||||
'some callback string'
|
||||
}
|
||||
},
|
||||
|
||||
-- persistent data
|
||||
-- see documentation about persistent variables
|
||||
data = {
|
||||
myVar = { initial = 5 },
|
||||
myHistoryVar = { maxItems = 10 },
|
||||
},
|
||||
|
||||
-- custom logging level for this script
|
||||
logging = {
|
||||
level = domoticz.LOG_DEBUG,
|
||||
marker = "Cool script"
|
||||
},
|
||||
|
||||
-- actual event code
|
||||
-- the second parameter is depending on the trigger
|
||||
-- when it is a device change, the second parameter is the device object
|
||||
-- similar for variables, scenes and groups and httpResponses
|
||||
-- inspect the type like: triggeredItem.isDevice
|
||||
execute = function(domoticz, triggeredItem, info)
|
||||
--[[
|
||||
|
||||
The domoticz object holds all information about your Domoticz system. E.g.:
|
||||
|
||||
local myDevice = domoticz.devices('myDevice')
|
||||
local myVariable = domoticz.variables('myUserVariable')
|
||||
local myGroup = domoticz.groups('myGroup')
|
||||
local myScene = domoticz.scenes('myScene')
|
||||
|
||||
The device object is the device that was triggered due to the device in the 'on' section above.
|
||||
]] --
|
||||
|
||||
-- example
|
||||
|
||||
if (triggerdItem.active) then -- state == 'On'
|
||||
triggerdItem.switchOff().afterMin(2) -- if it is a switch
|
||||
domoticz.notify('Light info', 'The light ' .. triggerdItem.name .. ' will be switched off soon')
|
||||
end
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/device.lua
Normal file
10
dzVents/examples/templates/device.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
devices = {
|
||||
'myDevice'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, device)
|
||||
domoticz.log('Device ' .. device.name .. ' was changed', domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
18
dzVents/examples/templates/global_data.lua
Normal file
18
dzVents/examples/templates/global_data.lua
Normal file
@@ -0,0 +1,18 @@
|
||||
-- this scripts holds all the globally persistent variables and helper functions
|
||||
-- see the documentation in the wiki
|
||||
-- NOTE:
|
||||
-- THERE CAN BE ONLY ONE global_data SCRIPT in your Domoticz install.
|
||||
|
||||
return {
|
||||
-- global persistent data
|
||||
data = {
|
||||
myGlobalVar = { initial = 12 }
|
||||
},
|
||||
|
||||
-- global helper functions
|
||||
helpers = {
|
||||
myHelperFunction = function(domoticz)
|
||||
-- code
|
||||
end
|
||||
}
|
||||
}
|
||||
10
dzVents/examples/templates/group.lua
Normal file
10
dzVents/examples/templates/group.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
groups = {
|
||||
'myGroup'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, group)
|
||||
domoticz.log('Group ' .. group.name .. ' was changed', domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/scene.lua
Normal file
10
dzVents/examples/templates/scene.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
scenes = {
|
||||
'myScene'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, scene)
|
||||
domoticz.log('Scene ' .. scene.name .. ' was changed', domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
10
dzVents/examples/templates/security.lua
Normal file
10
dzVents/examples/templates/security.lua
Normal file
@@ -0,0 +1,10 @@
|
||||
return {
|
||||
on = {
|
||||
security = {
|
||||
domoticz.SECURITY_ARMEDAWAY,
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, security, info)
|
||||
domoticz.log('Security was triggered by ' .. security.trigger, domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
53
dzVents/examples/templates/timer.lua
Normal file
53
dzVents/examples/templates/timer.lua
Normal file
@@ -0,0 +1,53 @@
|
||||
return {
|
||||
on = {
|
||||
timer = {
|
||||
'every minute', -- causes the script to be called every minute
|
||||
'every other minute', -- minutes: xx:00, xx:02, xx:04, ..., xx:58
|
||||
'every <xx> minutes', -- starting from xx:00 triggers every xx minutes
|
||||
-- (0 > xx < 60)
|
||||
'every hour', -- 00:00, 01:00, ..., 23:00 (24x per 24hrs)
|
||||
'every other hour', -- 00:00, 02:00, ..., 22:00 (12x per 24hrs)
|
||||
'every <xx> hours', -- starting from 00:00, triggers every xx
|
||||
-- hours (0 > xx < 24)
|
||||
'at 13:45', -- specific time
|
||||
'at *:45', -- every 45th minute in the hour
|
||||
'at 15:*', -- every minute between 15:00 and 16:00
|
||||
'at 12:45-21:15', -- between 12:45 and 21:15. You cannot use '*'!
|
||||
'at 19:30-08:20', -- between 19:30 and 8:20 then next day
|
||||
'at 13:45 on mon,tue', -- at 13:45 only on Monday en Tuesday (english)
|
||||
'every hour on sat', -- you guessed it correctly
|
||||
'at sunset', -- uses sunset/sunrise info from Domoticz
|
||||
'at sunrise',
|
||||
'at sunset on sat,sun',
|
||||
'xx minutes before sunset',
|
||||
'xx minutes after sunset',
|
||||
'xx minutes before sunrise',
|
||||
'xx minutes after sunrise', -- guess ;-)
|
||||
'between aa and bb', -- aa/bb can be a time stamp like 15:44
|
||||
-- aa/bb can be sunrise/sunset
|
||||
-- aa/bb can be 'xx minutes before/after
|
||||
-- sunrise/sunset'
|
||||
'at nighttime', -- between sunset and sunrise
|
||||
'at daytime', -- between sunrise and sunset
|
||||
'at civildaytime', -- between civil twilight start and civil twilight end
|
||||
'at civilnighttime', -- between civil twilight end and civil twilight startœ
|
||||
'at daytime on mon,tue', -- between sunrise and sunset
|
||||
-- only on monday and tuesday
|
||||
|
||||
-- or if you want to go really wild:
|
||||
'at nighttime at 21:32-05:44 every 5 minutes on sat, sun',
|
||||
'every 10 minutes between 20 minutes before sunset and 30 minutes after sunrise on mon,fri,tue',
|
||||
|
||||
-- or just do it yourself:
|
||||
function(domoticz)
|
||||
-- you can use domoticz.time to get the current time
|
||||
-- note that this function is called every minute!
|
||||
-- custom code that either returns true or false
|
||||
return true
|
||||
end
|
||||
},
|
||||
},
|
||||
execute = function(domoticz, timer)
|
||||
domoticz.log('Timer event was triggered by ' .. timer.trigger, domoticz.LOG_INFO)
|
||||
end
|
||||
}
|
||||
11
dzVents/examples/templates/variable.lua
Normal file
11
dzVents/examples/templates/variable.lua
Normal file
@@ -0,0 +1,11 @@
|
||||
return {
|
||||
on = {
|
||||
variables = {
|
||||
'myUserVariable'
|
||||
}
|
||||
},
|
||||
execute = function(domoticz, variable)
|
||||
domoticz.log('Variable ' .. variable.name .. ' was changed', domoticz.LOG_INFO)
|
||||
-- code
|
||||
end
|
||||
}
|
||||
3
dzVents/generated_scripts/README.md
Normal file
3
dzVents/generated_scripts/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
This folder will contain scripts that are created inside Domoticz using
|
||||
the internal script editor. Don't remove this folder and do not edit the scripts in
|
||||
here as they will be overwritten.
|
||||
3
dzVents/scripts/README.md
Normal file
3
dzVents/scripts/README.md
Normal file
@@ -0,0 +1,3 @@
|
||||
**Scripts folder**
|
||||
|
||||
Place all your scripts in this folder. Only these scripts will be executed by dzVents. See the example folder for some script examples and check the README.md in the root for instructions.
|
||||
486
dzVents/scripts/livebox.old
Normal file
486
dzVents/scripts/livebox.old
Normal file
@@ -0,0 +1,486 @@
|
||||
--[[
|
||||
Prérequis :
|
||||
Domoticz v3.8837 or later (dzVents version 2.4 or later)
|
||||
|
||||
Sources : https://www.alex-braga.fr/ressources_externe/xdslbox_3.4.10.sh
|
||||
https://github.com/rene-d/sysbus
|
||||
https://github.com/NextDom/plugin-livebox/
|
||||
|
||||
Livebox 4 stats
|
||||
|
||||
https://easydomoticz.com/forum/viewtopic.php?f=17&t=7247
|
||||
https://github.com/papo-o/domoticz_scripts/new/master/dzVents/scripts/livebox.lua
|
||||
https://pon.fr/dzvents-toutes-les-infos-de-la-livebox-en-un-seul-script/
|
||||
|
||||
-- Authors ----------------------------------------------------------------
|
||||
V1.0 - Neutrino - Domoticz
|
||||
V1.1 - Neutrino - Activation/désactivation du WiFi
|
||||
V1.2 - papoo - Liste des n derniers appels manqués, sans réponse, réussis et surveillance périphériques des connectés/déconnectés
|
||||
V1.3 - Neutrino - Possibilité de purger le journal d'appels
|
||||
V1.4 - papoo - Possibilité de rebooter la Livebox
|
||||
V1.5 - papoo - Correction non mise à jour des devices après RAZ de la liste des appels
|
||||
V1.6 - papoo - Correction horodatage heures d'appel à GMT+2
|
||||
V1.7 - papoo - Affichage des noms connus via fichiers de contacts
|
||||
]]--
|
||||
-- Variables à modifier ------------------------------------------------
|
||||
|
||||
local fetchIntervalMins = 3 -- intervalle de mise à jour.
|
||||
local adresseLB = '192.168.1.1' --Adresse IP de votre Livebox 4
|
||||
local password = "jefa6jyu"
|
||||
local tmpDir = "/var/tmp" --répertoire temporaire, dans l'idéal en RAM
|
||||
local myOutput=tmpDir.."/Output.txt"
|
||||
local myCookies=tmpDir.."/Cookies.txt"
|
||||
|
||||
-- Domoticz devices
|
||||
local SyncATM = nil --"Sync ATM" -- Nom du capteur custom Synchro ATM down, nil si non utilisé
|
||||
local SyncATMup = nil --"Sync ATM up" -- Nom du capteur custom Synchro ATM up, nil si non utilisé
|
||||
local Attn = nil --"Attn" -- Nom du capteur custom Attenuation de la ligne, nil si non utilisé
|
||||
local MargedAttn = nil --"Marge d'Attn" -- Nom du capteur custom Marge d'atténuation, nil si non utilisé
|
||||
local IPWAN = nil --"IP WAN" -- Nom du capteur Text IP WAN, nil si non utilisé
|
||||
local IPv6WAN = nil --"IPv6 WAN" -- Nom du capteur Text IPv6 WAN, nil si non utilisé
|
||||
local DernierAppel = "Dernier Appel" -- Nom du capteur Text Dernier Appel, nil si non utilisé
|
||||
local UptimeLB = nil -- "Uptime Livebox" -- Nom du capteur Text Uptime Livebox, nil si non utilisé
|
||||
local TransmitBlocks = nil --"TransmitBlocks" -- Nom du capteur Incremental Counter TransmitBlocks, nil si non utilisé
|
||||
local ReceiveBlocks = nil --"ReceiveBlocks" -- Nom du capteur Incremental Counter ReceiveBlocks, nil si non utilisé
|
||||
local internet = nil --"Internet" -- Nom du capteur Interrupteur Internet, nil si non utilisé
|
||||
local VoIP = nil --"VoIP" -- Nom du capteur Interrupteur VoIP, nil si non utilisé
|
||||
local ServiceTV = nil --"Service TV" -- Nom du capteur Interrupteur Service TV, nil si non utilisé
|
||||
local wifi24 = nil --"WiFi 2.4" -- Nom du capteur Interrupteur wifi 2.4Ghz, nil si non utilisé
|
||||
local wifi5 = nil --"WiFi 5" -- Nom du capteur Interrupteur wifi 5Ghz, nil si non utilisé
|
||||
local missedCall = "Appels manqués" -- Nom du capteur Text appels manqués, nil si non utilisé
|
||||
local nbMissedCall = 4 -- Nombre d'appels manqués à afficher
|
||||
local failedCall = "Appels sans réponse" -- Nom du capteur Text appels sans réponse, nil si non utilisé
|
||||
local nbFailedCall = 4 -- Nombre d'appels sans réponse à afficher
|
||||
local succeededCall = nil -- "Appels Réussis" -- Nom du capteur Text appels réussis, nil si non utilisé
|
||||
local nbSucceededCall = 4 -- Nombre d'appels réussis à afficher
|
||||
local clearCallList = "Effacer liste appels" -- Nom du capteur Interrupteur PushOn clearCallList
|
||||
local reboot = 1297 -- Nom du capteur Interrupteur PushOn reboot
|
||||
local devices_livebox_mac_adress = { -- MAC ADDRESS des périphériques à surveiller
|
||||
"44:6D:6C:A2:68:0C", "8C:1A:BF:49:63:06", "00:25:22:6C:7B:8C",
|
||||
"44:6D:57:8E:EA:E7", "C8:D0:83:09:22:D3"
|
||||
}
|
||||
local fichier_contacts = "/opt/domoticz/scripts/contacts.json"
|
||||
json = assert(loadfile('/opt/domoticz/scripts/lua/JSON.lua'))()
|
||||
commandArray = {}
|
||||
-- SVP, ne rien changer sous cette ligne (sauf pour modifier le logging level)
|
||||
function os.capture(cmd, raw)
|
||||
local f = assert(io.popen(cmd, 'r'))
|
||||
local s = assert(f:read('*a'))
|
||||
f:close()
|
||||
if raw then return s end
|
||||
s = string.gsub(s, '^%s+', '')
|
||||
s = string.gsub(s, '%s+$', '')
|
||||
s = string.gsub(s, '[\n\r]+', ' ')
|
||||
return s
|
||||
end
|
||||
|
||||
function disp_time(time)
|
||||
local days = math.floor(time/86400)
|
||||
local remaining = time % 86400
|
||||
local hours = math.floor(remaining/3600)
|
||||
remaining = remaining % 3600
|
||||
local minutes = math.floor(remaining/60)
|
||||
remaining = remaining % 60
|
||||
local seconds = remaining
|
||||
return string.format("%d:%02d:%02d:%02d",days,hours,minutes,seconds)
|
||||
end
|
||||
|
||||
function traduction(str) -- supprime les accents de la chaîne str
|
||||
if (str) then
|
||||
str = string.gsub (str,"missed", "manqué")
|
||||
str = string.gsub (str,"failed", "échoué")
|
||||
str = string.gsub (str,"succeeded", "réussi")
|
||||
end
|
||||
return (str)
|
||||
end
|
||||
function format_date(str) -- supprime les caractères T et Z de la chaîne str et corrige l'heure a GMT +2
|
||||
if (str) then
|
||||
_, _, A, M, j, h, m, s = string.find(str, "^(%d+)-(%d+)-(%d+)T(%d+):(%d+):(%d+)Z$")
|
||||
h = h + 2
|
||||
str= A.."-"..M.."-"..j.." - "..h..":"..m..":"..s
|
||||
end
|
||||
return (str)
|
||||
end
|
||||
function ReverseTable(t)
|
||||
local reversedTable = {}
|
||||
local itemCount = #t
|
||||
for k, v in ipairs(t) do
|
||||
reversedTable[itemCount + 1 - k] = v
|
||||
end
|
||||
return reversedTable
|
||||
end
|
||||
function json2table(file)
|
||||
local f = io.open(file, "rb")
|
||||
if(f == nil) then
|
||||
return ""
|
||||
else
|
||||
local content = f:read("*all")
|
||||
f:close()
|
||||
jsonValeur = json:decode(content)
|
||||
return jsonValeur
|
||||
end
|
||||
end
|
||||
function testActive(domoticz, name, active)
|
||||
if active == true then
|
||||
if domoticz.devices(name) then
|
||||
domoticz.devices(name).switchOn().checkFirst()
|
||||
end
|
||||
domoticz.log("Activation de : " .. name, domoticz.LOG_INFO)
|
||||
else
|
||||
if domoticz.devices(name) then
|
||||
domoticz.devices(name).switchOff().checkFirst()
|
||||
end
|
||||
domoticz.log("DésActivation de : " .. name, domoticz.LOG_INFO)
|
||||
end
|
||||
end
|
||||
|
||||
contacts = {}
|
||||
contacts = json2table(fichier_contacts)
|
||||
|
||||
function searchName(contacts, phoneNumber)
|
||||
-- for index, variable in pairs(contacts) do
|
||||
-- if variable.Phone == phoneNumber then
|
||||
-- name = variable.Name
|
||||
-- end
|
||||
-- end
|
||||
-- if name == nil then
|
||||
name = phoneNumber
|
||||
-- end
|
||||
return name
|
||||
end
|
||||
local scriptName = 'Livebox'
|
||||
local scriptVersion = '1.7'
|
||||
|
||||
local missedCallList = ""
|
||||
local failedCallList = ""
|
||||
local succeededCallList = ""
|
||||
local patternMacAdresses = string.format("([^%s]+)", ";")
|
||||
|
||||
return {
|
||||
active = true,
|
||||
logging = {
|
||||
-- level = domoticz.LOG_DEBUG, -- Uncomment to override the dzVents global logging setting
|
||||
-- level = domoticz.LOG_INFO, -- Seulement un niveau peut être actif; commenter les autres
|
||||
-- level = domoticz.LOG_ERROR,
|
||||
-- level = domoticz.LOG_DEBUG,
|
||||
-- level = domoticz.LOG_MODULE_EXEC_INFO,
|
||||
marker = scriptName..' '..scriptVersion
|
||||
},
|
||||
on = {
|
||||
timer = {
|
||||
'every '..tostring(fetchIntervalMins)..' minutes',
|
||||
},
|
||||
devices = {wifi5,wifi24,clearCallList,reboot}
|
||||
},
|
||||
|
||||
execute = function(domoticz, item)
|
||||
--Connexion et récupération du cookies
|
||||
os.execute("curl -s -o \""..myOutput.."\" -X POST -c \""..myCookies.."\" -H 'Content-Type: application/x-sah-ws-4-call+json' -H 'Authorization: X-Sah-Login' -d \"{\\\"service\\\":\\\"sah.Device.Information\\\",\\\"method\\\":\\\"createContext\\\",\\\"parameters\\\":{\\\"applicationName\\\":\\\"so_sdkut\\\",\\\"username\\\":\\\"admin\\\",\\\"password\\\":\\\""..password.."\\\"}}\" http://"..adresseLB.."/ws > /dev/null")
|
||||
|
||||
--Lecture du cookies pour utilisation ultérieure
|
||||
myContextID = os.capture("tail -n1 \""..myOutput.."\" | sed 's/{\"status\":0,\"data\":{\"contextID\":\"//1'| sed 's/\",//1' | sed 's/\"groups\":\"http,admin//1' | sed 's/\"}}//1'")
|
||||
domoticz.log('Context : '..myContextID, domoticz.LOG_DEBUG)
|
||||
|
||||
if (item.isTimer)then
|
||||
--Envoi des commandes pour récupérer les informations
|
||||
MIBs=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"NeMo.Intf.data\\\",\\\"method\\\":\\\"getMIBs\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('MIBs : '..MIBs, domoticz.LOG_DEBUG)
|
||||
|
||||
DSLstats=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"NeMo.Intf.dsl0\\\",\\\"method\\\":\\\"getDSLStats\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('DSLstats : '..DSLstats, domoticz.LOG_DEBUG)
|
||||
|
||||
WAN=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"NMC\\\",\\\"method\\\":\\\"getWANStatus\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('WAN : '..WAN, domoticz.LOG_DEBUG)
|
||||
|
||||
TVstatus=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"NMC.OrangeTV\\\",\\\"method\\\":\\\"getIPTVStatus\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('TVstatus : '..TVstatus, domoticz.LOG_DEBUG)
|
||||
|
||||
voip=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"VoiceService.VoiceApplication\\\",\\\"method\\\":\\\"listTrunks\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('voip : '..voip, domoticz.LOG_DEBUG)
|
||||
|
||||
devicesList=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"Devices\\\",\\\"method\\\":\\\"get\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('devicesList : '..devicesList, domoticz.LOG_DEBUG)
|
||||
|
||||
wifi=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"NeMo.Intf.lan\\\",\\\"method\\\":\\\"getMIBs\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('wifi : '..wifi, domoticz.LOG_DEBUG)
|
||||
|
||||
callList=os.capture("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..myContextID.."\" -d \"{\\\"service\\\":\\\"VoiceService.VoiceApplication\\\",\\\"method\\\":\\\"getCallList\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws")
|
||||
domoticz.log('callList : '..callList, domoticz.LOG_DEBUG)
|
||||
|
||||
--Données de connexion
|
||||
local lbAPIData = domoticz.utils.fromJSON(MIBs)
|
||||
if lbAPIData.status == nil or lbAPIData == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
if SyncATM then domoticz.log('ATM Down: '..lbAPIData.status.dsl.dsl0.DownstreamCurrRate, domoticz.LOG_INFO)
|
||||
domoticz.devices(SyncATM).updateCustomSensor(lbAPIData.status.dsl.dsl0.DownstreamCurrRate) end
|
||||
|
||||
if SyncATMup then domoticz.log('ATM Up: '..lbAPIData.status.dsl.dsl0.UpstreamCurrRate, domoticz.LOG_INFO)
|
||||
domoticz.devices(SyncATMup).updateCustomSensor(lbAPIData.status.dsl.dsl0.UpstreamCurrRate) end
|
||||
|
||||
if Attn then domoticz.log('Attn : '..tostring(lbAPIData.status.dsl.dsl0.DownstreamLineAttenuation/10)..' dB', domoticz.LOG_INFO)
|
||||
domoticz.devices(Attn).updateCustomSensor(tostring(lbAPIData.status.dsl.dsl0.DownstreamLineAttenuation/10)) end
|
||||
|
||||
if MargedAttn then domoticz.log('Marge d\'Attn : '..tostring(lbAPIData.status.dsl.dsl0.DownstreamNoiseMargin/10)..' dB', domoticz.LOG_INFO)
|
||||
domoticz.devices(MargedAttn).updateCustomSensor(tostring(lbAPIData.status.dsl.dsl0.DownstreamNoiseMargin/10)) end
|
||||
|
||||
if UptimeLB then Uptime = disp_time(lbAPIData.status.dhcp.dhcp_data.Uptime)
|
||||
domoticz.log('Uptime : '..Uptime, domoticz.LOG_INFO)
|
||||
domoticz.devices(UptimeLB).updateText(Uptime) end
|
||||
|
||||
domoticz.log('IP WAN : '..lbAPIData.status.dhcp.dhcp_data.IPAddress, domoticz.LOG_INFO)
|
||||
if IPWAN and domoticz.devices(IPWAN).text ~= lbAPIData.status.dhcp.dhcp_data.IPAddress then
|
||||
domoticz.devices(IPWAN).updateText(lbAPIData.status.dhcp.dhcp_data.IPAddress)
|
||||
end
|
||||
end
|
||||
|
||||
-- Volume de données échangées
|
||||
local lbAPIDataDSL = domoticz.utils.fromJSON(DSLstats)
|
||||
if lbAPIDataDSL.status == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
if TransmitBlocks then domoticz.devices(TransmitBlocks).update(0,lbAPIDataDSL.status.TransmitBlocks) end
|
||||
if ReceiveBlocks then domoticz.devices(ReceiveBlocks).update(0,lbAPIDataDSL.status.ReceiveBlocks) end
|
||||
end
|
||||
|
||||
-- Etat du lien WAN et IPv6
|
||||
local lbAPIDataInternet = domoticz.utils.fromJSON(WAN)
|
||||
if lbAPIDataInternet.status == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
domoticz.log('Internet : '..lbAPIDataInternet.data.LinkState, domoticz.LOG_INFO)
|
||||
if internet then
|
||||
if (lbAPIDataInternet.data.LinkState == 'up' and domoticz.devices(internet).active == false)then
|
||||
domoticz.devices(internet).switchOn()
|
||||
elseif (lbAPIDataInternet.data.LinkState ~= 'up' and domoticz.devices(internet).active)then
|
||||
domoticz.devices(internet).switchOff()
|
||||
end
|
||||
end
|
||||
domoticz.log('IPv6 : '..lbAPIDataInternet.data.IPv6Address, domoticz.LOG_INFO)
|
||||
if IPv6WAN and domoticz.devices(IPv6WAN).text ~= lbAPIDataInternet.data.IPv6Address then
|
||||
domoticz.devices(IPv6WAN).updateText(lbAPIDataInternet.data.IPv6Address)
|
||||
end
|
||||
end
|
||||
|
||||
-- État service VoIP
|
||||
local lbAPIDataVoIP = domoticz.utils.fromJSON(voip)
|
||||
if lbAPIDataVoIP.status == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
domoticz.log('VoIP : '..lbAPIDataVoIP.status[1].trunk_lines[1].status, domoticz.LOG_INFO)
|
||||
if VoIP then
|
||||
if (lbAPIDataVoIP.status[1].trunk_lines[1].status == 'Up' and domoticz.devices(VoIP).active == false)then
|
||||
domoticz.devices(VoIP).switchOn()
|
||||
elseif (lbAPIDataVoIP.status[1].trunk_lines[1].status ~= 'Up' and domoticz.devices(VoIP).active)then
|
||||
domoticz.devices(VoIP).switchOff()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--État service TV
|
||||
local lbAPIDataTV = domoticz.utils.fromJSON(TVstatus)
|
||||
if lbAPIDataTV.data == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
domoticz.log('TV : '..lbAPIDataTV.data.IPTVStatus, domoticz.LOG_INFO)
|
||||
if ServiceTV then
|
||||
if (lbAPIDataTV.data.IPTVStatus == 'Available' and domoticz.devices(ServiceTV).active == false)then
|
||||
domoticz.devices(ServiceTV).switchOn()
|
||||
elseif (lbAPIDataTV.data.IPTVStatus ~= 'Available' and domoticz.devices(ServiceTV).active)then
|
||||
domoticz.devices(ServiceTV).switchOff()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--État WiFi
|
||||
local lbAPIDataWifi = domoticz.utils.fromJSON(wifi)
|
||||
if lbAPIDataWifi.status == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
domoticz.log('Wifi 2.4 Ghz : '..lbAPIDataWifi.status.wlanvap.wl0.VAPStatus, domoticz.LOG_INFO)
|
||||
if wifi24 then
|
||||
if (lbAPIDataWifi.status.wlanvap.wl0.VAPStatus == 'Up' and domoticz.devices(wifi24).active == false)then
|
||||
domoticz.devices(wifi24).switchOn()
|
||||
elseif (lbAPIDataWifi.status.wlanvap.wl0.VAPStatus ~= 'Up' and domoticz.devices(wifi24).active)then
|
||||
domoticz.devices(wifi24).switchOff()
|
||||
end
|
||||
end
|
||||
|
||||
if wifi5 then
|
||||
domoticz.log('Wifi 5 Ghz : '..lbAPIDataWifi.status.wlanvap.eth6.VAPStatus, domoticz.LOG_INFO)
|
||||
if (lbAPIDataWifi.status.wlanvap.eth6.VAPStatus == 'Up' and domoticz.devices(wifi5).active == false)then
|
||||
domoticz.devices(wifi5).update(1,0)
|
||||
elseif (lbAPIDataWifi.status.wlanvap.eth6.VAPStatus ~= 'Up' and domoticz.devices(wifi5).active)then
|
||||
domoticz.devices(wifi5).update(0,0)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
--Dernier Appel reçu ou émis
|
||||
local lbAPIDataCallList = domoticz.utils.fromJSON(callList)
|
||||
if lbAPIDataCallList.status == nil then
|
||||
domoticz.log('Lecture de la MIBs impossible', domoticz.LOG_ERROR)
|
||||
else
|
||||
domoticz.log('CallList : '..#lbAPIDataCallList.status, domoticz.LOG_INFO)
|
||||
if (#lbAPIDataCallList.status>0) then
|
||||
domoticz.log('Dernier Appel : '..lbAPIDataCallList.status[#lbAPIDataCallList.status].remoteNumber, domoticz.LOG_INFO)
|
||||
domoticz.log('Dernier Appel : '..traduction(lbAPIDataCallList.status[#lbAPIDataCallList.status].callType), domoticz.LOG_INFO)
|
||||
NumeroEtat = searchName(contacts, lbAPIDataCallList.status[#lbAPIDataCallList.status].remoteNumber) .. " - "..lbAPIDataCallList.status[#lbAPIDataCallList.status].callType
|
||||
if DernierAppel and domoticz.devices(DernierAppel).text ~= traduction(NumeroEtat) then
|
||||
domoticz.devices(DernierAppel).updateText(traduction(NumeroEtat))
|
||||
end
|
||||
-- x Appels manqués, sans réponse, réussis
|
||||
for i, call in ipairs(ReverseTable(lbAPIDataCallList.status)) do
|
||||
if call.callType == "missed" and nbMissedCall > 0 then
|
||||
domoticz.log(call.remoteNumber .. " " .. traduction(call.callType) .. " " .. format_date(call.startTime), domoticz.LOG_INFO)
|
||||
missedCallList = missedCallList .. searchName(contacts, call.remoteNumber) .. " - " .. format_date(call.startTime) .. "\n"
|
||||
nbMissedCall = nbMissedCall - 1
|
||||
end
|
||||
if call.callType == "failed" and nbFailedCall > 0 then
|
||||
domoticz.log(call.remoteNumber .. " " .. traduction(call.callType) .." ".. format_date(call.startTime), domoticz.LOG_INFO)
|
||||
failedCallList = failedCallList .. searchName(contacts, call.remoteNumber) .." - ".. format_date(call.startTime) .. "\n"
|
||||
nbFailedCall = nbFailedCall - 1
|
||||
end
|
||||
if call.callType == "succeeded" and nbSucceededCall > 0 then
|
||||
domoticz.log(call.remoteNumber .. " " .. traduction(call.callType) .. " " .. format_date(call.startTime), domoticz.LOG_INFO)
|
||||
succeededCallList = succeededCallList .. searchName(contacts, call.remoteNumber) .. " - " .. format_date(call.startTime) .. "\n"
|
||||
nbSucceededCall = nbSucceededCall - 1
|
||||
end
|
||||
end
|
||||
if missedCallList == "" then missedCallList = "Aucun appel à afficher" end
|
||||
domoticz.log('Appels manqués : \n'..missedCallList, domoticz.LOG_INFO)
|
||||
if missedCall and domoticz.devices(missedCall).text ~= traduction(missedCallList) then
|
||||
domoticz.devices(missedCall).updateText(traduction(missedCallList))
|
||||
end
|
||||
if failedCallList == "" then failedCallList = "Aucun appel à afficher" end
|
||||
domoticz.log('Appels sans réponse : \n'..failedCallList, domoticz.LOG_INFO)
|
||||
if failedCall and domoticz.devices(failedCall).text ~= traduction(failedCallList) then
|
||||
domoticz.devices(failedCall).updateText(traduction(failedCallList))
|
||||
end
|
||||
if succeededCallList == "" then succeededCallList = "Aucun appel à afficher" end
|
||||
domoticz.log('Appels réussis : \n'..succeededCallList, domoticz.LOG_INFO)
|
||||
if succeededCall and domoticz.devices(succeededCall).text ~= traduction(succeededCallList) then
|
||||
domoticz.devices(succeededCall).updateText(traduction(succeededCallList))
|
||||
end
|
||||
else
|
||||
NumeroEtat = "Aucun appel à afficher"
|
||||
domoticz.log('Dernier Appel : '..NumeroEtat, domoticz.LOG_INFO)
|
||||
if DernierAppel and domoticz.devices(DernierAppel).text ~= NumeroEtat then
|
||||
domoticz.devices(DernierAppel).updateText(NumeroEtat)
|
||||
end
|
||||
if missedCallList == "" then missedCallList = "Aucun appel à afficher" end
|
||||
domoticz.log('Appels manqués : \n'..missedCallList, domoticz.LOG_INFO)
|
||||
if missedCall and domoticz.devices(missedCall).text ~= traduction(missedCallList) then
|
||||
domoticz.devices(missedCall).updateText(traduction(missedCallList))
|
||||
end
|
||||
if failedCallList == "" then failedCallList = "Aucun appel à afficher" end
|
||||
domoticz.log('Appels sans réponse : \n'..failedCallList, domoticz.LOG_INFO)
|
||||
if failedCall and domoticz.devices(failedCall).text ~= traduction(failedCallList) then
|
||||
domoticz.devices(failedCall).updateText(traduction(failedCallList))
|
||||
end
|
||||
if succeededCallList == "" then succeededCallList = "Aucun appel à afficher" end
|
||||
domoticz.log('Appels réussis : \n'..succeededCallList, domoticz.LOG_INFO)
|
||||
if succeededCall and domoticz.devices(succeededCall).text ~= traduction(succeededCallList) then
|
||||
domoticz.devices(succeededCall).updateText(traduction(succeededCallList))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local json_peripheriques = domoticz.utils.fromJSON(devicesList)
|
||||
etatPeripheriques = false
|
||||
-- Liste des périphériques
|
||||
|
||||
for index, peripherique in pairs(json_peripheriques.status) do
|
||||
domoticz.log("Péripherique " .. index .. " ".. peripherique.Name .." " .. tostring(peripherique.IPAddress) .. " [".. tostring(peripherique.PhysAddress) .."] actif : ".. tostring(peripherique.Active), domoticz.LOG_DEBUG)
|
||||
for i, mac in pairs(devices_livebox_mac_adress) do
|
||||
-- mac = string.lower(mac)
|
||||
if peripherique.PhysAddress == mac then
|
||||
domoticz.log("Statut du périphérique ".. peripherique.Name .." [" .. mac .. "] => actif:" .. tostring(peripherique.Active), domoticz.LOG_INFO)
|
||||
if peripherique.Active == true then
|
||||
etatPeripheriques = true
|
||||
if domoticz.devices(peripherique.Name) then
|
||||
domoticz.devices(peripherique.Name).switchOn().checkFirst()
|
||||
end
|
||||
domoticz.log("Activation de : " .. peripherique.Name, domoticz.LOG_INFO)
|
||||
else
|
||||
if domoticz.devices(peripherique.Name) then
|
||||
domoticz.devices(peripherique.Name).switchOff().checkFirst()
|
||||
end
|
||||
domoticz.log("DésActivation de : " .. peripherique.Name, domoticz.LOG_INFO)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local name = peripherique.Name
|
||||
local active = peripherique.Active
|
||||
--debug("Name : "..name.." "..tostring(active))
|
||||
|
||||
if (name == "Theo") then
|
||||
--commandArray['Theo']='On'
|
||||
testActive(domoticz, 'Theo', active)
|
||||
end
|
||||
if (name == "iPhone-de-Jerome") then
|
||||
--commandArray['moi']='On'
|
||||
testActive(domoticz, "Moi", active)
|
||||
end
|
||||
if (name == "Akhenaton-3") then
|
||||
testActive(domoticz, "Akhenaton", active)
|
||||
end
|
||||
if (name == "Manon") then
|
||||
--commandArray['Manon']='On'
|
||||
testActive(domoticz, "Manon", active)
|
||||
end
|
||||
if (name == "DomiPro") then
|
||||
--commandArray['Manon']='On'
|
||||
testActive(domoticz, "Domi", active)
|
||||
end
|
||||
if (name == "octoprint-1") then
|
||||
testActive(domoticz, "Octoprint", active)
|
||||
end
|
||||
if (name == "orangepizero-1") then
|
||||
testActive(domoticz, "orangepizero", active)
|
||||
end
|
||||
if (name == "TeleChambre"
|
||||
or name == "Volumio" or name == "LibreELEC" or name == "Akhesa"
|
||||
or name == "SoutiHP" or name == "Hackintosh"
|
||||
or name == "Recovery") then
|
||||
testActive(domoticz, name, active)
|
||||
end
|
||||
|
||||
if (name == "RadiateurManon" or name == "RadiateurTheo" or name == "RadiateurBureau"
|
||||
or name == "RadiateurChambre") then
|
||||
if active then
|
||||
-- nothing
|
||||
else
|
||||
-- commandArray['SendNotification']='Alerte radiateur '..name..'#Alerte radiateur ne repond pas au ping '..name
|
||||
end
|
||||
end
|
||||
end
|
||||
else
|
||||
if(item.name == wifi5)then
|
||||
os.execute("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..
|
||||
myContextID.."\" -d \"{\\\"service\\\":\\\"NeMo.Intf.lan\\\",\\\"method\\\":\\\"setWLANConfig\\\",\\\"parameters\\\":{\\\"mibs\\\":{\\\"penable\\\":{\\\"wifi0_quan\\\":{\\\"PersistentEnable\\\":"..
|
||||
tostring(item.active)..", \\\"Enable\\\":true}}}}}\" http://"..adresseLB.."/ws &")
|
||||
domoticz.log("wifi5 "..tostring(item.active),domoticz.LOG_INFO)
|
||||
elseif(item.name == wifi24)then
|
||||
os.execute("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..
|
||||
myContextID.."\" -d \"{\\\"service\\\":\\\"NeMo.Intf.lan\\\",\\\"method\\\":\\\"setWLANConfig\\\",\\\"parameters\\\":{\\\"mibs\\\":{\\\"penable\\\":{\\\"wifi0_bcm\\\":{\\\"PersistentEnable\\\":"..
|
||||
tostring(item.active)..", \\\"Enable\\\":true}}}}}\" http://"..adresseLB.."/ws &")
|
||||
domoticz.log("wifi24 "..tostring(item.active),domoticz.LOG_INFO)
|
||||
elseif(item.name == clearCallList)then
|
||||
os.execute("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..
|
||||
myContextID.."\" -d \"{\\\"service\\\":\\\"VoiceService.VoiceApplication\\\",\\\"method\\\":\\\"clearCallList\\\",\\\"parameters\\\":{}}\" http://"..adresseLB.."/ws &")
|
||||
domoticz.log("clearCallList "..tostring(item.active),domoticz.LOG_INFO)
|
||||
|
||||
elseif(item.name == reboot)then
|
||||
os.execute("curl -s -b \""..myCookies.."\" -X POST -H 'Content-Type: application/x-sah-ws-4-call+json' -H \"X-Context: "..
|
||||
myContextID.."\" -d \"{\\\"parameters\\\":{}}\" http://"..adresseLB.."/sysbus/NMC:reboot &")
|
||||
domoticz.log("reboot "..tostring(item.active),domoticz.LOG_INFO)
|
||||
end
|
||||
end
|
||||
--Déconnexion et suppression des fichiers temporaires
|
||||
os.execute("curl -s -b "..myCookies.." -X POST http://"..adresseLB.."/logout &")
|
||||
-- os.execute('rm "'..myCookies..'" "'..myOutput..'" &')
|
||||
end
|
||||
}
|
||||
|
||||
18
enedis.sh
Executable file
18
enedis.sh
Executable file
@@ -0,0 +1,18 @@
|
||||
#!/bin/bash
|
||||
export PATH=/opt/domoticz/:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
|
||||
|
||||
# Récupérer la date actuelle au format YYYY-MM-DD
|
||||
current_date=$(date +%F)
|
||||
|
||||
# Calculer la date antérieure de 30 jours
|
||||
previous_date=$(date -d "$current_date - 30 days" +%F)
|
||||
previous_date_1=$(date -d "$current_date - 1 days" +%F)
|
||||
|
||||
echo "Date actuelle : $current_date"
|
||||
echo "Date antérieure de 30 jours : $previous_date"
|
||||
|
||||
|
||||
/usr/bin/curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOlsiMTQ4OTg1NTI3OTMzOTciXSwiZXhwIjoxNzk1NTQ3MjgxLCJpYXQiOjE3MDExOTg0ODF9.l1kWoiJLFXsN9YUAaxn7Sy0PvtFiFt5spjF1E_deu_E" -X GET "https://conso.boris.sh/api/daily_consumption?prm=14898552793397&start=$previous_date&end=$current_date" >/opt/domoticz/www/enedis.json
|
||||
|
||||
/usr/bin/curl -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOlsiMTQ4OTg1NTI3OTMzOTciXSwiZXhwIjoxNzk1NTQ3MjgxLCJpYXQiOjE3MDExOTg0ODF9.l1kWoiJLFXsN9YUAaxn7Sy0PvtFiFt5spjF1E_deu_E" -X GET "https://conso.boris.sh/api/consumption_load_curve?prm=14898552793397&start=$previous_date_1&end=$current_date" >/opt/domoticz/www/enedis_curve.json
|
||||
|
||||
77
etcSAVE/init.d/mplayerd
Executable file
77
etcSAVE/init.d/mplayerd
Executable file
@@ -0,0 +1,77 @@
|
||||
# /etc/init.d/mplayerd
|
||||
### BEGIN INIT INFO
|
||||
# Provides: mplayer
|
||||
# Required-Start: $network $syslog
|
||||
# Required-Stop: $network $syslog
|
||||
# Should-Start: $time
|
||||
# Should-Stop: $time
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Start and stop the mplayer daemon
|
||||
# Description: mplayer daemon
|
||||
### END INIT INFO
|
||||
|
||||
CONTROLFILE="/tmp/mplayercontrol"
|
||||
DAEMONUSER=pi
|
||||
|
||||
DAEMON=/usr/bin/mplayer
|
||||
#DAEMON_ARGS="-slave -idle -input file=$CONTROLFILE"
|
||||
DAEMON_ARGS="-slave -idle -ao alsa -playlist http://volumio:8000/mpd.m3u"
|
||||
PIDFILE=/tmp/mplayerd.pid
|
||||
|
||||
start() {
|
||||
echo "Starting mplayer..."
|
||||
|
||||
# Prepare fifo file
|
||||
rm -rf $CONTROLFILE
|
||||
mkfifo $CONTROLFILE
|
||||
chmod a+rw $CONTROLFILE
|
||||
|
||||
start-stop-daemon --start --quiet --user $DAEMONUSER \
|
||||
--make-pidfile --pidfile $PIDFILE --background \
|
||||
--exec /bin/bash -- -c "HOME=/home/$DAEMONUSER $DAEMON $DAEMON_ARGS > /tmp/mplayerd.log 2>&1"
|
||||
|
||||
echo "Started for user: $DAEMONUSER."
|
||||
}
|
||||
|
||||
stop() {
|
||||
echo "Stopping mplayer..."
|
||||
killall mplayer
|
||||
kill -9 `cat $PIDFILE`
|
||||
# Cleanup fifo file
|
||||
rm -rf $CONTROLFILE
|
||||
}
|
||||
|
||||
status() {
|
||||
if [ -z `cat $PIDFILE` ];
|
||||
then
|
||||
echo "mplayerd: not running."
|
||||
else
|
||||
echo "mplayerd: running."
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start
|
||||
;;
|
||||
|
||||
stop)
|
||||
stop
|
||||
;;
|
||||
|
||||
restart|reload|force-reload)
|
||||
stop
|
||||
start
|
||||
;;
|
||||
|
||||
status)
|
||||
status
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/mplayerd {start|stop|reload|force-reload|restart|status}"
|
||||
exit 1
|
||||
|
||||
esac
|
||||
639
etcSAVE/motion/motion.conf
Executable file
639
etcSAVE/motion/motion.conf
Executable file
@@ -0,0 +1,639 @@
|
||||
# Rename this distribution example file to motion.conf
|
||||
#
|
||||
# This config file was generated by motion 3.2.12
|
||||
|
||||
|
||||
############################################################
|
||||
# Daemon
|
||||
############################################################
|
||||
|
||||
# Start in daemon (background) mode and release terminal (default: off)
|
||||
daemon off
|
||||
|
||||
# File to store the process ID, also called pid file. (default: not defined)
|
||||
process_id_file /home/pi/motion/motion.pid
|
||||
|
||||
############################################################
|
||||
# Basic Setup Mode
|
||||
############################################################
|
||||
|
||||
# Start in Setup-Mode, daemon disabled. (default: off)
|
||||
setup_mode off
|
||||
|
||||
###########################################################
|
||||
# Capture device options
|
||||
############################################################
|
||||
|
||||
# Videodevice to be used for capturing (default /dev/video0)
|
||||
# for FreeBSD default is /dev/bktr0
|
||||
videodevice /dev/video0
|
||||
|
||||
# v4l2_palette allows to choose preferable palette to be use by motion
|
||||
# to capture from those supported by your videodevice. (default: 8)
|
||||
# E.g. if your videodevice supports both V4L2_PIX_FMT_SBGGR8 and
|
||||
# V4L2_PIX_FMT_MJPEG then motion will by default use V4L2_PIX_FMT_MJPEG.
|
||||
# Setting v4l2_palette to 1 forces motion to use V4L2_PIX_FMT_SBGGR8
|
||||
# instead.
|
||||
#
|
||||
# Values :
|
||||
# V4L2_PIX_FMT_SN9C10X : 0 'S910'
|
||||
# V4L2_PIX_FMT_SBGGR8 : 1 'BA81'
|
||||
# V4L2_PIX_FMT_MJPEG : 2 'MJPEG'
|
||||
# V4L2_PIX_FMT_JPEG : 3 'JPEG'
|
||||
# V4L2_PIX_FMT_RGB24 : 4 'RGB3'
|
||||
# V4L2_PIX_FMT_UYVY : 5 'UYVY'
|
||||
# V4L2_PIX_FMT_YUYV : 6 'YUYV'
|
||||
# V4L2_PIX_FMT_YUV422P : 7 '422P'
|
||||
# V4L2_PIX_FMT_YUV420 : 8 'YU12'
|
||||
v4l2_palette 8
|
||||
|
||||
# Tuner device to be used for capturing using tuner as source (default /dev/tuner0)
|
||||
# This is ONLY used for FreeBSD. Leave it commented out for Linux
|
||||
; tunerdevice /dev/tuner0
|
||||
|
||||
# The video input to be used (default: 8)
|
||||
# Should normally be set to 0 or 1 for video/TV cards, and 8 for USB cameras
|
||||
input 8
|
||||
|
||||
# The video norm to use (only for video capture and TV tuner cards)
|
||||
# Values: 0 (PAL), 1 (NTSC), 2 (SECAM), 3 (PAL NC no colour). Default: 0 (PAL)
|
||||
norm 0
|
||||
|
||||
# The frequency to set the tuner to (kHz) (only for TV tuner cards) (default: 0)
|
||||
frequency 0
|
||||
|
||||
# Rotate image this number of degrees. The rotation affects all saved images as
|
||||
# well as mpeg movies. Valid values: 0 (default = no rotation), 90, 180 and 270.
|
||||
rotate 0
|
||||
|
||||
# Image width (pixels). Valid range: Camera dependent, default: 352
|
||||
width 640
|
||||
|
||||
# Image height (pixels). Valid range: Camera dependent, default: 288
|
||||
height 480
|
||||
|
||||
# Maximum number of frames to be captured per second.
|
||||
# Valid range: 2-100. Default: 100 (almost no limit).
|
||||
framerate 2
|
||||
|
||||
# Minimum time in seconds between capturing picture frames from the camera.
|
||||
# Default: 0 = disabled - the capture rate is given by the camera framerate.
|
||||
# This option is used when you want to capture images at a rate lower than 2 per second.
|
||||
minimum_frame_time 0
|
||||
|
||||
# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// or file:///)
|
||||
# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined
|
||||
; netcam_url value
|
||||
|
||||
# Username and password for network camera (only if required). Default: not defined
|
||||
# Syntax is user:password
|
||||
; netcam_userpass value
|
||||
|
||||
# The setting for keep-alive of network socket, should improve performance on compatible net cameras.
|
||||
# 1.0: The historical implementation using HTTP/1.0, closing the socket after each http request.
|
||||
# keep_alive: Use HTTP/1.0 requests with keep alive header to reuse the same connection.
|
||||
# 1.1: Use HTTP/1.1 requests that support keep alive as default.
|
||||
# Default: 1.0
|
||||
; netcam_http 1.0
|
||||
|
||||
# URL to use for a netcam proxy server, if required, e.g. "http://myproxy".
|
||||
# If a port number other than 80 is needed, use "http://myproxy:1234".
|
||||
# Default: not defined
|
||||
; netcam_proxy value
|
||||
|
||||
# Set less strict jpeg checks for network cameras with a poor/buggy firmware.
|
||||
# Default: off
|
||||
netcam_tolerant_check off
|
||||
|
||||
# Let motion regulate the brightness of a video device (default: off).
|
||||
# The auto_brightness feature uses the brightness option as its target value.
|
||||
# If brightness is zero auto_brightness will adjust to average brightness value 128.
|
||||
# Only recommended for cameras without auto brightness
|
||||
auto_brightness off
|
||||
|
||||
# Set the initial brightness of a video device.
|
||||
# If auto_brightness is enabled, this value defines the average brightness level
|
||||
# which Motion will try and adjust to.
|
||||
# Valid range 0-255, default 0 = disabled
|
||||
brightness 0
|
||||
|
||||
# Set the contrast of a video device.
|
||||
# Valid range 0-255, default 0 = disabled
|
||||
contrast 0
|
||||
|
||||
# Set the saturation of a video device.
|
||||
# Valid range 0-255, default 0 = disabled
|
||||
saturation 0
|
||||
|
||||
# Set the hue of a video device (NTSC feature).
|
||||
# Valid range 0-255, default 0 = disabled
|
||||
hue 0
|
||||
|
||||
|
||||
############################################################
|
||||
# Round Robin (multiple inputs on same video device name)
|
||||
############################################################
|
||||
|
||||
# Number of frames to capture in each roundrobin step (default: 1)
|
||||
roundrobin_frames 1
|
||||
|
||||
# Number of frames to skip before each roundrobin step (default: 1)
|
||||
roundrobin_skip 1
|
||||
|
||||
# Try to filter out noise generated by roundrobin (default: off)
|
||||
switchfilter off
|
||||
|
||||
|
||||
############################################################
|
||||
# Motion Detection Settings:
|
||||
############################################################
|
||||
|
||||
# Threshold for number of changed pixels in an image that
|
||||
# triggers motion detection (default: 1500)
|
||||
threshold 1500
|
||||
|
||||
# Automatically tune the threshold down if possible (default: off)
|
||||
threshold_tune off
|
||||
|
||||
# Noise threshold for the motion detection (default: 32)
|
||||
noise_level 32
|
||||
|
||||
# Automatically tune the noise threshold (default: on)
|
||||
noise_tune on
|
||||
|
||||
# Despeckle motion image using (e)rode or (d)ilate or (l)abel (Default: not defined)
|
||||
# Recommended value is EedDl. Any combination (and number of) of E, e, d, and D is valid.
|
||||
# (l)abeling must only be used once and the 'l' must be the last letter.
|
||||
# Comment out to disable
|
||||
despeckle EedDl
|
||||
|
||||
# Detect motion in predefined areas (1 - 9). Areas are numbered like that: 1 2 3
|
||||
# A script (on_area_detected) is started immediately when motion is 4 5 6
|
||||
# detected in one of the given areas, but only once during an event. 7 8 9
|
||||
# One or more areas can be specified with this option. (Default: not defined)
|
||||
; area_detect value
|
||||
|
||||
# PGM file to use as a sensitivity mask.
|
||||
# Full path name to. (Default: not defined)
|
||||
; mask_file value
|
||||
|
||||
# Dynamically create a mask file during operation (default: 0)
|
||||
# Adjust speed of mask changes from 0 (off) to 10 (fast)
|
||||
smart_mask_speed 0
|
||||
|
||||
# Ignore sudden massive light intensity changes given as a percentage of the picture
|
||||
# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled
|
||||
lightswitch 0
|
||||
|
||||
# Picture frames must contain motion at least the specified number of frames
|
||||
# in a row before they are detected as true motion. At the default of 1, all
|
||||
# motion is detected. Valid range: 1 to thousands, recommended 1-5
|
||||
minimum_motion_frames 1
|
||||
|
||||
# Specifies the number of pre-captured (buffered) pictures from before motion
|
||||
# was detected that will be output at motion detection.
|
||||
# Recommended range: 0 to 5 (default: 0)
|
||||
# Do not use large values! Large values will cause Motion to skip video frames and
|
||||
# cause unsmooth mpegs. To smooth mpegs use larger values of post_capture instead.
|
||||
pre_capture 0
|
||||
|
||||
# Number of frames to capture after motion is no longer detected (default: 0)
|
||||
post_capture 0
|
||||
|
||||
# Gap is the seconds of no motion detection that triggers the end of an event
|
||||
# An event is defined as a series of motion images taken within a short timeframe.
|
||||
# Recommended value is 60 seconds (Default). The value 0 is allowed and disables
|
||||
# events causing all Motion to be written to one single mpeg file and no pre_capture.
|
||||
gap 60
|
||||
|
||||
# Maximum length in seconds of an mpeg movie
|
||||
# When value is exceeded a new mpeg file is created. (Default: 0 = infinite)
|
||||
max_mpeg_time 0
|
||||
|
||||
# Always save images even if there was no motion (default: off)
|
||||
output_all off
|
||||
|
||||
|
||||
############################################################
|
||||
# Image File Output
|
||||
############################################################
|
||||
|
||||
# Output 'normal' pictures when motion is detected (default: on)
|
||||
# Valid values: on, off, first, best, center
|
||||
# When set to 'first', only the first picture of an event is saved.
|
||||
# Picture with most motion of an event is saved when set to 'best'.
|
||||
# Picture with motion nearest center of picture is saved when set to 'center'.
|
||||
# Can be used as preview shot for the corresponding movie.
|
||||
output_normal off
|
||||
|
||||
# Output pictures with only the pixels moving object (ghost images) (default: off)
|
||||
output_motion off
|
||||
|
||||
# The quality (in percent) to be used by the jpeg compression (default: 75)
|
||||
quality 75
|
||||
|
||||
# Output ppm images instead of jpeg (default: off)
|
||||
ppm off
|
||||
|
||||
|
||||
############################################################
|
||||
# FFMPEG related options
|
||||
# Film (mpeg) file output, and deinterlacing of the video input
|
||||
# The options movie_filename and timelapse_filename are also used
|
||||
# by the ffmpeg feature
|
||||
############################################################
|
||||
|
||||
# Use ffmpeg to encode mpeg movies in realtime (default: off)
|
||||
ffmpeg_cap_new on
|
||||
|
||||
# Use ffmpeg to make movies with only the pixels moving
|
||||
# object (ghost images) (default: off)
|
||||
ffmpeg_cap_motion off
|
||||
|
||||
# Use ffmpeg to encode a timelapse movie
|
||||
# Default value 0 = off - else save frame every Nth second
|
||||
ffmpeg_timelapse 0
|
||||
|
||||
# The file rollover mode of the timelapse video
|
||||
# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual
|
||||
ffmpeg_timelapse_mode daily
|
||||
|
||||
# Bitrate to be used by the ffmpeg encoder (default: 400000)
|
||||
# This option is ignored if ffmpeg_variable_bitrate is not 0 (disabled)
|
||||
ffmpeg_bps 500000
|
||||
|
||||
# Enables and defines variable bitrate for the ffmpeg encoder.
|
||||
# ffmpeg_bps is ignored if variable bitrate is enabled.
|
||||
# Valid values: 0 (default) = fixed bitrate defined by ffmpeg_bps,
|
||||
# or the range 2 - 31 where 2 means best quality and 31 is worst.
|
||||
ffmpeg_variable_bitrate 0
|
||||
|
||||
# Codec to used by ffmpeg for the video compression.
|
||||
# Timelapse mpegs are always made in mpeg1 format independent from this option.
|
||||
# Supported formats are: mpeg1 (ffmpeg-0.4.8 only), mpeg4 (default), and msmpeg4.
|
||||
# mpeg1 - gives you files with extension .mpg
|
||||
# mpeg4 or msmpeg4 - gives you files with extension .avi
|
||||
# msmpeg4 is recommended for use with Windows Media Player because
|
||||
# it requires no installation of codec on the Windows client.
|
||||
# swf - gives you a flash film with extension .swf
|
||||
# flv - gives you a flash video with extension .flv
|
||||
# ffv1 - FF video codec 1 for Lossless Encoding ( experimental )
|
||||
# mov - QuickTime ( testing )
|
||||
ffmpeg_video_codec mpeg4
|
||||
|
||||
# Use ffmpeg to deinterlace video. Necessary if you use an analog camera
|
||||
# and see horizontal combing on moving objects in video or pictures.
|
||||
# (default: off)
|
||||
ffmpeg_deinterlace off
|
||||
|
||||
|
||||
############################################################
|
||||
# Snapshots (Traditional Periodic Webcam File Output)
|
||||
############################################################
|
||||
|
||||
# Make automated snapshot every N seconds (default: 0 = disabled)
|
||||
snapshot_interval 0
|
||||
|
||||
|
||||
############################################################
|
||||
# Text Display
|
||||
# %Y = year, %m = month, %d = date,
|
||||
# %H = hour, %M = minute, %S = second, %T = HH:MM:SS,
|
||||
# %v = event, %q = frame number, %t = thread (camera) number,
|
||||
# %D = changed pixels, %N = noise level, \n = new line,
|
||||
# %i and %J = width and height of motion area,
|
||||
# %K and %L = X and Y coordinates of motion center
|
||||
# %C = value defined by text_event - do not use with text_event!
|
||||
# You can put quotation marks around the text to allow
|
||||
# leading spaces
|
||||
############################################################
|
||||
|
||||
# Locate and draw a box around the moving object.
|
||||
# Valid values: on, off and preview (default: off)
|
||||
# Set to 'preview' will only draw a box in preview_shot pictures.
|
||||
locate off
|
||||
|
||||
# Draws the timestamp using same options as C function strftime(3)
|
||||
# Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
|
||||
# Text is placed in lower right corner
|
||||
text_right %Y-%m-%d\n%T-%q
|
||||
|
||||
# Draw a user defined text on the images using same options as C function strftime(3)
|
||||
# Default: Not defined = no text
|
||||
# Text is placed in lower left corner
|
||||
; text_left CAMERA %t
|
||||
|
||||
# Draw the number of changed pixed on the images (default: off)
|
||||
# Will normally be set to off except when you setup and adjust the motion settings
|
||||
# Text is placed in upper right corner
|
||||
text_changes on
|
||||
|
||||
# This option defines the value of the special event conversion specifier %C
|
||||
# You can use any conversion specifier in this option except %C. Date and time
|
||||
# values are from the timestamp of the first image in the current event.
|
||||
# Default: %Y%m%d%H%M%S
|
||||
# The idea is that %C can be used filenames and text_left/right for creating
|
||||
# a unique identifier for each event.
|
||||
text_event %Y%m%d%H%M%S
|
||||
|
||||
# Draw characters at twice normal size on images. (default: off)
|
||||
text_double on
|
||||
|
||||
|
||||
############################################################
|
||||
# Target Directories and filenames For Images And Films
|
||||
# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename
|
||||
# you can use conversion specifiers
|
||||
# %Y = year, %m = month, %d = date,
|
||||
# %H = hour, %M = minute, %S = second,
|
||||
# %v = event, %q = frame number, %t = thread (camera) number,
|
||||
# %D = changed pixels, %N = noise level,
|
||||
# %i and %J = width and height of motion area,
|
||||
# %K and %L = X and Y coordinates of motion center
|
||||
# %C = value defined by text_event
|
||||
# Quotation marks round string are allowed.
|
||||
############################################################
|
||||
|
||||
# Target base directory for pictures and films
|
||||
# Recommended to use absolute path. (Default: current working directory)
|
||||
target_dir /home/pi/motion/
|
||||
|
||||
# File path for snapshots (jpeg or ppm) relative to target_dir
|
||||
# Default: %v-%Y%m%d%H%M%S-snapshot
|
||||
# Default value is equivalent to legacy oldlayout option
|
||||
# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot
|
||||
# File extension .jpg or .ppm is automatically added so do not include this.
|
||||
# Note: A symbolic link called lastsnap.jpg created in the target_dir will always
|
||||
# point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap'
|
||||
snapshot_filename %v-%Y%m%d%H%M%S-snapshot
|
||||
|
||||
# File path for motion triggered images (jpeg or ppm) relative to target_dir
|
||||
# Default: %v-%Y%m%d%H%M%S-%q
|
||||
# Default value is equivalent to legacy oldlayout option
|
||||
# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q
|
||||
# File extension .jpg or .ppm is automatically added so do not include this
|
||||
# Set to 'preview' together with best-preview feature enables special naming
|
||||
# convention for preview shots. See motion guide for details
|
||||
jpeg_filename %v-%Y%m%d%H%M%S-%q
|
||||
|
||||
# File path for motion triggered ffmpeg films (mpeg) relative to target_dir
|
||||
# Default: %v-%Y%m%d%H%M%S
|
||||
# Default value is equivalent to legacy oldlayout option
|
||||
# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S
|
||||
# File extension .mpg or .avi is automatically added so do not include this
|
||||
# This option was previously called ffmpeg_filename
|
||||
movie_filename %v-%Y%m%d%H%M%S
|
||||
|
||||
# File path for timelapse mpegs relative to target_dir
|
||||
# Default: %Y%m%d-timelapse
|
||||
# Default value is near equivalent to legacy oldlayout option
|
||||
# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse
|
||||
# File extension .mpg is automatically added so do not include this
|
||||
timelapse_filename %Y%m%d-timelapse
|
||||
|
||||
|
||||
############################################################
|
||||
# Live Webcam Server
|
||||
############################################################
|
||||
|
||||
# The mini-http server listens to this port for requests (default: 0 = disabled)
|
||||
webcam_port 8082
|
||||
|
||||
# Quality of the jpeg (in percent) images produced (default: 50)
|
||||
webcam_quality 50
|
||||
|
||||
# Output frames at 1 fps when no motion is detected and increase to the
|
||||
# rate given by webcam_maxrate when motion is detected (default: off)
|
||||
webcam_motion on
|
||||
|
||||
# Maximum framerate for webcam streams (default: 1)
|
||||
webcam_maxrate 5
|
||||
|
||||
# Restrict webcam connections to localhost only (default: on)
|
||||
webcam_localhost off
|
||||
|
||||
# Limits the number of images per connection (default: 0 = unlimited)
|
||||
# Number can be defined by multiplying actual webcam rate by desired number of seconds
|
||||
# Actual webcam rate is the smallest of the numbers framerate and webcam_maxrate
|
||||
webcam_limit 0
|
||||
|
||||
|
||||
############################################################
|
||||
# HTTP Based Control
|
||||
############################################################
|
||||
|
||||
# TCP/IP port for the http server to listen on (default: 0 = disabled)
|
||||
control_port 8080
|
||||
|
||||
# Restrict control connections to localhost only (default: on)
|
||||
control_localhost on
|
||||
|
||||
# Output for http server, select off to choose raw text plain (default: on)
|
||||
control_html_output on
|
||||
|
||||
# Authentication for the http based control. Syntax username:password
|
||||
# Default: not defined (Disabled)
|
||||
; control_authentication username:password
|
||||
|
||||
|
||||
############################################################
|
||||
# Tracking (Pan/Tilt)
|
||||
############################################################
|
||||
|
||||
# Type of tracker (0=none (default), 1=stepper, 2=iomojo, 3=pwc, 4=generic, 5=uvcvideo)
|
||||
# The generic type enables the definition of motion center and motion size to
|
||||
# be used with the conversion specifiers for options like on_motion_detected
|
||||
track_type 0
|
||||
|
||||
# Enable auto tracking (default: off)
|
||||
track_auto off
|
||||
|
||||
# Serial port of motor (default: none)
|
||||
; track_port value
|
||||
|
||||
# Motor number for x-axis (default: 0)
|
||||
track_motorx 0
|
||||
|
||||
# Motor number for y-axis (default: 0)
|
||||
track_motory 0
|
||||
|
||||
# Maximum value on x-axis (default: 0)
|
||||
track_maxx 0
|
||||
|
||||
# Maximum value on y-axis (default: 0)
|
||||
track_maxy 0
|
||||
|
||||
# ID of an iomojo camera if used (default: 0)
|
||||
track_iomojo_id 0
|
||||
|
||||
# Angle in degrees the camera moves per step on the X-axis
|
||||
# with auto-track (default: 10)
|
||||
# Currently only used with pwc type cameras
|
||||
track_step_angle_x 10
|
||||
|
||||
# Angle in degrees the camera moves per step on the Y-axis
|
||||
# with auto-track (default: 10)
|
||||
# Currently only used with pwc type cameras
|
||||
track_step_angle_y 10
|
||||
|
||||
# Delay to wait for after tracking movement as number
|
||||
# of picture frames (default: 10)
|
||||
track_move_wait 10
|
||||
|
||||
# Speed to set the motor to (stepper motor option) (default: 255)
|
||||
track_speed 255
|
||||
|
||||
# Number of steps to make (stepper motor option) (default: 40)
|
||||
track_stepsize 40
|
||||
|
||||
|
||||
############################################################
|
||||
# External Commands, Warnings and Logging:
|
||||
# You can use conversion specifiers for the on_xxxx commands
|
||||
# %Y = year, %m = month, %d = date,
|
||||
# %H = hour, %M = minute, %S = second,
|
||||
# %v = event, %q = frame number, %t = thread (camera) number,
|
||||
# %D = changed pixels, %N = noise level,
|
||||
# %i and %J = width and height of motion area,
|
||||
# %K and %L = X and Y coordinates of motion center
|
||||
# %C = value defined by text_event
|
||||
# %f = filename with full path
|
||||
# %n = number indicating filetype
|
||||
# Both %f and %n are only defined for on_picture_save,
|
||||
# on_movie_start and on_movie_end
|
||||
# Quotation marks round string are allowed.
|
||||
############################################################
|
||||
|
||||
# Do not sound beeps when detecting motion (default: on)
|
||||
# Note: Motion never beeps when running in daemon mode.
|
||||
quiet on
|
||||
|
||||
# Command to be executed when an event starts. (default: none)
|
||||
# An event starts at first motion detected after a period of no motion defined by gap
|
||||
; on_event_start value
|
||||
on_event_start /opt/domoticz/scripts/on_event_start.sh
|
||||
|
||||
# Command to be executed when an event ends after a period of no motion
|
||||
# (default: none). The period of no motion is defined by option gap.
|
||||
; on_event_end value
|
||||
on_event_end /opt/domoticz/scripts/on_event_end.sh
|
||||
|
||||
# Command to be executed when a picture (.ppm|.jpg) is saved (default: none)
|
||||
# To give the filename as an argument to a command append it with %f
|
||||
; on_picture_save value
|
||||
|
||||
# Command to be executed when a motion frame is detected (default: none)
|
||||
on_motion_detected /opt/domoticz/scripts/on_motion_detected.sh
|
||||
|
||||
# Command to be executed when motion in a predefined area is detected
|
||||
# Check option 'area_detect'. (default: none)
|
||||
; on_area_detected value
|
||||
|
||||
# Command to be executed when a movie file (.mpg|.avi) is created. (default: none)
|
||||
# To give the filename as an argument to a command append it with %f
|
||||
; on_movie_start value
|
||||
|
||||
# Command to be executed when a movie file (.mpg|.avi) is closed. (default: none)
|
||||
# To give the filename as an argument to a command append it with %f
|
||||
; on_movie_end value
|
||||
|
||||
# Command to be executed when a camera can't be opened or if it is lost
|
||||
# NOTE: There is situations when motion doesn't detect a lost camera!
|
||||
# It depends on the driver, some drivers don't detect a lost camera at all
|
||||
# Some hang the motion thread. Some even hang the PC! (default: none)
|
||||
; on_camera_lost value
|
||||
|
||||
############################################################
|
||||
# Common Options For MySQL and PostgreSQL database features.
|
||||
# Options require the MySQL/PostgreSQL options to be active also.
|
||||
############################################################
|
||||
|
||||
# Log to the database when creating motion triggered image file (default: on)
|
||||
sql_log_image on
|
||||
|
||||
# Log to the database when creating a snapshot image file (default: on)
|
||||
sql_log_snapshot on
|
||||
|
||||
# Log to the database when creating motion triggered mpeg file (default: off)
|
||||
sql_log_mpeg off
|
||||
|
||||
# Log to the database when creating timelapse mpeg file (default: off)
|
||||
sql_log_timelapse off
|
||||
|
||||
# SQL query string that is sent to the database
|
||||
# Use same conversion specifiers has for text features
|
||||
# Additional special conversion specifiers are
|
||||
# %n = the number representing the file_type
|
||||
# %f = filename with full path
|
||||
# Default value:
|
||||
# insert into security(camera, filename, frame, file_type, time_stamp, text_event) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
|
||||
sql_query insert into security(camera, filename, frame, file_type, time_stamp, event_time_stamp) values('%t', '%f', '%q', '%n', '%Y-%m-%d %T', '%C')
|
||||
|
||||
|
||||
############################################################
|
||||
# Database Options For MySQL
|
||||
############################################################
|
||||
|
||||
# Mysql database to log to (default: not defined)
|
||||
; mysql_db value
|
||||
|
||||
# The host on which the database is located (default: localhost)
|
||||
; mysql_host value
|
||||
|
||||
# User account name for MySQL database (default: not defined)
|
||||
; mysql_user value
|
||||
|
||||
# User password for MySQL database (default: not defined)
|
||||
; mysql_password value
|
||||
|
||||
|
||||
############################################################
|
||||
# Database Options For PostgreSQL
|
||||
############################################################
|
||||
|
||||
# PostgreSQL database to log to (default: not defined)
|
||||
; pgsql_db value
|
||||
|
||||
# The host on which the database is located (default: localhost)
|
||||
; pgsql_host value
|
||||
|
||||
# User account name for PostgreSQL database (default: not defined)
|
||||
; pgsql_user value
|
||||
|
||||
# User password for PostgreSQL database (default: not defined)
|
||||
; pgsql_password value
|
||||
|
||||
# Port on which the PostgreSQL database is located (default: 5432)
|
||||
; pgsql_port 5432
|
||||
|
||||
|
||||
############################################################
|
||||
# Video Loopback Device (vloopback project)
|
||||
############################################################
|
||||
|
||||
# Output images to a video4linux loopback device
|
||||
# The value '-' means next available (default: not defined)
|
||||
; video_pipe value
|
||||
|
||||
# Output motion images to a video4linux loopback device
|
||||
# The value '-' means next available (default: not defined)
|
||||
; motion_video_pipe value
|
||||
|
||||
|
||||
##############################################################
|
||||
# Thread config files - One for each camera.
|
||||
# Except if only one camera - You only need this config file.
|
||||
# If you have more than one camera you MUST define one thread
|
||||
# config file for each camera in addition to this config file.
|
||||
##############################################################
|
||||
|
||||
# Remember: If you have more than one camera you must have one
|
||||
# thread file for each camera. E.g. 2 cameras requires 3 files:
|
||||
# This motion.conf file AND thread1.conf and thread2.conf.
|
||||
# Only put the options that are unique to each camera in the
|
||||
# thread config files.
|
||||
; thread /usr/local/etc/thread1.conf
|
||||
; thread /usr/local/etc/thread2.conf
|
||||
; thread /usr/local/etc/thread3.conf
|
||||
; thread /usr/local/etc/thread4.conf
|
||||
|
||||
1566
forecast.py
Normal file
1566
forecast.py
Normal file
File diff suppressed because it is too large
Load Diff
4
fumeeOff.sh
Executable file
4
fumeeOff.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
|
||||
4
fumeeOn.sh
Executable file
4
fumeeOn.sh
Executable file
@@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
|
||||
|
||||
56
getgooglecal.py
Normal file
56
getgooglecal.py
Normal file
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# ce programme interroge l agenda google et renvoie les taches du jour
|
||||
# dans un fichier texte
|
||||
|
||||
|
||||
import time
|
||||
import os
|
||||
|
||||
|
||||
############# Parametres #################################
|
||||
# on utilise gcalcli qui doit etre installe
|
||||
|
||||
|
||||
# Nom du calendrier google qui contient les actions Domoticz
|
||||
domoticz_cal="Domoticz"
|
||||
|
||||
#options de la ligne de commande cf doc google
|
||||
options="--tsv --military"
|
||||
agenda_start="00:00"
|
||||
agenda_end="23:59"
|
||||
|
||||
# fichier et chemin pour agenda
|
||||
rep="/var/tmp/"
|
||||
file="googlecal.txt"
|
||||
|
||||
|
||||
#debug = 1 on affiche les chaines de caracteres recues
|
||||
debug=1
|
||||
|
||||
|
||||
|
||||
# fin du parametrage #
|
||||
|
||||
|
||||
############### fin des parametres #############################
|
||||
|
||||
|
||||
datej=time.strftime('%Y%m%d',time.localtime())
|
||||
#gcalcli --cal=Domoticz agenda '20141230T00:00' '20141230T23:59" --tsv --military
|
||||
lignecde="gcalcli --cal="+domoticz_cal+" agenda "+"'"+datej+"T"+agenda_start+"' '"+datej+"T"+agenda_end+"' "+options
|
||||
lignecde=lignecde+" > "+rep+file
|
||||
|
||||
if debug!=0:
|
||||
print datej
|
||||
print lignecde
|
||||
|
||||
os.system(lignecde)
|
||||
|
||||
|
||||
if debug!=0:
|
||||
print datej
|
||||
print lignecde
|
||||
os.system ('cat /var/tmp/googlecal.txt')
|
||||
|
||||
5
grafana.sh
Normal file
5
grafana.sh
Normal file
@@ -0,0 +1,5 @@
|
||||
apt-get install -y adduser libfontconfig1 musl
|
||||
wget https://dl.grafana.com/enterprise/release/grafana-enterprise_10.2.3_amd64.deb
|
||||
dpkg -i grafana-enterprise_10.2.3_amd64.deb
|
||||
grafana-cli plugins install frser-sqlite-datasource
|
||||
|
||||
34
hum.sh
Executable file
34
hum.sh
Executable file
@@ -0,0 +1,34 @@
|
||||
#!/bin/bash
|
||||
i=0
|
||||
|
||||
cd /opt/domoticz/scripts/
|
||||
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/games:/usr/games:/usr/local/lib/
|
||||
while ["$temp" -eq ""]
|
||||
do
|
||||
rm /tmp/digiterm.tmp
|
||||
/opt/domoticz/scripts/digiterm --raw --no-info >/tmp/digiterm.tmp 2>>/var/log/syslog
|
||||
|
||||
temp=`cat /tmp/digiterm.tmp |awk -F "," '{ print $2 }'|awk -F "@" '{print $1}'`
|
||||
hum=`cat /tmp/digiterm.tmp |awk -F "," '{ print $1 }'|awk -F "#" '{print $2}'`
|
||||
|
||||
echo "HUM " $temp "--" $hum >>/var/log/syslog
|
||||
|
||||
if [ -z "$temp" -a -z "$hum" ];
|
||||
then
|
||||
echo "Error: Value variable empty"
|
||||
else
|
||||
echo "HUM " $temp "--" $hum
|
||||
json="http://localhost:81/json.htm?type=command¶m=udevice&idx=68&svalue=$temp;$hum;0"
|
||||
echo "HUM " $json >>/var/log/syslog
|
||||
curl -s -i -H "Accept: application/json" $json >/dev/null 2>>/var/log/syslog
|
||||
exit 0
|
||||
fi
|
||||
sleep 1
|
||||
i+=1
|
||||
if [[ "$i" -ge 3 ]];
|
||||
then
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
|
||||
exit 0
|
||||
11
hum2.sh
Executable file
11
hum2.sh
Executable file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
i=0
|
||||
|
||||
while [ 1 ]
|
||||
do
|
||||
/opt/domoticz/scripts/hum.sh
|
||||
sleep 60
|
||||
|
||||
done
|
||||
|
||||
exit 0
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user