use of org.creek.mailcontrol.model.data.ItemStateData in project openhab1-addons by openhab.
the class ItemStateRequestProcessor method getItemState.
public ItemStateData getItemState(String itemId) throws ServiceException {
ItemRegistry itemRegistry = getItemRegistry();
ItemStateData itemState = null;
try {
Item item = itemRegistry.getItem(itemId);
StateTransformable state = getState(item);
itemState = new ItemStateData(System.currentTimeMillis(), itemId, state);
} catch (ItemNotFoundException ex) {
logger.info(itemId + " not found", ex);
}
return itemState;
}
use of org.creek.mailcontrol.model.data.ItemStateData in project openhab1-addons by openhab.
the class ItemStateRequestProcessor method getItemStates.
public List<ItemStateData> getItemStates() throws ServiceException {
List<ItemStateData> itemStates = new ArrayList<ItemStateData>();
ItemRegistry itemRegistry = getItemRegistry();
for (Item item : itemRegistry.getItems()) {
logger.debug("Item: " + item.getName() + " " + item.getState());
StateTransformable state = getState(item);
ItemStateData itemState = new ItemStateData(System.currentTimeMillis(), item.getName(), state);
itemStates.add(itemState);
}
return itemStates;
}
use of org.creek.mailcontrol.model.data.ItemStateData in project openhab1-addons by openhab.
the class MessagesProcessor method processReceivedMessages.
public void processReceivedMessages(Set<Object> messages) throws TransformException, ServiceException {
logger.debug("Processing messages");
for (Object msg : messages) {
if (msg instanceof String) {
logger.debug("Message: " + msg);
GenericMessage message = requestTransformer.transform((String) msg);
logger.debug("Processing message: " + message);
if (message.getMessageType() == ITEM_COMMAND_REQUEST_MESSAGE) {
ItemCommandData itemCommand = (ItemCommandData) ((ItemCommandRequestMessage) message).getItemCommand();
itemCommandProcessor.processItemCommand(itemCommand);
} else if (message.getMessageType() == ITEM_STATE_REQUEST_MESSAGE) {
ItemStateRequestMessage itemStateRequestMessage = (ItemStateRequestMessage) message;
ItemStateData itemState = itemStateRequestProcessor.getItemState(itemStateRequestMessage.getItemId());
messagesSender.sendMessage(message, itemState);
} else if (message.getMessageType() == ITEMS_STATE_REQUEST_MESSAGE) {
List<ItemStateData> itemStates = itemStateRequestProcessor.getItemStates();
messagesSender.sendMessage(message, itemStates);
}
}
}
}
Aggregations