use of org.openhab.binding.zwave.internal.protocol.commandclass.ZWaveCommandClass in project openhab1-addons by openhab.
the class ZWaveConverterHandler method getRefreshInterval.
/**
* Get the refresh interval for an item binding
*
* @param provider
* the {@link ZWaveBindingProvider} that provides the item
* @param itemName
* the name of the item to poll.
*/
@SuppressWarnings("unchecked")
public Integer getRefreshInterval(ZWaveBindingProvider provider, String itemName) {
ZWaveBindingConfig bindingConfiguration = provider.getZwaveBindingConfig(itemName);
ZWaveCommandClass commandClass;
String commandClassName = bindingConfiguration.getArguments().get("command");
// this binding is configured not to poll.
if (bindingConfiguration.getRefreshInterval() != null && 0 == bindingConfiguration.getRefreshInterval()) {
return 0;
}
ZWaveNode node = this.controller.getNode(bindingConfiguration.getNodeId());
// ignore nodes that are not initialized.
if (node == null) {
return 0;
}
if (commandClassName != null) {
// this is a report item, handle it with the report info converter.
if (commandClassName.equalsIgnoreCase("info")) {
return infoConverter.getRefreshInterval();
}
if (node.getNodeId() == this.controller.getOwnNodeId() && commandClassName.equalsIgnoreCase("switch_all")) {
return 0;
}
commandClass = node.resolveCommandClass(CommandClass.getCommandClass(commandClassName), bindingConfiguration.getEndpoint());
if (commandClass == null) {
logger.warn("No command class found for item = {}, command class name = {}, using 0 refresh interval.", itemName, commandClassName);
return 0;
}
} else {
commandClass = resolveConverter(provider.getItem(itemName), node, bindingConfiguration.getEndpoint());
}
if (commandClass == null) {
logger.warn("No converter found for item = {}, using 0 refresh interval.", itemName);
return 0;
}
ZWaveCommandClassConverter<ZWaveCommandClass> converter = (ZWaveCommandClassConverter<ZWaveCommandClass>) getConverter(commandClass.getCommandClass());
if (converter == null) {
logger.warn("No converter found for item = {}, using 0 refresh interval.", itemName);
return 0;
}
if (bindingConfiguration.getRefreshInterval() == null) {
bindingConfiguration.setRefreshInterval(converter.getRefreshInterval());
}
return bindingConfiguration.getRefreshInterval();
}
Aggregations