[Tuto] Consomation d'eau ajout simple dans DomoticZ
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Bonjour,
effectivement tu as l'air de récupérer correctement les infos !
c'est normal de ne rien avoir sur le graphique JOUR par ontre le graphique Semaine devrais afficher des données...
Que contient le fichier sql ?
Tu peux poster les lignes qui sont affichées lorsque tu lances ./updateConsoEau.sh ?
A+.
effectivement tu as l'air de récupérer correctement les infos !
c'est normal de ne rien avoir sur le graphique JOUR par ontre le graphique Semaine devrais afficher des données...
Que contient le fichier sql ?
Tu peux poster les lignes qui sont affichées lorsque tu lances ./updateConsoEau.sh ?
A+.
Raspberry B+ & PI2 / Domoticz / RFXtrx433E / multiple homemade devices
My blog/tutos for domoticz / electronics stuff : domotique.web2diz.net
My blog/tutos for domoticz / electronics stuff : domotique.web2diz.net
-
katalimero
- Messages : 7
- Inscription : 31 janv. 2016, 01:18
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Salut, merci de t'intéresser à mon problème!
Contenu du dernier fichier sql:
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-01'; INSERT INTO `Meter_Calendar` VALUES ('257', '49.2', '279.871', '2016-09-01' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-02'; INSERT INTO `Meter_Calendar` VALUES ('257', '59.9', '280.47', '2016-09-02' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-03'; INSERT INTO `Meter_Calendar` VALUES ('257', '58.1', '281.051', '2016-09-03' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-04'; INSERT INTO `Meter_Calendar` VALUES ('257', '54.9', '281.6', '2016-09-04' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-05'; INSERT INTO `Meter_Calendar` VALUES ('257', '44.9', '282.049', '2016-09-05' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-06'; INSERT INTO `Meter_Calendar` VALUES ('257', '50.2', '282.552', '2016-09-06' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-07'; INSERT INTO `Meter_Calendar` VALUES ('257', '70.5', '283.257', '2016-09-07' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-08'; INSERT INTO `Meter_Calendar` VALUES ('257', '32', '283.577', '2016-09-08' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-09'; INSERT INTO `Meter_Calendar` VALUES ('257', '58.5', '284.162', '2016-09-09' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-10'; INSERT INTO `Meter_Calendar` VALUES ('257', '60.5', '284.766', '2016-09-10' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-11'; INSERT INTO `Meter_Calendar` VALUES ('257', '202.1', '286.787', '2016-09-11' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-12'; INSERT INTO `Meter_Calendar` VALUES ('257', '43.8', '287.225', '2016-09-12' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-13'; INSERT INTO `Meter_Calendar` VALUES ('257', '54.6', '287.771', '2016-09-13' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-14'; INSERT INTO `Meter_Calendar` VALUES ('257', '57.8', '288.35', '2016-09-14' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-15'; INSERT INTO `Meter_Calendar` VALUES ('257', '34.1', '288.69', '2016-09-15' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-16'; INSERT INTO `Meter_Calendar` VALUES ('257', '43.2', '289.122', '2016-09-16' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-17'; INSERT INTO `Meter_Calendar` VALUES ('257', '42.7', '289.549', '2016-09-17' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-18'; INSERT INTO `Meter_Calendar` VALUES ('257', '69.1', '290.24', '2016-09-18' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-19'; INSERT INTO `Meter_Calendar` VALUES ('257', '29', '290.53', '2016-09-19' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-20'; INSERT INTO `Meter_Calendar` VALUES ('257', '31.9', '290.849', '2016-09-20' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-21'; INSERT INTO `Meter_Calendar` VALUES ('257', '70.2', '291.55', '2016-09-21' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-22'; INSERT INTO `Meter_Calendar` VALUES ('257', '41.2', '291.962', '2016-09-22' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-23'; INSERT INTO `Meter_Calendar` VALUES ('257', '36.4', '292.326', '2016-09-23' );
Résultat du lancement de ./updateConsoEau.sh :
pi@raspberrypi ~/EAU $ ./updateConsoEau.sh
Using Configuration from file /home/pi/EAU/setup_perso
- PART 1 Get the data from website for 2016-09
/home/pi/EAU/2016-09.dat generated
- PART 2 Update .dat file
/home/pi/EAU/2016-09.dat Updated
- PART 3 Generate SQL
update DeviceStatus set lastupdate = '2016-09-23 14:47:24' where id = 257;
- PART 4 Update the db
File size is zero -> DB update NOT needed
### END ###
Merci
Kata
Contenu du dernier fichier sql:
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-01'; INSERT INTO `Meter_Calendar` VALUES ('257', '49.2', '279.871', '2016-09-01' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-02'; INSERT INTO `Meter_Calendar` VALUES ('257', '59.9', '280.47', '2016-09-02' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-03'; INSERT INTO `Meter_Calendar` VALUES ('257', '58.1', '281.051', '2016-09-03' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-04'; INSERT INTO `Meter_Calendar` VALUES ('257', '54.9', '281.6', '2016-09-04' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-05'; INSERT INTO `Meter_Calendar` VALUES ('257', '44.9', '282.049', '2016-09-05' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-06'; INSERT INTO `Meter_Calendar` VALUES ('257', '50.2', '282.552', '2016-09-06' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-07'; INSERT INTO `Meter_Calendar` VALUES ('257', '70.5', '283.257', '2016-09-07' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-08'; INSERT INTO `Meter_Calendar` VALUES ('257', '32', '283.577', '2016-09-08' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-09'; INSERT INTO `Meter_Calendar` VALUES ('257', '58.5', '284.162', '2016-09-09' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-10'; INSERT INTO `Meter_Calendar` VALUES ('257', '60.5', '284.766', '2016-09-10' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-11'; INSERT INTO `Meter_Calendar` VALUES ('257', '202.1', '286.787', '2016-09-11' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-12'; INSERT INTO `Meter_Calendar` VALUES ('257', '43.8', '287.225', '2016-09-12' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-13'; INSERT INTO `Meter_Calendar` VALUES ('257', '54.6', '287.771', '2016-09-13' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-14'; INSERT INTO `Meter_Calendar` VALUES ('257', '57.8', '288.35', '2016-09-14' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-15'; INSERT INTO `Meter_Calendar` VALUES ('257', '34.1', '288.69', '2016-09-15' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-16'; INSERT INTO `Meter_Calendar` VALUES ('257', '43.2', '289.122', '2016-09-16' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-17'; INSERT INTO `Meter_Calendar` VALUES ('257', '42.7', '289.549', '2016-09-17' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-18'; INSERT INTO `Meter_Calendar` VALUES ('257', '69.1', '290.24', '2016-09-18' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-19'; INSERT INTO `Meter_Calendar` VALUES ('257', '29', '290.53', '2016-09-19' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-20'; INSERT INTO `Meter_Calendar` VALUES ('257', '31.9', '290.849', '2016-09-20' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-21'; INSERT INTO `Meter_Calendar` VALUES ('257', '70.2', '291.55', '2016-09-21' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-22'; INSERT INTO `Meter_Calendar` VALUES ('257', '41.2', '291.962', '2016-09-22' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=257 and date = '2016-09-23'; INSERT INTO `Meter_Calendar` VALUES ('257', '36.4', '292.326', '2016-09-23' );
Résultat du lancement de ./updateConsoEau.sh :
pi@raspberrypi ~/EAU $ ./updateConsoEau.sh
Using Configuration from file /home/pi/EAU/setup_perso
- PART 1 Get the data from website for 2016-09
/home/pi/EAU/2016-09.dat generated
- PART 2 Update .dat file
/home/pi/EAU/2016-09.dat Updated
- PART 3 Generate SQL
update DeviceStatus set lastupdate = '2016-09-23 14:47:24' where id = 257;
- PART 4 Update the db
File size is zero -> DB update NOT needed
### END ###
Merci
Kata
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Salut Kata.
As tu resolu ton probleme?
Je suis au SIEVA aussi et tout fonctionne!
On est donc voisins! De quelle commune est-tu? (MP si tu preferes)
Envoies moi tes scripts (en cachant tes infos perso bien sur) et je testerai!
Patrick
As tu resolu ton probleme?
Je suis au SIEVA aussi et tout fonctionne!
On est donc voisins! De quelle commune est-tu? (MP si tu preferes)
Envoies moi tes scripts (en cachant tes infos perso bien sur) et je testerai!
Patrick
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.4
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.4
-
katalimero
- Messages : 7
- Inscription : 31 janv. 2016, 01:18
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Salut,
je suis sur Conzy (Chatillon) et toi?
Problème non réglé, mais le site www.eau-en-ligne.com/?marque=SIEV semble HS pour le moment. Du coup je suis en standby....
++
kata
je suis sur Conzy (Chatillon) et toi?
Problème non réglé, mais le site www.eau-en-ligne.com/?marque=SIEV semble HS pour le moment. Du coup je suis en standby....
++
kata
-
KingOfNuls
- Messages : 4
- Inscription : 30 sept. 2015, 08:21
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Bonjour à tous,
Juste pour dire un grand merci à sirus pour son script, simplement parfait. Je suis quant à moi client de la SEE (société des eaux de l'essonne), et cela fonctionne parfaitement (sauf que je n'ai pas de données disponibles depuis Mars).
J'ai mis à jour mes données en utilisant la possibilité du script de récupérer le mois que l'on voulait. J'ai ainsi l'historique de Mars 2015 à Mars 2016 dans domoticz.
J'ai très légèrement retouché le script. filetmp est transformé en variable. Indentation du while pour améliorer la lisibilité. Ajout de la SEE parmis les providers. Le script tourne depuis le compte pi sans besoin dêtre root.
Ci-dessous un diff entre ma version et celle clonée sur github.
Sur un PI3, raspbian jessie, domoticz V3.5623.
Encore bravo à sirus qui a su rendre simple un projet compliqué (en tout cas pour moi).

Kingofnuls
Juste pour dire un grand merci à sirus pour son script, simplement parfait. Je suis quant à moi client de la SEE (société des eaux de l'essonne), et cela fonctionne parfaitement (sauf que je n'ai pas de données disponibles depuis Mars).
J'ai mis à jour mes données en utilisant la possibilité du script de récupérer le mois que l'on voulait. J'ai ainsi l'historique de Mars 2015 à Mars 2016 dans domoticz.
Code : Tout sélectionner
~/EAU$ ./updateConsoEau.sh 2016 01Ci-dessous un diff entre ma version et celle clonée sur github.
Code : Tout sélectionner
pi@SD-RPI-32-Dmtcz:~/EAU$ diff ./updateConsoEau.sh ./domoticz/updateConsoEau.sh
36d35
< filetmp=$workingDIR/filetmp
58c57
< echo "SDEI | SOGEST | SENART | SEE | SIEVA"
---
> echo "SDEI | SOGEST | SENART | SIEVA"
81d79
<
91,93d88
< elif [[ $PROVIDER == 'SEE' ]]
< then
< website="www.eauxdelessonne.com"
127,128c122,123
< sed -e 's/\\//g' -e 's/\],\[/\n/g' -e 's/\[\[/\n/g' -e 's/\]\]/\n/g' $export_file > $filetmp
< sed -e 's/\"//g' $filetmp |grep -v ",0,0" |grep -e '^$' -v |grep -v ERR > $export_file
---
> sed -e 's/\\//g' -e 's/\],\[/\n/g' -e 's/\[\[/\n/g' -e 's/\]\]/\n/g' $export_file > filetmp
> sed -e 's/\"//g' filetmp |grep -v ",0,0" |grep -e '^$' -v |grep -v ERR > $export_file
130c125
< rm $filetmp
---
> rm filetmp
146c141
< #### DATE ####
---
> #### DATE ####
148,150c143,145
< dd=`echo $date |awk -F/ '{print $1}'`
< mm=`echo $date |awk -F/ '{print $2}'`
< yy=`echo $date |awk -F/ '{print $3}'`
---
> dd=`echo $date |awk -F/ '{print $1}'`
> mm=`echo $date |awk -F/ '{print $2}'`
> yy=`echo $date |awk -F/ '{print $3}'`
152,153c147,148
< hh=`date +%H:%M:%S`
< #### VAL1 ####
---
> hh=`date +%H:%M:%S`
> #### VAL1 ####
156c151
< val1=$(( $val * 100))
---
> val1=$(( $val * 100))
158,161c153,156
< if [[ $val -eq 0 ]] && [[ ! -z "$prevVal2" ]];
< then
< float val1=$((100 * ($val2-$prevVal2)))
< fi
---
> if [[ $val -eq 0 ]] && [[ ! -z "$prevVal2" ]];
> then
> float val1=$((100 * ($val2-$prevVal2)))
> fi
163c158
< prevVal2=$val2
---
> prevVal2=$val2
165c160
< ### Generation ###
---
> ### Generation ###
167c162
< echo "DELETE FROM \`Meter_Calendar\` WHERE devicerowid=$devicerowid and date = '$yy-$mm-$dd'; INSERT INTO \`Meter_Calendar\` VALUES ('$devicerowid'," \'$val1\', \'$val2\', \'$yy-$mm-$dd\' ");" >> $sqltmpfile
---
> echo "DELETE FROM \`Meter_Calendar\` WHERE devicerowid=$devicerowid and date = '$yy-$mm-$dd'; INSERT INTO \`Meter_Calendar\` VALUES ('$devicerowid'," \'$val1\', \'$val2\', \'$yy-$mm-$dd\' ");" >> $sqltmpfile
pi@SD-RPI-32-Dmtcz:~/EAU$
Encore bravo à sirus qui a su rendre simple un projet compliqué (en tout cas pour moi).
Kingofnuls
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Pour Kata: On est voisins !! je t'envoie un MP
Sinon, je viens de tester le site de SIEVA fonctionne bien et toutes mes données sont remontées dans domoticz.
Patrick
Sinon, je viens de tester le site de SIEVA fonctionne bien et toutes mes données sont remontées dans domoticz.
Patrick
PRETTY_NAME="Debian GNU/Linux 13 (trixie)"
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.4
NAME="Debian GNU/Linux"
VERSION_ID="13"
VERSION="13 (trixie)"
VERSION_CODENAME=trixie
DEBIAN_VERSION_FULL=13.4
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Salut,
KingOfNuls si tu peux coller ton code complet je pourrais adapter le mien...
Pour les données non dispo depuis mars, les données son disponibles sur le site? Si non c'est peux etre ton compteur n'emet plus... et tu peux le signaler à ton fournisseur.
pchatill. Cool!!
Merci à tous pour vos retour!!
KingOfNuls si tu peux coller ton code complet je pourrais adapter le mien...
Pour les données non dispo depuis mars, les données son disponibles sur le site? Si non c'est peux etre ton compteur n'emet plus... et tu peux le signaler à ton fournisseur.
pchatill. Cool!!
Merci à tous pour vos retour!!
Raspberry B+ & PI2 / Domoticz / RFXtrx433E / multiple homemade devices
My blog/tutos for domoticz / electronics stuff : domotique.web2diz.net
My blog/tutos for domoticz / electronics stuff : domotique.web2diz.net
-
KingOfNuls
- Messages : 4
- Inscription : 30 sept. 2015, 08:21
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Non non, les données depuis fin mars ne sont pas dispo sur le site. Le script n'est pas en cause. Peut-être mon compteur mais il y a quand même une facture par trimestre avec l'index...
Comme dit, il n'y a que très peu de changements à ton script.
Comme dit, il n'y a que très peu de changements à ton script.
Code : Tout sélectionner
#!/usr/bin/ksh
#######################################################################################
# This script will get the data from SDEI/SOGEST website and insert into domoticz.db
# Site : http://domotique.web2diz.net/
# Detail : http://domotique.web2diz.net/?p=131
# List of working provider : http://domotique.web2diz.net/?p=320
# Source : https://github.com/Sirus10/domoticz/blob/master/updateConsoEau.sh
# License : CC BY-SA 4.0
#
# Usage:
# ./updateConsoEau.sh [year] [month]
#
#######################################################################################
#
# PART 0 Common variables and Conf file
#
#######################################################################################
# Temp set global C local
LC_ALL=C
# Date setup (if not set = today)
if [ "$1" != '' ] && [ "$2" != '' ] && [[ "$1" == +([0-9]) ]] && [[ "$2" == +([0-9]) ]]
then
dateY=$1
dateM=$2
else
dateY=`date "+%Y"`
dateM=`date "+%m"`
fi
# SQL Files setup for temporary and final file
workingDIR=/home/pi/EAU
sqlfinalfile=$workingDIR/only_new_generated.$dateY-$dateM.sql
sqlpreviousfile=$workingDIR/previous.generated.$dateY-$dateM.sql
sqltmpfile=$workingDIR/temps.generated.$dateY-$dateM.sql
# Database file setup
dbfile=/home/pi/domoticz/domoticz.db
# Export file :
export_file=$workingDIR/$dateY-$dateM.dat
filetmp=$workingDIR/filetmp
# Configuration file check, it will create new one is not exist
if [ -s $workingDIR/setup_perso ]
then
echo -e "\n Using Configuration from file $workingDIR/setup_perso"
. $workingDIR/setup_perso
else
echo "#######################################"
echo " NEED FOR CONFIG FILE CREATION : "
echo "#######################################"
echo "Personnal code counter number ( see http://domotique.web2diz.net/?p=137) "
read CODE
echo "Email adress : "
read EMAIL
echo "Password : "
read PASSWD
echo "Provider (copy/paste) : "
echo "SDEI | SOGEST | SENART | SEE | SIEVA"
read PROVIDER
echo "Your virtual device ID in domoticz (see step2 here http://domotique.web2diz.net/?p=138 ) "
read devicerowid
echo "SDEI_CODE=$CODE
SDEI_EMAIL=$EMAIL
SDEI_PASSWD=$PASSWD
PROVIDER=$PROVIDER
devicerowid=$devicerowid" > $workingDIR/setup_perso
echo "#######################################"
echo " CONFIG FILE setup_perso CREATED WITH : "
echo "#######################################"
cat $workingDIR/setup_perso
echo "#######################################"
. $workingDIR/setup_perso
fi
#######################################
#
# PART 1 get the data
#
######################################
echo -e "\n - PART 1 Get the data from website for $dateY-$dateM"
if [[ $PROVIDER == 'SDEI' ]]
then
website="www.lyonnaise-des-eaux.fr"
elif [[ $PROVIDER == 'SOGEST' ]]
then
website="www.sogest.info"
elif [[ $PROVIDER == 'SENART' ]]
then
website="www.eauxdesenart.com"
elif [[ $PROVIDER == 'SEE' ]]
then
website="www.eauxdelessonne.com"
elif [[ $PROVIDER == 'OLIVET' ]]
then
website="www.eau-olivet.fr"
elif [[ $PROVIDER == 'SIEVA' ]]
then
website="www.eau-en-ligne.com"
loginpage="https://$website/security/signin"
datapage="https://$website/ma-consommation/DetailConsoChart?year=$dateY&month=$dateM"
fi
# Special pages for eau-en-ligne.com
if [[ ! -n $loginpage ]]
then
loginpage="https://$website/mon-compte-en-ligne/connexion/validation"
datapage="https://$website/mon-compte-en-ligne/statJData/$dateY/$dateM/$SDEI_CODE"
fi
# This first cmd will allow to connect to the site and get the cookiefile
curl -s $loginpage -c $workingDIR/cookiefile -d "input_mail=$SDEI_EMAIL&input_password=$SDEI_PASSWD&signin[username]=$SDEI_EMAIL&signin[password]=$SDEI_PASSWD&" > /dev/null
# This second cmd will download the data
curl -s $datapage -b $workingDIR/cookiefile > $export_file
echo -e "\n $export_file generated "
# Remove cookiefiles
rm $workingDIR/cookiefile
#######################################
#
# PART 2 set the file to be usable
#
######################################
echo -e "\n - PART 2 Update .dat file "
sed -e 's/\\//g' -e 's/\],\[/\n/g' -e 's/\[\[/\n/g' -e 's/\]\]/\n/g' $export_file > $filetmp
sed -e 's/\"//g' $filetmp |grep -v ",0,0" |grep -e '^$' -v |grep -v ERR > $export_file
rm $filetmp
echo -e "\n $export_file Updated "
#######################################
#
# PART 3 Generate SQL
#
######################################
echo -e "\n - PART 3 Generate SQL"
# create the previous file is does not exits
if [ ! -f "$sqlpreviousfile" ] ; then touch $sqlpreviousfile ; fi
IFS=,
while read date val val2 ; do
#### DATE ####
dd=`echo $date |awk -F/ '{print $1}'`
mm=`echo $date |awk -F/ '{print $2}'`
yy=`echo $date |awk -F/ '{print $3}'`
hh=`date +%H:%M:%S`
#### VAL1 ####
val1=$(( $val * 100))
if [[ $val -eq 0 ]] && [[ ! -z "$prevVal2" ]];
then
float val1=$((100 * ($val2-$prevVal2)))
fi
prevVal2=$val2
### Generation ###
echo "DELETE FROM \`Meter_Calendar\` WHERE devicerowid=$devicerowid and date = '$yy-$mm-$dd'; INSERT INTO \`Meter_Calendar\` VALUES ('$devicerowid'," \'$val1\', \'$val2\', \'$yy-$mm-$dd\' ");" >> $sqltmpfile
done < $export_file
# GENERATE SQL FOR UPDATE DEVICE STATUS
DEVICESTATUS1="update DeviceStatus set lastupdate = '$yy-$mm-$dd $hh' where id = $devicerowid;"
### prepare and compare fromm previous run ####
comm -3 $sqltmpfile $sqlpreviousfile > $sqlfinalfile
cat $sqlfinalfile
echo $DEVICESTATUS1
mv $sqltmpfile $sqlpreviousfile
#######################################
#
# PART 4 Update the db
#
######################################
#exit
echo -e "\n - PART 4 Update the db "
if [ -s $sqlfinalfile ]
then
echo -e "\nFile size is NOT zero -> DB update needed"
echo " Stoping Domoticz ! "
sudo /etc/init.d/domoticz.sh stop
echo " Domoticz stopped"
echo Update DB START
echo Update Values
sudo cat $sqlfinalfile |sqlite3 $dbfile
echo Update Status
sudo echo $DEVICESTATUS1 |sqlite3 $dbfile
echo Update DB END
echo " Starting Domoticz !"
sudo /etc/init.d/domoticz.sh start
echo " Domoticz started "
else
echo -e "\nFile size is zero -> DB update NOT needed"
fi
echo -e "\n ### END ###\n"
-
katalimero
- Messages : 7
- Inscription : 31 janv. 2016, 01:18
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Bonsoir, le site SIEVA refonctionne pour moi, du coup j'ai creusé un peu mon problème et il semble y avoir une inversion dans ma base de donnée:
Une idée??
Merci
Une idée??
Merci
Re: [TUTO] Consomation d'eau ajout simple dans domoticz
Tu as fait une mise a jour de domoticz entre les deux dernier et ceux d'avant?
C'est etrange en effet mais je penses savoir comment regler ça. Il me faut just un peu de temps pour m'y pencher...
C'est etrange en effet mais je penses savoir comment regler ça. Il me faut just un peu de temps pour m'y pencher...
Raspberry B+ & PI2 / Domoticz / RFXtrx433E / multiple homemade devices
My blog/tutos for domoticz / electronics stuff : domotique.web2diz.net
My blog/tutos for domoticz / electronics stuff : domotique.web2diz.net