Add UoM support for rotational speed channels (#15002)

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
pull/15011/head
Jacob Laursen 2023-05-20 12:32:51 +02:00 committed by GitHub
parent 7ff5715dea
commit e598a06475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 56 additions and 37 deletions

View File

@ -21,12 +21,12 @@ These are the available configuration parameters:
## Channels
| channel | channel group | type | readable only (RO) or writable (RW) | description |
|---|---|---|---|---|
|----------------------|---------------|----------------------|-------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| current_time | main | DateTime | RO | Current time reported by the air unit. |
| mode | main | String | RW | Value to control the operation mode of the air unit. One of DEMAND, PROGRAM, MANUAL and OFF |
| manual_fan_step | main | Dimmer | RW | Value to control the fan step when in MANUAL mode (10 steps) |
| supply_fan_speed | main | Number | RO | Current rotation of the fan supplying air to the rooms (in rpm) |
| extract_fan_speed | main | Number | RO | Current rotation of the fan extracting air from the rooms (in rpm) |
| supply_fan_speed | main | Number:Frequency | RO | Current rotation of the fan supplying air to the rooms (in rpm) |
| extract_fan_speed | main | Number:Frequency | RO | Current rotation of the fan extracting air from the rooms (in rpm) |
| supply_fan_step | main | Dimmer | RO | Current step setting of the fan supplying air to the rooms |
| extract_fan_step | main | Dimmer | RO | Current step setting of the fan extracting air from the rooms |
| boost | main | Switch | RW | Enables fan boost |
@ -64,8 +64,8 @@ updateUnchangedValuesEveryMillis=30000]
```java
Dimmer DanfossHRV_ManualFanStep "Manual Fan Step [%s]" { channel = "danfossairunit:airunit:myairunit:main#manual_fan_step" }
Number DanfossHRV_SupplyFanSpeed "Supply Fan Speed" {channel = "danfossairunit:airunit:myairunit:main#supply_fan_speed"}
Number DanfossHRV_ExtractFanSpeed "Extract Fan Speed" {channel = "danfossairunit:airunit:myairunit:main#extract_fan_speed"}
Number:Frequency DanfossHRV_SupplyFanSpeed "Supply Fan Speed" { channel = "danfossairunit:airunit:myairunit:main#supply_fan_speed", unit="rpm" }
Number:Frequency DanfossHRV_ExtractFanSpeed "Extract Fan Speed" { channel = "danfossairunit:airunit:myairunit:main#extract_fan_speed", unit="rpm" }
String DanfossHRV_Mode "Operation Mode" { channel = "danfossairunit:airunit:myairunit:main#mode" }
Switch DanfossHRV_Boost "Boost" { channel = "danfossairunit:airunit:myairunit:main#boost" }
Switch DanfossHRV_Bypass "Bypass" { channel = "danfossairunit:airunit:myairunit:recuperator#bypass" }

View File

@ -23,6 +23,7 @@ import java.time.ZoneId;
import java.time.ZonedDateTime;
import javax.measure.quantity.Dimensionless;
import javax.measure.quantity.Frequency;
import javax.measure.quantity.Temperature;
import org.eclipse.jdt.annotation.NonNullByDefault;
@ -144,12 +145,12 @@ public class DanfossAirUnit {
return new PercentType(BigDecimal.valueOf(value * 10));
}
public DecimalType getSupplyFanSpeed() throws IOException {
return new DecimalType(BigDecimal.valueOf(getWord(REGISTER_4_READ, SUPPLY_FAN_SPEED)));
public QuantityType<Frequency> getSupplyFanSpeed() throws IOException {
return new QuantityType<>(BigDecimal.valueOf(getWord(REGISTER_4_READ, SUPPLY_FAN_SPEED)), Units.RPM);
}
public DecimalType getExtractFanSpeed() throws IOException {
return new DecimalType(BigDecimal.valueOf(getWord(REGISTER_4_READ, EXTRACT_FAN_SPEED)));
public QuantityType<Frequency> getExtractFanSpeed() throws IOException {
return new QuantityType<>(BigDecimal.valueOf(getWord(REGISTER_4_READ, EXTRACT_FAN_SPEED)), Units.RPM);
}
public PercentType getSupplyFanStep() throws IOException {

View File

@ -12,7 +12,6 @@
*/
package org.openhab.binding.danfossairunit.internal;
import java.util.Collections;
import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
@ -34,5 +33,5 @@ public class DanfossAirUnitBindingConstants {
public static final ThingTypeUID THING_TYPE_AIRUNIT = new ThingTypeUID(BINDING_ID, "airunit");
// The thing type as a set
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.singleton(THING_TYPE_AIRUNIT);
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_AIRUNIT);
}

View File

@ -18,7 +18,7 @@
</channel-groups>
<properties>
<property name="vendor">Danfoss</property>
<property name="thingTypeVersion">1</property>
<property name="thingTypeVersion">2</property>
</properties>
<representation-property>host</representation-property>
<config-description>
@ -159,14 +159,14 @@
<state step="10" min="0" max="100"/>
</channel-type>
<channel-type id="supplyFanSpeed">
<item-type>Number</item-type>
<item-type>Number:Frequency</item-type>
<label>Supply Fan Speed</label>
<description>Current rotation of the fan supplying air to the rooms</description>
<category>Fan</category>
<state pattern="%.0f rpm" readOnly="true" min="0"/>
</channel-type>
<channel-type id="extractFanSpeed">
<item-type>Number</item-type>
<item-type>Number:Frequency</item-type>
<label>Extract Fan Speed</label>
<description>Current rotation of the fan extracting air from the rooms</description>
<category>Fan</category>

View File

@ -9,6 +9,16 @@
<remove-channel id="manual_fan_speed" groupIds="main"/>
</instruction-set>
<instruction-set targetVersion="2">
<update-channel id="supply_fan_speed" groupIds="main">
<type>danfossairunit:supplyFanSpeed</type>
</update-channel>
<update-channel id="extract_fan_speed" groupIds="main">
<type>danfossairunit:extractFanSpeed</type>
</update-channel>
</instruction-set>
</thing-type>
</update:update-descriptions>

View File

@ -30,6 +30,7 @@ import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
import org.openhab.core.library.types.QuantityType;
import org.openhab.core.library.unit.Units;
import org.openhab.core.test.java.JavaTest;
/**
@ -146,6 +147,14 @@ public class DanfossAirUnitTest extends JavaTest {
assertEquals(new PercentType(50), airUnit.getManualFanStep());
}
@Test
public void getSupplyFanSpeedIsReturnedAsRPM() throws IOException {
byte[] response = new byte[] { (byte) 0x04, (byte) 0xda };
when(this.communicationController.sendRobustRequest(REGISTER_4_READ, SUPPLY_FAN_SPEED)).thenReturn(response);
var airUnit = new DanfossAirUnit(communicationController);
assertEquals(new QuantityType<>(1242, Units.RPM), airUnit.getSupplyFanSpeed());
}
@Test
public void getManualFanStepWhenOutOfRangeThrows() throws IOException {
byte[] response = new byte[] { (byte) 0x0b };