use of org.openhab.binding.modbus.stiebeleltron.internal.dto.EnergyBlock in project openhab-addons by openhab.
the class EnergyBlockParser method parse.
public EnergyBlock parse(ModbusRegisterArray raw) {
EnergyBlock block = new EnergyBlock();
block.productionHeatToday = extractUInt16(raw, 0, (short) 0);
block.productionHeatTotalLow = extractUInt16(raw, 1, (short) 0);
block.productionHeatTotalHigh = extractUInt16(raw, 2, (short) 0);
block.productionWaterToday = extractUInt16(raw, 3, (short) 0);
block.productionWaterTotalLow = extractUInt16(raw, 4, (short) 0);
block.productionWaterTotalHigh = extractUInt16(raw, 5, (short) 0);
block.consumptionHeatToday = extractUInt16(raw, 10, (short) 0);
block.consumptionHeatTotalLow = extractUInt16(raw, 11, (short) 0);
block.consumptionHeatTotalHigh = extractUInt16(raw, 12, (short) 0);
block.consumptionWaterToday = extractUInt16(raw, 13, (short) 0);
block.consumptionWaterTotalLow = extractUInt16(raw, 14, (short) 0);
block.consumptionWaterTotalHigh = extractUInt16(raw, 15, (short) 0);
return block;
}
use of org.openhab.binding.modbus.stiebeleltron.internal.dto.EnergyBlock in project openhab-addons by openhab.
the class StiebelEltronHandler method handlePolledEnergyData.
/**
* This method is called each time new data has been polled from the modbus
* slave The register array is first parsed, then each of the channels are
* updated to the new values
*
* @param registers byte array read from the modbus slave
*/
protected void handlePolledEnergyData(ModbusRegisterArray registers) {
logger.trace("Energy block received, size: {}", registers.size());
EnergyBlock block = energyBlockParser.parse(registers);
// Energy information group
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_HEAT_TODAY), new QuantityType<>(block.productionHeatToday, KILOWATT_HOUR));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_HEAT_TOTAL), getEnergyQuantity(block.productionHeatTotalHigh, block.productionHeatTotalLow));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_WATER_TODAY), new QuantityType<>(block.productionWaterToday, KILOWATT_HOUR));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_PRODUCTION_WATER_TOTAL), getEnergyQuantity(block.productionWaterTotalHigh, block.productionWaterTotalLow));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_HEAT_TODAY), new QuantityType<>(block.consumptionHeatToday, KILOWATT_HOUR));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_HEAT_TOTAL), getEnergyQuantity(block.consumptionHeatTotalHigh, block.consumptionHeatTotalLow));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TODAY), new QuantityType<>(block.consumptionWaterToday, KILOWATT_HOUR));
updateState(channelUID(GROUP_ENERGY_INFO, CHANNEL_CONSUMPTION_WATER_TOTAL), getEnergyQuantity(block.consumptionWaterTotalHigh, block.consumptionWaterTotalLow));
resetCommunicationError();
}
Aggregations