Skip to content

Commit

Permalink
Merge pull request #13 from spitzlbergerj/development
Browse files Browse the repository at this point in the history
Anpassungen an den analog Skripten
  • Loading branch information
spitzlbergerj authored Mar 11, 2024
2 parents 6e3e00e + 0793983 commit bf9021c
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 22 deletions.
5 changes: 3 additions & 2 deletions analogSignals/gassensorCheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ def main():
gassensorDigitalIn = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorDigitalIn")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorDigitalIn") is not None else -1
gassensorAnalogIn = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorAnalogIn")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorAnalogIn") is not None else -1
gassensorAlarmActive = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorAlarmActive"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorAlarmActive") is not None else False
gassensorAlarmResume = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorAlarmResume"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/gassensorAlarmResume") is not None else False

print(f"Digital: {gassensorDigitalIn} , Analog: {gassensorAnalogIn}, Alarm aktiv: {gassensorAlarmActive}, Delay: {delay} Sekunden")

Expand Down Expand Up @@ -133,8 +134,8 @@ def main():
# kein Gas detektiert
gasDetected = False

if not gassensorAlarmActive:
# Alarm wieder einschalten
if not gassensorAlarmActive and gassensorAlarmResume:
print("Alarm wieder einschalten")
cplib.writeCaravanPiConfigItem("caravanpiDefaults/gassensorAlarmActive", 1)
gassensorAlarmActive = True

Expand Down
4 changes: 3 additions & 1 deletion analogSignals/v12Check.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def main():
v12CheckInstalled = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckInstalled"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckInstalled") is not None else False
v12CheckADCPin = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckADCPin")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckADCPin") is not None else -1
v12CheckAlarmActive = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckAlarmActive"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckAlarmActive") is not None else False
v12CheckAlarmResume = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckAlarmResume"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryCheckAlarmResume") is not None else False
v12xmlItemAlarm = "v12BatteryCheckAlarmActive"
v12R1 = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryR1")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryR1") is not None else 0
v12R2 = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryR2")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12BatteryR2") is not None else 0
Expand All @@ -92,6 +93,7 @@ def main():
v12CheckInstalled = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckInstalled"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckInstalled") is not None else False
v12CheckADCPin = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckADCPin")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckADCPin") is not None else -1
v12CheckAlarmActive = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckAlarmActive"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckAlarmActive") is not None else False
v12CheckAlarmResume = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckAlarmResume"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarCheckAlarmResume") is not None else False
v12xmlItemAlarm = "v12CarCheckAlarmActive"
v12R1 = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarR1")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarR1") is not None else 0
v12R2 = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarR2")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v12CarR2") is not None else 0
Expand Down Expand Up @@ -203,7 +205,7 @@ def main():
cpfunc.play_alarm_single(GPIO, buzzer_pin, 3)

