Package org.openhab.core.events

Examples of org.openhab.core.events.EventPublisher


   * @param args array which contains the arguments for the update command
   * @param console the console for printing messages for the user
   */
  static public void handleUpdate(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ConsoleActivator.eventPublisherTracker.getService();
    if(publisher!=null) {
      if(registry!=null) {
        if(args.length>0) {
          String itemName = args[0];
          try {
            Item item = registry.getItemByPattern(itemName);
            if(args.length>1) {
              String stateName = args[1];
              State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateName);
              if(state!=null) {
                publisher.postUpdate(item.getName(), state);
                console.println("Update has been sent successfully.");
              } else {
                console.println("Error: State '" + stateName +
                    "' is not valid for item '" + itemName + "'");
                console.print("Valid data types are: ( ");
View Full Code Here


   * @param args array which contains the arguments for the send command
   * @param console the console for printing messages for the user
   */
  static public void handleSend(String[] args, Console console) {
    ItemRegistry registry = (ItemRegistry) ConsoleActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ConsoleActivator.eventPublisherTracker.getService();
    if(publisher!=null) {
      if(registry!=null) {
        if(args.length>0) {
          String itemName = args[0];
          try {
            Item item = registry.getItemByPattern(itemName);
            if(args.length>1) {
              String commandName = args[1];
              Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandName);
              if(command!=null) {
                publisher.sendCommand(itemName, command);
                console.println("Command has been sent successfully.");
              } else {
                console.println("Error: Command '" + commandName +
                    "' is not valid for item '" + itemName + "'");
                console.print("Valid command types are: ( ");
View Full Code Here

  static private final Logger logger = LoggerFactory.getLogger(BusEvent.class);
 
  static public void sendCommand(String itemName, String commandString) {
    ItemRegistry registry = (ItemRegistry) RulesActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) RulesActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandString);
        publisher.sendCommand(itemName, command);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
  }
View Full Code Here

    }
  }

  static public void postUpdate(String itemName, String stateString) {
    ItemRegistry registry = (ItemRegistry) RulesActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) RulesActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateString);
        publisher.postUpdate(itemName, state);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
  }
View Full Code Here

   * @param itemName the name of the item to send the command to
   * @param commandString the command to send
   */
  static public Object sendCommand(String itemName, String commandString) {
    ItemRegistry registry = (ItemRegistry) ScriptActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        Command command = TypeParser.parseCommand(item.getAcceptedCommandTypes(), commandString);
        publisher.sendCommand(itemName, command);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
    return null;
View Full Code Here

   *
   * @param item the item to send the command to
   * @param command the command to send
   */
  static public Object sendCommand(Item item, Command command) {
    EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
    if (publisher!=null && item != null) {
      publisher.sendCommand(item.getName(), command);
    }
    return null;
  }
View Full Code Here

   * @param itemName the name of the item to send the status update for
   * @param stateAsString the new state of the item
   */
  static public Object postUpdate(String itemName, String stateString) {
    ItemRegistry registry = (ItemRegistry) ScriptActivator.itemRegistryTracker.getService();
    EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
    if(publisher!=null && registry!=null) {
      try {
        Item item = registry.getItem(itemName);
        State state = TypeParser.parseState(item.getAcceptedDataTypes(), stateString);
        publisher.postUpdate(itemName, state);
      } catch (ItemNotFoundException e) {
        logger.warn("Item '" + itemName + "' does not exist.");
      }
    }
    return null;
View Full Code Here

   * t
   * @param item the item to send the status update for
   * @param state the new state of the item
   */
  static public Object postUpdate(Item item, State state) {
    EventPublisher publisher = (EventPublisher) ScriptActivator.eventPublisherTracker.getService();
    if (publisher!=null && item != null) {
      publisher.postUpdate(item.getName(), state);
    }
    return null;
  }
View Full Code Here

TOP

Related Classes of org.openhab.core.events.EventPublisher

Copyright © 2018 www.massapicom. 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.