Skip to content

Commit

Permalink
Merge pull request #22 from spitzlbergerj/development
Browse files Browse the repository at this point in the history
Testdaten generiert für Kühlschrank, Gas und Klima sowie Lage; Import…
  • Loading branch information
spitzlbergerj authored Mar 17, 2024
2 parents 369d053 + 654aa57 commit 702e492
Show file tree
Hide file tree
Showing 18 changed files with 92,605 additions and 19 deletions.
24 changes: 12 additions & 12 deletions .crontabs/crontab-pi
Original file line number Diff line number Diff line change
Expand Up @@ -11,44 +11,44 @@
#

# Temperatursensoren alle 60 Sekunden auslesen
00-59/10 * * * * python3 -u /home/pi/CaravanPi/temperature/temp2file.py >/home/pi/CaravanPi/.log/temp2file.log 2>&1
#### 00-59/10 * * * * python3 -u /home/pi/CaravanPi/temperature/temp2file.py >/home/pi/CaravanPi/.log/temp2file.log 2>&1

# Gasflaschenwaage alle 60 Sekunden auslesen
01-59/10 * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 1 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1
01-59/10 * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 2 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1
#### 01-59/10 * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 1 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1
#### 01-59/10 * * * * python3 -u /home/pi/CaravanPi/gas-weight/gasScale2file.py -g 2 >/home/pi/CaravanPi/.log/gasScale2file.log 2>&1

# Klimasensoren alle 60 Sekunden auslesen
02-59/10 * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py -i 76 >/home/pi/CaravanPi/.log/climate2file76.log 2>&1
#### 02-59/10 * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py -i 76 >/home/pi/CaravanPi/.log/climate2file76.log 2>&1
# 03-59/10 * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py -i 77 >/home/pi/CaravanPi/.log/climate2file77.log 2>&1

# Lagesensor auslesen, Zeitsteuerung im Skript inkl. Live Modus
@reboot sleep 300 && python3 -u /home/pi/CaravanPi/position/position2file.py -s >/home/pi/CaravanPi/.log/position2file.log 2>&1
#### @reboot sleep 300 && python3 -u /home/pi/CaravanPi/position/position2file.py -s >/home/pi/CaravanPi/.log/position2file.log 2>&1

# Taster für Kalibrierung Lagesensor und Gaswaage aktivieren
@reboot sleep 310 && python3 -u /home/pi/CaravanPi/tactileSwitch/tactileSwitches.py >/home/pi/CaravanPi/.log/tactileSwitches.log 2>&1
#### @reboot sleep 310 && python3 -u /home/pi/CaravanPi/tactileSwitch/tactileSwitches.py >/home/pi/CaravanPi/.log/tactileSwitches.log 2>&1

# Füllmenge Tanks auslesen
@reboot sleep 320 && python3 -u /home/pi/CaravanPi/levels/freshLevels2file.py -t 1 -f >/home/pi/CaravanPi/.log/levels.log 2>&1
#### @reboot sleep 320 && python3 -u /home/pi/CaravanPi/levels/freshLevels2file.py -t 1 -f >/home/pi/CaravanPi/.log/levels.log 2>&1
# 04-59/10 * * * * python3 -u /home/pi/CaravanPi/levels/wasteLevels2file.py -t 2 -f >/home/pi/CaravanPi/.log/levels.log 2>&1

# Batteriemanagement auslesen
05-59/10 * * * * python3 -u /home/pi/CaravanPi/batteryMgmt/bms2file.py -s >/home/pi/CaravanPi/.log/bms2file.log 2>&1
#### 05-59/10 * * * * python3 -u /home/pi/CaravanPi/batteryMgmt/bms2file.py -s >/home/pi/CaravanPi/.log/bms2file.log 2>&1

# Systemdaten Raspberry Pi lesen
@reboot sleep 330 && python3 -u /home/pi/CaravanPi/raspberrypi/systemstat2file.py -s >/home/pi/CaravanPi/.log/systemstat.log 2>&1
#### @reboot sleep 330 && python3 -u /home/pi/CaravanPi/raspberrypi/systemstat2file.py -s >/home/pi/CaravanPi/.log/systemstat.log 2>&1

