Refactorpi

Refactor lamp and pi controller. Set sleep time to be based on changed web app conditions.