Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[comfoair] Extend UoM support, add semantic tags & update state descriptions #15167

Merged
merged 20 commits into from
Jul 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions bundles/org.openhab.binding.comfoair/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ The ComfoAir binding supports the following channels.
| ventilation#fanIn3 | Number | Fan In Level 3 | Fan level 3 performance (%) of incoming fan | false | yes |
| ventilation#fanInPercent | Number | Fan In (%) | Current relative speed (%) of incoming fan | false | yes |
| ventilation#fanOutPercent | Number | Fan Out (%) | Current relative speed (%) of outgoing fan | true | yes |
| ventilation#fanInRPM | Number | Fan In (rpm) | Current absolute speed (rpm) of incoming fan | true | yes |
| ventilation#fanOutRPM | Number | Fan Out (rpm) | Current absolute speed (rpm) of outgoing fan | true | yes |
| ventilation#fanInRPM | Number:Frequency | Fan In (rpm) | Current absolute speed (rpm) of incoming fan | true | yes |
| ventilation#fanOutRPM | Number:Frequency | Fan Out (rpm) | Current absolute speed (rpm) of outgoing fan | true | yes |
| **Temperature Values** | | | | | |
| temperatures#targetTemperature | Number:Temperature | Target Temperature | Target (comfort) temperature | false | no |
| temperatures#outdoorTemperatureIn | Number:Temperature | Outdoor Temperature Incoming | Intake air temperature (outside) | true | yes |
Expand Down Expand Up @@ -108,14 +108,14 @@ The ComfoAir binding supports the following channels.
| menuP1#menu28Mode | Switch | Menu 28 Mode (P18) | State of menu 28 mode (P18) | true | yes |
| menuP1#menu29Mode | Switch | Menu 29 Mode (P19) | State of menu 29 mode (P19) | true | yes |
| **Menu P2: Delay Settings** | | | | | |
| menuP2#bathroomStartDelay | Number | Menu P21 | Start delay for bathroom switch (min) | false | yes |
| menuP2#bathroomEndDelay | Number | Menu P22 | End delay for bathroom switch (min) | false | yes |
| menuP2#L1EndDelay | Number | Menu P23 | End delay for L1 switch (min) | false | yes |
| menuP2#pulseVentilation | Number | Menu P27 | Period for pulse ventilation (min) | false | yes |
| menuP2#filterWeeks | Number | Menu P24 | Usage period until filter pollution message (weeks) | false | yes |
| menuP2#RFShortDelay | Number | Menu P25 | End delay (RF short actuation) for ventilation level 3 (min) | false | yes |
| menuP2#RFLongDelay | Number | Menu P26 | End delay (RF long actuation) for ventilation level 3 (min) | false | yes |
| menuP2#cookerhoodDelay | Number | Menu P20 | End delay for cooker hood control (min) | false | yes |
| menuP2#bathroomStartDelay | Number:Time | Menu P21 | Start delay for bathroom switch (uses minutes internally) | false | yes |
| menuP2#bathroomEndDelay | Number:Time | Menu P22 | End delay for bathroom switch (uses minutes internally) | false | yes |
| menuP2#L1EndDelay | Number:Time | Menu P23 | End delay for L1 switch (uses minutes internally) | false | yes |
| menuP2#pulseVentilation | Number:Time | Menu P27 | Period for pulse ventilation (uses minutes internally) | false | yes |
| menuP2#filterWeeks | Number:Time | Menu P24 | Usage period until filter pollution message (uses weeks internally) | false | yes |
| menuP2#RFShortDelay | Number:Time | Menu P25 | End delay (RF short actuation) for ventilation level 3 (uses minutes internally) | false | yes |
| menuP2#RFLongDelay | Number:Time | Menu P26 | End delay (RF long actuation) for ventilation level 3 (uses minutes internally) | false | yes |
| menuP2#cookerhoodDelay | Number:Time | Menu P20 | End delay for cooker hood control (uses minutes internally) | false | yes |
| **Menu P9: Option States** | | | | | |
| menuP9#chimneyState | Switch | Chimney Control State | State of the chimney control | true | yes |
| menuP9#bypassState | Switch | Bypass State | State of the bypass (ON = open / OFF = closed) | true | yes |
Expand All @@ -140,7 +140,7 @@ The ComfoAir binding supports the following channels.
| preheater#preheaterValve | Number | Preheater Valve | State of the preheater valve | true | yes |
| preheater#preheaterFrostProtect | Switch | Frost Protection | State of the frost protection | true | yes |
| preheater#preheaterHeating | Switch | Preheater | State of the preheater | true | yes |
| preheater#preheaterFrostTime | Number | Preheater Frost Time | Frost minutes | true | yes |
| preheater#preheaterFrostTime | Number:Time | Preheater Frost Time | Frost minutes | true | yes |
| preheater#preheaterSafety | Number | Preheater Frost Safety | Frost safety setting | true | yes |
| **GHX Values** | | | | | |
| ewt#ewtTemperatureLow | Number:Temperature | GHX Temperature (low) | Lower temperature of the geothermal heat exchanger | true | yes |
Expand All @@ -156,7 +156,7 @@ The ComfoAir binding supports the following channels.
| enthalpy#enthalpyTemperature | Number:Temperature | Enthalpy Sensor Temperature | Temperature of the enthalpy sensor | true | yes |
| enthalpy#enthalpyHumidity | Number | Enthalpy Sensor Humidity | Humidity of the enthalpy sensor | true | yes |
| enthalpy#enthalpyLevel | Number | Enthalpy Sensor Level | Level of the enthalpy sensor | true | yes |
| enthalpy#enthalpyTime | Number | Enthalpy Sensor Timer | Timer state of the enthalpy sensor | true | yes |
| enthalpy#enthalpyTime | Number:Time | Enthalpy Sensor Timer | Timer state of the enthalpy sensor | true | yes |
| **Option Settings** | | | | | |
| options#isPreheater | Switch | Preheater | Preheater option installed | true | yes |
| options#isBypass | Switch | Bypass | Bypass option installed | true | yes |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,8 @@
import org.openhab.binding.comfoair.internal.datatypes.DataTypeTime;
import org.openhab.binding.comfoair.internal.datatypes.DataTypeVolt;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.types.Command;
import org.openhab.core.types.State;
import org.openhab.core.types.UnDefType;