# MariaDB bereinigen, jeden Montag 01:05
05 01 * * 1 python3 -u /home/pi/CaravanPi/raspberrypi/clean_MariaDB.py -d 150 >/home/pi/CaravanPi/.log/cleanMariaDB.log 2>&1

# Gassensor überwachen
@reboot sleep 340 && python3 -u /home/pi/CaravanPi/analogSignals/gassensorCheck.py -s >/home/pi/CaravanPi/.log/gassensorCheck.log 2>&1
#### @reboot sleep 340 && python3 -u /home/pi/CaravanPi/analogSignals/gassensorCheck.py -s >/home/pi/CaravanPi/.log/gassensorCheck.log 2>&1

# 230V Eingang überwachen
@reboot sleep 350 && python3 -u /home/pi/CaravanPi/analogSignals/v230Check.py -s >/home/pi/CaravanPi/.log/v230Check.log 2>&1
#### @reboot sleep 350 && python3 -u /home/pi/CaravanPi/analogSignals/v230Check.py -s >/home/pi/CaravanPi/.log/v230Check.log 2>&1

# 12V Eingang überwachen
# @reboot sleep 360 && python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "car" -s >/home/pi/CaravanPi/.log/v12Check.log 2>&1
@reboot sleep 370 && python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "bord" -s >/home/pi/CaravanPi/.log/v12Check.log 2>&1
#### @reboot sleep 370 && python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "bord" -s >/home/pi/CaravanPi/.log/v12Check.log 2>&1

# Zeit zwischen StromPi und Raspberry Pi synchronisieren
# @reboot sleep 380 && python /home/pi/StromPi3/RTCSerial.py >/home/pi/CaravanPi/.log/StromPi-RTC-sync.log 2>&1
15 changes: 11 additions & 4 deletions .lib/CaravanPiFilesClass.py
Original file line number Diff line number Diff line change
Expand Up @@ -699,14 +699,21 @@ def insert_into_table(self, connection, table_name, columns, values):

# Überprüfen, ob 'zeitstempel' in den Spalten ist und CURRENT_TIMESTAMP einsetzen
timestamp_index = None
using_timestamp = False
if "zeitstempel" in columns:
timestamp_index = columns.index("zeitstempel")
columns = [col for col in columns if col != "zeitstempel"] # 'zeitstempel' aus den Spalten entfernen
values = tuple(value for i, value in enumerate(values) if i != timestamp_index) # entsprechenden Wert entfernen
using_timestamp = True

# Erstellen der SQL-Abfrage
columns_string = ', '.join(columns + (["zeitstempel"] if timestamp_index is not None else []))
values_string = ', '.join(['%s'] * len(values) + (["CURRENT_TIMESTAMP"] if timestamp_index is not None else []))
if using_timestamp:
# Wenn ein Zeitstempel übergeben wird, nutzen wir diesen in der Abfrage
values_string = ', '.join(['%s'] * len(values))
else:
# Wenn kein Zeitstempel übergeben wird, fügen wir CURRENT_TIMESTAMP hinzu
columns.append("zeitstempel") # 'zeitstempel' zu den Spalten hinzufügen
values_string = ', '.join(['%s'] * len(values) + ["CURRENT_TIMESTAMP"])

columns_string = ', '.join(columns)
query = f"INSERT INTO {table_name} ({columns_string}) VALUES ({values_string})"

# Ausführen der Abfrage
Expand Down
6 changes: 3 additions & 3 deletions defaults/caravanpiConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,15 @@
</caravanpiDefaults>
<adjustmentPosition>
<adjustX>-0.2353596</adjustX>
<adjustY>1.3729310000000001</adjustY>
<adjustY>1.372931</adjustY>
<adjustZ>8.9044382</adjustZ>
<toleranceX>0.2</toleranceX>
<toleranceY>0.2</toleranceY>
<approximationX>0.25</approximationX>
<approximationY>0.25</approximationY>
<distRight>140</distRight>
<distFront>10</distFront>
<distAxis>20</distAxis>
<distFront>3300</distFront>
<distAxis>400</distAxis>
</adjustmentPosition>
<dimensionsCaravan>
<lengthOverAll>7900</lengthOverAll>
Expand Down
Loading

0 comments on commit 702e492

Please sign in to comment.