Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hdpowerview] Introduce command channel for shades #12138

Merged
merged 1 commit into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bundles/org.openhab.binding.hdpowerview/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. |
Expand All @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
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;
Expand Down Expand Up @@ -70,6 +71,8 @@ private enum RefreshKind {
BATTERY_LEVEL
}

private static final String COMMAND_CALIBRATE = "CALIBRATE";

private final Logger logger = LoggerFactory.getLogger(HDPowerViewShadeHandler.class);
private final ShadeCapabilitiesDatabase db = new ShadeCapabilitiesDatabase();

Expand Down Expand Up @@ -226,9 +229,14 @@ private void handleShadeCommand(String channelId, Command command, HDPowerViewWe
}
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"/>
Expand Down Expand Up @@ -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">
Expand Down