import bottle
import waitress
import controller
import breathe


if __name__ == '__main__':
    bottle_app = bottle.app()
    breather = breathe.Breathe()
    my_controller = controller.Controller(bottle_app, breather)
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)

import bottle
import waitress
import controller
import breathe
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler

bottle_app = bottle.app()
scheduler = BackgroundScheduler()
scheduler.configure(timezone=timezone('US/Pacific'))
breather = breathe.Breathe()
my_controller = controller.Controller(bottle_app, None)


@scheduler.scheduled_job(trigger='cron', hour=21, minute=0)
def on_job():
    """Start at 9:00pm PT"""
    print('STARTING BREATHER')
    breather.restart()

@scheduler.scheduled_job(trigger='cron', hour=23, minute=0)
def off_job():
    """End at 11:00pm PT"""
    print("STOPPING BREATHER")
    breather.shutdown()

if __name__ == '__main__':
    scheduler.start()
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)

Add scheduler. Schedule lights on for 9:00pm and lights off for 11:00pm
Add scheduler. Schedule lights on for 9:00pm and lights off for 11:00pm

  import bottle
  import waitress
  import controller
  import breathe
+ from pytz import timezone
+ from apscheduler.schedulers.background import BackgroundScheduler
+ 
+ bottle_app = bottle.app()
+ scheduler = BackgroundScheduler()
+ scheduler.configure(timezone=timezone('US/Pacific'))
+ breather = breathe.Breathe()
+ my_controller = controller.Controller(bottle_app, None)
  
  
+ @scheduler.scheduled_job(trigger='cron', hour=21, minute=0)
+ def on_job():
+     """Start at 9:00pm PT"""
+     print('STARTING BREATHER')
+     breather.restart()
+ 
+ @scheduler.scheduled_job(trigger='cron', hour=23, minute=0)
+ def off_job():
+     """End at 11:00pm PT"""
+     print("STOPPING BREATHER")
+     breather.shutdown()
+ 
  if __name__ == '__main__':
+     scheduler.start()
-     bottle_app = bottle.app()
-     breather = breathe.Breathe()
-     my_controller = controller.Controller(bottle_app, breather)
      waitress.serve(bottle_app, host='0.0.0.0', port=7000)
  
Add scheduler. Schedule lights on for 9:00pm and lights off for 11:00pm
## Code Before:
import bottle
import waitress
import controller
import breathe


if __name__ == '__main__':
    bottle_app = bottle.app()
    breather = breathe.Breathe()
    my_controller = controller.Controller(bottle_app, breather)
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)

## Instruction:
Add scheduler. Schedule lights on for 9:00pm and lights off for 11:00pm
## Code After:
import bottle
import waitress
import controller
import breathe
from pytz import timezone
from apscheduler.schedulers.background import BackgroundScheduler

bottle_app = bottle.app()
scheduler = BackgroundScheduler()
scheduler.configure(timezone=timezone('US/Pacific'))
breather = breathe.Breathe()
my_controller = controller.Controller(bottle_app, None)


@scheduler.scheduled_job(trigger='cron', hour=21, minute=0)
def on_job():
    """Start at 9:00pm PT"""
    print('STARTING BREATHER')
    breather.restart()

@scheduler.scheduled_job(trigger='cron', hour=23, minute=0)
def off_job():
    """End at 11:00pm PT"""
    print("STOPPING BREATHER")
    breather.shutdown()

if __name__ == '__main__':
    scheduler.start()
    waitress.serve(bottle_app, host='0.0.0.0', port=7000)
