use of org.openhab.binding.homematic.internal.model.HmValueItem in project openhab1-addons by openhab.
the class ItemDisabler method run.
/**
* Sends the OFF commands to the openHAB bus.
*/
@Override
public void run() {
Iterator<Map.Entry<HomematicBindingConfig, Long>> iterator = itemsToDisable.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<HomematicBindingConfig, Long> entry = iterator.next();
long diff = System.currentTimeMillis() - entry.getValue();
if (diff > MIN_AGE) {
new ProviderItemIterator().iterate(entry.getKey(), new ProviderItemIteratorCallback() {
@Override
public void next(HomematicBindingConfig providerBindingConfig, Item item, Converter<?> converter) {
HmValueItem hmValueItem = context.getStateHolder().getState(providerBindingConfig);
if (providerBindingConfig instanceof ProgramConfig || providerBindingConfig instanceof ActionConfig) {
context.getEventPublisher().postUpdate(item.getName(), OnOffType.OFF);
} else {
hmValueItem.setValue(converter.convertToBinding(OnOffType.OFF, hmValueItem));
State state = converter.convertFromBinding(hmValueItem);
context.getEventPublisher().postUpdate(item.getName(), state);
}
logger.debug("Disabled Item {} with binding {}", item.getName(), providerBindingConfig);
}
});
iterator.remove();
}
}
}
use of org.openhab.binding.homematic.internal.model.HmValueItem in project openhab1-addons by openhab.
the class RemoteControlOptionParser method getValueItems.
/**
* Returns all possible value items from the remote control.
*/
private String[] getValueItems(String parameterName) {
DatapointConfig dpConfig = new DatapointConfig(remoteControlAddress, "18", parameterName);
HmValueItem hmValueItem = context.getStateHolder().getState(dpConfig);
if (hmValueItem != null) {
String[] valueList = (String[]) ArrayUtils.remove(hmValueItem.getValueList(), 0);
int onIdx = ArrayUtils.indexOf(valueList, "ON");
if (onIdx != -1) {
valueList[onIdx] = parameterName + "_ON";
}
return valueList;
}
return new String[0];
}
use of org.openhab.binding.homematic.internal.model.HmValueItem in project openhab1-addons by openhab.
the class StateHolder method loadDatapoints.
/**
* Loads all datapoints from the Homematic server, only executed at startup.
*/
public void loadDatapoints() throws HomematicClientException {
logger.info("Loading Homematic datapoints");
context.getHomematicClient().iterateAllDatapoints(new HmValueItemIteratorCallback() {
@Override
public void iterate(HomematicBindingConfig bindingConfig, HmValueItem hmValueItem) {
datapoints.put(bindingConfig, hmValueItem);
}
});
logger.info("Finished loading {} Homematic datapoints", datapoints.size());
}
use of org.openhab.binding.homematic.internal.model.HmValueItem in project openhab1-addons by openhab.
the class StateHolder method updateRssiInfo.
/**
* Upates the RSSI datapoint if available.
*/
private void updateRssiInfo(DatapointConfig bindingConfig, Integer rssiValue) {
HmValueItem valueItem = datapoints.get(bindingConfig);
if (valueItem != null) {
if (!valueItem.getValue().equals(rssiValue)) {
logger.debug("Value changed from '{}' to '{}' for binding {}", valueItem == null ? "null" : valueItem.getValue(), rssiValue, bindingConfig);
valueItem.setValue(rssiValue);
publish(bindingConfig, valueItem);
}
} else {
logger.debug("Rssi info not found: {}", bindingConfig);
}
}
use of org.openhab.binding.homematic.internal.model.HmValueItem in project openhab1-addons by openhab.
the class HomematicCommunicator method publishChangedItemToOpenhab.
/**
* Called on startup or when some binding has changed, for example if a item
* file is reloaded. Publishes the current States to openHAB.
*/
public void publishChangedItemToOpenhab(Item item, HomematicBindingConfig bindingConfig) {
HmValueItem hmValueItem = context.getStateHolder().getState(bindingConfig);
if (hmValueItem != null) {
Converter<?> converter = context.getConverterFactory().createConverter(item, bindingConfig);
if (converter != null) {
State state = converter.convertFromBinding(hmValueItem);
context.getEventPublisher().postUpdate(item.getName(), state);
}
} else if (bindingConfig instanceof ProgramConfig || bindingConfig instanceof ActionConfig) {
context.getEventPublisher().postUpdate(item.getName(), OnOffType.OFF);
} else {
logger.warn("Can't find {}, value is not published to openHAB!", bindingConfig);
}
}
Aggregations