Re: [TUTO] Consomation d'eau ajout dans domoticz - SDEI
Publié : 11 août 2015, 18:45
Merci je vais tester de suite!!! 
Reprenez le contrôle de votre domotique
https://easydomoticz.com/forum/
Code : Tout sélectionner
- PART 4 Update the db
File size is NOT zero -> DB update needed
Stoping Domoticz !
Domoticz stopped
Update DB START
Update Values
Error: near line 1: attempt to write a readonly database
Error: near line 2: attempt to write a readonly database
Error: near line 3: attempt to write a readonly database
Error: near line 4: attempt to write a readonly database
Error: near line 5: attempt to write a readonly database
Error: near line 6: attempt to write a readonly database
Error: near line 7: attempt to write a readonly database
Update Status
Error: near line 1: attempt to write a readonly database
Update DB END
Starting Domoticz !
2015-08-11 20:03:46.034 Domoticz V2.2713 (c)2012-2015 GizMoCuz
2015-08-11 20:03:46.035 System: Raspberry Pi
2015-08-11 20:03:46.037 Startup Path: /home/pi/domoticz/
domoticz: Domoticz is starting up....
Code : Tout sélectionner
- PART 3 Generate SQL
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-01'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*18 5), '468.902', '2015-08-01' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-02'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*34 4), '469.246', '2015-08-02' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-03'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*44 5), '469.691', '2015-08-03' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-04'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*58 1), '470.271', '2015-08-04' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-05'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*43 3), '470.704', '2015-08-05' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-06'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*50 8), '471.212', '2015-08-06' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=68 and date = '2015-08-07'; INSERT INTO `Meter_Calendar` VALUES ('68', (100*41 6), '471.628', '2015-08-07' );
update DeviceStatus set lastupdate = '2015-08-07 22:22:38' where id = 68;
Code : Tout sélectionner
root@raspberrypi:/home/pi# /home/pi/SDEI/updateConsoEau.sh
/home/pi/SDEI/updateConsoEau.sh[18]: [: argument expected
- PART 1 Get the data from SDEI for 2015-08
/home/pi/SDEI/2015-08.dat generated
rm: impossible de supprimer « /home/pi/SDEI/cookiefile »: Aucun fichier ou dossier de ce type
- PART 2 Update .dat file
/home/pi/SDEI/2015-08.dat Updated
- PART 3 Generate SQL
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-01'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*185), '468.902', '2015-08-01' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-02'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*344), '469.246', '2015-08-02' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-03'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*445), '469.691', '2015-08-03' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-04'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*581), '470.271', '2015-08-04' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-05'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*433), '470.704', '2015-08-05' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-06'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*508), '471.212', '2015-08-06' );
DELETE FROM `Meter_Calendar` WHERE devicerowid=69 and date = '2015-08-07'; INSERT INTO `Meter_Calendar` VALUES ('69', (100*416), '471.628', '2015-08-07' );
update DeviceStatus set lastupdate = '2015-08-07 00:02:20' where id = 69;
- PART 4 Update the db
File size is NOT zero -> DB update needed
Stoping Domoticz !
Domoticz stopped
Update DB START
Update Values
Update Status
Update DB END
Starting Domoticz !
2015-08-12 00:02:25.600 Domoticz V2.2713 (c)2012-2015 GizMoCuz
2015-08-12 00:02:25.601 System: Raspberry Pi
2015-08-12 00:02:25.602 Startup Path: /home/pi/domoticz/
domoticz: Domoticz is starting up....
Domoticz started
### END ###
Code : Tout sélectionner
sed -e 's/0./0/g' file3 > file4Code : Tout sélectionner
01/08/2015,185,468.902
02/08/2015,344,469.246
03/08/2015,445,469.691
04/08/2015,581,470.271
05/08/2015,433,470.704
06/08/2015,508,471.212
07/08/2015,416,471.628Code : Tout sélectionner
[[0/0/205,0185,468.90],[0/0/205,0344,469.246],[0/0/205,0445,469.691],[0/0/205,0581,470271],[0/0/205,0433,47070],[0/0/205,050,471.212],[0/0/205,0416,471.628],[0/0/205,04,472.08],[0/0/205,0314,472.3$Code : Tout sélectionner
sed -e 's/\\//g' $export_file > file1 # supprime les "\" et les remplace par rien
sed -e 's/\],\[/\n/g' file1 > file2 # supprime les "],[" et remplace par des saut de ligne
sed -e 's/\[\[/\n/g' file2 > file3 # supprime les "[[" et remplace par des saut de ligne
sed -e 's/\"//g' file3 |grep -v ",0,0" |grep -e '^$' -v |grep -v ERR > $export_file
# supprime les " , les ",0,0"
# supprime les lignes d'erreur si il y en a (ex : pbl de connection)Code : Tout sélectionner
rm file1 file2 file3 Code : Tout sélectionner
val1=$(( $val * 100))Code : Tout sélectionner
val1=`echo $val | sed -e 's/0\.//g'`