if channel.voltage > v12Level1 and channel.voltage <= v12Level3:
if not v12CheckAlarmActive:
if not v12CheckAlarmActive and v12CheckAlarmResume:
# Alarm wieder einschalten
print("Alarm in Config einschalten")
cplib.writeCaravanPiConfigItem(f"caravanpiDefaults/{v12xmlItemAlarm}", 1)
Expand Down
3 changes: 2 additions & 1 deletion analogSignals/v230Check.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ def main():
v230CheckInstalled = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckInstalled"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckInstalled") is not None else False
v230CheckADCPin = int(cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckADCPin")) if cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckADCPin") is not None else -1
v230CheckAlarmActive = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckAlarmActive"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckAlarmActive") is not None else False
v230CheckAlarmResume = cplib.typwandlung(cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckAlarmResume"), "bool") if cplib.readCaravanPiConfigItem("caravanpiDefaults/v230CheckAlarmResume") is not None else False

print(f"ADC Pin: {v230CheckADCPin}, Alarm aktiv: {v230CheckAlarmActive}, Delay: {delay} Sekunden")

Expand Down Expand Up @@ -138,7 +139,7 @@ def main():
# 230 Volt liegen an
v230DropDetected = False

if not v230CheckAlarmActive:
if not v230CheckAlarmActive and v230CheckAlarmResume:
# Alarm wieder einschalten
print("Alarm in Config einschalten")
cplib.writeCaravanPiConfigItem("caravanpiDefaults/v230CheckAlarmActive", 1)
Expand Down
8 changes: 6 additions & 2 deletions defaults/caravanpiConfig.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<MariaDBdatabase>CaravanPiValues</MariaDBdatabase>
<MQTTbroker>MQTTBrokerWebAdresse</MQTTbroker>
<MQTTport>8883</MQTTport>
<MQTTuser>NodeRED-MQTT</MQTTuser>
<MQTTuser>CaravanPiMQTT</MQTTuser>
<MQTTpassword>dasGeheimePasswort</MQTTpassword>
<countClimateSensors>1</countClimateSensors>
<stromPiInstalled>0</stromPiInstalled>
Expand All @@ -33,14 +33,18 @@
<v12BatteryCheckInstalled>1</v12BatteryCheckInstalled>
<v12BatteryCheckADCPin>2</v12BatteryCheckADCPin>
<v12BatteryCheckAlarmActive>0</v12BatteryCheckAlarmActive>
<v12CarCheckInstalled>0</v12CarCheckInstalled>
<v12CarCheckInstalled>1</v12CarCheckInstalled>
<v12CarCheckADCPin>3</v12CarCheckADCPin>
<v12CarCheckAlarmActive>0</v12CarCheckAlarmActive>
<BuzzerGPIOPin>26</BuzzerGPIOPin>
<v12BatteryR1>560</v12BatteryR1>
<v12BatteryR2>150</v12BatteryR2>
<v12CarR1>560</v12CarR1>
<v12CarR2>150</v12CarR2>
<gassensorAlarmResume>True</gassensorAlarmResume>
<v230CheckAlarmResume>True</v230CheckAlarmResume>
<v12BatteryCheckAlarmResume>True</v12BatteryCheckAlarmResume>
<v12CarCheckAlarmResume>True</v12CarCheckAlarmResume>
</caravanpiDefaults>
<adjustmentPosition>
<adjustX>-0.0392266</adjustX>
Expand Down
8 changes: 8 additions & 0 deletions html-flask/config_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,24 @@ def config_caravanpi():
gassensorDigitalIn = request.form.get('gassensorDigitalIn')
gassensorAnalogIn = request.form.get('gassensorAnalogIn')
gassensorAlarmActive = request.form.get('gassensorAlarmActive')
gassensorAlarmResume = request.form.get('gassensorAlarmResume')

v230CheckInstalled = request.form.get('v230CheckInstalled')
v230CheckADCPin = request.form.get('v230CheckADCPin')
v230CheckAlarmActive = request.form.get('v230CheckAlarmActive')
v230CheckAlarmResume = request.form.get('v230CheckAlarmResume')

v12BatteryCheckInstalled = request.form.get('v12BatteryCheckInstalled')
v12BatteryCheckADCPin = request.form.get('v12BatteryCheckADCPin')
v12BatteryCheckAlarmActive = request.form.get('v12BatteryCheckAlarmActive')
v12BatteryCheckAlarmResume = request.form.get('v12BatteryCheckAlarmResume')
v12BatteryR1 = request.form.get('v12BatteryR1')
v12BatteryR2 = request.form.get('v12BatteryR2')

v12CarCheckInstalled = request.form.get('v12CarCheckInstalled')
v12CarCheckADCPin = request.form.get('v12CarCheckADCPin')
v12CarCheckAlarmActive = request.form.get('v12CarCheckAlarmActive')
v12CarCheckAlarmResume = request.form.get('v12CarCheckAlarmResume')
v12CarR1 = request.form.get('v12CarR1')
v12CarR2 = request.form.get('v12CarR2')

Expand Down Expand Up @@ -117,20 +121,24 @@ def config_caravanpi():
'gassensorDigitalIn': int(gassensorDigitalIn) if gassensorDigitalIn and 0 <= int(gassensorDigitalIn) <= 40 else None,
'gassensorAnalogIn': int(gassensorAnalogIn) if gassensorAnalogIn and 0 <= int(gassensorAnalogIn) <= 3 else None,
'gassensorAlarmActive': bool(gassensorAlarmActive) if gassensorAlarmActive is not None else None,
'gassensorAlarmResume': bool(gassensorAlarmResume) if gassensorAlarmResume is not None else None,

'v230CheckInstalled': bool(v230CheckInstalled) if v230CheckInstalled is not None else None,
'v230CheckADCPin': int(v230CheckADCPin) if v230CheckADCPin and 0 <= int(v230CheckADCPin) <= 40 else None,
'v230CheckAlarmActive': bool(v230CheckAlarmActive) if v230CheckAlarmActive is not None else None,
'v230CheckAlarmResume': bool(v230CheckAlarmResume) if v230CheckAlarmResume is not None else None,

'v12BatteryCheckInstalled': bool(v12BatteryCheckInstalled) if v12BatteryCheckInstalled is not None else None,
'v12BatteryCheckADCPin': int(v12BatteryCheckADCPin) if v12BatteryCheckADCPin and 0 <= int(v12BatteryCheckADCPin) <= 40 else None,
'v12BatteryCheckAlarmActive': bool(v12BatteryCheckAlarmActive) if v12BatteryCheckAlarmActive is not None else None,
'v12BatteryCheckAlarmResume': bool(v12BatteryCheckAlarmResume) if v12BatteryCheckAlarmResume is not None else None,
'v12BatteryR1': int(v12BatteryR1) if v12BatteryR1 and 0 <= int(v12BatteryR1) <= 10000000 else None,
'v12BatteryR2': int(v12BatteryR2) if v12BatteryR2 and 0 <= int(v12BatteryR2) <= 10000000 else None,

'v12CarCheckInstalled': bool(v12CarCheckInstalled) if v12CarCheckInstalled is not None else None,
'v12CarCheckADCPin': int(v12CarCheckADCPin) if v12CarCheckADCPin and 0 <= int(v12CarCheckADCPin) <= 40 else None,
'v12CarCheckAlarmActive': bool(v12CarCheckAlarmActive) if v12CarCheckAlarmActive is not None else None,
'v12CarCheckAlarmResume': bool(v12CarCheckAlarmResume) if v12CarCheckAlarmResume is not None else None,
'v12CarR1': int(v12CarR1) if v12CarR1 and 0 <= int(v12CarR1) <= 10000000 else None,
'v12CarR2': int(v12CarR2) if v12CarR2 and 0 <= int(v12CarR2) <= 10000000 else None,

Expand Down
69 changes: 53 additions & 16 deletions html-flask/templates/config_caravanpi.html
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ <h1>CaravanPi Grundeinstellungen</h1>
</div>
</div>

<h2>Sensoren, die einen aktustischen Alarm auslösen</h2>
<p>Nachfolgende Sensoren können bei entsprechenden Fehlerzuständen einen akustischen Alarm auslösen </br>
Dieser Alarm kann über die CaravanPi Website ausgeschaltet werden, falls der Zustand länger andauern sollte.</br>
Der Alarm kann automatisch wieder eingeschaltet werden, sobald der Fehlerzustand überwunden ist.</br>
Dies empfiehlt sich insbesondere beim Gassensor.</p>


<br/><br/>
Expand Down Expand Up @@ -338,12 +343,20 @@ <h1>CaravanPi Grundeinstellungen</h1>
</div>
<div class="row">
<div class="col-75">
<label for="gassensorAlarmActive">soll akustischer Alarm ausgelöst werden?</label>
<label for="gassensorAlarmActive">Akustischen Alarm auslösen?</label>
</div>
<div class="col-25">
<input name="gassensorAlarmActive" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('gassensorAlarmActive', False) else '' }}>
</div>
</div>
<div class="row">
<div class="col-75">
<label for="gassensorAlarmResume">Akustischen Alarm reaktivieren?</label>
</div>
<div class="col-25">
<input name="gassensorAlarmResume" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('gassensorAlarmResume', False) else '' }}>
</div>
</div>



