[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 14 deletions

View File

@ -92,7 +92,7 @@ All of these channels appear in the binding, but only those which have a physica
| 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 similar 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). |
| calibrate | Switch | Setting this to ON will calibrate the shade. Note: include `{autoupdate="false"}` in the item configuration to avoid having to reset it to off after use. |
| command | String | Send a command to the shade. Valid values are: `CALIBRATE` |
| lowBattery | Switch | Indicates ON when the battery level of the shade is low, as determined by the hub's internal rules. |
| batteryLevel | Number | Battery level (10% = low, 50% = medium, 100% = high)
| batteryVoltage | Number:ElectricPotential | Battery voltage reported by the shade. |
@ -102,7 +102,7 @@ All of these channels appear in the binding, but only those which have a physica
| Channel | Item Type | Description |
|-----------------|-----------|-------------------------------|
| identify | String | Flash repeater to identify. Valid values are: IDENTIFY |
| identify | String | Flash repeater to identify. Valid values are: `IDENTIFY` |
| blinkingEnabled | Switch | Blink during commands. |
### Roller Shutter Up/Down Position vs. Open/Close State
@ -226,7 +226,7 @@ Rollershutter Living_Room_Shade_Position "Living Room Shade Position [%.0f %%]"
Rollershutter Living_Room_Shade_Secondary "Living Room Shade Secondary Position [%.0f %%]" {channel="hdpowerview:shade:g24:s50150:secondary"}
Dimmer Living_Room_Shade_Vane "Living Room Shade Vane [%.0f %%]" {channel="hdpowerview:shade:g24:s50150:vane"}
Switch Living_Room_Shade_Battery_Low_Alarm "Living Room Shade Battery Low Alarm [%s]" {channel="hdpowerview:shade:g24:s50150:lowBattery"}
Switch Living_Room_Shade_Calibrate "Living Room Shade Calibrate" {channel="hdpowerview:shade:g24:s50150:calibrate", autoupdate="false"}
String Living_Room_Shade_Command "Living Room Shade Command" {channel="hdpowerview:shade:g24:s50150:command"}
```
Repeater items:

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