[hdpowerview] Convert calibrate to command channel. (#12138)

Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
This commit is contained in:
Jacob Laursen
2022-01-27 20:49:27 +01:00
committed by GitHub
parent 89b8b2eb0a
commit 369b985192
6 changed files with 32 additions and 14 deletions

View File

@@ -41,7 +41,7 @@ public class HDPowerViewBindingConstants {
public static final String CHANNEL_SHADE_POSITION = "position";
public static final String CHANNEL_SHADE_SECONDARY_POSITION = "secondary";
public static final String CHANNEL_SHADE_VANE = "vane";
public static final String CHANNEL_SHADE_CALIBRATE = "calibrate";
public static final String CHANNEL_SHADE_COMMAND = "command";
public static final String CHANNEL_SHADE_LOW_BATTERY = "lowBattery";
public static final String CHANNEL_SHADE_BATTERY_LEVEL = "batteryLevel";
public static final String CHANNEL_SHADE_BATTERY_VOLTAGE = "batteryVoltage";

View File

@@ -42,6 +42,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.types.StopMoveType;
import org.openhab.core.library.types.StringType;
import org.openhab.core.library.types.UpDownType;
import org.openhab.core.library.unit.Units;
import org.openhab.core.thing.Bridge;
@@ -70,6 +71,8 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
BATTERY_LEVEL
}
private static final String COMMAND_CALIBRATE = "CALIBRATE";
private final Logger logger = LoggerFactory.getLogger(HDPowerViewShadeHandler.class);
private final ShadeCapabilitiesDatabase db = new ShadeCapabilitiesDatabase();
@@ -226,9 +229,14 @@ public class HDPowerViewShadeHandler extends AbstractHubbedThingHandler {
}
break;
case CHANNEL_SHADE_CALIBRATE:
if (OnOffType.ON == command) {
calibrateShade(webTargets, shadeId);
case CHANNEL_SHADE_COMMAND:
if (command instanceof StringType) {
if (COMMAND_CALIBRATE.equals(((StringType) command).toString())) {
logger.debug("Calibrate shade {}", shadeId);
calibrateShade(webTargets, shadeId);
}
} else {
logger.warn("Unsupported command: {}. Supported commands are: " + COMMAND_CALIBRATE, command);
}
break;
}

View File

@@ -38,8 +38,9 @@ channel-type.hdpowerview.repeater-blinking-enabled.description = Blink during co
channel-type.hdpowerview.repeater-identify.label = Identify
channel-type.hdpowerview.repeater-identify.description = Flash repeater to identify
channel-type.hdpowerview.repeater-identify.command.option.IDENTIFY = Identify
channel-type.hdpowerview.shade-calibrate.label = Calibrate
channel-type.hdpowerview.shade-calibrate.description = Perform calibration of the shade
channel-type.hdpowerview.shade-command.label = Command
channel-type.hdpowerview.shade-command.description = Send a command to the shade
channel-type.hdpowerview.shade-command.command.option.CALIBRATE = Calibrate
channel-type.hdpowerview.shade-position.label = Position
channel-type.hdpowerview.shade-position.description = The vertical position of the shade
channel-type.hdpowerview.shade-vane.label = Vane

View File

@@ -10,6 +10,9 @@ channel-type.hdpowerview.repeater-blinking-enabled.description = Blink når komm
channel-type.hdpowerview.repeater-identify.label = Identificer
channel-type.hdpowerview.repeater-identify.description = Identificer ved at lade repeater blinke
channel-type.hdpowerview.repeater-identify.command.option.IDENTIFY = Identificer
channel-type.hdpowerview.shade-command.label = Kommando
channel-type.hdpowerview.shade-command.description = Send en kommando til gardinet
channel-type.hdpowerview.shade-command.command.option.CALIBRATE = Kalibrer
# dynamic channels

View File

@@ -61,7 +61,7 @@
<description>The secondary vertical position (on top-down/bottom-up shades)</description>
</channel>
<channel id="vane" typeId="shade-vane"/>
<channel id="calibrate" typeId="shade-calibrate"/>
<channel id="command" typeId="shade-command"/>
<channel id="lowBattery" typeId="system.low-battery"/>
<channel id="batteryLevel" typeId="system.battery-level"/>
<channel id="batteryVoltage" typeId="battery-voltage"/>
@@ -121,10 +121,16 @@
<description>The opening of the slats in the shade</description>
</channel-type>
<channel-type id="shade-calibrate" advanced="true">
<item-type>Switch</item-type>
<label>Calibrate</label>
<description>Perform calibration of the shade</description>
<channel-type id="shade-command" advanced="true">
<item-type>String</item-type>
<label>Command</label>
<description>Send a command to the shade</description>
<command>
<options>
<option value="CALIBRATE">Calibrate</option>
</options>
</command>
<autoUpdatePolicy>veto</autoUpdatePolicy>
</channel-type>
<channel-type id="scene-activate">