Expand All @@ -370,12 +383,20 @@ <h1>CaravanPi Grundeinstellungen</h1>
</div>
<div class="row">
<div class="col-75">
<label for="v230CheckAlarmActive">soll akustischer Alarm ausgelöst werden?</label>
<label for="v230CheckAlarmActive">Akustischen Alarm auslösen?</label>
</div>
<div class="col-25">
<input name="v230CheckAlarmActive" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v230CheckAlarmActive', False) else '' }}>
</div>
</div>
<div class="row">
<div class="col-75">
<label for="v230CheckAlarmResume">Akustischen Alarm reaktivieren?</label>
</div>
<div class="col-25">
<input name="v230CheckAlarmResume" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v230CheckAlarmResume', False) else '' }}>
</div>
</div>



Expand All @@ -402,32 +423,40 @@ <h1>CaravanPi Grundeinstellungen</h1>
</div>
<div class="row">
<div class="col-75">
<label for="v12BatteryCheckAlarmActive">soll akustischer Alarm ausgelöst werden?</label>
<label for="v12BatteryR1">Spannungsteiler Widerstand R1 (an V-in)</label>
</div>
<div class="col-25">
<input name="v12BatteryCheckAlarmActive" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v12BatteryCheckAlarmActive', False) else '' }}>
<input name="v12BatteryR1" type="char" value="{{ caravanpiDefaults.get('v12BatteryR1', '')}}" >
</div>
</div>

