Refactor of home_automator.py, using Flask templates