Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
elschnorro77 committed Mar 8, 2024
1 parent 1a14711 commit a452415
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 2 additions & 4 deletions wittypi/wittyPi.py
Original file line number Diff line number Diff line change
Expand Up @@ -1401,6 +1401,8 @@ def process_schedule_data(schedule_file_data):

def getAll():
wittypi = {}
wittypi['is_rtc_connected'] = False
wittypi['is_mc_connected'] = False
wittypi['is_rtc_connected'] = is_rtc_connected()
if wittypi['is_rtc_connected']:
wittypi['is_rtc_connected'] = True
Expand All @@ -1421,8 +1423,6 @@ def getAll():
wittypi['shutdown_timedelta'] = shutdown_timedelta
wittypi['temperature'] = get_temperature()
wittypi['alarm_flags'] = get_alarm_flags()
else:
wittypi['is_rtc_connected'] = False
wittypi['is_mc_connected'] = is_mc_connected()
if wittypi['is_mc_connected']:
wittypi['is_mc_connected'] = True
Expand All @@ -1437,8 +1437,6 @@ def getAll():
wittypi['white_led_duration'] = get_white_led_duration()
wittypi['low_voltage_threshold'] = get_low_voltage_threshold()
wittypi['recovery_voltage_threshold'] = get_recovery_voltage_threshold()
else:
wittypi['is_mc_connected'] = False
wittypi['wittyPiPath'] = get_wittypi_folder()
wittypi['is_schedule_file_in_use'] = is_schedule_file_in_use()
if wittypi['is_schedule_file_in_use']:
Expand Down
8 changes: 5 additions & 3 deletions wittypiutilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def check_wittypi(settings):
try:
wittypi_status = get_wittypi_status(settings)
wittypi_status['service_active']=is_service_active('wittypi.service')
if wittypi_status['is_rtc_connected'] and not wittypi_status['service_active']:
if 'is_rtc_connected' in wittypi_status and wittypi_status['is_rtc_connected'] is not None and wittypi_status['is_rtc_connected'] and not wittypi_status['service_active']:
if wittypi_status['is_mc_connected']:
logger.debug("WittyPi 3 is connected and WittyPi Service is not running!")
else:
Expand All @@ -192,6 +192,7 @@ def check_wittypi(settings):
elif alarm_type == 2:
logger.warning("HoneyPi was woken up by Shutdown Alarm from RTC, should go to sleep!")
do_shutdown()
wittypi_status = check_wittypi_rtc(settings, wittypi_status)
#create WittyPi folder if not existing to be able to save schedule file.
if wittypi_status['wittyPiPath'] == "" or wittypi_status['wittyPiPath'] is None:
path = homeFolder + '/wittypi'
Expand All @@ -203,6 +204,8 @@ def check_wittypi(settings):
logger.info("Created directory for WittyPi schedule file '%s'" % path)
except OSError:
logger.critical("Creation of the directory for WittyPi schedule file '%s' failed" % path)
if 'is_rtc_connected' in wittypi_status and wittypi_status['is_rtc_connected'] is not None and wittypi_status['is_rtc_connected'] == False and settings['wittyPi']['enabled']:
logger.critical("No WittyPi present but enabled in HoneyPi settings!")
if wittypi_status['service_active'] and wittypi_status['service_active'] != settings['wittyPi']['enabled']:
logger.critical("WittyPi service is active but WittyPi is disabled in HoneyPi settings!")
if wittypi_status['service_active'] and settings['wittyPi']['enabled']:
Expand All @@ -223,9 +226,8 @@ def check_wittypi(settings):
logger.debug("WittyPi recovery voltage threshold is set to '" + str(wittypi_status['recovery_voltage_threshold']) + " Volt', HoneyPi low voltage threshold is set to '" + str(settings['wittyPi']['low']['voltage']) + " Volt'")
else:
logger.debug("WittyPi recovery voltage threshold is set to " + str(wittypi_status['recovery_voltage_threshold']) + " Volt" )
wittypi_status = check_wittypi_rtc(settings, wittypi_status) # TODO this will be called each time from main even if wittypi is disabled/ not connected - sure? Call it seperately after check_wittypi got called if required
if settings['wittyPi']['enabled']:
if wittypi_status['is_mc_connected']:
if 'is_mc_connected' in wittypi_status and wittypi_status['is_mc_connected'] is not None and wittypi_status['is_mc_connected']:
if settings['wittyPi']['dummyload'] is not None and (wittypi_status['dummy_load_duration'] != settings['wittyPi']['dummyload']):
logger.warning("WittyPi dummy load duration defered from settings, updating setting on WittyPi to " + str(settings['wittyPi']['dummyload']) + " seconds")
set_dummy_load_duration(settings['wittyPi']['dummyload'])
Expand Down

0 comments on commit a452415

Please sign in to comment.