]> git.basschouten.com Git - openhab-addons.git/commitdiff
[ventaair] Add Air quality and service time channels (#11792)
authorStefan Triller <t2000@users.noreply.github.com>
Tue, 21 Dec 2021 07:26:32 +0000 (08:26 +0100)
committerGitHub <noreply@github.com>
Tue, 21 Dec 2021 07:26:32 +0000 (08:26 +0100)
* [ventaair] Add Air quality and service time channels

- also add value 4 for water level

Signed-off-by: Stefan Triller <github@stefantriller.de>
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaAirBindingConstants.java
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/VentaThingHandler.java
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/message/dto/Info.java
bundles/org.openhab.binding.ventaair/src/main/java/org/openhab/binding/ventaair/internal/message/dto/Measurements.java
bundles/org.openhab.binding.ventaair/src/main/resources/OH-INF/i18n/ventaair.properties
bundles/org.openhab.binding.ventaair/src/main/resources/OH-INF/thing/channels.xml
bundles/org.openhab.binding.ventaair/src/main/resources/OH-INF/thing/thing-types.xml

index 4e2e797408b17c80affc7de1060d204936a985df..4e21edd78d4ed945bfa2c9f6d5805567d3438257 100644 (file)
@@ -41,6 +41,7 @@ public class VentaAirBindingConstants {
     public static final String CHANNEL_AUTOMATIC = "automatic";
     public static final String CHANNEL_TEMPERATURE = "temperature";
     public static final String CHANNEL_HUMIDITY = "humidity";
+    public static final String CHANNEL_PM25 = "pm25";
     public static final String CHANNEL_WATERLEVEL = "waterLevel";
     public static final String CHANNEL_FAN_RPM = "fanRPM";
     public static final String CHANNEL_CLEAN_MODE = "cleanMode";
@@ -48,6 +49,7 @@ public class VentaAirBindingConstants {
     public static final String CHANNEL_DISC_REPLACE_TIME = "discReplaceTime";
     public static final String CHANNEL_CLEANING_TIME = "cleaningTime";
     public static final String CHANNEL_TIMER_TIME_PASSED = "timerTimePassed";
+    public static final String CHANNEL_SERVICE_TIME = "serviceTime";
 
     public static final int PORT = 48000;
 }
index 396c37c20d75ef91220f34b79c7c1195c019a3ab..39fd3c3f8ad22e9ce9f9aac60f73fa213d77b662 100644 (file)
@@ -38,6 +38,7 @@ import org.openhab.binding.ventaair.internal.message.dto.DeviceInfoMessage;
 import org.openhab.binding.ventaair.internal.message.dto.Header;
 import org.openhab.binding.ventaair.internal.message.dto.Info;
 import org.openhab.binding.ventaair.internal.message.dto.Measurements;
+import org.openhab.core.library.dimension.Density;
 import org.openhab.core.library.types.DecimalType;
 import org.openhab.core.library.types.OnOffType;
 import org.openhab.core.library.types.QuantityType;
@@ -275,6 +276,11 @@ public class VentaThingHandler extends BaseThingHandler {
                 updateState(VentaAirBindingConstants.CHANNEL_HUMIDITY, humidityState);
                 channelValueCache.put(VentaAirBindingConstants.CHANNEL_HUMIDITY, humidityState);
 
+                QuantityType<Density> pm25State = new QuantityType<>(measurements.getDust(),
+                        Units.MICROGRAM_PER_CUBICMETRE);
+                updateState(VentaAirBindingConstants.CHANNEL_PM25, pm25State);
+                channelValueCache.put(VentaAirBindingConstants.CHANNEL_PM25, pm25State);
+
                 DecimalType waterLevelState = new DecimalType(measurements.getWaterLevel());
                 updateState(VentaAirBindingConstants.CHANNEL_WATERLEVEL, waterLevelState);
                 channelValueCache.put(VentaAirBindingConstants.CHANNEL_WATERLEVEL, waterLevelState);
@@ -310,6 +316,10 @@ public class VentaThingHandler extends BaseThingHandler {
                 updateState(VentaAirBindingConstants.CHANNEL_TIMER_TIME_PASSED, timerTimePassedState);
                 channelValueCache.put(VentaAirBindingConstants.CHANNEL_TIMER_TIME_PASSED, timerTimePassedState);
 
+                QuantityType<Time> serviceTimeState = new QuantityType<Time>(info.getServiceT(), Units.MINUTE);
+                updateState(VentaAirBindingConstants.CHANNEL_SERVICE_TIME, serviceTimeState);
+                channelValueCache.put(VentaAirBindingConstants.CHANNEL_SERVICE_TIME, serviceTimeState);
+
                 updateProperties(info);
             }
 
index b487f351af7f99adf1fc26fe83084b9de0bb6867..ccb6382f334fff347ec0087396d034710701b4d6 100644 (file)
@@ -54,6 +54,9 @@ public class Info {
     @SerializedName(value = "FilterT")
     private int filterT;
 
+    @SerializedName(value = "ServiceT")
+    private int serviceT;
+
     @SerializedName(value = "UVCOnT")
     private int uvCOnT;
 
@@ -110,6 +113,10 @@ public class Info {
         return filterT;
     }
 
+    public int getServiceT() {
+        return serviceT;
+    }
+
     public int getUvCOnT() {
         return uvCOnT;
     }
index 611ad86dd84e393850c404c50cf4d541bb5de72a..17758cc359a31dde06c1b22f6e4d7298b95940b1 100644 (file)
@@ -28,7 +28,7 @@ public class Measurements {
     private double humidity;
 
     @SerializedName(value = "Dust")
-    private int dust;
+    private double dust;
 
     @SerializedName(value = "WaterLevel")
     private int waterLevel;
@@ -44,7 +44,7 @@ public class Measurements {
         return humidity;
     }
 
-    public int getDust() {
+    public double getDust() {
         return dust;
     }
 
index bec544e58e7398bc8f7373c1c452040d73d39562..ee378607366e0b192e2457c8954c974ac0b58e34 100644 (file)
@@ -51,6 +51,10 @@ channel-type.ventaair.humidity.label = Humidity
 channel-type.ventaair.humidity.description = Current Humidity
 channel-type.ventaair.operationTime.label = Operation Time
 channel-type.ventaair.operationTime.description = Operation Time since the device was first started (in hours)
+channel-type.ventaair.pm25.label = Air Quality
+channel-type.ventaair.pm25.description = Current Air Quality measured in PM 2.5
+channel-type.ventaair.serviceTime.label = Service Time
+channel-type.ventaair.serviceTime.description = Service time in minutes
 channel-type.ventaair.sleepMode.label = Sleep Mode
 channel-type.ventaair.sleepMode.description = Sleep Mode
 channel-type.ventaair.targetHumidity.label = Target Humidity
@@ -82,3 +86,4 @@ channel-type.ventaair.waterLevel.state.option.0 = Critical
 channel-type.ventaair.waterLevel.state.option.1 = Refill tank
 channel-type.ventaair.waterLevel.state.option.2 = OK
 channel-type.ventaair.waterLevel.state.option.3 = Full
+channel-type.ventaair.waterLevel.state.option.4 = Max
index 42639dd5d5fc104d10e023f66945bcd29c71400f..c5d05ac076f75fe41b8b8110cd9fbf93260ffeae 100644 (file)
                <state pattern="%.1f %unit%" readOnly="true"/>
        </channel-type>
 
+       <channel-type id="pm25">
+               <item-type>Number:Density</item-type>
+               <label>Air Quality</label>
+               <description>Current Air Quality measured in PM 2.5</description>
+               <state pattern="%.1f %unit%" readOnly="true"/>
+       </channel-type>
+
        <channel-type id="waterLevel">
                <item-type>Number</item-type>
                <label>Water Level</label>
                                <option value="1">Refill tank</option>
                                <option value="2">OK</option>
                                <option value="3">Full</option>
+                               <option value="4">Max</option>
                        </options>
                </state>
        </channel-type>
                <state pattern="%d" readOnly="true"/>
        </channel-type>
 
+       <channel-type id="serviceTime">
+               <item-type>Number:Time</item-type>
+               <label>Service Time</label>
+               <description>Service time in minutes</description>
+               <state pattern="%d" readOnly="true"/>
+       </channel-type>
+
 </thing:thing-descriptions>
index f12a17d53335dfc15dd66a843bdd81026e0379d1..045764586aa5cc1bdb7e53ad54a713e7c97646ee 100644 (file)
@@ -49,6 +49,7 @@
                        <channel id="automatic" typeId="automatic"/>
                        <channel id="temperature" typeId="temperature"/>
                        <channel id="humidity" typeId="humidity"/>
+                       <channel id="pm25" typeId="pm25"/>
                        <channel id="waterLevel" typeId="waterLevel"/>
                        <channel id="fanRPM" typeId="fanRPM"/>
                        <channel id="cleanMode" typeId="cleanMode"/>
@@ -56,6 +57,7 @@
                        <channel id="operationTime" typeId="operationTime"/>
                        <channel id="discReplaceTime" typeId="discReplaceTime"/>
                        <channel id="cleaningTime" typeId="cleaningTime"/>
+                       <channel id="serviceTime" typeId="serviceTime"/>
                </channels>
 
                <representation-property>macAddress</representation-property>