예제 #1
0
 /**
  * Updates a AudioZone's source text fields when a AudioSource changes
  *
  * @param as the audio source that has been updated
  */
 private void updateAudioZoneText(AudioSource as) {
   for (OmniLinkBindingProvider provider : providers) {
     for (String itemName : provider.getItemNames()) {
       OmniLinkBindingConfig config = provider.getOmniLinkBindingConfig(itemName);
       if (config != null) {
         switch (config.getObjectType()) {
           case AUDIOZONE_TEXT:
           case AUDIOZONE_TEXT_FIELD1:
           case AUDIOZONE_TEXT_FIELD2:
           case AUDIOZONE_TEXT_FIELD3:
             {
               AudioZone az = (AudioZone) config.getDevice();
               az.setAudioSource(audioSourceMap);
               if (az.getProperties().getSource() == as.getProperties().getNumber()) {
                 az.updateItem(provider.getItem(itemName), config, eventPublisher);
               }
             }
             break;
           default:
             break;
         }
       }
     }
   }
 }
예제 #2
0
  /**
   * Update a device based on a status message from the system
   *
   * @param status
   */
  protected void updateDeviceStatus(Status status) {

    logger.debug("updateDeviceStatus {} {}", status.getNumber(), status.getClass());

    Integer number = new Integer(status.getNumber());

    if (status instanceof UnitStatus && unitMap.containsKey(number)) {
      Unit unit = unitMap.get(number);
      unit.getProperties().updateUnit((UnitStatus) status);
      updateItemsForDevice(unit);
    } else if (status instanceof ThermostatStatus && thermostatMap.containsKey(number)) {
      logger.debug("Updating thermo " + number);
      Thermostat thermo = thermostatMap.get(number);
      thermo.getProperties().updateThermostat((ThermostatStatus) status);
      updateItemsForDevice(thermo);
    } else if (status instanceof AudioZoneStatus && audioZoneMap.containsKey(number)) {
      logger.debug("Updating audioZone " + number);
      AudioZone az = audioZoneMap.get(number);
      az.getProperties().updateAudioZone((AudioZoneStatus) status);
      updateItemsForDevice(az);
    } else if (status instanceof AreaStatus && areaMap.containsKey(number)) {
      logger.debug("Updating area " + number);
      Area area = areaMap.get(number);
      area.getProperties().updateArea((AreaStatus) status);
      updateItemsForDevice(area);
    } else if (status instanceof ZoneStatus && zoneMap.containsKey(number)) {
      logger.debug("Updating zone " + number);
      Zone zone = zoneMap.get(number);
      zone.getProperties().updateZone((ZoneStatus) status);
      updateItemsForDevice(zone);
    }
  }
