public void processMessage(String msg) {
   if (msg.length() > 0 && msg.contains("/")) {
     String deviceName = msg.substring(0, msg.indexOf("/"));
     String cmd = msg.substring(msg.indexOf("/") + 1, msg.length());
     if (deviceName != null && cmd != null) {
       for (Device d : Kernel.getInstance().devices) {
         if (d.getName().equals(deviceName)) {
           try {
             d.send(cmd);
           } catch (IOException ex) {
             Logger.getLogger(SerialListener.class.getName())
                 .log(
                     Level.SEVERE,
                     "Error sending Serial Message to {0}. {1}",
                     new Object[] {d.getName(), ex.getMessage()});
           }
         }
       }
     }
   }
 }
  @GET
  @Produces("text/html")
  @Path("/sensor/{device}/{sensor}")
  public String execute(
      @PathParam("device") String deviceName, @PathParam("sensor") String sensor) {
    if (deviceName != null && sensor != null) {
      for (Device d : Kernel.getInstance().devices) {
        if (d.getName().equals(deviceName)) {
          try {
            return d.getThings().get(sensor).execute(sensor);

          } catch (Exception ex) {
            Logger.getLogger(SerialListener.class.getName())
                .log(
                    Level.SEVERE,
                    "Error sending Serial Message to {0}. {1}",
                    new Object[] {d.getName(), ex.getMessage()});
          }
        }
      }
    }
    return "not found";
  }