Search in sources :

Example 1 with StateTransformable

use of org.creek.mailcontrol.model.data.StateTransformable in project openhab1-addons by openhab.

the class ItemStateRequestProcessor method getState.

private StateTransformable getState(Item item) {
    StateTransformable state = null;
    if (item.getState() instanceof HSBType) {
        HSBType hsb = (HSBType) item.getState();
        state = new HSBData(hsb.getHue().longValue(), hsb.getHue().longValue(), hsb.getHue().longValue());
    } else if (item.getState() instanceof DateTimeType) {
        DateTimeType dt = (DateTimeType) item.getState();
        DateTimeDataType data = new DateTimeDataType(dt.toString());
        state = new DateTimeData(data);
    } else if (item.getState() instanceof DecimalType) {
    } else if (item.getState() instanceof OnOffType) {
    } else if (item.getState() instanceof OpenClosedType) {
    } else if (item.getState() instanceof PercentType) {
    } else if (item.getState() instanceof UpDownType) {
    }
    return state;
}
Also used : DateTimeType(org.openhab.core.library.types.DateTimeType) DateTimeDataType(org.creek.mailcontrol.model.types.DateTimeDataType) StateTransformable(org.creek.mailcontrol.model.data.StateTransformable) HSBData(org.creek.mailcontrol.model.data.HSBData) OnOffType(org.openhab.core.library.types.OnOffType) OpenClosedType(org.openhab.core.library.types.OpenClosedType) DecimalType(org.openhab.core.library.types.DecimalType) DateTimeData(org.creek.mailcontrol.model.data.DateTimeData) UpDownType(org.openhab.core.library.types.UpDownType) PercentType(org.openhab.core.library.types.PercentType) HSBType(org.openhab.core.library.types.HSBType)

Example 2 with StateTransformable

use of org.creek.mailcontrol.model.data.StateTransformable 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;
}
Also used : Item(org.openhab.core.items.Item) StateTransformable(org.creek.mailcontrol.model.data.StateTransformable) ItemStateData(org.creek.mailcontrol.model.data.ItemStateData) ItemRegistry(org.openhab.core.items.ItemRegistry) ItemNotFoundException(org.openhab.core.items.ItemNotFoundException)

Example 3 with StateTransformable

use of org.creek.mailcontrol.model.data.StateTransformable 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;
}
Also used : Item(org.openhab.core.items.Item) StateTransformable(org.creek.mailcontrol.model.data.StateTransformable) ArrayList(java.util.ArrayList) ItemStateData(org.creek.mailcontrol.model.data.ItemStateData) ItemRegistry(org.openhab.core.items.ItemRegistry)

Aggregations

StateTransformable (org.creek.mailcontrol.model.data.StateTransformable)3 ItemStateData (org.creek.mailcontrol.model.data.ItemStateData)2 Item (org.openhab.core.items.Item)2 ItemRegistry (org.openhab.core.items.ItemRegistry)2 ArrayList (java.util.ArrayList)1 DateTimeData (org.creek.mailcontrol.model.data.DateTimeData)1 HSBData (org.creek.mailcontrol.model.data.HSBData)1 DateTimeDataType (org.creek.mailcontrol.model.types.DateTimeDataType)1 ItemNotFoundException (org.openhab.core.items.ItemNotFoundException)1 DateTimeType (org.openhab.core.library.types.DateTimeType)1 DecimalType (org.openhab.core.library.types.DecimalType)1 HSBType (org.openhab.core.library.types.HSBType)1 OnOffType (org.openhab.core.library.types.OnOffType)1 OpenClosedType (org.openhab.core.library.types.OpenClosedType)1 PercentType (org.openhab.core.library.types.PercentType)1 UpDownType (org.openhab.core.library.types.UpDownType)1