]> git.basschouten.com Git - openhab-addons.git/commitdiff
Add UoM support for rotational speed channels (#15002)
authorJacob Laursen <jacob-github@vindvejr.dk>
Sat, 20 May 2023 10:32:51 +0000 (12:32 +0200)
committerGitHub <noreply@github.com>
Sat, 20 May 2023 10:32:51 +0000 (12:32 +0200)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.danfossairunit/README.md
bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/DanfossAirUnit.java
bundles/org.openhab.binding.danfossairunit/src/main/java/org/openhab/binding/danfossairunit/internal/DanfossAirUnitBindingConstants.java
bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/thing/thing-types.xml
bundles/org.openhab.binding.danfossairunit/src/main/resources/OH-INF/update/instructions.xml
bundles/org.openhab.binding.danfossairunit/src/test/java/org/openhab/binding/danfossairunit/internal/DanfossAirUnitTest.java

index 49d7d3a6e97787df569e385f0570e2ec25b9b392..4869d793583861546a6904b1c999fae2b2b70342 100644 (file)
@@ -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
 
@@ -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" }
index 565c2714ed19b084feeef97fdfb7b3c9d0e300c3..576130bd53ffcbf67d34dd721a5a215a9958c19e 100644 (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 {
index 535c8130de46017931bc4592f6144569f6e09caa..8724a742832057beb574b82f46a21236561b2376 100644 (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);
 }
index d2be979b0dfda2af2414c570fa10ba6c4ab1fc20..c35320b94e212e216bf09c29ba9a4ddd89f990d2 100644 (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>
                <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>
index 93796e0db2bc3c683a167d231835ea24cbcc6381..783f5c8f2019dffb68308d82a8c041de2471b37b 100644 (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>
index 5c5654f0e60b33c51632e2467a2a711b1f650493..5caa10704cd80343c215899e2a48f6e76c3d7c11 100644 (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 };