]> git.basschouten.com Git - openhab-addons.git/commitdiff
[hdpowerview] Add new batteryVoltage channel (#11155)
authorjlaur <jacob-github@vindvejr.dk>
Thu, 26 Aug 2021 16:57:27 +0000 (18:57 +0200)
committerGitHub <noreply@github.com>
Thu, 26 Aug 2021 16:57:27 +0000 (18:57 +0200)
* Add new batteryVoltage channel.

Fixes #11154

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Fix documentation for lowBattery.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Organized channels into two groups: Shade and Battery.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
* Revert breaking change.

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.hdpowerview/README.md
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewBindingConstants.java
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java
bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/thing/thing-types.xml

index db69bacb7e3158bf4443ae54dea969271cf951cf..421f2cf8cd1c257708fb2b792aa197f953443b75 100644 (file)
@@ -73,12 +73,13 @@ If the shade has slats or rotatable vanes, there is also a dimmer channel `vane`
 If it is a dual action (top-down plus bottom-up) shade, there is also a roller shutter channel `secondary` which controls the vertical position of the secondary rail.
 All of these channels appear in the binding, but only those which have a physical implementation in the shade, will have any physical effect.
 
-| Channel    | Item Type     | Description |
-|------------|---------------|------------|
-| position   | Rollershutter | The vertical position of the shade's rail -- see [next chapter](#Roller-Shutter-Up/Down-Position-vs.-Open/Close-State). Up/Down commands will move the rail completely up or completely down. Percentage commands will move the rail to an intermediate position. Stop commands will halt any current movement of the rail. |
-| secondary  | Rollershutter | The vertical position of the secondary rail (if any). Its function is basically identical to the `position` channel above -- but see [next chapter](#Roller-Shutter-Up/Down-Position-vs.-Open/Close-State). |
-| vane       | Dimmer        | The degree of opening of the slats or vanes. Setting this to a non-zero value will first move the shade `position` fully down, since the slats or vanes can only have a defined state if the shade is in its down position -- see [Interdependency between Channel positions](#Interdependency-between-Channel-positions). |
-| batteryLow | Switch        | Indicates ON when the battery level of the shade is low, as determined by the hub's internal rules. |
+| Channel        | Item Type                | Description |
+|----------------|--------------------------|------------|
+| position       | Rollershutter            | The vertical position of the shade's rail -- see [next chapter](#Roller-Shutter-Up/Down-Position-vs.-Open/Close-State). Up/Down commands will move the rail completely up or completely down. Percentage commands will move the rail to an intermediate position. Stop commands will halt any current movement of the rail. |
+| secondary      | Rollershutter            | The vertical position of the secondary rail (if any). Its function is basically identical to the `position` channel above -- but see [next chapter](#Roller-Shutter-Up/Down-Position-vs.-Open/Close-State). |
+| vane           | Dimmer                   | The degree of opening of the slats or vanes. Setting this to a non-zero value will first move the shade `position` fully down, since the slats or vanes can only have a defined state if the shade is in its down position -- see [Interdependency between Channel positions](#Interdependency-between-Channel-positions). |
+| lowBattery     | Switch                   | Indicates ON when the battery level of the shade is low, as determined by the hub's internal rules. |
+| batteryVoltage | Number:ElectricPotential | Battery voltage reported by the shade. |
 
 ### Roller Shutter Up/Down Position vs. Open/Close State
 
index ac020d5bdde8c6cf2905a6f5fe4a1eb0456aeda6..8deafad6d17388757b5edc5827cc046a52a59082 100644 (file)
@@ -40,6 +40,7 @@ public class HDPowerViewBindingConstants {
     public static final String CHANNEL_SHADE_POSITION = "position";
     public static final String CHANNEL_SHADE_VANE = "vane";
     public static final String CHANNEL_SHADE_LOW_BATTERY = "lowBattery";
+    public static final String CHANNEL_SHADE_BATTERY_VOLTAGE = "batteryVoltage";
     public static final String CHANNEL_SHADE_SECONDARY_POSITION = "secondary";
 
     public static final String CHANNELTYPE_SCENE_ACTIVATE = "scene-activate";
index 3856de9d7561fd9a7aec253be10edef628043760..bacd143f6248843797b02aac080df97c4ed255fd 100644 (file)
@@ -32,8 +32,10 @@ import org.openhab.binding.hdpowerview.internal.api.responses.Shades.ShadeData;
 import org.openhab.binding.hdpowerview.internal.config.HDPowerViewShadeConfiguration;
 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.types.StopMoveType;
 import org.openhab.core.library.types.UpDownType;
+import org.openhab.core.library.unit.Units;
 import org.openhab.core.thing.ChannelUID;
 import org.openhab.core.thing.Thing;
 import org.openhab.core.thing.ThingStatus;
@@ -135,6 +137,7 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
             updateStatus(ThingStatus.ONLINE);
             updateBindingStates(shadeData.positions);
             updateState(CHANNEL_SHADE_LOW_BATTERY, shadeData.batteryStatus < 2 ? OnOffType.ON : OnOffType.OFF);
+            updateState(CHANNEL_SHADE_BATTERY_VOLTAGE, new QuantityType<>(shadeData.batteryStrength / 10, Units.VOLT));
         } else {
             updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR);
         }
index 0bf419a12bf3a899a8ee99595fefe4747c709352..6ffde4ed88382e342a39f01069b37e6da90fba5e 100644 (file)
@@ -48,6 +48,7 @@
                        </channel>
                        <channel id="vane" typeId="shade-vane"/>
                        <channel id="lowBattery" typeId="system.low-battery"/>
+                       <channel id="batteryVoltage" typeId="battery-voltage"/>
                </channels>
 
                <properties>
                <description>Activates the scene</description>
        </channel-type>
 
+       <channel-type id="battery-voltage" advanced="true">
+               <item-type>Number:ElectricPotential</item-type>
+               <label>Battery Voltage</label>
+               <description>Battery voltage reported by the shade</description>
+               <state pattern="%.1f %unit%" readOnly="true"/>
+       </channel-type>
+
 </thing:thing-descriptions>