feat: Implement immediate application of active schedule on startup and enhance schedule resume handling
Fixes #24
This commit is contained in:
parent
229bde85e9
commit
b346be9431
@ -270,10 +270,18 @@ class TempWebServer:
|
|||||||
|
|
||||||
if self._save_config_to_file(config):
|
if self._save_config_to_file(config):
|
||||||
print("▶️ Schedule resumed - Automatic mode")
|
print("▶️ Schedule resumed - Automatic mode")
|
||||||
|
|
||||||
if schedule_monitor:
|
if schedule_monitor:
|
||||||
schedule_monitor.reload_config(config)
|
schedule_monitor.reload_config(config)
|
||||||
|
# ===== IMMEDIATELY APPLY ACTIVE SCHEDULE =====
|
||||||
|
active_schedule = schedule_monitor._find_active_schedule()
|
||||||
|
if active_schedule:
|
||||||
|
schedule_monitor._apply_schedule(active_schedule)
|
||||||
|
print("✅ Active schedule applied immediately after resume: {}".format(
|
||||||
|
active_schedule.get('name', 'Unnamed')
|
||||||
|
))
|
||||||
|
|
||||||
|
# Send Discord notification
|
||||||
try:
|
try:
|
||||||
from scripts.discord_webhook import send_discord_message
|
from scripts.discord_webhook import send_discord_message
|
||||||
send_discord_message("▶️ Schedule resumed - Automatic temperature control active")
|
send_discord_message("▶️ Schedule resumed - Automatic temperature control active")
|
||||||
|
|||||||
18
main.py
18
main.py
@ -297,6 +297,24 @@ schedule_monitor = ScheduleMonitor(
|
|||||||
config=config, # Pass config with schedules
|
config=config, # Pass config with schedules
|
||||||
interval=60 # Check schedule every 60 seconds
|
interval=60 # Check schedule every 60 seconds
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# ===== APPLY ACTIVE SCHEDULE IMMEDIATELY ON STARTUP =====
|
||||||
|
if config.get('schedule_enabled', False):
|
||||||
|
try:
|
||||||
|
# Find and apply the current active schedule
|
||||||
|
active_schedule = schedule_monitor._find_active_schedule()
|
||||||
|
if active_schedule:
|
||||||
|
schedule_monitor._apply_schedule(active_schedule)
|
||||||
|
print("✅ Active schedule applied on startup: {}".format(
|
||||||
|
active_schedule.get('name', 'Unnamed')
|
||||||
|
))
|
||||||
|
else:
|
||||||
|
print("ℹ️ No active schedule found (using manual targets)")
|
||||||
|
except Exception as e:
|
||||||
|
print("⚠️ Warning: Could not apply startup schedule: {}".format(e))
|
||||||
|
else:
|
||||||
|
print("ℹ️ Schedules disabled - using manual targets")
|
||||||
|
# ===== END: APPLY ACTIVE SCHEDULE ON STARTUP =====
|
||||||
# ===== END: Schedule Monitor Setup =====
|
# ===== END: Schedule Monitor Setup =====
|
||||||
|
|
||||||
# ===== START: Print Current Settings =====
|
# ===== START: Print Current Settings =====
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user