@Override protected void internalReceiveUpdate(String itemName, State newState) { MqttItemConfig itemConfig = getBindingProvider().getItemConfig(itemName); for (MqttMessagePublisher publisher : itemConfig.getMessagePublishers()) { if (publisher.supportsState(newState)) { logger.debug("Publishing state {} to {}", newState.toString(), publisher.getTopic()); publisher.publish(publisher.getTopic(), newState.toString().getBytes()); } } }
@Override public void complete_ValidState( EObject model, RuleCall ruleCall, ContentAssistContext context, ICompletionProposalAcceptor acceptor) { super.complete_ValidState(model, ruleCall, context, acceptor); for (State state : stateAndCommandProvider.getAllStates()) { if (state.toString().startsWith(context.getPrefix())) { acceptor.accept(createCompletionProposal(state.toString(), context)); } } }
/* (non-Javadoc) * @see org.openhab.core.binding.AbstractBinding#internalReceiveUpdate(java.lang.String, org.openhab.core.types.State) */ @Override protected void internalReceiveUpdate(String itemName, State newState) { logger.debug("Received update (item='{}', state='{}')", itemName, newState.toString()); if (!isEcho(itemName, newState)) { writeToKNX(itemName, newState); } }
@Override public String toString() { return DateFormat.getDateTimeInstance().format(timestamp) + ": " + name + " -> " + state.toString(); }
/** {@inheritDoc} */ public EList<Widget> renderWidget(Widget w, StringBuilder sb) throws RenderException { Switch s = (Switch) w; String snippetName = null; Item item; try { item = itemUIRegistry.getItem(w.getItem()); if (s.getMappings().size() == 0) { if (item instanceof RollershutterItem) { snippetName = "rollerblind"; } else if (item instanceof GroupItem && ((GroupItem) item).getBaseItem() instanceof RollershutterItem) { snippetName = "rollerblind"; } else { snippetName = "switch"; } } else { snippetName = "buttons"; } } catch (ItemNotFoundException e) { logger.warn("Cannot determine item type of '{}'", w.getItem(), e); snippetName = "switch"; } String snippet = getSnippet(snippetName); snippet = StringUtils.replace(snippet, "%id%", itemUIRegistry.getWidgetId(w)); System.out.println("\nSwitchRenderer->getICon->" + itemUIRegistry.getIcon(w)); snippet = StringUtils.replace(snippet, "%icon%", escapeURLPath(itemUIRegistry.getIcon(w))); snippet = StringUtils.replace(snippet, "%item%", w.getItem()); snippet = StringUtils.replace(snippet, "%label%", getLabel(w)); snippet = StringUtils.replace(snippet, "%servletname%", WebAppServlet.SERVLET_NAME); State state = itemUIRegistry.getState(w); System.out.println("\nSwitchRenderer->getState->" + state.toString()); if (s.getMappings().size() == 0) { if (state instanceof PercentType) { state = ((PercentType) state).intValue() > 0 ? OnOffType.ON : OnOffType.OFF; } if (state.equals(OnOffType.ON)) { snippet = snippet.replaceAll("%checked%", "checked=true"); } else { snippet = snippet.replaceAll("%checked%", ""); } } else { StringBuilder buttons = new StringBuilder(); for (Mapping mapping : s.getMappings()) { String button = getSnippet("button"); button = StringUtils.replace(button, "%item%", w.getItem()); button = StringUtils.replace(button, "%cmd%", mapping.getCmd()); button = StringUtils.replace(button, "%label%", mapping.getLabel()); if (s.getMappings().size() > 1 && state.toString().equals(mapping.getCmd())) { button = StringUtils.replace(button, "%type%", "Warn"); // button with red color } else { button = StringUtils.replace(button, "%type%", "Action"); // button with blue color } buttons.insert(0, button); } snippet = StringUtils.replace(snippet, "%buttons%", buttons.toString()); } // Process the color tags snippet = processColor(w, snippet); sb.append(snippet); return null; }