diff --git a/.crontabs/crontab-pi b/.crontabs/crontab-pi
index 27a2344..79357eb 100644
--- a/.crontabs/crontab-pi
+++ b/.crontabs/crontab-pi
@@ -19,36 +19,36 @@
# 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
-#03-59/10 * * * * python3 -u /home/pi/CaravanPi/climate/climate2file.py -i 77 >/home/pi/CaravanPi/.log/climate2file77.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 python3 -u /home/pi/CaravanPi/position/position2file.py -f >/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 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 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
+@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 >/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 python3 -u /home/pi/CaravanPi/raspberrypi/systemstat2file.py >/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 python3 -u /home/pi/CaravanPi/analogSignals/gassensorCheck.py >/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 python3 -u /home/pi/CaravanPi/analogSignals/v230Check.py >/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 python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "car" >/home/pi/CaravanPi/.log/v12Check.log 2>&1
-@reboot python3 -u /home/pi/CaravanPi/analogSignals/v12Check.py -b "bord" >/home/pi/CaravanPi/.log/v12Check.log 2>&1
+# @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
# Zeit zwischen StromPi und Raspberry Pi synchronisieren
-@reboot python /home/pi/StromPi3/RTCSerial.py >/home/pi/CaravanPi/.log/StromPi-RTC-sync.log 2>&1
+# @reboot sleep 380 && python /home/pi/StromPi3/RTCSerial.py >/home/pi/CaravanPi/.log/StromPi-RTC-sync.log 2>&1
diff --git a/.git_hooks/pre-commit b/.git_hooks/pre-commit
index 978a43e..d22c1ad 100755
--- a/.git_hooks/pre-commit
+++ b/.git_hooks/pre-commit
@@ -11,7 +11,7 @@ CRONTABS_DIR="/home/pi/CaravanPi/.crontabs"
# Backup-Funktion
backup_files() {
- cp "$1" "$BACKUP_DIR/$(basename $1).backup"
+ cp "$1" "$BACKUP_DIR/$(basename $1).backup"
}
# Dateien vor der Bearbeitung sichern
@@ -20,9 +20,38 @@ backup_files "$README_MD"
# Funktion, um die Dateien zu bearbeiten (wie zuvor)
update_files() {
- sed -i 's/
+
+
+
+ """
+
+ session = smtplib.SMTP(SERVER, PORT)
+ session.set_debuglevel(1)
+ session.ehlo()
+ session.starttls()
+ session.ehlo
+ session.login(EMAIL, PASSWORT)
+ msg = MIMEText(BODY, 'html')
+ msg['Subject'] = SUBJECT_Powerback
+ msg['From'] = EMAIL
+ msg['To'] = ", ".join(EMPFAENGER)
+ session.sendmail(EMAIL, EMPFAENGER, msg.as_string())
+ Detect_Powerfail()
+
+def Sendmail_Restart():
+ BODY = """
+
+
+
+
+
+
+ StromPi hat Spannung wiedererkannt!
+
+
+
+
+ """
+
+ session = smtplib.SMTP(SERVER, PORT)
+ session.set_debuglevel(1)
+ session.ehlo()
+ session.starttls()
+ session.ehlo
+ session.login(EMAIL, PASSWORT)
+ msg = MIMEText(BODY, 'html')
+ msg['Subject'] = SUBJECT_Restart
+ msg['From'] = EMAIL
+ msg['To'] = ", ".join(EMPFAENGER)
+ session.sendmail(EMAIL, EMPFAENGER, msg.as_string())
+ Detect_Powerfail()
+
+def Sendmail_Powerfail():
+ BODY = """
+
+
+
+
+
+
+ Ihr Raspberry Pi wurde neugestartet.
+
+
+
+
+ """
+
+ session = smtplib.SMTP(SERVER, PORT)
+ session.set_debuglevel(1)
+ session.ehlo()
+ session.starttls()
+ session.ehlo
+ session.login(EMAIL, PASSWORT)
+ msg = MIMEText(BODY, 'html')
+ msg['Subject'] = SUBJECT_Powerfail
+ msg['From'] = EMAIL
+ msg['To'] = ", ".join(EMPFAENGER)
+ session.sendmail(EMAIL, EMPFAENGER, msg.as_string())
+ Detect_Powerback()
+
+def Detect_Powerback():
+ while 1:
+ x=ser.readline()
+ y=x.decode(encoding='UTF-8',errors='strict')
+ if y==('xxx--StromPiPowerBack--xxx\n'):
+ print ("PowerBack - Email Sent")
+ Sendmail_Powerback()
+
+ser = serial.Serial(
+ port='/dev/serial0',
+ baudrate = 38400,
+ parity=serial.PARITY_NONE,
+ stopbits=serial.STOPBITS_ONE,
+ bytesize=serial.EIGHTBITS,
+ timeout=1
+)
+counter=0
+
+time.sleep(5)
+if Restart_Mail == 1:
+ Sendmail_Restart()
+
+
+
+
+
+
+
+Detect_Powerfail()
diff --git a/StromPi3/serialShutdown.py b/StromPi3/serialShutdown.py
index c74bf5d..ce318e6 100644
--- a/StromPi3/serialShutdown.py
+++ b/StromPi3/serialShutdown.py
@@ -1,8 +1,6 @@
#!/usr/bin/env python
import serial
import os
-import time
-import sys
##############################################################################
#Hier muss der wait_for_shutdowntimer eingestellt werden - dieser wartet mit dem Herunterfahren des Raspberry Pi,
# fuer den Fall dass die primaere Stromquelle wiederhergesttelt werden sollte
@@ -18,18 +16,6 @@
t=0 #Temporary time-variable
-os.system('sudo date')
-print ('StromPi - serial shutdown Skript started')
-print ('-----------------------------------------')
-print ('wait to bring up all things')
-sys.stdout.flush()
-
-time.sleep(90)
-
-os.system('sudo date')
-print ('start serial ...')
-sys.stdout.flush()
-
ser = serial.Serial(
port='/dev/serial0',
baudrate = 38400,
@@ -40,28 +26,18 @@
)
counter=0
-os.system('sudo date')
-print ('enter loop')
-sys.stdout.flush()
-
while 1:
x=ser.readline()
y = x.decode(encoding='UTF-8',errors='strict')
- if y==('xxxShutdownRaspberryPixxx\n'):
- os.system('sudo date')
- print ("PowerFail - Raspberry Pi Shutdown")
- sys.stdout.flush()
- t= wait_for_shutdowntimer + 1
- elif y==('xxx--StromPiPowerBack--xxx\n'):
- os.system('sudo date')
+ if y != "":
+ print(y)
+ if y.find('xxx--StromPiPowerBack--xxx\n') != -1:
print ("PowerBack - Raspberry Pi Shutdown aborted")
- sys.stdout.flush()
t=0
+ elif y.find('xxxShutdownRaspberryPixxx\n') != -1:
+ print ("PowerFail - Raspberry Pi Shutdown")
+ t= wait_for_shutdowntimer + 1
if t>0:
t-=1
if t == 1:
- os.system('sudo date')
- print ("shutdown Raspberry Pi in 1 second")
- sys.stdout.flush()
- time.sleep(1)
- os.system("sudo shutdown -h now")
\ No newline at end of file
+ os.system("sudo shutdown -h now")
diff --git a/StromPi3/strompi_config.py b/StromPi3/strompi_config.py
new file mode 100644
index 0000000..2f10f07
--- /dev/null
+++ b/StromPi3/strompi_config.py
@@ -0,0 +1,1005 @@
+import serial
+from time import sleep
+import datetime
+import os
+import time
+from time import sleep
+
+wide_range_volt_min = 4.8
+battery_volt_min = 0.5
+mUSB_volt_min = 4.1
+
+breakS = 0.1
+breakL = 0.5
+
+serial_port = serial.Serial()
+
+serial_port.baudrate = 38400
+serial_port.port = '/dev/serial0'
+serial_port.timeout = 1
+serial_port.bytesize = 8
+serial_port.stopbits = 1
+serial_port.parity = serial.PARITY_NONE
+
+if serial_port.isOpen(): serial_port.close()
+serial_port.open()
+
+#######################################################################################################################
+
+def enabled_disabled_converter(argument):
+ switcher = {
+ 0: 'Disabled',
+ 1: 'Enabled',
+ }
+ return switcher.get(argument, 'nothing')
+
+def weekday_converter(argument):
+ switcher = {
+ 1: 'Monday',
+ 2: 'Tuesday',
+ 3: 'Wednesday',
+ 4: 'Thursday',
+ 5: 'Friday',
+ 6: 'Saturday',
+ 7: 'Sunday',
+ }
+ return switcher.get(argument, 'nothing')
+
+def strompi_mode_converter(argument):
+ switcher = {
+ 1: 'mUSB -> Wide',
+ 2: 'Wide -> mUSB',
+ 3: 'mUSB -> Battery',
+ 4: 'Wide -> Battery',
+ 5: "mUSB -> Wide -> Battery",
+ 6: "Wide -> mUSB -> Battery",
+ }
+ return switcher.get(argument, 'nothing')
+
+def alarm_mode_converter(argument):
+ switcher = {
+ 1: 'Time-Alarm',
+ 2: 'Date-Alarm',
+ 3: 'Weekday-Alarm',
+ 4: 'Wakeup Timer',
+ }
+ return switcher.get(argument, 'nothing')
+
+def batterylevel_shutdown_converter(argument):
+ switcher = {
+ 0: 'Disabled',
+ 1: '10%',
+ 2: '25%',
+ 3: '50%',
+ }
+ return switcher.get(argument, 'nothing')
+
+def output_status_converter(argument):
+ switcher = {
+ 0: 'Power-Off', #only for Debugging-Purposes
+ 1: 'mUSB',
+ 2: 'Wide',
+ 3: 'Battery',
+ }
+ return switcher.get(argument, 'nothing')
+
+
+def batterylevel_converter(batterylevel,charging):
+
+ if charging:
+ switcher = {
+ 1: ' [10%] [charging]',
+ 2: ' [25%] [charging]',
+ 3: ' [50%] [charging]',
+ 4: ' [100%] [charging]',
+ }
+ return switcher.get(batterylevel, 'nothing')
+ else:
+ switcher = {
+ 1: ' [10%]',
+ 2: ' [25%]',
+ 3: ' [50%]',
+ 4: ' [100%]',
+ }
+ return switcher.get(batterylevel, 'nothing')
+
+#######################################################################################################################
+serial_port.write(str.encode('quit'))
+sleep(breakS)
+serial_port.write(str.encode('\x0D'))
+sleep(breakL)
+
+serial_port.write(str.encode('status-rpi'))
+sleep(1)
+serial_port.write(str.encode('\x0D'))
+sp3_time = serial_port.readline(9999);
+sp3_date = serial_port.readline(9999);
+sp3_weekday = serial_port.readline(9999);
+sp3_modus = serial_port.readline(9999);
+sp3_alarm_enable = serial_port.readline(9999);
+sp3_alarm_mode = serial_port.readline(9999);
+sp3_alarm_hour = serial_port.readline(9999);
+sp3_alarm_min = serial_port.readline(9999);
+sp3_alarm_day = serial_port.readline(9999);
+sp3_alarm_month = serial_port.readline(9999);
+sp3_alarm_weekday = serial_port.readline(9999);
+sp3_alarmPoweroff = serial_port.readline(9999);
+sp3_alarm_hour_off = serial_port.readline(9999);
+sp3_alarm_min_off = serial_port.readline(9999);
+sp3_shutdown_enable = serial_port.readline(9999);
+sp3_shutdown_time = serial_port.readline(9999);
+sp3_warning_enable = serial_port.readline(9999);
+sp3_serialLessMode = serial_port.readline(9999);
+sp3_intervalAlarm = serial_port.readline(9999);
+sp3_intervalAlarmOnTime = serial_port.readline(9999);
+sp3_intervalAlarmOffTime = serial_port.readline(9999);
+sp3_batLevel_shutdown = serial_port.readline(9999);
+sp3_batLevel = serial_port.readline(9999);
+sp3_charging = serial_port.readline(9999);
+sp3_powerOnButton_enable = serial_port.readline(9999);
+sp3_powerOnButton_time = serial_port.readline(9999);
+sp3_powersave_enable = serial_port.readline(9999);
+sp3_poweroffMode = serial_port.readline(9999);
+sp3_poweroff_time_enable = serial_port.readline(9999);
+sp3_poweroff_time = serial_port.readline(9999);
+sp3_wakeupweekend_enable = serial_port.readline(9999);
+sp3_ADC_Wide = float(serial_port.readline(9999))/1000;
+sp3_ADC_BAT = float(serial_port.readline(9999))/1000;
+sp3_ADC_USB = float(serial_port.readline(9999))/1000;
+sp3_ADC_OUTPUT = float(serial_port.readline(9999))/1000;
+sp3_output_status = serial_port.readline(9999);
+sp3_powerfailure_counter = serial_port.readline(9999);
+sp3_firmwareVersion = serial_port.readline(9999);
+powerofftime_enabletest = (str(sp3_poweroff_time_enable, 'utf-8').rstrip('\n').zfill(2))
+date = int(sp3_date)
+
+strompi_year = int(sp3_date) // 10000
+strompi_month = int(sp3_date) % 10000 // 100
+strompi_day = int(sp3_date) % 100
+
+strompi_hour = int(sp3_time) // 10000
+strompi_min = int(sp3_time) % 10000 // 100
+strompi_sec = int(sp3_time) % 100
+
+try:
+ print('###########################################################################')
+ print('\rStromPi V3 Serial Config Script (PYTHON3)\r')
+ print('###########################################################################')
+
+ print('\n---------------------------------------------------------------------------')
+ print(' Main Configuration')
+ print('---------------------------------------------------------------------------')
+
+ #strompi-mode
+ print('[StromPi-Mode: ' + sp3_modus.decode(encoding='UTF-8', errors='strict').rstrip('\n') + ' (' + strompi_mode_converter((int(sp3_modus))) + ')]')
+ print('\nSetting the StromPi mode \n(1 = mUSB -> Wide, 2 = Wide -> mUSB, 3 = mUSB -> Battery, 4 = Wide -> Battery, 5 = mUSB -> Wide -> Battery, 6 = Wide -> mUSB -> Battery)\n')
+ sp3_modus_temp = int(sp3_modus)
+ sp3_modus = input('Mode (1-6): ')
+ while int(sp3_modus) < 1 or int(sp3_modus) > 6:
+ sp3_modus = input('Failed! Value not in Range - Please try again\nMode (1-6): ')
+
+ if sp3_modus_temp != int(sp3_modus):
+ modusreset = 1
+ else:
+ modusreset = 0
+
+ print('\n--------------------------------------')
+ #Shutdown-enable & set-timer
+ print('[Raspberry Pi Shutdown: ' + enabled_disabled_converter(int(sp3_shutdown_enable)) + ']')
+ print('\nEnabling or disabling the Raspberry Pi shutdown (0 = disable, 1 = enable)\n')
+
+ sp3_shutdown_enable = input('Shutdown enable/disable (0 - 1): ')
+ while int(sp3_shutdown_enable ) < 0 or int(sp3_shutdown_enable ) > 1:
+ sp3_shutdown_enable = input('Failed! Value not in Range - Please try again\nShutdown status (0 - 1): ')
+
+ if int(sp3_shutdown_enable ) == 1:
+ print('\n--------------------------------------')
+ print('[Shutdown-Timer: ' + str(sp3_shutdown_time, 'utf-8').rstrip('\n').zfill(2) + ' seconds' + ']')
+ print('\nSetting shutdown timer (seconds)\n')
+
+ sp3_shutdown_time = input('Seconds (0 - 65535): ')
+ while int(sp3_shutdown_time) < 0 or int(sp3_shutdown_time) > 65535:
+ sp3_shutdown_time = input('Failed! Value not in Range - Please try again\nSeconds (0 - 65535): ')
+
+ #batlevel-shutdown
+ print('\n--------------------------------------')
+ print('[Battery-Level Shutdown: ' + batterylevel_shutdown_converter(int(sp3_batLevel_shutdown)) + ']')
+ print('\nSetting battery level shutdown (0 = disable, 1 = below 10%, 2 = below 25%, 3 = below 50%)\n')
+
+ sp3_batLevel_shutdown = input('Battery level shutdown (0 - 3): ')
+ while int(sp3_batLevel_shutdown) < 0 or int(sp3_batLevel_shutdown) > 3:
+ sp3_batLevel_shutdown = input('Failed! Value not in Range - Please try again\nBattery level shutdown (0 - 3): ')
+
+
+ #serialless-mode
+ print('\n--------------------------------------')
+ print('[Serial-Less Mode: ' + enabled_disabled_converter(int(sp3_serialLessMode)) + ']')
+ print('\nEnabling or disabling serialless-mode (0 = disable, 1 = enable)\n')
+
+ sp3_serialLessMode = input('Serialless mode (0 - 1): ')
+ while int(sp3_serialLessMode) < 0 or int(sp3_serialLessMode) > 1:
+ sp3_serialLessMode = input('Failed! Value not in Range - Please try again\nSerialless mode (0 - 1): ')
+
+ #powersave
+ print('\n--------------------------------------')
+ print('[Power Save Mode: ' + enabled_disabled_converter(int(sp3_powersave_enable)) + ']')
+ print('\nEnabling or disabling the Power Save mode (0 = disable, 1 = enable)\n')
+
+ sp3_powersave_enable = input('Power Save mode (0 - 1): ')
+ while int(sp3_powersave_enable) < 0 or int(sp3_powersave_enable) > 1:
+ sp3_powersave_enable = input('Failed! Value not in Range - Please try again\nPower Save mode (0 - 1): ')
+
+
+ #warning-enable
+ print('\n--------------------------------------')
+ print('[Powerfail Warning: ' + enabled_disabled_converter(int(sp3_warning_enable)) + ']')
+ print('\nEnabling or disabling the Powerfail-Warning (instead of a shutdown) through the serial interface (0 = disable, 1 = enable)\n')
+
+ sp3_warning_enable = input('Warning enable/disable (0 - 1): ')
+ while int(sp3_warning_enable) < 0 or int(sp3_warning_enable) > 1:
+ sp3_warning_enable = input('Failed! Value not in Range - Please try again\nWarning status (0 - 1): ')
+
+ print('\n--------------------------------------')
+ # PowerOn-Button Enable & PowerOn-Button Timer
+ print('[PowerOn-Button: ' + enabled_disabled_converter(int(sp3_powerOnButton_enable)) + ']')
+ print('\nEnabling or disabling the PowerOn-Button Feature (0 = disable, 1 = enable)\n')
+
+ sp3_powerOnButton_enable = input('PowerOn-Button enable/disable (0 - 1): ')
+ while int(sp3_powerOnButton_enable) < 0 or int(sp3_powerOnButton_enable) > 1:
+ sp3_powerOnButton_enable = input('Failed! Value not in Range - Please try again\nShutdown status (0 - 1): ')
+
+ if int(sp3_powerOnButton_enable) == 1 and int(sp3_shutdown_enable) == 1:
+ print('\n--------------------------------------')
+ print('[Poweroff Mode: ' + enabled_disabled_converter(int(sp3_poweroffMode)) + ']')
+
+ sp3_poweroffMode = input('Poweroff Mode enable/disable (0 - 1): ')
+ while int(sp3_poweroffMode) < 0 or int(sp3_poweroffMode) > 1:
+ sp3_poweroffMode = input('Failed! Value not in Range - Please try again\nPoweroff Mode status (0 - 1): ')
+
+ if int(sp3_powerOnButton_enable) == 1:
+ print('\n--------------------------------------')
+ print('[PowerOn-Button Initialization Time: ' + str(sp3_powerOnButton_time, 'utf-8').rstrip('\n').zfill(2) + ' seconds' + ']')
+ print('\nPowerOn-Button Initialization Time: (seconds)\n')
+
+ sp3_powerOnButton_time = input('Seconds (0 - 65535): ')
+ while int(sp3_powerOnButton_time) < 0 or int(sp3_powerOnButton_time) > 65535:
+ sp3_powerOnButton_time = input('Failed! Value not in Range - Please try again\nSeconds (0 - 65535): ')
+
+ print('\n---------------------------------------------------------------------------')
+ print(' Time&Date-Configuration')
+ print('---------------------------------------------------------------------------')
+ #set-clock
+ print('[Actual Raspberry Pi Time&Date]')
+ print('[Time: ' + str(strompi_hour).zfill(2) + ':' + str(strompi_min).zfill(2) + ':' + str(strompi_sec).zfill(2) + ']')
+ print('[Date: ' + weekday_converter(int(sp3_weekday)) + ' ' + str(strompi_day).zfill(2) + '.' + str(strompi_month).zfill(
+ 2) + '.' + str(strompi_year).zfill(2) + ']')
+
+ timeconfig = input('\nDo you want to change the Time&Date-Configuration? (Y) Yes | (N) No:')
+ while not (timeconfig == 'Y' or timeconfig == 'N'):
+ timeconfig = input('Failed! Value not in Range - Please try again\nDo you want to change the Alarm-Configuration? (Y) Yes | (N) No: ')
+
+ if timeconfig == 'Y':
+
+ internettime = input(
+ 'Do you want to change the Time&Date Manual\n or do you want to transfer the actual SystemTime of the Raspberry Pi (S) Systemtime | (M) Manual:')
+ while not (internettime == 'S' or internettime == 'M'):
+ internettime = input(
+ 'Failed! Value not in Range - Please try again\nDo you want to change the Alarm-Configuration? (Y) Yes | (N) No: ')
+
+ if internettime == 'S':
+
+ print('-----------------------------------------')
+ print('TimeSync-Process | Please Wait')
+ print('-----------------------------------------')
+
+ serial_port.write(str.encode('Q'))
+ sleep(1)
+ serial_port.write(str.encode('\x0D'))
+ sleep(1)
+ serial_port.write(str.encode('date-rpi'))
+ sleep(0.1)
+ serial_port.write(str.encode('\x0D'))
+ data = serial_port.read(9999);
+ date = int(data)
+
+ strompi_year = date // 10000
+ strompi_month = date % 10000 // 100
+ strompi_day = date % 100
+
+ sleep(0.1)
+ serial_port.write(str.encode('time-rpi'))
+ sleep(0.1)
+ serial_port.write(str.encode('\x0D'))
+ data = serial_port.read(9999);
+ timevalue = int(data)
+
+ strompi_hour = timevalue // 10000
+ strompi_min = timevalue % 10000 // 100
+ strompi_sec = timevalue % 100
+
+ rpi_time = datetime.datetime.now().replace(microsecond=0)
+ strompi_time = datetime.datetime(2000 + strompi_year, strompi_month, strompi_day, strompi_hour, strompi_min,
+ strompi_sec, 0)
+
+ if rpi_time > strompi_time:
+ serial_port.write(str.encode('set-date %02d %02d %02d %02d' % (
+ int(rpi_time.strftime('%d')), int(rpi_time.strftime('%m')), int(rpi_time.strftime('%Y')) % 100,
+ int(rpi_time.isoweekday()))))
+ sleep(0.5)
+ serial_port.write(str.encode('\x0D'))
+ sleep(1)
+ serial_port.write(str.encode('set-clock %02d %02d %02d' % (
+ int(rpi_time.strftime('%H')), int(rpi_time.strftime('%M')), int(rpi_time.strftime('%S')))))
+ sleep(0.5)
+ serial_port.write(str.encode('\x0D'))
+
+ print ('-----------------------------------------')
+ print ('The date und time has been synced: Raspberry Pi -> StromPi')
+ print ('-----------------------------------------')
+
+
+ elif internettime == 'M':
+ print('\n--------------------------------------')
+ print('\nSetting the clock (hour, minute)\n')
+
+ setClockH = input('Hour (0-23): ')
+ while int(setClockH) < 0 or int(setClockH) > 23:
+ setClockH = input('Failed! Value not in Range - Please try again\nHour (0-23): ')
+
+ setClockM = input('Minute (0-59): ')
+ while int(setClockM) < 0 or int(setClockM) > 59:
+ setClockM = input('Failed! Value not in Range - Please try again\nMinute (0-59): ')
+
+ setClockS = '00'
+
+ # set-date
+ print('\n--------------------------------------')
+ print('\nSetting the date (day, month, year, weekday)\n')
+
+ setDateD = input('Day (1-31): ')
+ while int(setDateD) < 1 or int(setDateD) > 31:
+ setDateD = input('Failed! Value not in Range - Please try again\nDay (1-31): ')
+
+ setDateM = input('Month (1-12): ')
+ while int(setDateM) < 1 or int(setDateM) > 12:
+ setDateM = input('Failed! Value not in Range - Please try again\nMonth (1-12): ')
+
+ setDateY = input('Year (0-99): ')
+ while int(setDateY) < 0 or int(setDateY) > 99:
+ setDateY = input('Failed! Value not in Range - Please try again\nYear (0-99): ')
+
+ setDateWD = input(
+ 'Weekday (1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday): ')
+ while int(setDateWD) < 1 or int(setDateWD) > 7:
+ setDateWD = input(
+ 'Failed! Value not in Range - Please try again\nWeekday (1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday): ')
+
+ serial_port.write(str.encode('quit'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-date ' + setDateD + ' ' + setDateM + ' ' + setDateY + ' ' + setDateWD))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ print('\n\nSetting set-date...')
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-clock ' + setClockH + ' ' + setClockM + ' ' + setClockS))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ print('Setting set-clock...')
+ sleep(breakL)
+
+ print('\n---------------------------------------------------------------------------')
+ print(' Alarm-Configuration')
+ print('---------------------------------------------------------------------------')
+
+ print('[Actual Raspberry Pi Time&Date]')
+ if powerofftime_enabletest == "01":
+ print(' Alarm-Mode: Wakeup Timer')
+ else:
+ print(' Alarm-Mode: ' + alarm_mode_converter(int(sp3_alarm_mode)))
+ print(
+ ' Alarm-Time: ' + str(sp3_alarm_hour, 'utf-8').rstrip('\n').zfill(2) + ':' + str(sp3_alarm_min, 'utf-8').rstrip(
+ '\n').zfill(2))
+ print(' Alarm-Date: ' + str(sp3_alarm_day, 'utf-8').rstrip('\n').zfill(2) + '.' + str(sp3_alarm_month,
+ 'utf-8').rstrip(
+ '\n').zfill(2))
+ print(' WakeUp-Alarm: ' + weekday_converter(int(sp3_alarm_weekday)))
+ print(' ')
+ print('PowerOff-Alarm: ' + enabled_disabled_converter(int(sp3_alarmPoweroff)))
+ print(
+ ' PowerOff-Alarm-Time: ' + str(sp3_alarm_hour_off, 'utf-8').rstrip('\n').zfill(2) + ':' + str(sp3_alarm_min_off,
+ 'utf-8').rstrip(
+ '\n').zfill(2))
+ print(' ')
+ print('Interval-Alarm: ' + enabled_disabled_converter(int(sp3_intervalAlarm)))
+ print(' Interval-On-Time: ' + str(sp3_intervalAlarmOnTime, 'utf-8').rstrip('\n').zfill(2) + ' minutes')
+ print(' Interval-Off-Time: ' + str(sp3_intervalAlarmOffTime, 'utf-8').rstrip('\n').zfill(2) + ' minutes')
+ print(' ')
+
+ alarmconfig = '0'
+ alarmconfig = input('Do you want to change the Alarm-Configuration? (Y) Yes | (N) No:')
+ while not (alarmconfig == 'Y' or alarmconfig == 'N'):
+ alarmconfig = input(
+ 'Failed! Value not in Range - Please try again\nDo you want to change the Alarm-Configuration? (Y) Yes | (N) No: ')
+
+ if alarmconfig == 'Y':
+
+ print('\n----------------------------------------------')
+ print(' Power-Off Alarm Configuration')
+ print('-----------------------------------------------')
+
+ alarmconfig = '0'
+ alarmconfig = input('Do you want to change the Power-Off Alarm-Configuration? (Y) Yes | (N) No:')
+ while not (alarmconfig == 'Y' or alarmconfig == 'N'):
+ alarmconfig = input(
+ 'Failed! Value not in Range - Please try again\nDo you want to change the Alarm-Configuration? (Y) Yes | (N) No: ')
+
+ if alarmconfig == 'Y':
+ # poweroff-enable & poweroff-set-time
+ print('\n--------------------------------------')
+ print('Enabling or disabling poweroff (0 = disable, 1 = enable)\n')
+
+ sp3_alarmPoweroff = input('Poweroff status (0 - 1): ')
+ while int(sp3_alarmPoweroff) < 0 or int(sp3_alarmPoweroff) > 1:
+ sp3_alarmPoweroff = input('Failed! Value not in Range - Please try again\nPoweroff status (0 - 1): ')
+
+ if int(sp3_alarmPoweroff) == 1:
+ print('\n--------------------------------------')
+ print('Setting poweroff time (hour, minute)\n')
+
+ sp3_alarm_hour_off = input('Hour (0 - 23): ')
+ while int(sp3_alarm_hour_off) < 0 or int(sp3_alarm_hour_off) > 23:
+ sp3_alarm_hour_off = input('Failed! Value not in Range - Please try again\nHour (0 - 23): ')
+
+ sp3_alarm_min_off = input('Minute (0 - 59): ')
+ while int(sp3_alarm_min_off) < 0 or int(sp3_alarm_min_off) > 59:
+ sp3_alarm_min_off = input('Failed! Value not in Range - Please try again\nMinute (0 - 59): ')
+
+ print('\n---------------------------------------------------------------------------')
+ print(' Wake-Up Alarm-Configuration')
+ print('---------------------------------------------------------------------------')
+
+ alarmconfig = '0'
+ alarmconfig = input('Do you want to change the Wake-Up Alarm-Configuration? (Y) Yes | (N) No:')
+ while not (alarmconfig == 'Y' or alarmconfig == 'N'):
+ alarmconfig = input(
+ 'Failed! Value not in Range - Please try again\nDo you want to change the Alarm-Configuration? (Y) Yes | (N) No: ')
+
+ if alarmconfig == 'Y':
+ print('\n--------------------------------------')
+ # alarm-enable & alarm-mode
+ print('\nEnabling or disabling wake up alarm (0 = disable, 1 = enable)\n')
+
+ sp3_alarm_enable = input('Wake up alarm status (0 - 1): ')
+ while int(sp3_alarm_enable) < 0 or int(sp3_alarm_enable) > 1:
+ sp3_alarm_enable = input(
+ 'Failed! Value not in Range - Please try again\nWake up alarm status (0 - 1): ')
+
+ if int(sp3_alarm_enable) == 1:
+ print('\n--------------------------------------')
+ print('Setting the wake up alarm mode (1 = Time-Alarm , 2 = Date-Alarm, 3 = Weekday-Alarm, 4 = Wakeup Timer)\n')
+
+ sp3_alarm_mode = input('Wake up alarm mode (1 - 4): ')
+ while int(sp3_alarm_mode) < 1 or int(sp3_alarm_mode) > 4:
+ sp3_alarm_mode = input('Failed! Value not in Range - Please try again\nWake up alarm mode (1 - 4): ')
+ if int(sp3_alarm_mode) == 4:
+ print('\n--------------------------------------')
+ print('Set the wake up Timer\n')
+
+ sp3_poweroff_time = input('Wake up Timer (1-65535): ')
+ while int(sp3_poweroff_time) < 1 or int(sp3_poweroff_time) > 65535:
+ sp3_poweroff_time = input('Failed! Value not in Range - Please try again\nWake up Timer (1-65535): ')
+
+ # Wake up alarm time
+ if int(sp3_alarm_mode) == 1:
+ print('\n--------------------------------------')
+ print('Setting the wake up alarm time (hours, minutes)\n')
+
+ sp3_alarm_hour = input('Hours (0-23): ')
+ while int(sp3_alarm_hour) < 0 or int(sp3_alarm_hour) > 23:
+ sp3_alarm_hour = input('Failed! Value not in Range - Please try again\nHours (0-23): ')
+
+ sp3_alarm_min = input('Minutes (0-59): ')
+ while int(sp3_alarm_min) < 0 or int(sp3_alarm_min) > 59:
+ sp3_alarm_min = input('Failed! Value not in Range - Please try again\nHours (0-59): ')
+
+ sp3_wakeupweekend_enable = input('Wakeup Weekend mode (0-1): ')
+ while int(sp3_wakeupweekend_enable) < 0 or int(sp3_wakeupweekend_enable) > 1:
+ sp3_wakeupweekend_enable = input('Failed! Value not in Range - Please try again\nDisable Enable (0 - 1): ')
+ # Wake up alarm date
+ elif int(sp3_alarm_mode) == 2:
+ print('\n--------------------------------------')
+ print('Setting the wake up alarm date (day, month)\n')
+
+ sp3_alarm_day = input('Day (1-31): ')
+ while int(sp3_alarm_day) < 1 or int(sp3_alarm_day) > 31:
+ sp3_alarm_day = input('Failed! Value not in Range - Please try again\nDay (1-31): ')
+
+ sp3_alarm_month = input('Month (1-12): ')
+ while int(sp3_alarm_month) < 1 or int(sp3_alarm_month) > 12:
+ sp3_alarm_month = input('Failed! Value not in Range - Please try again\nMonth (1-12): ')
+
+ else:
+ print('\n--------------------------------------')
+ print(
+ 'Setting the wake up alarm date (1 = Monday, 2 = Tuesday, 3 = Wednesday, 4 = Thursday, 5 = Friday, 6 = Saturday, 7 = Sunday)\n')
+
+ sp3_alarm_weekday = input('Weekday (1 - 7): ')
+ while int(sp3_alarm_weekday) < 1 or int(sp3_alarm_weekday) > 7:
+ sp3_alarm_weekday = input('Failed! Value not in Range - Please try again\nWeekday (1 - 7): ')
+
+ print('\n----------------------------------------------')
+ print(' Interval-Alarm Configuration')
+ print('-----------------------------------------------')
+
+ alarmconfig = '0'
+ alarmconfig = input('Do you want to change the Interval-Alarm-Configuration? (Y) Yes | (N) No:')
+ while not (alarmconfig == 'Y' or alarmconfig == 'N'):
+ alarmconfig = input(
+ 'Failed! Value not in Range - Please try again\nDo you want to change the Alarm-Configuration? (Y) Yes | (N) No: ')
+
+ if alarmconfig == 'Y':
+ # poweroff-enable & poweroff-set-time
+ print('\n--------------------------------------')
+ print('\nEnabling or disabling the Interval-Alarm (0 = disable, 1 = enable)\n')
+
+ sp3_intervalAlarm = input('Interval-Alarm status (0 - 1): ')
+ while int(sp3_intervalAlarm) < 0 or int(sp3_intervalAlarm) > 1:
+ sp3_intervalAlarm = input(
+ 'Failed! Value not in Range - Please try again\nInterval-Alarm status (0 - 1): ')
+
+ if int(sp3_intervalAlarm) == 1:
+ print('\n--------------------------------------')
+ print('\nSetting Interval-Time Settings\n')
+
+ sp3_intervalAlarmOnTime = input('Interval On-Time in minutes (1-65535): ')
+ while int(sp3_intervalAlarmOnTime) < 1 or int(sp3_intervalAlarmOnTime) > 65535:
+ sp3_intervalAlarmOnTime = input(
+ 'Failed! Value not in Range - Please try again\nInterval On-Time in minutes (1-65535): ')
+
+ sp3_intervalAlarmOffTime = input('Interval Off-Time in minutes (1-65535): ')
+ while int(sp3_intervalAlarmOffTime) < 0 or int(sp3_intervalAlarmOffTime) > 65535:
+ sp3_intervalAlarmOffTime = input(
+ 'Failed! Value not in Range - Please try again\nInterval Off-Time in minutes (1-65535): ')
+
+
+#######################################################################################################################
+
+ print('\n----------------------------------------------')
+ print(' Configuration Successful')
+ print(' Transfer new Configuration to the StromPi 3')
+ print(' \n###Please Wait###')
+ print('-----------------------------------------------')
+
+ breakS = 0.1
+ breakL = 0.2
+
+
+ if type(sp3_modus) == str:
+ serial_port.write(str.encode('set-config ' + '1 ' + sp3_modus))
+ else:
+ serial_port.write(str.encode('set-config ' + '1 ' + sp3_modus.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if sp3_alarm_mode == "1":
+ serial_port.write(str.encode('set-config ' + '2 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ elif sp3_alarm_mode == "2":
+ serial_port.write(str.encode('set-config ' + '2 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ elif sp3_alarm_mode == "3":
+ serial_port.write(str.encode('set-config ' + '2 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ elif sp3_alarm_mode == "4":
+ serial_port.write(str.encode('set-config ' + '2 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+
+ if type(sp3_alarmPoweroff) == str:
+ serial_port.write(str.encode('set-config ' + '5 ' + sp3_alarmPoweroff))
+ else:
+ serial_port.write(str.encode('set-config ' + '5 ' + sp3_alarmPoweroff.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_min) == str:
+ serial_port.write(str.encode('set-config ' + '6 ' + sp3_alarm_min))
+ else:
+ serial_port.write(str.encode('set-config ' + '6 ' + sp3_alarm_min.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_hour) == str:
+ serial_port.write(str.encode('set-config ' + '7 ' + sp3_alarm_hour))
+ else:
+ serial_port.write(str.encode('set-config ' + '7 ' + sp3_alarm_hour.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_min_off) == str:
+ serial_port.write(str.encode('set-config ' + '8 ' + sp3_alarm_min_off))
+ else:
+ serial_port.write(str.encode('set-config ' + '8 ' + sp3_alarm_min_off.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_hour_off) == str:
+ serial_port.write(str.encode('set-config ' + '9 ' + sp3_alarm_hour_off))
+ else:
+ serial_port.write(str.encode('set-config ' + '9 ' + sp3_alarm_hour_off.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_day) == str:
+ serial_port.write(str.encode('set-config ' + '10 ' + sp3_alarm_day))
+ else:
+ serial_port.write(str.encode('set-config ' + '10 ' + sp3_alarm_day.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_month) == str:
+ serial_port.write(str.encode('set-config ' + '11 ' + sp3_alarm_month))
+ else:
+ serial_port.write(str.encode('set-config ' + '11 ' + sp3_alarm_month.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_weekday) == str:
+ serial_port.write(str.encode('set-config ' + '12 ' + sp3_alarm_weekday))
+ else:
+ serial_port.write(str.encode('set-config ' + '12 ' + sp3_alarm_weekday.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_alarm_enable) == str:
+ serial_port.write(str.encode('set-config ' + '13 ' + sp3_alarm_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '13 ' + sp3_alarm_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_shutdown_enable) == str:
+ serial_port.write(str.encode('set-config ' + '14 ' + sp3_shutdown_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '14 ' + sp3_shutdown_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_shutdown_time) == str:
+ serial_port.write(str.encode('set-config ' + '15 ' + sp3_shutdown_time))
+ else:
+ serial_port.write(str.encode('set-config ' + '15 ' + sp3_shutdown_time.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_warning_enable) == str:
+ serial_port.write(str.encode('set-config ' + '16 ' + sp3_warning_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '16 ' + sp3_warning_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_serialLessMode) == str:
+ serial_port.write(str.encode('set-config ' + '17 ' + sp3_serialLessMode))
+ else:
+ serial_port.write(str.encode('set-config ' + '17 ' + sp3_serialLessMode.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_batLevel_shutdown) == str:
+ serial_port.write(str.encode('set-config ' + '18 ' + sp3_batLevel_shutdown))
+ else:
+ serial_port.write(str.encode('set-config ' + '18 ' + sp3_batLevel_shutdown.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_intervalAlarm) == str:
+ serial_port.write(str.encode('set-config ' + '19 ' + sp3_intervalAlarm))
+ else:
+ serial_port.write(str.encode('set-config ' + '19 ' + sp3_intervalAlarm.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_intervalAlarmOnTime) == str:
+ serial_port.write(str.encode('set-config ' + '20 ' + sp3_intervalAlarmOnTime))
+ else:
+ serial_port.write(str.encode('set-config ' + '20 ' + sp3_intervalAlarmOnTime.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_intervalAlarmOffTime) == str:
+ serial_port.write(str.encode('set-config ' + '21 ' + sp3_intervalAlarmOffTime))
+ else:
+ serial_port.write(str.encode('set-config ' + '21 ' + sp3_intervalAlarmOffTime.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_powerOnButton_enable) == str:
+ serial_port.write(str.encode('set-config ' + '22 ' + sp3_powerOnButton_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '22 ' + sp3_powerOnButton_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_powerOnButton_time) == str:
+ serial_port.write(str.encode('set-config ' + '23 ' + sp3_powerOnButton_time))
+ else:
+ serial_port.write(str.encode('set-config ' + '23 ' + sp3_powerOnButton_time.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_powersave_enable) == str:
+ serial_port.write(str.encode('set-config ' + '24 ' + sp3_powersave_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '24 ' + sp3_powersave_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_poweroffMode) == str:
+ serial_port.write(str.encode('set-config ' + '25 ' + sp3_poweroffMode))
+ else:
+ serial_port.write(str.encode('set-config ' + '25 ' + sp3_poweroffMode.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_poweroff_time) == str:
+ serial_port.write(str.encode('set-config ' + '27 ' + sp3_poweroff_time))
+ else:
+ serial_port.write(str.encode('set-config ' + '27 ' + sp3_poweroff_time.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if type(sp3_wakeupweekend_enable) == str:
+ serial_port.write(str.encode('set-config ' + '28 ' + sp3_wakeupweekend_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '28 ' + sp3_wakeupweekend_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if modusreset == 1:
+ serial_port.write(str.encode('set-config ' + '0 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+
+ elif modusreset != 1:
+ serial_port.write(str.encode('set-config ' + '0 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ print('\n----------------------------------------------')
+ print(' Transfer Successful')
+ print('-----------------------------------------------')
+
+ serial_port.write(str.encode('status-rpi'))
+ sleep(0.1)
+ serial_port.write(str.encode('\x0D'))
+ sp3_time = serial_port.readline(9999);
+ sp3_date = serial_port.readline(9999);
+ sp3_weekday = serial_port.readline(9999);
+ sp3_modus = serial_port.readline(9999);
+ sp3_alarm_enable = serial_port.readline(9999);
+ sp3_alarm_mode = serial_port.readline(9999);
+ sp3_alarm_hour = serial_port.readline(9999);
+ sp3_alarm_min = serial_port.readline(9999);
+ sp3_alarm_day = serial_port.readline(9999);
+ sp3_alarm_month = serial_port.readline(9999);
+ sp3_alarm_weekday = serial_port.readline(9999);
+ sp3_alarmPoweroff = serial_port.readline(9999);
+ sp3_alarm_hour_off = serial_port.readline(9999);
+ sp3_alarm_min_off = serial_port.readline(9999);
+ sp3_shutdown_enable = serial_port.readline(9999);
+ sp3_shutdown_time = serial_port.readline(9999);
+ sp3_warning_enable = serial_port.readline(9999);
+ sp3_serialLessMode = serial_port.readline(9999);
+ sp3_intervalAlarm = serial_port.readline(9999);
+ sp3_intervalAlarmOnTime = serial_port.readline(9999);
+ sp3_intervalAlarmOffTime = serial_port.readline(9999);
+ sp3_batLevel_shutdown = serial_port.readline(9999);
+ sp3_batLevel = serial_port.readline(9999);
+ sp3_charging = serial_port.readline(9999);
+ sp3_powerOnButton_enable = serial_port.readline(9999);
+ sp3_powerOnButton_time = serial_port.readline(9999);
+ sp3_powersave_enable = serial_port.readline(9999);
+ sp3_poweroffMode = serial_port.readline(9999);
+ sp3_poweroff_time_enable = serial_port.readline(9999);
+ sp3_poweroff_time = serial_port.readline(9999);
+ sp3_wakeupweekend_enable = serial_port.readline(9999);
+ sp3_ADC_Wide = float(serial_port.readline(9999))/1000;
+ sp3_ADC_BAT = float(serial_port.readline(9999))/1000;
+ sp3_ADC_USB = float(serial_port.readline(9999))/1000;
+ sp3_ADC_OUTPUT = float(serial_port.readline(9999))/1000;
+ sp3_output_status = serial_port.readline(9999);
+ sp3_powerfailure_counter = serial_port.readline(9999);
+ sp3_firmwareVersion = serial_port.readline(9999);
+ powerofftime_enabletest = (str(sp3_poweroff_time_enable, 'utf-8').rstrip('\n').zfill(2))
+
+ date = int(sp3_date)
+
+ strompi_year = int(sp3_date) // 10000
+ strompi_month = int(sp3_date) % 10000 // 100
+ strompi_day = int(sp3_date) % 100
+
+ strompi_hour = int(sp3_time) // 10000
+ strompi_min = int(sp3_time) % 10000 // 100
+ strompi_sec = int(sp3_time) % 100
+
+ if sp3_ADC_Wide > wide_range_volt_min:
+ wide_range_volt = str(sp3_ADC_Wide) + 'V'
+ else:
+ wide_range_volt = ' not connected'
+
+ if sp3_ADC_BAT > battery_volt_min:
+ battery_volt = str(sp3_ADC_BAT) + 'V' + batterylevel_converter(int(sp3_batLevel),int(sp3_charging))
+ else:
+ battery_volt = ' not connected'
+
+ if sp3_ADC_USB > mUSB_volt_min:
+ microUSB_volt = str(sp3_ADC_USB) + 'V'
+ else:
+ microUSB_volt = ' not connected'
+
+ output_volt = str(sp3_ADC_OUTPUT) + 'V'
+
+ print(' ')
+ print('---------------------------------')
+ print('StromPi-Status:')
+ print('---------------------------------')
+ print('Time: ' + str(strompi_hour).zfill(2) + ':' + str(strompi_min).zfill(2) + ':' + str(strompi_sec).zfill(2))
+ print('Date: ' + weekday_converter(int(sp3_weekday)) + ' ' + str(strompi_day).zfill(2) + '.' + str(strompi_month).zfill(2) + '.' + str(strompi_year).zfill(2))
+ print(' ')
+ print('StromPi-Output: ' + output_status_converter((int(sp3_output_status))))
+ print(' ')
+ print('StromPi-Mode: ' + strompi_mode_converter((int(sp3_modus))))
+ print(' ')
+ print('Raspberry Pi Shutdown: ' + enabled_disabled_converter(int(sp3_shutdown_enable)))
+ print(' Shutdown-Timer: ' + str(sp3_shutdown_time, 'utf-8').rstrip('\n').zfill(2) + ' seconds')
+ print(' ')
+ print('Powerfail Warning: ' + enabled_disabled_converter(int(sp3_warning_enable)))
+ print(' ')
+ print('Serial-Less Mode: ' + enabled_disabled_converter(int(sp3_serialLessMode)))
+ print(' ')
+ print('Power Save Mode: ' + enabled_disabled_converter(int(sp3_powersave_enable)))
+ print(' ')
+ print('PowerOn-Button: ' + enabled_disabled_converter(int(sp3_powerOnButton_enable)))
+ print(' PowerOn-Button-Timer: ' + str(sp3_powerOnButton_time, 'utf-8').rstrip('\n').zfill(2) + ' seconds')
+ print(' ')
+ print('Poweroff Mode: ' + enabled_disabled_converter(int(sp3_poweroffMode)))
+ print(' ')
+ print('Battery-Level Shutdown: ' + batterylevel_shutdown_converter(int(sp3_batLevel_shutdown)))
+ print(' ')
+ print('Powerfail-Counter: ' + str(sp3_powerfailure_counter, 'utf-8').rstrip('\n'))
+ print(' ')
+ print('---------------------------------')
+ print('Alarm-Configuration:')
+ print('---------------------------------')
+ print('WakeUp-Alarm: ' + enabled_disabled_converter(int(sp3_alarm_enable)))
+ if powerofftime_enabletest == "01":
+ print(' Alarm-Mode: Wakeup Timer')
+ else:
+ print(' Alarm-Mode: ' + alarm_mode_converter(int(sp3_alarm_mode)))
+ print(' Alarm-Time: ' + str(sp3_alarm_hour, 'utf-8').rstrip('\n').zfill(2) + ':' + str(sp3_alarm_min, 'utf-8').rstrip('\n').zfill(2))
+ print(' Alarm-Date: ' + str(sp3_alarm_day, 'utf-8').rstrip('\n').zfill(2) + '.' + str(sp3_alarm_month, 'utf-8').rstrip('\n').zfill(2))
+ print(' WakeUp-Alarm: ' + weekday_converter(int(sp3_alarm_weekday)))
+ print(' ')
+ print('PowerOff-Alarm: ' + enabled_disabled_converter(int(sp3_alarmPoweroff)))
+ print(' PowerOff-Alarm-Time: ' + str(sp3_alarm_hour_off, 'utf-8').rstrip('\n').zfill(2) + ':' + str(sp3_alarm_min_off, 'utf-8').rstrip('\n').zfill(2))
+ print(' ')
+ print('Interval-Alarm: ' + enabled_disabled_converter(int(sp3_intervalAlarm)))
+ print(' Interval-On-Time: ' + str(sp3_intervalAlarmOnTime, 'utf-8').rstrip('\n').zfill(2) + ' minutes')
+ print(' Interval-Off-Time: ' + str(sp3_intervalAlarmOffTime, 'utf-8').rstrip('\n').zfill(2) + ' minutes')
+ print(' ')
+ print('---------------------------------')
+ print('Voltage-Levels:')
+ print('---------------------------------')
+ print('Wide-Range-Inputvoltage: ' + wide_range_volt)
+ print('LifePo4-Batteryvoltage: ' + battery_volt)
+ print('microUSB-Inputvoltage: ' + microUSB_volt)
+ print('Output-Voltage: ' + output_volt)
+ print(' ')
+
+except KeyboardInterrupt:
+ print('interrupted!')
+
+serial_port.close()
\ No newline at end of file
diff --git a/StromPi3/strompi_config_gui.py b/StromPi3/strompi_config_gui.py
new file mode 100644
index 0000000..413d1b1
--- /dev/null
+++ b/StromPi3/strompi_config_gui.py
@@ -0,0 +1,1378 @@
+#!/usr/bin/env python3
+
+import serial
+from time import sleep
+import datetime
+import os
+import sys
+import time
+from time import sleep
+import tkinter as tk
+from tkinter import *
+from tkinter import ttk
+from PIL import ImageTk, Image
+import functools
+fp = functools.partial
+#need sudo apt-get install python3-pil python3-pil.imagetk
+
+wide_range_volt_min = 4.8
+battery_volt_min = 0.5
+mUSB_volt_min = 4.1
+TimeSynctmp = 0
+
+
+
+breakS = 0.1
+breakL = 0.5
+
+serial_port = serial.Serial()
+serial_port.baudrate = 38400
+serial_port.port = '/dev/serial0'
+serial_port.timeout = 1
+serial_port.bytesize = 8
+serial_port.stopbits = 1
+serial_port.parity = serial.PARITY_NONE
+
+Alarm_Powerofffailmin = 0
+Alarm_Powerofffailhour = 0
+
+def enabled_disabled_converter(argument):
+ switcher = {
+ 0: 'Disabled',
+ 1: 'Enabled',
+ }
+ return switcher.get(argument, 'nothing')
+
+def weekday_converter(argument):
+ switcher = {
+ 1: 'Monday',
+ 2: 'Tuesday',
+ 3: 'Wednesday',
+ 4: 'Thursday',
+ 5: 'Friday',
+ 6: 'Saturday',
+ 7: 'Sunday',
+ }
+ return switcher.get(argument, 'nothing')
+
+def strompi_mode_converter(argument):
+ switcher = {
+ 1: 'mUSB -> Wide',
+ 2: 'Wide -> mUSB',
+ 3: 'mUSB -> Battery',
+ 4: 'Wide -> Battery',
+ 5: "mUSB -> Wide -> Battery",
+ 6: "Wide -> mUSB -> Battery",
+ }
+ return switcher.get(argument, 'nothing')
+
+def alarm_mode_converter(argument):
+ switcher = {
+ 1: 'Time-Alarm',
+ 2: 'Date-Alarm',
+ 3: 'Weekday-Alarm',
+ 4: 'Minute Wakeup-Alarm',
+ }
+ return switcher.get(argument, 'nothing')
+
+def batterylevel_shutdown_converter(argument):
+ switcher = {
+ 0: 'Disabled',
+ 1: '10%',
+ 2: '25%',
+ 3: '50%',
+ }
+ return switcher.get(argument, 'nothing')
+
+def output_status_converter(argument):
+ switcher = {
+ 0: 'Power-Off', #only for Debugging-Purposes
+ 1: 'mUSB',
+ 2: 'Wide',
+ 3: 'Battery',
+ }
+ return switcher.get(argument, 'nothing')
+
+def batterylevel_converter(batterylevel,charging):
+
+ if charging:
+ switcher = {
+ 1: ' [10%] [charging]',
+ 2: ' [25%] [charging]',
+ 3: ' [50%] [charging]',
+ 4: ' [100%] [charging]',
+ }
+ return switcher.get(batterylevel, 'nothing')
+ else:
+ switcher = {
+ 1: ' [10%]',
+ 2: ' [25%]',
+ 3: ' [50%]',
+ 4: ' [100%]',
+ }
+ return switcher.get(batterylevel, 'nothing')
+
+def Set_Alarm_Mode(sp3_alarm_mode):
+ if sp3_alarm_mode == "1":
+ serial_port.write(str.encode('set-config ' + '2 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ elif sp3_alarm_mode == "2":
+ serial_port.write(str.encode('set-config ' + '2 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ elif sp3_alarm_mode == "3":
+ serial_port.write(str.encode('set-config ' + '2 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if sp3_alarm_mode == "4":
+ serial_port.write(str.encode('set-config ' + '2 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '3 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '4 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-config ' + '26 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Warning_enable(sp3_warning_enable):
+ if (sp3_warning_enable == "1") or (sp3_warning_enable == "0"):
+ if type(sp3_warning_enable) == str:
+ serial_port.write(str.encode('set-config ' + '16 ' + sp3_warning_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '16 ' + sp3_warning_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_PoweroffMode(sp3_poweroffMode):
+ if (sp3_poweroffMode == "1") or (sp3_poweroffMode == "0"):
+ if type(sp3_poweroffMode) == str:
+ serial_port.write(str.encode('set-config ' + '25 ' + sp3_poweroffMode))
+ else:
+ serial_port.write(str.encode('set-config ' + '25 ' + sp3_poweroffMode.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_wakeupweekend_enable(sp3_wakeupweekend_enable):
+ if (sp3_wakeupweekend_enable == "1") or (sp3_wakeupweekend_enable == "0"):
+ if type(sp3_wakeupweekend_enable) == str:
+ serial_port.write(str.encode('set-config ' + '28 ' + sp3_wakeupweekend_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '28 ' + sp3_wakeupweekend_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Shutdown_enable(sp3_shutdown_enable):
+ if (sp3_shutdown_enable == "1") or (sp3_shutdown_enable == "0"):
+ if type(sp3_shutdown_enable) == str:
+ serial_port.write(str.encode('set-config ' + '14 ' + sp3_shutdown_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '14 ' + sp3_shutdown_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Batlevel_Shutdown(sp3_batLevel_shutdown):
+ if (sp3_batLevel_shutdown == "1") or (sp3_batLevel_shutdown == "0") or (sp3_batLevel_shutdown == "2") or (sp3_batLevel_shutdown == "3"):
+ if type(sp3_batLevel_shutdown) == str:
+ serial_port.write(str.encode('set-config ' + '18 ' + sp3_batLevel_shutdown))
+ else:
+ serial_port.write(str.encode('set-config ' + '18 ' + sp3_batLevel_shutdown.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Serialless_mode(sp3_serialLessMode):
+ if (sp3_serialLessMode == "1") or (sp3_serialLessMode == "0"):
+ if type(sp3_serialLessMode) == str:
+ serial_port.write(str.encode('set-config ' + '17 ' + sp3_serialLessMode))
+ else:
+ serial_port.write(str.encode('set-config ' + '17 ' + sp3_serialLessMode.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_PoweronButton(sp3_powerOnButton_enable):
+ if (sp3_powerOnButton_enable == "1") or (sp3_powerOnButton_enable == "0"):
+ if type(sp3_powerOnButton_enable) == str:
+ serial_port.write(str.encode('set-config ' + '22 ' + sp3_powerOnButton_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '22 ' + sp3_powerOnButton_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Use_Modusreset(modusreset):
+ if modusreset == 1:
+ serial_port.write(str.encode('set-config ' + '0 1'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+
+ elif modusreset != 1:
+ serial_port.write(str.encode('set-config ' + '0 0'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_WakeUpAlarm(sp3_alarm_enable):
+ if (sp3_alarm_enable == "1") or (sp3_alarm_enable == "0"):
+ if type(sp3_alarm_enable) == str:
+ serial_port.write(str.encode('set-config ' + '13 ' + sp3_alarm_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '13 ' + sp3_alarm_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Intervalmode(sp3_intervalAlarm):
+ if (sp3_intervalAlarm == "1") or (sp3_intervalAlarm == "0"):
+ if type(sp3_intervalAlarm) == str:
+ serial_port.write(str.encode('set-config ' + '19 ' + sp3_intervalAlarm))
+ else:
+ serial_port.write(str.encode('set-config ' + '19 ' + sp3_intervalAlarm.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_Poweroff(sp3_alarmPoweroff):
+ if (sp3_alarmPoweroff == "1") or (sp3_alarmPoweroff == "0"):
+ if type(sp3_alarmPoweroff) == str:
+ serial_port.write(str.encode('set-config ' + '5 ' + sp3_alarmPoweroff))
+ else:
+ serial_port.write(str.encode('set-config ' + '5 ' + sp3_alarmPoweroff.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_min(sp3_alarm_min, Alarm_Powerofffailmin):
+ sp3_alarm_min = ''.join([i for i in sp3_alarm_min if i.isdigit()])
+ if sp3_alarm_min.isdigit():
+ sp3_alarm_minint = int(sp3_alarm_min)
+ if (sp3_alarm_minint < 61) and (sp3_alarm_minint >= 0):
+ serial_port.write(str.encode('set-config ' + '8 ' + sp3_alarm_min))
+ else:
+ Alarm_Powerofffailmin = 1
+ else:
+ Alarm_Powerofffailmin = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_hour(sp3_alarm_hour):
+ sp3_alarm_hour = ''.join([i for i in sp3_alarm_hour if i.isdigit()])
+ if sp3_alarm_hour.isdigit():
+ sp3_alarm_hourint = int(sp3_alarm_hour)
+ if (sp3_alarm_hourint < 25) and (sp3_alarm_hourint >= 0):
+ serial_port.write(str.encode('set-config ' + '9 ' + sp3_alarm_hour))
+ else:
+ Alarm_Powerofffailhour = 1
+ else:
+ Alarm_Powerofffailhour = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_hour_off(sp3_alarm_hour_off):
+ sp3_alarm_hour_off = ''.join([i for i in sp3_alarm_hour_off if i.isdigit()])
+ if sp3_alarm_hour_off.isdigit():
+ sp3_alarm_hour_off2 = int(sp3_alarm_hour_off)
+ if (sp3_alarm_hour_off2 < 61) and (sp3_alarm_hour_off2 >= 0):
+ serial_port.write(str.encode('set-config ' + '7 ' + str(sp3_alarm_hour_off)))
+ else:
+ ShutdownTimeError = 1 #("You can only use Digits between 0 and 65535 for the shutdown timer")
+ else:
+ ShutdownTimeError = 1 #("You can only use Digits between 0 and 65535 for the shutdown timer")
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_min_off(sp3_alarm_min_off):
+ sp3_alarm_min_off = ''.join([i for i in sp3_alarm_min_off if i.isdigit()])
+ if sp3_alarm_min_off.isdigit():
+ sp3_alarm_min_off2 = int(sp3_alarm_min_off)
+ if (sp3_alarm_min_off2 < 61) and (sp3_alarm_min_off2 >= 0):
+ serial_port.write(str.encode('set-config ' + '6 ' + str(sp3_alarm_min_off)))
+ else:
+ ShutdownTimeError = 1 #("You can only use Digits between 0 and 65535 for the shutdown timer")
+ else:
+ ShutdownTimeError = 1 #("You can only use Digits between 0 and 65535 for the shutdown timer")
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_Day(sp3_alarm_day):
+ sp3_alarm_day = ''.join([i for i in sp3_alarm_day if i.isdigit()])
+ if sp3_alarm_day.isdigit():
+ sp3_alarm_dayint = int(sp3_alarm_day)
+ if (sp3_alarm_dayint <= 31) and (sp3_alarm_dayint >= 0):
+ serial_port.write(str.encode('set-config ' + '10 ' + sp3_alarm_day))
+ else:
+ Alarm_Dayerror = 1
+ else:
+ Alarm_Dayerror = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_Alarm_Weekday(sp3_alarm_weekday):
+ if sp3_alarm_weekday.isdigit():
+ serial_port.write(str.encode('set-config ' + '12 ' + sp3_alarm_weekday))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_IntervalAlarmOffTime(sp3_intervalAlarmOffTime): #21
+ sp3_intervalAlarmOffTime = ''.join([i for i in sp3_intervalAlarmOffTime if i.isdigit()])
+ if sp3_intervalAlarmOffTime.isdigit():
+ sp3_intervalAlarmOffTimeint = int(sp3_intervalAlarmOffTime)
+ if (sp3_intervalAlarmOffTimeint < 65535) and (sp3_intervalAlarmOffTimeint > 0):
+ serial_port.write(str.encode('set-config ' + '21 ' + str(sp3_intervalAlarmOffTime)))
+ else:
+ IntervalOffTimeError = 1
+ else:
+ IntervalOffTimeError = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_IntervalAlarmOnTime(sp3_intervalAlarmOnTime): #20
+ sp3_intervalAlarmOnTime = ''.join([i for i in sp3_intervalAlarmOnTime if i.isdigit()])
+ if sp3_intervalAlarmOnTime.isdigit():
+ sp3_intervalAlarmOnTimeint = int(sp3_intervalAlarmOnTime)
+ if (sp3_intervalAlarmOnTimeint < 65535) and (sp3_intervalAlarmOnTimeint > 0):
+ serial_port.write(str.encode('set-config ' + '20 ' + str(sp3_intervalAlarmOnTime)))
+ else:
+ IntervalOnTimeError = 1
+ else:
+ IntervalOnTimeError = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_RTC():
+ serial_port.write(str.encode('Q'))
+ sleep(1)
+ serial_port.write(str.encode('\x0D'))
+ sleep(1)
+ serial_port.write(str.encode('date-rpi'))
+ sleep(0.1)
+ serial_port.write(str.encode('\x0D'))
+ data = serial_port.read(9999);
+ date = int(data)
+ strompi_year = date // 10000
+ strompi_month = date % 10000 // 100
+ strompi_day = date % 100
+ sleep(0.1)
+ serial_port.write(str.encode('time-rpi'))
+ sleep(0.1)
+ serial_port.write(str.encode('\x0D'))
+ data = serial_port.read(9999);
+ timevalue = int(data)
+ strompi_hour = timevalue // 10000
+ strompi_min = timevalue % 10000 // 100
+ strompi_sec = timevalue % 100
+ rpi_time = datetime.datetime.now().replace(microsecond=0)
+ strompi_time = datetime.datetime(2000 + strompi_year, strompi_month, strompi_day, strompi_hour, strompi_min,strompi_sec, 0)
+ if rpi_time > strompi_time:
+ serial_port.write(str.encode('set-date %02d %02d %02d %02d' % (
+ int(rpi_time.strftime('%d')), int(rpi_time.strftime('%m')), int(rpi_time.strftime('%Y')) % 100,
+ int(rpi_time.isoweekday()))))
+ sleep(0.5)
+ serial_port.write(str.encode('\x0D'))
+ sleep(1)
+ serial_port.write(str.encode('set-clock %02d %02d %02d' % (
+ int(rpi_time.strftime('%H')), int(rpi_time.strftime('%M')), int(rpi_time.strftime('%S')))))
+ sleep(0.5)
+ serial_port.write(str.encode('\x0D'))
+
+def Set_RTC_Manual(SetClockHstr, SetClockMstr, SetDateDstr, SetDateM, SetDateWD, SetDateYstr):
+ SetDateWDstr = str(SetDateWD)
+ SetDateMstr = ''.join([i for i in SetDateM if i.isdigit()])
+ SetClockHstr = ''.join([i for i in SetClockHstr if i.isdigit()])
+ SetClockMstr = ''.join([i for i in SetClockMstr if i.isdigit()])
+ SetDateDstr = ''.join([i for i in SetDateDstr if i.isdigit()])
+ SetDateYstr = ''.join([i for i in SetDateYstr if i.isdigit()])
+ if (SetDateWDstr == "1 = Monday") or (SetDateWDstr == "Monday"):
+ SetDateWDstr = "1"
+ if (SetDateWDstr == "2 = Tuesday") or (SetDateWDstr == "Tuesday"):
+ SetDateWDstr = "2"
+ if (SetDateWDstr == "3 = Wednesday") or (SetDateWDstr == "Wednesday"):
+ SetDateWDstr = "3"
+ if (SetDateWDstr == "4 = Thursday") or (SetDateWDstr == "Thursday"):
+ SetDateWDstr = "4"
+ if (SetDateWDstr == "5 = Friday") or (SetDateWDstr == "Friday"):
+ SetDateWDstr = "5"
+ if (SetDateWDstr == "6 = Saturday") or (SetDateWDstr == "Saturday"):
+ SetDateWDstr = "6"
+ if (SetDateWDstr == "7 = Sunday") or (SetDateWDstr == "Sunday"):
+ SetDateWDstr = "7"
+ if SetDateWDstr.isdigit():
+ SetDateWD = int(SetDateWDstr)
+ if (SetDateWD <= 7) and (SetDateWD >= 1):
+ SetDateWDError = 0
+ else:
+ SetDateWDError = 1
+ else:
+ SetDateWDError = 1
+
+
+ SetDateM = int(SetDateMstr)
+
+ SetDateD = 0
+ SetDateY = 0
+ SetClockM = 0
+ SetClockH = 0
+
+
+ SetClockS = '00'
+ if SetClockHstr.isdigit():
+ SetClockH = int(SetClockHstr)
+ if (SetClockH < 24) and (SetClockH >= 0):
+ SetClockHError = 0
+ else:
+ SetClockHError = 1
+ else:
+ SetClockHError = 1
+ if SetClockMstr.isdigit():
+ SetClockM = int(SetClockMstr)
+ if (SetClockM < 60) and (SetClockM >= 0):
+ SetClockMError = 0
+ else:
+ SetClockMError = 1
+ else:
+ SetClockMError = 1
+
+ if SetDateDstr.isdigit():
+ SetDateD = int(SetDateDstr)
+ if (SetDateD < 32) and (SetDateD >= 1):
+ SetDateDError = 0
+ else:
+ SetDateDError = 1
+ else:
+ SetDateDError = 1
+ if SetDateYstr.isdigit():
+ SetDateY = int(SetDateYstr)
+ if (SetDateY <= 99) and (SetDateY >= 0):
+ SetDateYError = 0
+ else:
+ SetDateYError = 1
+ else:
+ SetDateYError = 1
+ if (SetDateM <= 12) and (SetDateM >= 1):
+ SetDateMError = 0
+ else:
+ SetDateMError = 1
+
+
+
+
+ if (SetClockHError == 0) and (SetClockMError == 0) and (SetDateWDError == 0) and (SetDateDError == 0) and (SetDateMError == 0) and (SetDateYError == 0):
+ serial_port.write(str.encode('quit'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-date ' + SetDateDstr + ' ' + SetDateMstr + ' ' + SetDateYstr + ' ' + SetDateWDstr))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('set-clock ' + SetClockHstr + ' ' + SetClockMstr + ' ' + SetClockS))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+ else:
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+ Refresh_Status()
+
+def SetDateYFocusIn(SetDateYstr):
+ SetDateYstr = tkSetDateY.get()
+ SetDateYstr = ''.join([i for i in SetDateYstr if i.isdigit()])
+ tkSetDateY.set(SetDateYstr)
+
+def SetDateYFocusOut(SetDateYstr):
+ SetDateYstr = ''.join([i for i in SetDateYstr if i.isdigit()])
+ tkSetDateY.set(SetDateYstr + " Year")
+
+def SetDateDFocusIn(SetDateDstr):
+ SetDateDstr = tkSetDateD.get()
+ SetDateDstr = ''.join([i for i in SetDateDstr if i.isdigit()])
+ tkSetDateD.set(SetDateDstr)
+
+def SetDateDFocusOut(SetDateDstr):
+ SetDateDstr = ''.join([i for i in SetDateDstr if i.isdigit()])
+ tkSetDateD.set(SetDateDstr + " Day")
+
+def SetClockHFocusIn(SetClockHstr):
+ SetClockHstr = tkSetClockH.get()
+ SetClockHstr = ''.join([i for i in SetClockHstr if i.isdigit()])
+ tkSetClockH.set(SetClockHstr)
+
+def SetClockHFocusOut(SetClockHstr):
+ SetClockHstr = ''.join([i for i in SetClockHstr if i.isdigit()])
+ tkSetClockH.set(SetClockHstr + " Hours")
+
+def SetClockMFocusIn(SetClockMstr):
+ SetClockMstr = tkSetClockM.get()
+ SetClockMstr = ''.join([i for i in SetClockMstr if i.isdigit()])
+ tkSetClockM.set(SetClockMstr)
+
+def SetClockMFocusOut(SetClockMstr):
+ SetClockMstr = ''.join([i for i in SetClockMstr if i.isdigit()])
+ tkSetClockM.set(SetClockMstr + " Minutes")
+
+def Set_PowerSaveMode(sp3_powersave_enable):
+ if (sp3_powersave_enable == "1") or (sp3_powersave_enable == "0"):
+ if type(sp3_powersave_enable) == str:
+ serial_port.write(str.encode('set-config ' + '24 ' + sp3_powersave_enable))
+ else:
+ serial_port.write(str.encode('set-config ' + '24 ' + sp3_powersave_enable.decode(encoding='UTF-8', errors='strict')))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+def Set_powerofftimer(sp3_poweroff_time):
+ sp3_poweroff_time = ''.join([i for i in sp3_poweroff_time if i.isdigit()])
+ if sp3_poweroff_time.isdigit():
+ sp3_poweroff_timeint = int(sp3_poweroff_time)
+ if (sp3_poweroff_timeint < 65535) and (sp3_poweroff_timeint > 0):
+ serial_port.write(str.encode('set-config ' + '27 ' + str(sp3_poweroff_time)))
+ else:
+ powerOffTimeError = 1
+ else:
+ powerOffTimeError = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+
+def Upload_to_StromPi():
+ Info.config(text="Uploading data to StromPi")
+ fenster.update_idletasks()
+ sp3_powerOnButton_timestr = tkButton_time.get()
+ sp3_modusstr = tkmode.get()
+ sp3_shutdown_enablestr = tkShutdownMode.get()
+ sp3_batLevel_shutdownstr = tkBatShutdown.get()
+ sp3_serialLessModestr = tkSerialless.get()
+ sp3_warning_enablestr = tkPowerfailWarning.get()
+ sp3_powerOnButton_enablestr = tkPoweronButton.get()
+ sp3_shutdown_timestr = tkshutdown_time.get()
+ sp3_alarm_modestr = tkAlarm_Mode.get()
+ sp3_alarm_enablestr = tkWakeupAlarm.get()
+ sp3_intervalAlarmstr = tkIntervalAlarm.get()
+ sp3_alarmPoweroffstr = tkAlarmPoweroff.get()
+ sp3_alarm_min = tkAlarmPoweroffmin.get()
+ sp3_alarm_hour = tkAlarmPoweroffhour.get()
+ sp3_alarm_day = tkAlarmPoweroffday.get()
+ sp3_alarm_weekdaystr = tkAlarmPoweroffweekday.get()
+ sp3_alarm_monthstr = tkAlarmPoweroffmonth.get()
+ sp3_alarm_min_off = tkAlarmminoff.get()
+ sp3_alarm_hour_off = tkAlarmhouroff.get()
+ sp3_intervalAlarmOnTime = tkIntervalAlarmOnTime.get()
+ sp3_intervalAlarmOffTime = tkIntervalAlarmOffTime.get()
+ sp3_timesetting = tkTimeSync.get()
+ TimeSyncRB1test = TimeSyncRB1.get()
+ sp3_powersave_enablestr = tkPowerSave.get()
+ sp3_poweroffModestr = tkPoweroffMode.get()
+ sp3_wakeupweekend_enablestr = tkwakeupweekend_enable.get()
+
+ sp3_wakeupweekend_enable = sp3_wakeupweekend_enablestr[0]
+ sp3_alarmPoweroff = sp3_alarmPoweroffstr[0]
+ sp3_alarm_weekday = sp3_alarm_weekdaystr[0]
+ sp3_alarm_month = sp3_alarm_monthstr[0]
+ sp3_alarm_month2 = sp3_alarm_monthstr[1]
+ sp3_modus = sp3_modusstr[0]
+ sp3_modus_temp = sp3_modus
+ sp3_serialLessMode = sp3_serialLessModestr[0]
+ sp3_batLevel_shutdown = sp3_batLevel_shutdownstr[0]
+ sp3_warning_enable = sp3_warning_enablestr[0]
+ sp3_powerOnButton_enable = sp3_powerOnButton_enablestr[0]
+ sp3_shutdown_enable = sp3_shutdown_enablestr[0]
+ sp3_alarm_mode = sp3_alarm_modestr[0]
+ sp3_alarm_enable = sp3_alarm_enablestr [0]
+ sp3_intervalAlarm = sp3_intervalAlarmstr [0]
+ sp3_powersave_enable = sp3_powersave_enablestr [0]
+ sp3_poweroffMode = sp3_poweroffModestr [0]
+ SetClockHstr = tkSetClockH.get()
+ SetClockMstr = tkSetClockM.get()
+ SetDateDstr = tkSetDateD.get()
+ SetDateM = tkSetDateM.get()
+ SetDateWD = tkSetDateWD.get()
+ SetDateYstr = tkSetDateY.get()
+ sp3_poweroff_time = tkPoweroff_time.get()
+
+
+ breakS = 0.1
+ breakL = 0.2
+
+ if serial_port.isOpen(): serial_port.close()
+ serial_port.open()
+
+ serial_port.write(str.encode('quit'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ if TimeSyncRB1test == 2:
+ Set_RTC()
+ elif TimeSyncRB1test == 3:
+ Set_RTC_Manual(SetClockHstr, SetClockMstr, SetDateDstr, SetDateM, SetDateWD, SetDateYstr)
+
+ if (sp3_modus == "0") or (sp3_modus == "1") or (sp3_modus == "2") or (sp3_modus == "3") or (sp3_modus == "4") or (sp3_modus == "5") or (sp3_modus == "6"):
+ modusreset = 1
+ serial_port.write(str.encode('set-config ' + '1 ' + sp3_modus))
+ else:
+ modusreset = 0
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ Set_Alarm_Mode(sp3_alarm_mode) #2-4 and 26
+
+ Set_Alarm_Poweroff(sp3_alarmPoweroff) #5
+
+ Set_Alarm_min(sp3_alarm_min, Alarm_Powerofffailmin) #6
+
+ Set_Alarm_hour(sp3_alarm_hour) #7
+
+ Set_Alarm_min_off(sp3_alarm_min_off) #8
+
+ Set_Alarm_hour_off(sp3_alarm_hour_off) #9
+
+ Set_Alarm_Day(sp3_alarm_day) #10
+
+ if sp3_alarm_month2 == "1":
+ serial_port.write(str.encode('set-config ' + '11 ' + '11'))
+ elif sp3_alarm_month2 == "0":
+ serial_port.write(str.encode('set-config ' + '11 ' + '10'))
+ elif sp3_alarm_month2 == "2":
+ serial_port.write(str.encode('set-config ' + '11 ' + '12'))
+ else:
+ serial_port.write(str.encode('set-config ' + '11 ' + sp3_alarm_month))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ Set_Alarm_Weekday(sp3_alarm_weekday) #12
+
+ Set_WakeUpAlarm(sp3_alarm_enable) #13
+
+ Set_Shutdown_enable(sp3_shutdown_enable) #14
+ sp3_shutdown_timestr = ''.join([i for i in sp3_shutdown_timestr if i.isdigit()])
+ if sp3_shutdown_timestr.isdigit():
+ sp3_shutdown_time = int(sp3_shutdown_timestr)
+ if (sp3_shutdown_time < 65535) and (sp3_shutdown_time > 0):
+ serial_port.write(str.encode('set-config ' + '15 ' + str(sp3_shutdown_time)))
+ else:
+ ShutdownTimeError = 1
+ else:
+ ShutdownTimeError = 1
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ Set_Warning_enable(sp3_warning_enable) #16
+
+ Set_Serialless_mode(sp3_serialLessMode) #17
+
+ Set_Batlevel_Shutdown(sp3_batLevel_shutdown) #18
+
+ Set_Intervalmode(sp3_intervalAlarm) #19
+
+ Set_IntervalAlarmOnTime(sp3_intervalAlarmOnTime) #20
+
+ Set_IntervalAlarmOffTime(sp3_intervalAlarmOffTime) #21
+
+ Set_PoweronButton(sp3_powerOnButton_enable) #22
+
+ sp3_powerOnButton_timestr = ''.join([i for i in sp3_powerOnButton_timestr if i.isdigit()])
+ if sp3_powerOnButton_timestr.isdigit():
+ sp3_powerOnButton_time = int(sp3_powerOnButton_timestr)
+ if (sp3_powerOnButton_time < 65535) and (sp3_powerOnButton_time > 0):
+ serial_port.write(str.encode('set-config ' + '23 ' + str(sp3_powerOnButton_time)))
+ else:
+ ButtonTimeError = 1 #("You can only use Digits between 0 and 65535 for the Button timer")
+ else:
+ ButtonTimeError = 1 #("You can only use Digits between 0 and 65535 for the Button timer")
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ Set_PowerSaveMode(sp3_powersave_enable) #24
+
+ Set_PoweroffMode(sp3_poweroffMode) #25
+
+ Set_powerofftimer(sp3_poweroff_time)#27
+
+ Set_wakeupweekend_enable(sp3_wakeupweekend_enable)#28
+
+ Use_Modusreset(modusreset)
+ Refresh_Status()
+ Info.config(text="Finished Uploading")
+
+def Refresh_Status():
+
+ serial_port = serial.Serial()
+ serial_port.baudrate = 38400
+ serial_port.port = '/dev/serial0'
+ serial_port.timeout = 1
+ serial_port.bytesize = 8
+ serial_port.stopbits = 1
+ serial_port.parity = serial.PARITY_NONE
+
+ if serial_port.isOpen(): serial_port.close()
+ serial_port.open()
+
+ serial_port.write(str.encode('quit'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+
+ serial_port.write(str.encode('status-rpi'))
+ sleep(1)
+ serial_port.write(str.encode('\x0D'))
+ sp3_time = serial_port.readline(9999);
+ sp3_date = serial_port.readline(9999);
+ sp3_weekday = serial_port.readline(9999);
+ sp3_modus = serial_port.readline(9999);
+ sp3_alarm_enable = serial_port.readline(9999);
+ sp3_alarm_mode = serial_port.readline(9999);
+ sp3_alarm_hour = serial_port.readline(9999);
+ sp3_alarm_min = serial_port.readline(9999);
+ sp3_alarm_day = serial_port.readline(9999);
+ sp3_alarm_month = serial_port.readline(9999);
+ sp3_alarm_weekday = serial_port.readline(9999);
+ sp3_alarmPoweroff = serial_port.readline(9999);
+ sp3_alarm_hour_off = serial_port.readline(9999);
+ sp3_alarm_min_off = serial_port.readline(9999);
+ sp3_shutdown_enable = serial_port.readline(9999);
+ sp3_shutdown_time = serial_port.readline(9999);
+ sp3_warning_enable = serial_port.readline(9999);
+ sp3_serialLessMode = serial_port.readline(9999);
+ sp3_intervalAlarm = serial_port.readline(9999);
+ sp3_intervalAlarmOnTime = serial_port.readline(9999);
+ sp3_intervalAlarmOffTime = serial_port.readline(9999);
+ sp3_batLevel_shutdown = serial_port.readline(9999);
+ sp3_batLevel = serial_port.readline(9999);
+ sp3_charging = serial_port.readline(9999);
+ sp3_powerOnButton_enable = serial_port.readline(9999);
+ sp3_powerOnButton_time = serial_port.readline(9999);
+ sp3_powersave_enable = serial_port.readline(9999);
+ sp3_poweroffMode = serial_port.readline(9999);
+ sp3_poweroff_time_enable = serial_port.readline(9999);
+ sp3_poweroff_time = serial_port.readline(9999);
+ sp3_wakeupweekend_enable = serial_port.readline(9999);
+ sp3_ADC_Wide = float(serial_port.readline(9999))/1000;
+ sp3_ADC_BAT = float(serial_port.readline(9999))/1000;
+ sp3_ADC_USB = float(serial_port.readline(9999))/1000;
+ sp3_ADC_OUTPUT = float(serial_port.readline(9999))/1000;
+ sp3_output_status = serial_port.readline(9999);
+ sp3_powerfailure_counter = serial_port.readline(9999);
+ sp3_firmwareVersion = serial_port.readline(9999);
+
+ sp3_modus_temp = int(sp3_modus)
+
+ strompi_year = int(sp3_date) // 10000
+ strompi_month = int(sp3_date) % 10000 // 100
+ strompi_day = int(sp3_date) % 100
+
+ strompi_hour = int(sp3_time) // 10000
+ strompi_min = int(sp3_time) % 10000 // 100
+ strompi_sec = int(sp3_time) % 100
+
+
+ sp3_poweroff_time_enable = int(sp3_poweroff_time_enable.decode())
+ if sp3_poweroff_time_enable == 1:
+ sp3_alarm_mode = "4"
+ tkmode.set(strompi_mode_converter((int(sp3_modus))))
+ tkshutdown_time.set(str(sp3_shutdown_time, 'utf-8').rstrip('\n') + ' Seconds')
+ tkButton_time.set(str(sp3_powerOnButton_time, 'utf-8').rstrip('\n') + ' Seconds')
+ tkShutdownMode.set(enabled_disabled_converter(int(sp3_shutdown_enable)))
+ tkBatShutdown.set(batterylevel_shutdown_converter(int(sp3_batLevel_shutdown)))
+ tkSerialless.set(enabled_disabled_converter(int(sp3_serialLessMode)))
+ tkPowerfailWarning.set(enabled_disabled_converter(int(sp3_warning_enable)))
+ tkPoweronButton.set(enabled_disabled_converter(int(sp3_powerOnButton_enable)))
+ tkAlarm_Mode.set('Alarm-Mode: ' + alarm_mode_converter(int(sp3_alarm_mode)))
+ tkPowerSave.set('Power Save Mode: ' + enabled_disabled_converter(int(sp3_powersave_enable)))
+ tkwakeupweekend_enable.set('Weekend Wakeup: ' + enabled_disabled_converter(int(sp3_wakeupweekend_enable)))
+ #tkTimeSync.set('No Change')
+ tkWakeupAlarm.set('WakeUp-Alarm: ' + enabled_disabled_converter(int(sp3_alarm_enable)))
+ tkIntervalAlarm.set('Interval-Alarm: ' + enabled_disabled_converter(int(sp3_intervalAlarm)))
+ tkAlarmPoweroff.set('PowerOff-Alarm: ' + enabled_disabled_converter(int(sp3_alarmPoweroff)))
+ tkAlarmPoweroffmin.set(str(sp3_alarm_min_off, 'utf-8').rstrip('\n').zfill(2) + ' Minutes')
+ tkAlarmPoweroffhour.set(str(sp3_alarm_hour_off, 'utf-8').rstrip('\n').zfill(2) + ' Hours')
+ tkAlarmPoweroffmonth.set(str(sp3_alarm_month, 'utf-8').rstrip('\n').zfill(2))
+ tkAlarmPoweroffweekday.set(weekday_converter(int(sp3_alarm_weekday)))
+ tkAlarmPoweroffday.set(str(sp3_alarm_day, 'utf-8').rstrip('\n').zfill(2) + ' Day')
+ tkAlarmhouroff.set(str(sp3_alarm_hour, 'utf-8').rstrip('\n').zfill(2) + ' Hours')
+ tkAlarmminoff.set(str(sp3_alarm_min, 'utf-8').rstrip('\n').zfill(2) + ' Minutes')
+ tkIntervalAlarmOffTime.set(str(sp3_intervalAlarmOffTime, 'utf-8').rstrip('\n').zfill(2) + ' Minutes')
+ tkIntervalAlarmOnTime.set(str(sp3_intervalAlarmOnTime, 'utf-8').rstrip('\n').zfill(2) + ' Minutes')
+ tkSetClockH.set(str(strompi_hour).zfill(2) + ' Hours')
+ tkSetClockM.set(str(strompi_min).zfill(2) + ' Minutes')
+ tkSetDateD.set(str(strompi_day).zfill(2) + ' Day')
+ tkSetDateM.set(str(strompi_month).zfill(2))
+ tkSetDateWD.set(weekday_converter(int(sp3_weekday)))
+ tkSetDateY.set(str(strompi_year).zfill(2) + ' Year')
+ tkPoweroffMode.set('Poweroff Mode: ' + enabled_disabled_converter(int(sp3_poweroffMode)))
+ tkPoweroff_time.set(str(sp3_poweroff_time, 'utf-8').rstrip('\n').zfill(2) + ' Minutes')
+ tkfirmwareVersion.set(str(sp3_firmwareVersion, 'utf-8').strip('\nv').zfill(2))
+ serial_port.close()
+
+def alarmPoweroffhourFocusIn(alarmPoweroffhour):
+ alarmPoweroffhour = tkAlarmPoweroffhour.get()
+ alarmPoweroffhour = ''.join([i for i in alarmPoweroffhour if i.isdigit()])
+ tkAlarmPoweroffhour.set(alarmPoweroffhour)
+
+def alarmPoweroffhourFocusOut(alarmPoweroffhour):
+ alarmPoweroffhour = ''.join([i for i in alarmPoweroffhour if i.isdigit()])
+ tkAlarmPoweroffhour.set(alarmPoweroffhour + " Hours")
+
+def alarmPoweroffminFocusIn(alarmPoweroffmin):
+ alarmPoweroffmin = tkAlarmPoweroffmin.get()
+ alarmPoweroffmin = ''.join([i for i in alarmPoweroffmin if i.isdigit()])
+ tkAlarmPoweroffmin.set(alarmPoweroffmin)
+
+def alarmPoweroffminFocusOut(alarmPoweroffmin):
+ alarmPoweroffmin = ''.join([i for i in alarmPoweroffmin if i.isdigit()])
+ tkAlarmPoweroffmin.set(alarmPoweroffmin + " Minutes")
+
+def alarmPoweroffdayFocusIn(alarmPoweroffday):
+ alarmPoweroffday = tkAlarmPoweroffday.get()
+ alarmPoweroffday = ''.join([i for i in alarmPoweroffday if i.isdigit()])
+ tkAlarmPoweroffday.set(alarmPoweroffday)
+
+def alarmPoweroffdayFocusOut(alarmPoweroffday):
+ alarmPoweroffday = ''.join([i for i in alarmPoweroffday if i.isdigit()])
+ tkAlarmPoweroffday.set(alarmPoweroffday + " Day")
+
+def WakeUpMinFocusIn(WakeUpMin):
+ WakeUpMin = tkAlarmminoff.get()
+ WakeUpMin = ''.join([i for i in WakeUpMin if i.isdigit()])
+ tkAlarmminoff.set(WakeUpMin)
+
+def WakeUpMinFocusOut(WakeUpMin):
+ WakeUpMin = ''.join([i for i in WakeUpMin if i.isdigit()])
+ tkAlarmminoff.set(WakeUpMin + " Minutes")
+
+def WakeUpHourFocusIn(WakeUpHour):
+ WakeUpHour = tkAlarmhouroff.get()
+ WakeUpHour = ''.join([i for i in WakeUpHour if i.isdigit()])
+ tkAlarmhouroff.set(WakeUpHour)
+
+def WakeUpHourFocusOut(WakeUpHour):
+ WakeUpHour = ''.join([i for i in WakeUpHour if i.isdigit()])
+ tkAlarmhouroff.set(WakeUpHour + " Hours")
+
+def AlarmminonFocusIn(IntervalAlarmOnTime):
+ IntervalAlarmOnTime = tkIntervalAlarmOnTime.get()
+ IntervalAlarmOnTime = ''.join([i for i in IntervalAlarmOnTime if i.isdigit()])
+ tkIntervalAlarmOnTime.set(IntervalAlarmOnTime)
+
+def AlarmminonFocusOut(IntervalAlarmOnTime):
+ IntervalAlarmOnTime = ''.join([i for i in IntervalAlarmOnTime if i.isdigit()])
+ tkIntervalAlarmOnTime.set(IntervalAlarmOnTime + " Minutes")
+
+def AlarmminoffFocusIn(IntervalAlarmOffTime):
+ IntervalAlarmOffTime = tkIntervalAlarmOffTime.get()
+ IntervalAlarmOffTime = ''.join([i for i in IntervalAlarmOffTime if i.isdigit()])
+ tkIntervalAlarmOffTime.set(IntervalAlarmOffTime)
+
+def AlarmminoffFocusOut(IntervalAlarmOffTime):
+ IntervalAlarmOffTime = ''.join([i for i in IntervalAlarmOffTime if i.isdigit()])
+ tkIntervalAlarmOffTime.set(IntervalAlarmOffTime + " Minutes")
+
+def ShutdownTimeFocusIn(ShutdownTime):
+ ShutdownTime = tkshutdown_time.get()
+ ShutdownTime = ''.join([i for i in ShutdownTime if i.isdigit()])
+ tkshutdown_time.set(ShutdownTime)
+
+def ShutdownTimeFocusOut(ShutdownTime):
+ ShutdownTime = ''.join([i for i in ShutdownTime if i.isdigit()])
+ tkshutdown_time.set(ShutdownTime + " Seconds")
+
+def PoweronButtonTimeFocusIn(PoweronButtonTime):
+ PoweronButtonTime = tkButton_time.get()
+ PoweronButtonTime = ''.join([i for i in PoweronButtonTime if i.isdigit()])
+ tkButton_time.set(PoweronButtonTime)
+
+def PoweronButtonTimeFocusOut(PoweronButtonTime):
+ PoweronButtonTime = ''.join([i for i in PoweronButtonTime if i.isdigit()])
+ tkButton_time.set(PoweronButtonTime + " Seconds")
+
+def PoweroffTimeFocusIn(Poweroff_time_tmp):
+ Poweroff_time_tmp = tkPoweroff_time.get()
+ Poweroff_time_tmp = ''.join([i for i in Poweroff_time_tmp if i.isdigit()])
+ tkPoweroff_time.set(Poweroff_time_tmp)
+
+def PoweroffTimeFocusOut(Poweroff_time_tmp):
+ Poweroff_time_tmp = ''.join([i for i in Poweroff_time_tmp if i.isdigit()])
+ tkPoweroff_time.set(Poweroff_time_tmp + " Minutes")
+
+def loading_process():
+ if serial_port.isOpen(): serial_port.close()
+ serial_port.open()
+
+ serial_port.write(str.encode('quit'))
+ sleep(breakS)
+ serial_port.write(str.encode('\x0D'))
+ sleep(breakL)
+ serial_port.write(str.encode('status-rpi'))
+ sleep(1)
+ serial_port.write(str.encode('\x0D'))
+ sp3_time = serial_port.readline(9999);
+ sp3_date = serial_port.readline(9999);
+ sp3_weekday = serial_port.readline(9999);
+ sp3_modus = serial_port.readline(9999);
+ sp3_alarm_enable = serial_port.readline(9999);
+ sp3_alarm_mode = serial_port.readline(9999);
+ sp3_alarm_hour = serial_port.readline(9999);
+ sp3_alarm_min = serial_port.readline(9999);
+ sp3_alarm_day = serial_port.readline(9999);
+ sp3_alarm_month = serial_port.readline(9999);
+ sp3_alarm_weekday = serial_port.readline(9999);
+ sp3_alarmPoweroff = serial_port.readline(9999);
+ sp3_alarm_hour_off = serial_port.readline(9999);
+ sp3_alarm_min_off = serial_port.readline(9999);
+ sp3_shutdown_enable = serial_port.readline(9999);
+ sp3_shutdown_time = serial_port.readline(9999);
+ sp3_warning_enable = serial_port.readline(9999);
+ sp3_serialLessMode = serial_port.readline(9999);
+ sp3_intervalAlarm = serial_port.readline(9999);
+ sp3_intervalAlarmOnTime = serial_port.readline(9999);
+ sp3_intervalAlarmOffTime = serial_port.readline(9999);
+ sp3_batLevel_shutdown = serial_port.readline(9999);
+ sp3_batLevel = serial_port.readline(9999);
+ sp3_charging = serial_port.readline(9999);
+ sp3_powerOnButton_enable = serial_port.readline(9999);
+ sp3_powerOnButton_time = serial_port.readline(9999);
+ sp3_powersave_enable = serial_port.readline(9999);
+ sp3_poweroffMode = serial_port.readline(9999);
+ sp3_poweroff_time_enable = serial_port.readline(9999);
+ sp3_poweroff_time = serial_port.readline(9999);
+ sp3_wakeupweekend_enable = serial_port.readline(9999);
+ sp3_ADC_Wide = float(serial_port.readline(9999))/1000;
+ sp3_ADC_BAT = float(serial_port.readline(9999))/1000;
+ sp3_ADC_USB = float(serial_port.readline(9999))/1000;
+ sp3_ADC_OUTPUT = float(serial_port.readline(9999))/1000;
+ sp3_output_status = serial_port.readline(9999);
+ sp3_powerfailure_counter = serial_port.readline(9999);
+ sp3_firmwareVersion = serial_port.readline(9999);
+ sp3_modus_temp = int(sp3_modus)
+ sleep(2)
+ root.destroy()
+
+def _on_mousewheel(event,scroll):
+ canvas.yview_scroll(int(scroll), "units")
+
+
+root = tk.Tk()
+root.title("Strompi V3 Serial Config Tool")
+root.geometry("400x300")
+root.configure(background="#275c6b")
+root.overrideredirect(True)
+root.eval('tk::PlaceWindow . center')
+load = Label(root, text="Loading...", fg="snow", bg="#275c6b",font='Helvetica 18 bold',width=400, height=150, anchor=CENTER)
+load.pack()
+root.iconphoto(True, ImageTk.PhotoImage(Image.open("favicon.png")))
+root.after(200,loading_process)
+root.mainloop()
+
+
+#----------------Graphic User Interface------------------------
+fenster = tk.Tk()
+fenster.title("Strompi V3 Serial Config Tool")
+fenster.geometry("1000x600")
+#fenster.resizable(width="false", height="true")
+fenster.iconphoto(True, ImageTk.PhotoImage(Image.open("favicon.png")))
+mainframe = Frame(fenster)
+mainframe.pack(fill=BOTH, expand=1)
+canvas = Canvas(mainframe)
+canvas.pack(side=LEFT, fill=BOTH, expand=1)
+scrollbar = tk.Scrollbar(mainframe, orient=VERTICAL, command=canvas.yview)
+scrollbar.pack(side=RIGHT, fill=Y)
+canvas.configure(yscrollcommand=scrollbar.set)
+canvas.bind_all("
+
+ StromPi hat einen STROMAUSFALL erkannt!!!!
+ CaravanPi Grundeinstellungen
+
Anzahl von Sensoren
Einstellungen für die Abfrageintervalle der Sensoren
Liontron Battery Management
Gassensor
Gassensor
230V Überwachung
230V Überwachung
12V Bordbatterie Überwachung
12V Bordbatterie Überwachung
12V Auto Überwachung
12V Auto Überwachung