diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiBindingConstants.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiBindingConstants.java index f5618aa165bac..b9bea78bb4571 100644 --- a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiBindingConstants.java +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiBindingConstants.java @@ -30,7 +30,47 @@ public class KermiBindingConstants { // Supported Thing Types public static final ThingTypeUID THING_TYPE_KERMI_XCENTER = new ThingTypeUID(BINDING_ID, "kermi-xcenter"); - // Channels for State Block + // Channels for State public static final String GLOBAL_STATE_CHANNEL = "global-state"; public static final String GLOBAL_STATE_ID_CHANNEL = "global-state-id"; + + // Alarm State + public static final String ALARM_STATE_CHANNEL = "alarm-state"; + + // Energy Source + public static final String FLOW_TEMPERATURE_CHANNEL = "flow-temperature"; + public static final String RETURN_TEMPERATURE_CHANNEL = "return-temperature"; + public static final String FLOW_SPEED_CHANNEL = "flow-speed"; + + // Charging Circuit + public static final String EXIT_TEMPERATURE_CHANNEL = "exit-temperature"; + public static final String INCOMING_TEMPERATURE_CHANNEL = "incoming-temperature"; + public static final String TEMPERATURE_SENSOR_OUTSIDE_CHANNEL = "temperature-sensor-outside"; + + // Power + public static final String COP_CHANNEL = "cop"; + public static final String COP_HEATING_CHANNEL = "cop-heating"; + public static final String COP_DRINKINGWATER_CHANNEL = "cop-drinkingwater"; + public static final String COP_COOLING_CHANNEL = "cop-cooling"; + + public static final String POWER_CHANNEL = "power"; + public static final String POWER_HEATING_CHANNEL = "power-heating"; + public static final String POWER_DRINKINGWATER_CHANNEL = "power-drinkingwater"; + public static final String POWER_COOLING_CHANNEL = "power-cooling"; + + public static final String ELECTRIC_POWER_CHANNEL = "electric-power"; + public static final String ELECTRIC_POWER_HEATING_CHANNEL = "electric-power-heating"; + public static final String ELECTRIC_POWER_DRINKINGWATER_CHANNEL = "electric-power-drinkingwater"; + public static final String ELECTRIC_POWER_COOLING_CHANNEL = "electric-power-cooling"; + + // Work hours + public static final String WORKHOURS_FAN_CHANNEL = "workhours-fan"; + public static final String WORKHOURS_STORAGE_LOADING_PUMP_CHANNEL = "workhours-storage-loading-pump"; + public static final String WORKHOURS_COMPRESSOR_CHANNEL = "workhours-compressor"; + + // PV + public static final String PV_STATE_CHANNEL = "pv-state"; + public static final String PV_POWER_CHANNEL = "pv-power"; + public static final String PV_TARGET_TEMPERATURE_HEATING_CHANNEL = "pv-target-temperature-heating"; + public static final String PV_TARGET_TEMPERATURE_DRINKINGWATER_CHANNEL = "pv-target-temperature-drinkingwater"; } diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiConfiguration.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiConfiguration.java index dab20b767bf1d..f1401dc218f0e 100644 --- a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiConfiguration.java +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/KermiConfiguration.java @@ -23,4 +23,5 @@ public class KermiConfiguration { public int refresh = 5000; + public boolean pvEnabled = false; } diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/AlarmDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/AlarmDTO.java new file mode 100644 index 0000000000000..06109bc2f6100 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/AlarmDTO.java @@ -0,0 +1,34 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.kermi.internal.dto; + +import static org.openhab.binding.modbus.kermi.internal.modbus.KermiModbusConstans.ALARM_REG_SIZE; + +import org.openhab.binding.modbus.kermi.internal.modbus.Data; +import org.openhab.core.io.transport.modbus.ModbusBitUtilities; +import org.openhab.core.library.types.OnOffType; + +/** + * The {@link AlarmDTO} Data object for Kermi Xcenter + * + * @author Kai Neuhaus - Initial contribution + */ +public class AlarmDTO implements Data { + + public OnOffType alarmIsActive; + + public AlarmDTO(byte[] bArray) { + int status = ModbusBitUtilities.extractBit(bArray, ALARM_REG_SIZE); + alarmIsActive = status == 0 ? OnOffType.OFF : OnOffType.ON; + } +} diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/ChargingCircuitDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/ChargingCircuitDTO.java new file mode 100644 index 0000000000000..57aa0af7a8445 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/ChargingCircuitDTO.java @@ -0,0 +1,42 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.kermi.internal.dto; + +import static org.openhab.core.library.unit.Units.LITRE_PER_MINUTE; + +import javax.measure.quantity.Temperature; + +import org.openhab.binding.modbus.kermi.internal.modbus.Data; +import org.openhab.core.io.transport.modbus.ValueBuffer; +import org.openhab.core.library.dimension.VolumetricFlowRate; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.SIUnits; + +/** + * The {@link ChargingCircuitDTO} Data object for Kermi Xcenter + * + * @author Kai Neuhaus - Initial contribution + */ +public class ChargingCircuitDTO implements Data { + + public QuantityType flowTemperature; + public QuantityType returnFlowTemperature; + public QuantityType flowSpeed; + + public ChargingCircuitDTO(byte[] bArray) { + ValueBuffer wrap = ValueBuffer.wrap(bArray); + flowTemperature = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), SIUnits.CELSIUS); + returnFlowTemperature = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), SIUnits.CELSIUS); + flowSpeed = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), LITRE_PER_MINUTE); + } +} diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/EnergySourceDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/EnergySourceDTO.java new file mode 100644 index 0000000000000..d55893670618c --- /dev/null +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/EnergySourceDTO.java @@ -0,0 +1,39 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.kermi.internal.dto; + +import javax.measure.quantity.Temperature; + +import org.openhab.binding.modbus.kermi.internal.modbus.Data; +import org.openhab.core.io.transport.modbus.ValueBuffer; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.SIUnits; + +/** + * The {@link EnergySourceDTO} Data object for Kermi Xcenter + * + * @author Kai Neuhaus - Initial contribution + */ +public class EnergySourceDTO implements Data { + + public QuantityType exitTemperature; + public QuantityType incomingTemperature; + public QuantityType outsideTemperature; + + public EnergySourceDTO(byte[] bArray) { + ValueBuffer wrap = ValueBuffer.wrap(bArray); + exitTemperature = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), SIUnits.CELSIUS); + incomingTemperature = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), SIUnits.CELSIUS); + outsideTemperature = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), SIUnits.CELSIUS); + } +} diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/PowerDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/PowerDTO.java new file mode 100644 index 0000000000000..2ce4bba818053 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/PowerDTO.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.kermi.internal.dto; + +import javax.measure.quantity.Power; + +import org.openhab.binding.modbus.kermi.internal.modbus.Data; +import org.openhab.core.io.transport.modbus.ValueBuffer; +import org.openhab.core.library.types.DecimalType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.Units; + +/** + * The {@link PowerDTO} Data object for Kermi Xcenter State Block + * + * @author Kai Neuhaus - Initial contribution + */ +public class PowerDTO implements Data { + + public DecimalType cop; + public DecimalType copHeating; + public DecimalType copDrinkingwater; + public DecimalType copCooling; + + public QuantityType power; + public QuantityType powerHeating; + public QuantityType powerDrinkingwater; + public QuantityType powerCooling; + + public QuantityType electricPower; + public QuantityType electricPowerHeating; + public QuantityType electricPowerDrinkingwater; + public QuantityType electricPowerCooling; + + public PowerDTO(byte[] bArray) { + + ValueBuffer wrap = ValueBuffer.wrap(bArray); + + cop = new DecimalType(DataConverter.getUDoubleValue(wrap, 0.1)); + copHeating = new DecimalType(DataConverter.getUDoubleValue(wrap, 0.1)); + copDrinkingwater = new DecimalType(DataConverter.getUDoubleValue(wrap, 0.1)); + copCooling = new DecimalType(DataConverter.getUDoubleValue(wrap, 0.1)); + + power = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + powerHeating = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + powerDrinkingwater = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + powerCooling = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + + electricPower = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + electricPowerHeating = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + electricPowerDrinkingwater = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + electricPowerCooling = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 100), Units.WATT); + } +} diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/PvDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/PvDTO.java new file mode 100644 index 0000000000000..f6da0ab9da781 --- /dev/null +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/PvDTO.java @@ -0,0 +1,52 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.kermi.internal.dto; + +import javax.measure.quantity.Power; +import javax.measure.quantity.Temperature; + +import org.openhab.binding.modbus.kermi.internal.modbus.Data; +import org.openhab.core.io.transport.modbus.ModbusBitUtilities; +import org.openhab.core.io.transport.modbus.ValueBuffer; +import org.openhab.core.library.types.OnOffType; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.SIUnits; +import org.openhab.core.library.unit.Units; + +/** + * The {@link PvDTO} Data object for Kermi Xcenter + * + * @author Kai Neuhaus - Initial contribution + */ +public class PvDTO implements Data { + + public OnOffType pvModulationActive; + public QuantityType pvModulationPower; + public QuantityType pvTargetTemperatureHeating; + public QuantityType pvTargetTemperatureDrinkingwater; + + public PvDTO(byte[] bArray) { + + int modActive = ModbusBitUtilities.extractBit(bArray, 0); + pvModulationActive = modActive == 0 ? OnOffType.OFF : OnOffType.ON; + + ValueBuffer wrap = ValueBuffer.wrap(bArray); + // skip first bit -> modActive-Value + wrap.position(2); + + pvModulationPower = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), Units.WATT); + pvTargetTemperatureHeating = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), SIUnits.CELSIUS); + pvTargetTemperatureDrinkingwater = QuantityType.valueOf(DataConverter.getUDoubleValue(wrap, 0.1), + SIUnits.CELSIUS); + } +} diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/StateDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/StateDTO.java index 6e63eb339e7f3..e9ad4adad100f 100644 --- a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/StateDTO.java +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/StateDTO.java @@ -18,14 +18,14 @@ import org.openhab.core.library.types.StringType; /** - * The {@link StateDTO} Data object for Kermi Xcenter State Block + * The {@link StateDTO} Data object for Kermi Xcenter * * @author Kai Neuhaus - Initial contribution */ public class StateDTO implements Data { - public StringType globalState = STATE_UNKOWN; - public DecimalType globalStateId = new DecimalType(-1); + public StringType globalState; + public DecimalType globalStateId; // State definitions public static final StringType STATE_STANDBY = StringType.valueOf("Standby"); @@ -45,7 +45,7 @@ public class StateDTO implements Data { public StateDTO(byte[] bArray) { - int status = ModbusBitUtilities.extractUInt16(bArray, 0); + int status = ModbusBitUtilities.extractBit(bArray, 0); globalStateId = new DecimalType(status); @@ -54,11 +54,5 @@ public StateDTO(byte[] bArray) { } else { globalState = STATE_UNKOWN; } - // - // // index handling to calculate the correct start index - // ValueBuffer wrap = ValueBuffer.wrap(bArray); - // - // // int32_swap value = 4 byte - // int globalState = wrap.getUInt16(); } } diff --git a/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/WorkHoursDTO.java b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/WorkHoursDTO.java new file mode 100644 index 0000000000000..f3bb44d99616a --- /dev/null +++ b/bundles/org.openhab.binding.modbus.kermi/src/main/java/org/openhab/binding/modbus/kermi/internal/dto/WorkHoursDTO.java @@ -0,0 +1,41 @@ +/** + * Copyright (c) 2010-2024 Contributors to the openHAB project + * + * See the NOTICE file(s) distributed with this work for additional + * information. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which is available at + * http://www.eclipse.org/legal/epl-2.0 + * + * SPDX-License-Identifier: EPL-2.0 + */ +package org.openhab.binding.modbus.kermi.internal.dto; + +import javax.measure.quantity.Time; + +import org.openhab.binding.modbus.kermi.internal.modbus.Data; +import org.openhab.core.io.transport.modbus.ValueBuffer; +import org.openhab.core.library.types.QuantityType; +import org.openhab.core.library.unit.Units; + +/** + * The {@link WorkHoursDTO} Data object for Kermi Xcenter State Block + * + * @author Kai Neuhaus - Initial contribution + */ +public class WorkHoursDTO implements Data { + + public QuantityType