use of org.openhab.binding.tinkerforge.internal.model.SwitchSensor in project openhab1-addons by openhab.
the class TinkerforgeBinding method updateItemValues.
/**
* Triggers an update of state values for all devices.
*
* @param provider The {@code TinkerforgeBindingProvider} which is bound to the device as
* {@code Item}
* @param itemName The name of the {@code Item} as String
* @param only_poll_enabled Fetch only the values of devices which do not support callback
* listeners. These devices are marked with poll "true" flag.
*/
protected void updateItemValues(TinkerforgeBindingProvider provider, String itemName, boolean only_poll_enabled) {
if (tinkerforgeEcosystem == null) {
logger.warn("tinkerforge ecosystem not yet ready");
return;
}
String deviceUid = provider.getUid(itemName);
Item item = provider.getItem(itemName);
String deviceSubId = provider.getSubId(itemName);
String deviceName = provider.getName(itemName);
if (deviceName != null) {
String[] ids = getDeviceIdsForDeviceName(deviceName);
deviceUid = ids[0];
deviceSubId = ids[1];
}
MBaseDevice mDevice = tinkerforgeEcosystem.getDevice(deviceUid, deviceSubId);
if (mDevice != null && mDevice.getEnabledA().get()) {
if (only_poll_enabled && !mDevice.isPoll()) {
// do nothing
logger.debug("{} omitting fetch value for no poll{}:{}", LoggerConstants.ITEMUPDATE, deviceUid, deviceSubId);
} else {
if (mDevice instanceof MSensor) {
((MSensor<?>) mDevice).fetchSensorValue();
} else if (mDevice instanceof SwitchSensor && item instanceof SwitchItem) {
((SwitchSensor) mDevice).fetchSwitchState();
} else if (mDevice instanceof DigitalActor) {
((DigitalActor) mDevice).fetchDigitalValue();
}
}
}
}
Aggregations