use of org.openhab.binding.homematic.internal.model.HmBattery in project openhab1-addons by openhab.
the class BaseHomematicClient method addBatteryInfo.
/**
* Adds the battery info datapoint to the specified device if the device has
* batteries.
*/
protected void addBatteryInfo(HmDevice device) throws HomematicClientException {
HmBattery battery = HmBatteryTypeProvider.getBatteryType(device.getType());
if (battery != null) {
for (HmChannel channel : device.getChannels()) {
if ("0".equals(channel.getNumber())) {
try {
logger.debug("Adding battery type to device {}: {}", device.getType(), battery.getInfo());
HmDatapoint dp = new HmDatapoint();
FieldUtils.writeField(dp, "name", "BATTERY_TYPE", true);
FieldUtils.writeField(dp, "writeable", Boolean.FALSE, true);
FieldUtils.writeField(dp, "valueType", 20, true);
dp.setValue(battery.getInfo());
channel.addDatapoint(dp);
} catch (IllegalAccessException ex) {
throw new HomematicClientException(ex.getMessage(), ex);
}
}
}
}
}
Aggregations