Skip to content

Commit

Permalink
Add UoM support for rotational speed channels (#15002)
Browse files Browse the repository at this point in the history
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
  • Loading branch information
jlaur authored May 20, 2023
1 parent 7ff5715 commit e598a06
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 37 deletions.
56 changes: 28 additions & 28 deletions bundles/org.openhab.binding.danfossairunit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ 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_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 |
| night_cooling | main | Switch | RW | Enables night cooling |
| room_temp | temps | Number:Temperature | RO | Temperature of the air in the room of the Air Dial |
| room_temp_calculated | temps | Number:Temperature | RO | Calculated Room Temperature |
| outdoor_temp | temps | Number:Temperature | RO | Temperature of the air outside |
| humidity | humidity | Number:Dimensionless | RO | Current relative humidity measured by the air unit |
| bypass | recuperator | Switch | RW | Disables the heat exchange. Useful in summer when room temperature is above target and outside temperature is below target. |
| supply_temp | recuperator | Number | RO | Temperature of air which is passed to the rooms |
| extract_temp | recuperator | Number | RO | Temperature of the air as extracted from the rooms |
| exhaust_temp | recuperator | Number | RO | Temperature of the air when pushed outside |
| battery_life | service | Number | RO | Remaining Air Dial Battery Level (percentage) |
| filter_life | service | Number | RO | Remaining life of filter until exchange is necessary (percentage) |
| filter_period | service | Number | RW | Number of months between filter replacements (between 3 and 12). This value affects calculation of filter_life by the unit, and might get overwritten by Air Dial or Link CC Controller. |
| 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: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 |
| night_cooling | main | Switch | RW | Enables night cooling |
| room_temp | temps | Number:Temperature | RO | Temperature of the air in the room of the Air Dial |
| room_temp_calculated | temps | Number:Temperature | RO | Calculated Room Temperature |
| outdoor_temp | temps | Number:Temperature | RO | Temperature of the air outside |
| humidity | humidity | Number:Dimensionless | RO | Current relative humidity measured by the air unit |
| bypass | recuperator | Switch | RW | Disables the heat exchange. Useful in summer when room temperature is above target and outside temperature is below target. |
| supply_temp | recuperator | Number | RO | Temperature of air which is passed to the rooms |
| extract_temp | recuperator | Number | RO | Temperature of the air as extracted from the rooms |
| exhaust_temp | recuperator | Number | RO | Temperature of the air when pushed outside |
| battery_life | service | Number | RO | Remaining Air Dial Battery Level (percentage) |
| filter_life | service | Number | RO | Remaining life of filter until exchange is necessary (percentage) |
| filter_period | service | Number | RW | Number of months between filter replacements (between 3 and 12). This value affects calculation of filter_life by the unit, and might get overwritten by Air Dial or Link CC Controller. |

## Full Example

Expand All @@ -63,12 +63,12 @@ updateUnchangedValuesEveryMillis=30000]
### Items

```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"}
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"}
Dimmer DanfossHRV_ManualFanStep "Manual Fan Step [%s]" { channel = "danfossairunit:airunit:myairunit:main#manual_fan_step" }
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" }
Number:Dimensionless DanfossHRV_Humidity "Relative humidity" <humidity> { channel = "danfossairunit:airunit:myairunit:humidity#humidity" }
Number:Temperature DanfossHRV_RoomTemperature "Room air temperatuyre" <temperature> { channel = "danfossairunit:airunit:myairunit:temps#room_temp" }
Number:Temperature DanfossHRV_OutdoorTemperature "Outdoor air temperature" <temperature> { channel = "danfossairunit:airunit:myairunit:temps#outdoor_temp" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
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;
Expand Down Expand Up @@ -144,12 +145,12 @@ public PercentType getManualFanStep() throws IOException, UnexpectedResponseValu
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.binding.danfossairunit.internal;

import java.util.Collections;
import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
Expand All @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
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;

/**
Expand Down Expand Up @@ -146,6 +147,14 @@ public void getManualFanStepWhenWithinValidRangeIsConvertedIntoPercent()
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 };
Expand Down

0 comments on commit e598a06

Please sign in to comment.