Examples of DSCAlarmBindingConfig


Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

    if(dscAlarmItemType == null) {
      logger.error("processBindingConfiguration(): {}: DSC Alarm Item Type is NULL! Item Not Added!",item.getName());
      return;
    }
   
    DSCAlarmBindingConfig config = new DSCAlarmBindingConfig(dscAlarmDeviceType, partitionId, zoneId, dscAlarmItemType);
    addBindingConfig(item, config);
    Set<Item> items = contextMap.get(context);
    if (items == null) {
      items = new HashSet<Item>();
      contextMap.put(context, items);
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

    } else {

      DSCAlarmBindingProvider dscAlarmBindingProvider = (DSCAlarmBindingProvider) provider;
     
      if(dscAlarmBindingProvider != null) {
        DSCAlarmBindingConfig dscAlarmBindingConfig = dscAlarmBindingProvider.getDSCAlarmBindingConfig(itemName);
        if(dscAlarmBindingConfig != null) {
          dscAlarmUpdateMap.put(itemName, dscAlarmBindingConfig);
        }
      }
    }
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

  /**
   * @{inheritDoc
   */
  @Override
  protected void internalReceiveCommand(String itemName, Command command) {
    DSCAlarmBindingConfig dscAlarmBindingConfig = null;
    Item item = null;
    for (DSCAlarmBindingProvider prov : providers) {
      dscAlarmBindingConfig = prov.getDSCAlarmBindingConfig(itemName);
      item = prov.getItem(itemName);
      if( dscAlarmBindingConfig != null) {
        DSCAlarmDeviceType dscAlarmDeviceType = dscAlarmBindingConfig.getDeviceType();
        int partitionId;
        int zoneId;
   
        logger.debug("internalReceiveCommand():  Item Name: {} Command: {} Item Device Type: {}",itemName,command,dscAlarmDeviceType);

        if(connected) {
          switch(dscAlarmDeviceType) {
            case PANEL:
              switch (dscAlarmBindingConfig.getDSCAlarmItemType()) {
                case PANEL_CONNECTION:
                  if(command.toString() == "0") {
                    closeConnection();
                    if(!connected) {
                      dscAlarmItemUpdate.setConnected(false);
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 0, "Disconnected");
                    }
                  }
                  break;
                case PANEL_COMMAND:
                  int cmd = Integer.parseInt(command.toString());
                  switch (cmd) {
                  case 0: api.sendCommand(APICode.Poll);
                    break;
                  case 1: api.sendCommand(APICode.StatusReport);
                    break;
                  case 2: api.sendCommand(APICode.LabelsRequest);
                    break;
                  case 8: api.sendCommand(APICode.DumpZoneTimers);
                    break;
                  case 10: api.sendCommand(APICode.SetTimeDate);
                    break;
                  case 200: api.sendCommand(APICode.CodeSend);
                    break;
                  default:
                    break;
                  }

                  itemName = getItemName(DSCAlarmItemType.PANEL_COMMAND,0,0);
                  if(itemName != "") {
                    updateDeviceProperties(itemName,-1,"");
                    updateItem(itemName);
                  }
                  break;
                default:
                  break;
              }
             
              break;
            case PARTITION:
              partitionId = dscAlarmBindingConfig.getPartitionId();
              switch(dscAlarmBindingConfig.getDSCAlarmItemType()) {
                case PARTITION_ARM_MODE:
                  if(command.toString().equals("0")) {
                    if(api.sendCommand(APICode.PartitionDisarmControl, String.valueOf(partitionId))) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 0, "Partition Disarmed");
                    }
                  }else if(command.toString().equals("1")) {
                    if(api.sendCommand(APICode.PartitionArmControlAway, String.valueOf(partitionId))) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 1, "Partition Armed (Away)");
                    }
                  }else if(command.toString().equals("2")) {
                    if(api.sendCommand(APICode.PartitionArmControlStay, String.valueOf(partitionId))) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 2, "Partition Armed (Stay)");
                    }
                  }else if(command.toString().equals("3")) {
                    if(api.sendCommand(APICode.PartitionArmControlZeroEntryDelay, String.valueOf(partitionId))) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 3, "Partition Armed (Zero Entry Delay)");
                    }
                  }else if(command.toString().equals("4")) {
                    if(api.sendCommand(APICode.PartitionArmControlWithUserCode, String.valueOf(partitionId))) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 4, "Partition Armed (With User Code)");
                    }
                  }
                  break;
                default:
                  break;
              }
             
              dscAlarmUpdateMap.put(itemName, dscAlarmBindingConfig);
              processUpdateMap();
              break;
            case ZONE:
              partitionId = dscAlarmBindingConfig.getPartitionId();
              zoneId = dscAlarmBindingConfig.getZoneId();
              switch(dscAlarmBindingConfig.getDSCAlarmItemType()) {
                case ZONE_BYPASS_MODE:
                  if(command.toString().equals("0")) {
                    String data = String.valueOf(partitionId) + "*1" + String.format("%02d", zoneId) + "#";
                    if(api.sendCommand(APICode.KeySequence, data)) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 0, "Zone Armed");
                    }
                  }else if(command.toString().equals("1")) {
                    String data = String.valueOf(partitionId) + "*1" + String.format("%02d", zoneId) + "#";
                    if(api.sendCommand(APICode.KeySequence, data)) {
                      dscAlarmItemUpdate.updateDeviceProperties(item, dscAlarmBindingConfig, 1, "Zone Bypassed");
                    }                   
                  }
                  break;
 
                   
                default:
                  break;
              }
             
              break;
            default:
              logger.debug("internalReceiveCommand(): No Command Sent.");
              break;
          }
        }
        else {
          if(dscAlarmDeviceType == DSCAlarmDeviceType.PANEL) {
            if(dscAlarmBindingConfig.getDSCAlarmItemType() == DSCAlarmItemType.PANEL_CONNECTION) {
              if(command.toString().equals("1")) {
                if (api != null) {
                  openConnection();
                  if(connected){
                    dscAlarmItemUpdate.setConnected(true);
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

   /**
   * Build the Update Items Map
   */
  private void buildUpdateMap() {
    DSCAlarmBindingConfig config;

    for (DSCAlarmBindingProvider prov : providers) {
       if(!prov.getItemNames().isEmpty()) {
         itemCount = prov.getItemNames().size();        
        dscAlarmUpdateMap.clear();
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

    }
   
    Map<String, DSCAlarmBindingConfig> itemsMap = new HashMap<String, DSCAlarmBindingConfig>(dscAlarmUpdateMap);
 
    for (String itemName : itemsMap.keySet()) {
      DSCAlarmBindingConfig dscAlarmBindingConfig = itemsMap.get(itemName);
      dscAlarmUpdateMap.remove(itemName);
      Item item = null;
      for (DSCAlarmBindingProvider provider : providers) {
        item = provider.getItem(itemName);
      }
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

   * @param zoneId
   * @return itemName
   */
  private String getItemName(DSCAlarmItemType dscAlarmItemType, int partitionId, int zoneId) {
    String itemName = "";
    DSCAlarmBindingConfig config = null;
   
    for (DSCAlarmBindingProvider prov : providers) {
      for (String iName : prov.getItemNames()) {
        config = prov.getDSCAlarmBindingConfig(iName);
        if(config.getDSCAlarmItemType() == dscAlarmItemType) {
          if((config.getPartitionId() == partitionId) && (config.getZoneId() == zoneId)) {
            itemName = iName;
            break;
          }
        }
      }
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

   * Update a DSC Alarm item
   *
   * @param itemName
   */
  private void updateItem(String itemName) {
    DSCAlarmBindingConfig config = null;
    Item item = null;

    for (DSCAlarmBindingProvider prov : providers) {
      for (String iName : prov.getItemNames()) {
        if(itemName == iName) {
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

   * @param itemName
   * @param state
   * @param description
   */ 
  private void updateDeviceProperties(String itemName, int state, String description) {
    DSCAlarmBindingConfig config = null;
    Item item = null;

    for (DSCAlarmBindingProvider prov : providers) {
      for (String iName : prov.getItemNames()) {
        if(itemName == iName) {
View Full Code Here

Examples of org.openhab.binding.dscalarm.DSCAlarmBindingConfig

    APIMessage.APIMessageType apiMessageType = apiMessage.getAPIMessageType();

    DSCAlarmItemType dscAlarmItemType = null;
    APICode apiCode = APICode.getAPICodeValue(apiMessage.getAPICode());
    String apiData = apiMessage.getAPIData();
    DSCAlarmBindingConfig config = null;
    Item item = null;
    String itemName = "";
    int forLimit = 1;

    boolean found = false;
   
    switch(apiCode) {
      case CommandAcknowledge: /*500*/
        dscAlarmItemUpdate.setConnected(true);
        dscAlarmItemType = DSCAlarmItemType.PANEL_CONNECTION;
        break;
      case SystemError: /*502*/
        dscAlarmItemType = DSCAlarmItemType.PANEL_SYSTEM_ERROR;
        break;
      case KeypadLEDState: /*510*/
      case KeypadLEDFlashState: /*511*/
        keypadLEDStateEventHandler(event);
        break;
      case TimeDateBroadcast: /*550*/
        dscAlarmItemType = DSCAlarmItemType.PANEL_TIME_DATE;
        break;
      case PartitionReady: /*650*/
      case PartitionNotReady: /*651*/
      case PartitionReadyForceArming: /*653*/
      case PartitionInAlarm: /*654*/
      case FailureToArm: /*672*/
      case SystemArmingInProgress:
        dscAlarmItemType = DSCAlarmItemType.PARTITION_STATUS;
        break;
      case PartitionArmed: /*652*/
        forLimit = 2;
      case PartitionDisarmed: /*655*/
        dscAlarmItemType = DSCAlarmItemType.PARTITION_ARM_MODE;
        break;
      case ZoneAlarm: /*601*/
      case ZoneAlarmRestore: /*602*/
        dscAlarmItemType = DSCAlarmItemType.ZONE_ALARM_STATUS;
        break;
      case ZoneTamper: /*603*/
      case ZoneTamperRestore: /*604*/
        dscAlarmItemType = DSCAlarmItemType.ZONE_TAMPER_STATUS;
        break;
      case ZoneFault: /*605*/
      case ZoneFaultRestore: /*606*/
        dscAlarmItemType = DSCAlarmItemType.ZONE_FAULT_STATUS;
        break;
      case ZoneOpen: /*609*/
      case ZoneRestored: /*610*/
        dscAlarmItemType = DSCAlarmItemType.ZONE_GENERAL_STATUS;
        break;
      case CodeRequired: /*900*/
        api.sendCommand(APICode.CodeSend);
        break;
      case LEDStatus: /*903*/
        int aData = Integer.parseInt(apiData.substring(0,1));
        switch(aData) {
          case 1:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_READY_LED;
            break;
          case 2:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_ARMED_LED;
            break;
          case 3:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_MEMORY_LED;
            break;
          case 4:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_BYPASS_LED;
            break;
          case 5:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_TROUBLE_LED;
            break;
          case 6:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_PROGRAM_LED;
            break;
          case 7:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_FIRE_LED;
            break;
          case 8:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_BACKLIGHT_LED;
            break;
          case 9:
            dscAlarmItemType = DSCAlarmItemType.KEYPAD_AC_LED;
            break;
        }
      default:
        break;
   
    }

    int partitionId = apiMessage.getPartition();
   
    int zoneId = apiMessage.getZone();
   
    logger.debug("dscAlarmEventRecieved(): Event received! Looking for item: {}", dscAlarmItemType);

    for (int i=0; i <= forLimit; i++) {
      if(dscAlarmItemType != null) {
        for (DSCAlarmBindingProvider prov : providers) {
          for (String iName : prov.getItemNames()) {
            config = prov.getDSCAlarmBindingConfig(iName);
            if(config != null) {
              switch(apiMessageType) {
                case PANEL_EVENT:
                  if(dscAlarmItemType == config.getDSCAlarmItemType()) {
                    itemName = iName;
                    found = true;
                  }
                  break;
                case PARTITION_EVENT:
                  if(partitionId == config.getPartitionId() && dscAlarmItemType == config.getDSCAlarmItemType()) {
                    itemName = iName;
                    found = true;
                  }
                  break;
                case ZONE_EVENT:
                  if(zoneId == config.getZoneId() && dscAlarmItemType == config.getDSCAlarmItemType()) {
                    itemName = iName;
                    found = true;
                  }
                  break;
                case KEYPAD_EVENT:
                  if(dscAlarmItemType == config.getDSCAlarmItemType()) {
                    itemName = iName;
                    found = true;
                  }
                  break;
                default:
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.