예제 #3
0
    /**
     * This goes through a map of item names and updates their state's
     *
     * @throws IOException
     * @throws OmniNotConnectedException
     * @throws OmniInvalidResponseException
     * @throws OmniUnknownMessageTypeException
     */
    private void updateRefreshItems()
        throws IOException, OmniNotConnectedException, OmniInvalidResponseException,
            OmniUnknownMessageTypeException {

      if (refreshMap.size() == 0) return;

      Map<String, OmniLinkBindingConfig> itemMap =
          new HashMap<String, OmniLinkBindingConfig>(refreshMap);

      for (String itemName : itemMap.keySet()) {
        OmniLinkBindingConfig config = itemMap.get(itemName);
        refreshMap.remove(itemName);
        if (config != null) {
          Integer number = new Integer(config.getNumber());
          for (OmniLinkBindingProvider provider : providers) {
            switch (config.getObjectType()) {
              case UNIT:
                {
                  UnitProperties p = readUnitProperties(config.getNumber());
                  Unit unit = unitMap.get(number);
                  if (unit == null) {
                    unit = new Unit(p);
                    unitMap.put(number, unit);
                  }
                  config.setDevice(unit);
                  unit.setProperties(p);
                  unit.updateItem(provider.getItem(itemName), config, eventPublisher);
                }
                break;
              case THERMO_COOL_POINT:
              case THERMO_FAN_MODE:
              case THERMO_HEAT_POINT:
              case THERMO_HOLD_MODE:
              case THERMO_SYSTEM_MODE:
              case THERMO_TEMP:
                {
                  ThermostatProperties p = readThermoProperties(config.getNumber());
                  Thermostat thermo = thermostatMap.get(number);
                  if (thermo == null) {
                    thermo = new Thermostat(p, celius);
                    thermostatMap.put(number, thermo);
                  }
                  config.setDevice(thermo);
                  thermo.setProperties(p);
                  thermo.updateItem(provider.getItem(itemName), config, eventPublisher);
                }
                break;
              case AUDIOZONE_MUTE:
              case AUDIOZONE_POWER:
              case AUDIOZONE_SOURCE:
              case AUDIOZONE_KEY:
              case AUDIOZONE_TEXT:
              case AUDIOZONE_TEXT_FIELD1:
              case AUDIOZONE_TEXT_FIELD2:
              case AUDIOZONE_TEXT_FIELD3:
              case AUDIOZONE_VOLUME:
                {
                  AudioZoneProperties p = readAudioZoneProperties(config.getNumber());
                  AudioZone audioZone = audioZoneMap.get(number);
                  if (audioZone == null) {
                    audioZone = new AudioZone(p);
                    audioZone.setAudioSource(audioSourceMap);
                    audioZoneMap.put(number, audioZone);
                  }
                  config.setDevice(audioZone);
                  audioZone.setProperties(p);
                  audioZone.updateItem(provider.getItem(itemName), config, eventPublisher);
                }
                break;
              case AUDIOSOURCE_TEXT:
              case AUDIOSOURCE_TEXT_FIELD1:
              case AUDIOSOURCE_TEXT_FIELD2:
              case AUDIOSOURCE_TEXT_FIELD3:
                {
                  AudioSource as = audioSourceMap.get(number);
                  if (as != null) {
                    config.setDevice(as);
                    as.updateItem(provider.getItem(itemName), config, eventPublisher);
                  }
                }
                break;
              case AREA_ENTRY_TIMER:
              case AREA_EXIT_TIMER:
              case AREA_STATUS_ALARM:
              case AREA_STATUS_ENTRY_DELAY:
              case AREA_STATUS_EXIT_DELAY:
              case AREA_STATUS_MODE:
                {
                  AreaProperties p = readAreaProperties(config.getNumber());
                  Area area = areaMap.get(number);
                  if (area == null) {
                    area = new Area(p, omni);
                    areaMap.put(number, area);
                  }
                  config.setDevice(area);
                  area.setProperties(p);
                  area.updateItem(provider.getItem(itemName), config, eventPublisher);
                }
                break;
              case AUX_CURRENT:
              case AUX_HIGH:
              case AUX_LOW:
              case AUX_STATUS:
                {
                  AuxSensorProperties p = readAuxProperties(config.getNumber());
                  Auxiliary auxiliary = auxMap.get(number);
                  if (auxiliary == null) {
                    auxiliary = new Auxiliary(p, celius);
                    auxMap.put(number, auxiliary);
                  }
                  config.setDevice(auxiliary);
                  auxiliary.setProperties(p);
                  auxiliary.updateItem(provider.getItem(itemName), config, eventPublisher);
                }
                break;
              case ZONE_STATUS_ARMING:
              case ZONE_STATUS_CURRENT:
              case ZONE_STATUS_LATCHED:
              case ZONE_STATUS_ALL:
                {
                  ZoneProperties p = readZoneProperties(config.getNumber());
                  Zone zone = zoneMap.get(number);
                  if (zone == null) {
                    zone = new Zone(p);
                    zoneMap.put(number, zone);
                  }
                  config.setDevice(zone);
                  zone.setProperties(p);
                  zone.updateItem(provider.getItem(itemName), config, eventPublisher);
                }
                break;
              case BUTTON:
                {
                  ButtonProperties p = readButtonProperties(config.getNumber());
                  Button button = buttonMap.get(number);
                  if (button == null) {
                    button = new Button(p);
                    buttonMap.put(number, button);
                  }
                  config.setDevice(button);
                }
                break;
              default:
                break;
            }
          }
        }
      }
    }