Example #1
0
 /**
  * For a given {@link Activity}, update an {@link Item} with its {@link State} state
  *
  * @param item
  * @param state
  * @param activity
  */
 private void updateActivityForItem(
     String itemName, Class<? extends Item> itemType, Activity activity) {
   if (itemType.isAssignableFrom(NumberItem.class)) {
     eventPublisher.postUpdate(itemName, new DecimalType(activity.getId()));
   } else {
     eventPublisher.postUpdate(itemName, new StringType(activity.getLabel()));
   }
 }
Example #2
0
  /**
   * For a given {@link Activity}, update all items who need to know about it
   *
   * @param activity
   */
  private void updateActivity(Activity activity, String qualifier) {
    logger.debug("updateActivity {}" + activity.getLabel());
    for (HarmonyHubBindingProvider provider : providers) {
      for (String itemName : provider.getItemNames()) {

        HarmonyHubBindingConfig config = provider.getHarmonyHubBindingConfig(itemName);
        if (config.matchesQualifier(qualifier)
            && config.getBindingType() == HarmonyHubBindingType.CurrentActivity) {
          updateActivityForItem(itemName, config.getItemType(), activity);
        }
      }
    }
  }