@RequestMapping("/device_status")
 public @ResponseBody DeviceStatus[] getDeviceStatus() {
   Device devices[] = powerControlDeviceService.getDevices();
   DeviceStatus[] deviceStatus = new DeviceStatus[devices.length];
   for (int i = 0; i < devices.length; i++) {
     deviceStatus[i] = new DeviceStatus(devices[i]);
   }
   return deviceStatus;
 }
 @RequestMapping("/programme_devices_status/{id}")
 public @ResponseBody DeviceStatus[] getProgrammeDeviceStatus(@PathVariable("id") long id) {
   ProgrammeDevice[] devices =
       powerControlDeviceService.getProgrammeStatus(id).getProgrammeDevices();
   DeviceStatus[] deviceStatus = new DeviceStatus[devices.length];
   for (int i = 0; i < devices.length; i++) {
     deviceStatus[i] = new DeviceStatus(devices[i].getDevice());
   }
   return deviceStatus;
 }
 @RequestMapping("/secure/device_override/{id}/{on}/{duration}")
 public @ResponseBody boolean deviceOverride(
     @PathVariable("id") long id,
     @PathVariable("on") boolean on,
     @PathVariable("duration") long duration) {
   powerControlDeviceService
       .getDevice(id)
       .setOverridingMode(new OnOffMode(on), duration * 1000 * 60);
   return true;
 }
 @RequestMapping("/device_status/{id}")
 public @ResponseBody DeviceStatus getDeviceStatus(@PathVariable("id") long id) {
   Device devices[] = powerControlDeviceService.getDevices();
   for (int i = 0; i < devices.length; i++) {
     if (devices[i].getId() == id) {
       return new DeviceStatus(devices[i]);
     }
   }
   return null;
 }
 @RequestMapping("/secure/activate_programme/{id}")
 public String activateProgramme(@PathVariable("id") long id) {
   powerControlDeviceService.activateProgramme(id);
   return "redirect:/programmes";
 }
 @RequestMapping("/programme_detail/{id}")
 public @ResponseBody ModelAndView getProgrammes(@PathVariable("id") long id) {
   ModelAndView mav = new ModelAndView("programme_detail");
   mav.addObject("programmeStatus", powerControlDeviceService.getProgrammeStatus(id));
   return mav;
 }
 @RequestMapping("/programmes")
 public @ResponseBody ModelAndView getProgrammes() {
   ModelAndView mav = new ModelAndView("maintenance");
   mav.addObject("programmesStatus", powerControlDeviceService.getProgrammesStatus());
   return mav;
 }
 @RequestMapping("/secure/cancel_device_override/{id}")
 public @ResponseBody boolean cancelOverride(@PathVariable("id") long id) {
   powerControlDeviceService.getDevice(id).cancelOverridingMode();
   return true;
 }
 @RequestMapping("/device/{id}")
 public @ResponseBody ModelAndView getDeviceDetail(@PathVariable("id") long id) {
   ModelAndView mav = new ModelAndView("device_detail");
   mav.addObject("device", powerControlDeviceService.getDevice(id));
   return mav;
 }