<div class="row">
<div class="col-75">
<label for="v12BatteryR1">Spannungsteiler Widerstand R1 (an V-in)</label>
<label for="v12BatteryR2">Spannungsteiler Widerstand R2 (an GND)</label>
</div>
<div class="col-25">
<input name="v12BatteryR1" type="char" value="{{ caravanpiDefaults.get('v12BatteryR1', '')}}" >
<input name="v12BatteryR2" type="char" value="{{ caravanpiDefaults.get('v12BatteryR2', '')}}" >
</div>
</div>
<div class="row">
<div class="col-75">
<label for="v12BatteryR2">Spannungsteiler Widerstand R2 (an GND)</label>
<label for="v12BatteryCheckAlarmActive">Akustischen Alarm auslösen?</label>
</div>
<div class="col-25">
<input name="v12BatteryR2" type="char" value="{{ caravanpiDefaults.get('v12BatteryR2', '')}}" >
<input name="v12BatteryCheckAlarmActive" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v12BatteryCheckAlarmActive', False) else '' }}>
</div>
</div>
<div class="row">
<div class="col-75">
<label for="v12BatteryCheckAlarmResume">Akustischen Alarm reaktivieren?</label>
</div>
<div class="col-25">
<input name="v12BatteryCheckAlarmResume" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v12BatteryCheckAlarmResume', False) else '' }}>
</div>
</div>




<br/><br/>
<hr>
<p><b>12V Auto Überwachung</b><br/></p>
Expand All @@ -451,31 +480,39 @@ <h1>CaravanPi Grundeinstellungen</h1>
</div>
<div class="row">
<div class="col-75">
<label for="v12CarCheckAlarmActive">soll akustischer Alarm ausgelöst werden?</label>
<label for="v12CarR1">Spannungsteiler Widerstand R1 (an V-in)</label>
</div>
<div class="col-25">
<input name="v12CarCheckAlarmActive" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v12CarCheckAlarmActive', False) else '' }}>
<input name="v12CarR1" type="char" value="{{ caravanpiDefaults.get('v12CarR1', '')}}" >
</div>
</div>

<div class="row">
<div class="col-75">
<label for="v12CarR1">Spannungsteiler Widerstand R1 (an V-in)</label>
<label for="v12CarR2">Spannungsteiler Widerstand R2 (an GND)</label>
</div>
<div class="col-25">
<input name="v12CarR1" type="char" value="{{ caravanpiDefaults.get('v12CarR1', '')}}" >
<input name="v12CarR2" type="char" value="{{ caravanpiDefaults.get('v12CarR2', '')}}" >
</div>
</div>
<div class="row">
<div class="col-75">
<label for="v12CarR2">Spannungsteiler Widerstand R2 (an GND)</label>
<label for="v12CarCheckAlarmActive">Akustischen Alarm auslösen?</label>
</div>
<div class="col-25">
<input name="v12CarR2" type="char" value="{{ caravanpiDefaults.get('v12CarR2', '')}}" >
<input name="v12CarCheckAlarmActive" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v12CarCheckAlarmActive', False) else '' }}>
</div>
</div>
<div class="row">
<div class="col-75">
<label for="v12CarCheckAlarmResume">Akustischen Alarm reaktivieren?</label>
</div>
<div class="col-25">
<input name="v12CarCheckAlarmResume" type="checkbox" value="1" {{ 'checked' if caravanpiDefaults.get('v12CarCheckAlarmResume', False) else '' }}>
</div>
</div>



<br/><br/>
<hr>
<p><b>Sonstige Einstellungen</b><br/></p>
Expand Down

0 comments on commit bf9021c

Please sign in to comment.