[comfoair] fix data handling for restricted devices (#10685)

Signed-off-by: Hans Böhm <h.boehm@gmx.at>
This commit is contained in:
boehan 2021-05-26 21:12:15 +02:00 committed by GitHub
parent aa665e54f5
commit 19029b7358
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 169 additions and 32 deletions

View File

@ -27,11 +27,14 @@ sudo usermod -a -G dialout openhab
## Supported Things
Only a single generic thing type is supported by the binding:
The binding supports thing types for different device types.
They only differ in the available channels, where the generic *comfoair* thing type supports all available channels.
If there is no thing type that matches your specific device you can safely choose the *comfoair* type.
|Thing Type ID |Description |
|--------------|---------------------------------------------------------------------|
|--------------|-----------------------------------------------------------------------------|
|comfoair |A ComfoAir ventilation system connected via RS232 serial connection. |
|WHR930 |Thing type restricted to the data points available for the StorkAir WHR930. |
## Discovery

View File

@ -12,6 +12,8 @@
*/
package org.openhab.binding.comfoair.internal;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;
@ -27,6 +29,10 @@ public class ComfoAirBindingConstants {
private static final String BINDING_ID = "comfoair";
public static final ThingTypeUID THING_TYPE_COMFOAIR_GENERIC = new ThingTypeUID(BINDING_ID, "comfoair");
public static final ThingTypeUID THING_TYPE_COMFOAIR_WHR930 = new ThingTypeUID(BINDING_ID, "WHR930");
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_COMFOAIR_GENERIC,
THING_TYPE_COMFOAIR_WHR930);
// Thing properties
public static final String PROPERTY_SOFTWARE_MAIN_VERSION = "SOFTWARE_VERSION_MAIN";

View File

@ -88,7 +88,7 @@ public class ComfoAirHandler extends BaseThingHandler {
.getAffectedReadCommands(channelId, keysToUpdate);
if (!affectedReadCommands.isEmpty()) {
Runnable updateThread = new AffectedItemsUpdateThread(affectedReadCommands);
Runnable updateThread = new AffectedItemsUpdateThread(affectedReadCommands, keysToUpdate);
affectedItemsPoller = scheduler.schedule(updateThread, 3, TimeUnit.SECONDS);
}
} else {
@ -273,7 +273,8 @@ public class ComfoAirHandler extends BaseThingHandler {
}
if (value instanceof UnDefType) {
if (logger.isWarnEnabled()) {
logger.warn("unexpected value for DATA: {}", ComfoAirSerialConnector.dumpData(response));
logger.warn("unexpected value for key '{}'. DATA: {}", commandKey,
ComfoAirSerialConnector.dumpData(response));
}
}
return value;
@ -320,9 +321,11 @@ public class ComfoAirHandler extends BaseThingHandler {
private class AffectedItemsUpdateThread implements Runnable {
private Collection<ComfoAirCommand> affectedReadCommands;
private Set<String> linkedChannels;
public AffectedItemsUpdateThread(Collection<ComfoAirCommand> affectedReadCommands) {
public AffectedItemsUpdateThread(Collection<ComfoAirCommand> affectedReadCommands, Set<String> linkedChannels) {
this.affectedReadCommands = affectedReadCommands;
this.linkedChannels = linkedChannels;
}
@Override
@ -334,6 +337,7 @@ public class ComfoAirHandler extends BaseThingHandler {
for (ComfoAirCommandType commandType : commandTypes) {
String commandKey = commandType.getKey();
if (linkedChannels.contains(commandKey)) {
State state = sendCommand(readCommand, commandKey);
updateState(commandKey, state);
}
@ -342,3 +346,4 @@ public class ComfoAirHandler extends BaseThingHandler {
}
}
}
}

View File

@ -12,9 +12,6 @@
*/
package org.openhab.binding.comfoair.internal;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.io.transport.serial.SerialPortManager;
@ -36,9 +33,6 @@ import org.osgi.service.component.annotations.Reference;
@Component(configurationPid = "binding.comfoair", service = ThingHandlerFactory.class)
public class ComfoAirHandlerFactory extends BaseThingHandlerFactory {
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections
.singleton(ComfoAirBindingConstants.THING_TYPE_COMFOAIR_GENERIC);
private @NonNullByDefault({}) SerialPortManager serialPortManager;
@Reference
@ -52,14 +46,15 @@ public class ComfoAirHandlerFactory extends BaseThingHandlerFactory {
@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
return ComfoAirBindingConstants.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}
@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
ThingTypeUID thingTypeUID = thing.getThingTypeUID();
if (ComfoAirBindingConstants.THING_TYPE_COMFOAIR_GENERIC.equals(thingTypeUID)) {
if (ComfoAirBindingConstants.THING_TYPE_COMFOAIR_GENERIC.equals(thingTypeUID)
|| ComfoAirBindingConstants.THING_TYPE_COMFOAIR_WHR930.equals(thingTypeUID)) {
return new ComfoAirHandler(thing, serialPortManager);
}

View File

@ -511,7 +511,9 @@ public class ComfoAirSerialConnector {
if (preRequestData.length > 0 && newRequestData.length <= preRequestData.length) {
System.arraycopy(preRequestData, 0, newRequestData, 0, 6);
if (preRequestData.length > 10) {
System.arraycopy(preRequestData, 10, newRequestData, 6, newRequestData.length - 6);
}
newRequestData[dataPosition] = requestValue;
} else {
return ComfoAirCommandType.Constants.EMPTY_INT_ARRAY;

View File

@ -50,8 +50,8 @@ public class DataTypeMessage implements ComfoAirDataType {
if (readReplyDataPos != null) {
int errorAlo = data[readReplyDataPos[0]];
int errorE = data[readReplyDataPos[1]];
int errorEA = data[readReplyDataPos[2]];
int errorAhi = data[readReplyDataPos[3]];
int errorEA = (data.length > 9) ? data[readReplyDataPos[2]] : -1;
int errorAhi = (data.length > 9) ? data[readReplyDataPos[3]] : -1;
StringBuilder errorCode = new StringBuilder();

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<config-description:config-descriptions
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:config-description="https://openhab.org/schemas/config-description/v1.0.0"
xsi:schemaLocation="https://openhab.org/schemas/config-description/v1.0.0
https://openhab.org/schemas/config-description-1.0.0.xsd">
<config-description uri="thing-type:comfoair:serial">
<parameter name="serialPort" type="text" required="true">
<label>Serial Port</label>
<context>serial-port</context>
<description>Serial port that the ComfoAir is connected to</description>
</parameter>
<parameter name="refreshInterval" type="integer" max="65535" min="10" unit="s" required="false">
<label>Refresh Interval</label>
<description>Refresh interval in seconds</description>
<default>60</default>
</parameter>
</config-description>
</config-description:config-descriptions>

View File

@ -41,18 +41,32 @@
<channel-group id="resets" typeId="resets"/>
</channel-groups>
<config-description>
<parameter name="serialPort" type="text" required="true">
<label>Serial Port</label>
<context>serial-port</context>
<description>Serial port that the ComfoAir is connected to</description>
</parameter>
<parameter name="refreshInterval" type="integer" max="65535" min="10" unit="s" required="false">
<label>Refresh Interval</label>
<description>Refresh interval in seconds</description>
<default>60</default>
</parameter>
</config-description>
<config-description-ref uri="thing-type:comfoair:serial"/>
</thing-type>
<thing-type id="WHR930">
<label>Zehnder WHR930 Ventilation System</label>
<description>Provides a generic access to a Zehnder WHR930 ventilation device</description>
<channel-groups>
<channel-group id="bindingControl" typeId="bindingControl"/>
<channel-group id="ventilation" typeId="ventilation_WHR930"/>
<channel-group id="temperatures" typeId="temperatures_WHR930"/>
<channel-group id="times" typeId="times_WHR930"/>
<channel-group id="bypass" typeId="bypass"/>
<channel-group id="preheater" typeId="preheater"/>
<channel-group id="options" typeId="options_WHR930"/>
<channel-group id="menuP1" typeId="menuP1_WHR930"/>
<channel-group id="menuP2" typeId="menuP2_WHR930"/>
<channel-group id="menuP9" typeId="menuP9_WHR930"/>
<channel-group id="inputs" typeId="inputs"/>
<channel-group id="analogRF" typeId="analogRF"/>
<channel-group id="errors" typeId="errors"/>
<channel-group id="resets" typeId="resets"/>
</channel-groups>
<config-description-ref uri="thing-type:comfoair:serial"/>
</thing-type>
@ -82,6 +96,23 @@
</channels>
</channel-group-type>
<channel-group-type id="ventilation_WHR930">
<label>Ventilation Values</label>
<channels>
<channel id="fanLevel" typeId="fan_evel"/>
<channel id="fanOut0" typeId="fan_out_0"/>
<channel id="fanOut1" typeId="fan_out_1"/>
<channel id="fanOut2" typeId="fan_out_2"/>
<channel id="fanIn0" typeId="fan_in_0"/>
<channel id="fanIn1" typeId="fan_in_1"/>
<channel id="fanIn2" typeId="fan_in_2"/>
<channel id="fanInPercent" typeId="fan_in_percent"/>
<channel id="fanOutPercent" typeId="fan_out_percent"/>
<channel id="fanInRPM" typeId="fan_in_RPM"/>
<channel id="fanOutRPM" typeId="fan_out_RPM"/>
</channels>
</channel-group-type>
<channel-group-type id="temperatures">
<label>Temperature Values</label>
<channels>
@ -103,6 +134,21 @@
</channels>
</channel-group-type>
<channel-group-type id="temperatures_WHR930">
<label>Temperature Values</label>
<channels>
<channel id="targetTemperature" typeId="target_temperature"/>
<channel id="outdoorTemperatureIn" typeId="outdoor_temperature_in"/>
<channel id="outdoorTemperatureOut" typeId="outdoor_temperature_out"/>
<channel id="indoorTemperatureIn" typeId="indoor_temperature_in"/>
<channel id="indoorTemperatureOut" typeId="indoor_temperature_out"/>
<channel id="isT1Sensor" typeId="is_T1_sensor"/>
<channel id="isT2Sensor" typeId="is_T2_sensor"/>
<channel id="isT3Sensor" typeId="is_T3_sensor"/>
<channel id="isT4Sensor" typeId="is_T4_sensor"/>
</channels>
</channel-group-type>
<channel-group-type id="times">
<label>Uptimes</label>
<channels>
@ -117,6 +163,19 @@
</channels>
</channel-group-type>
<channel-group-type id="times_WHR930">
<label>Uptimes</label>
<channels>
<channel id="level0Time" typeId="level0_time"/>
<channel id="level1Time" typeId="level1_time"/>
<channel id="level2Time" typeId="level2_time"/>
<channel id="freezeTime" typeId="freeze_time"/>
<channel id="preheaterTime" typeId="preheater_time"/>
<channel id="bypassTime" typeId="bypass_time"/>
<channel id="filterHours" typeId="filter_hours"/>
</channels>
</channel-group-type>
<channel-group-type id="bypass">
<label>Bypass Values</label>
<channels>
@ -189,6 +248,18 @@
</channels>
</channel-group-type>
<channel-group-type id="options_WHR930">
<label>Option Settings</label>
<channels>
<channel id="isPreheater" typeId="is_preheater"/>
<channel id="isBypass" typeId="is_bypass"/>
<channel id="recuType" typeId="recu_type"/>
<channel id="recuSize" typeId="recu_size"/>
<channel id="isChimney" typeId="is_chimney"/>
<channel id="isEnthalpy" typeId="is_enthalpy"/>
</channels>
</channel-group-type>
<channel-group-type id="menuP1">
<label>Menu P1: Control States</label>
<channels>
@ -205,6 +276,18 @@
</channels>
</channel-group-type>
<channel-group-type id="menuP1_WHR930">
<label>Menu P1: Control States</label>
<channels>
<channel id="menu21Mode" typeId="menu21_mode"/>
<channel id="menu22Mode" typeId="menu22_mode"/>
<channel id="menu23Mode" typeId="menu23_mode"/>
<channel id="menu24Mode" typeId="menu24_mode"/>
<channel id="menu25Mode" typeId="menu25_mode"/>
<channel id="menu26Mode" typeId="menu26_mode"/>
</channels>
</channel-group-type>
<channel-group-type id="menuP2">
<label>Menu P2: Delay Settings</label>
<channels>
@ -219,6 +302,18 @@
</channels>
</channel-group-type>
<channel-group-type id="menuP2_WHR930">
<label>Menu P2: Delay Settings</label>
<channels>
<channel id="bathroomStartDelay" typeId="bathroom_start_delay"/>
<channel id="bathroomEndDelay" typeId="bathroom_end_delay"/>
<channel id="L1EndDelay" typeId="L1_end_delay"/>
<channel id="filterWeeks" typeId="filter_weeks"/>
<channel id="RFShortDelay" typeId="RF_short_delay"/>
<channel id="RFLongDelay" typeId="RF_long_delay"/>
</channels>
</channel-group-type>
<channel-group-type id="menuP9">
<label>Menu P9: Option Control States</label>
<channels>
@ -233,6 +328,17 @@
</channels>
</channel-group-type>
<channel-group-type id="menuP9_WHR930">
<label>Menu P9: Option Control States</label>
<channels>
<channel id="chimneyState" typeId="chimney_state"/>
<channel id="bypassState" typeId="bypass_state"/>
<channel id="vControlState" typeId="v_control_state"/>
<channel id="frostState" typeId="frost_state"/>
<channel id="enthalpyState" typeId="enthalpy_state"/>
</channels>
</channel-group-type>
<channel-group-type id="inputs">
<label>Inputs</label>
<channels>