[hdpowerview] Add new batteryVoltage channel (#11155)

* 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>
This commit is contained in:
jlaur
2021-08-26 18:57:27 +02:00
committed by GitHub
parent 36377a790e
commit 4e50a985e6
4 changed files with 19 additions and 6 deletions

View 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";

View 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);
}

View 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>
@@ -82,4 +83,11 @@
<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>