lights, groups, and schedules apis, and some refactoring