/**
* Represents all valid commands which could be processed by this binding
Expand Down Expand Up @@ -107,28 +105,28 @@ public enum ComfoAirCommandType {
DataTypeBoolean.getInstance(), Constants.REQUEST_GET_STATES, Constants.REPLY_GET_STATES, new int[] { 7 },
0x02),
BATHROOM_START_DELAY(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_BR_START_DELAY,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 0, new ComfoAirCommandType[] { MENU21_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 0, new ComfoAirCommandType[] { MENU21_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 0 }),
BATHROOM_END_DELAY(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_BR_END_DELAY,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 1, new ComfoAirCommandType[] { MENU22_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 1, new ComfoAirCommandType[] { MENU22_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 1 }),
L1_END_DELAY(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_L1_END_DELAY,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 2, new ComfoAirCommandType[] { MENU27_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 2, new ComfoAirCommandType[] { MENU27_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 2 }),
PULSE_VENTILATION(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_PULSE_VENTILATION,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 3, new ComfoAirCommandType[] { MENU23_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 3, new ComfoAirCommandType[] { MENU23_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 3 }),
FILTER_WEEKS(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_FILTER_WEEKS,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 4, new ComfoAirCommandType[] { MENU24_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 4, new ComfoAirCommandType[] { MENU24_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 4 }),
RF_SHORT_DELAY(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_RF_SHORT_DELAY,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 5, new ComfoAirCommandType[] { MENU25_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 5, new ComfoAirCommandType[] { MENU25_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 5 }),
RF_LONG_DELAY(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_RF_LONG_DELAY,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 6, new ComfoAirCommandType[] { MENU26_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 6, new ComfoAirCommandType[] { MENU26_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 6 }),
COOKERHOOD_DELAY(ComfoAirBindingConstants.CG_MENUP2_PREFIX + ComfoAirBindingConstants.CHANNEL_COOKERHOOD_DELAY,
DataTypeNumber.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 7, new ComfoAirCommandType[] { MENU20_MODE },
DataTypeTime.getInstance(), Constants.REQUEST_SET_DELAYS, 8, 7, new ComfoAirCommandType[] { MENU20_MODE },
Constants.REQUEST_GET_DELAYS, Constants.REPLY_GET_DELAYS, new int[] { 7 }),
CHIMNEY_STATE(ComfoAirBindingConstants.CG_MENUP9_PREFIX + ComfoAirBindingConstants.CHANNEL_CHIMNEY_STATE,
DataTypeBoolean.getInstance(), Constants.REQUEST_GET_STATES, Constants.REPLY_GET_STATES, new int[] { 8 },
Expand Down Expand Up @@ -229,7 +227,7 @@ public enum ComfoAirCommandType {
ENTHALPY_LEVEL(ComfoAirBindingConstants.CG_ENTHALPY_PREFIX + ComfoAirBindingConstants.CHANNEL_ENTHALPY_LEVEL,
DataTypeNumber.getInstance(), Constants.REQUEST_GET_SENSORS, Constants.REPLY_GET_SENSORS, new int[] { 4 }),
ENTHALPY_TIME(ComfoAirBindingConstants.CG_ENTHALPY_PREFIX + ComfoAirBindingConstants.CHANNEL_ENTHALPY_TIME,
DataTypeNumber.getInstance(), Constants.REQUEST_GET_SENSORS, Constants.REPLY_GET_SENSORS, new int[] { 5 }),
DataTypeTime.getInstance(), Constants.REQUEST_GET_SENSORS, Constants.REPLY_GET_SENSORS, new int[] { 5 }),
PREHEATER_VALVE(ComfoAirBindingConstants.CG_PREHEATER_PREFIX + ComfoAirBindingConstants.CHANNEL_PREHEATER_VALVE,
DataTypeNumber.getInstance(), Constants.REQUEST_GET_PREHEATER, Constants.REPLY_GET_PREHEATER,
new int[] { 0 }),
Expand All @@ -242,7 +240,7 @@ public enum ComfoAirCommandType {
new int[] { 2 }),
PREHEATER_FROST_TIME(
ComfoAirBindingConstants.CG_PREHEATER_PREFIX + ComfoAirBindingConstants.CHANNEL_PREHEATER_FROST_TIME,
DataTypeNumber.getInstance(), Constants.REQUEST_GET_PREHEATER, Constants.REPLY_GET_PREHEATER,
DataTypeTime.getInstance(), Constants.REQUEST_GET_PREHEATER, Constants.REPLY_GET_PREHEATER,
new int[] { 3, 4 }),
PREHEATER_OPTION(ComfoAirBindingConstants.CG_PREHEATER_PREFIX + ComfoAirBindingConstants.CHANNEL_PREHEATER_SAFETY,
DataTypeNumber.getInstance(), Constants.REQUEST_GET_PREHEATER, Constants.REPLY_GET_PREHEATER,
Expand Down Expand Up @@ -786,29 +784,22 @@ public int getReadReplyDataBits() {
* new state
* @return initialized ComfoAirCommand
*/
@SuppressWarnings("PMD.CompareObjectsWithEquals")
public static @Nullable ComfoAirCommand getChangeCommand(String key, Command command) {
ComfoAirCommandType commandType = getCommandTypeByKey(key);
State value = UnDefType.NULL;

if (commandType != null) {
ComfoAirDataType dataType = commandType.getDataType();
if (dataType == DataTypeBoolean.getInstance() || dataType == DataTypeNumber.getInstance()
|| dataType == DataTypeRPM.getInstance() || command instanceof QuantityType<?>) {
value = (State) command;
}
if (value instanceof UnDefType) {
return null;
} else {
int[] data = dataType.convertFromState(value, commandType);
DecimalType decimalValue = value.as(DecimalType.class);
if (decimalValue != null) {
int intValue = decimalValue.intValue();

if (data != null) {
int dataPosition = commandType.getChangeDataPos();
return new ComfoAirCommand(key, commandType.changeCommand, null, data, dataPosition, intValue);
}

State value = (State) command;

int[] data = dataType.convertFromState(value, commandType);
DecimalType decimalValue = value.as(DecimalType.class);
if (decimalValue != null) {
int intValue = decimalValue.intValue();

if (data != null) {
int dataPosition = commandType.getChangeDataPos();
return new ComfoAirCommand(key, commandType.changeCommand, null, data, dataPosition, intValue);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,19 @@ public void open() throws ComfoAirSerialException {
SerialPort serialPort = portIdentifier.open(this.getClass().getName(), 3000);
serialPort.setSerialPortParams(baudRate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,
SerialPort.PARITY_NONE);
serialPort.enableReceiveThreshold(1);
serialPort.enableReceiveTimeout(1000);
serialPort.notifyOnDataAvailable(true);

try {
serialPort.enableReceiveThreshold(1);
} catch (UnsupportedCommOperationException e) {
logger.debug("Enable receive threshold is unsupported");
}
try {
serialPort.enableReceiveTimeout(1000);
} catch (UnsupportedCommOperationException e) {
logger.debug("Enable receive timeout is unsupported");
}

this.serialPort = serialPort;

inputStream = new DataInputStream(new BufferedInputStream(serialPort.getInputStream()));
Expand Down
Loading