Example #1
0
 /** Start this device */
 public void startDevice() {
   if (m_open_web_net == null) {
     m_open_web_net = new OpenWebNet(m_host, m_port, m_rescan_interval_secs);
     m_open_web_net.addEventListener(this);
     m_open_web_net.onStart();
   }
   m_device_is_started = true;
   logger.debug("Gateway [" + m_gateway_id + "], started OK");
 }
Example #2
0
 public void stopDevice() {
   if (m_open_web_net != null) {
     m_open_web_net.interrupt();
     m_open_web_net = null;
   }
   m_device_is_started = false;
 }
Example #3
0
  public void receiveCommand(
      String itemName, Command command, BticinoBindingConfig itemBindingConfig) {
    try {
      synchronized (m_lock) {
        // An command is received from the openHab system
        // analyse it and execute it
        logger.debug(
            "Gateway [" + m_gateway_id + "], Command '{}' received for item {}",
            (Object[]) new String[] {command.toString(), itemName});

        ProtocolRead l_pr = new ProtocolRead(itemBindingConfig.who + "*" + itemBindingConfig.where);
        l_pr.addProperty("who", itemBindingConfig.who);
        l_pr.addProperty("address", itemBindingConfig.where);

        int l_who = Integer.parseInt(itemBindingConfig.who);
        switch (l_who) {
            // Lights
          case 1:
            {
              if (OnOffType.ON.equals(command)) l_pr.addProperty("what", "1");
              else l_pr.addProperty("what", "0");
              break;
            }
            // Shutter
          case 2:
            {
              if (UpDownType.UP.equals(command)) l_pr.addProperty("what", "1");
              else if (UpDownType.DOWN.equals(command)) l_pr.addProperty("what", "2");
              else if (StopMoveType.STOP.equals(command)) l_pr.addProperty("what", "0");
              break;
            }
            // CEN Basic & Evolved
          case 15:
            {
              // Only for the on type, send a CEN event (aka a pushbutton
              // device)
              // the CEN can start a scenario on eg. a MH200N gateway
              // device
              if (OnOffType.ON.equals(command)) l_pr.addProperty("what", itemBindingConfig.what);
              break;
            }
        }

        m_open_web_net.onCommand(l_pr);
      }
    } catch (Exception e) {
      logger.error(
          "Gateway [" + m_gateway_id + "], Error processing receiveCommand '{}'",
          (Object[]) new String[] {e.getMessage()});
    }
  }