From: Jacob Laursen Date: Thu, 27 Jan 2022 19:49:27 +0000 (+0100) Subject: [hdpowerview] Convert calibrate to command channel. (#12138) X-Git-Url: https://git.basschouten.com/?a=commitdiff_plain;h=369b985192e7854587f4ec2b2780e45ab2cc5814;p=openhab-addons.git [hdpowerview] Convert calibrate to command channel. (#12138) Signed-off-by: Jacob Laursen --- diff --git a/bundles/org.openhab.binding.hdpowerview/README.md b/bundles/org.openhab.binding.hdpowerview/README.md index 694e812983..85d358fbac 100644 --- a/bundles/org.openhab.binding.hdpowerview/README.md +++ b/bundles/org.openhab.binding.hdpowerview/README.md @@ -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: diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewBindingConstants.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewBindingConstants.java index 0d45171d8a..b8800f394c 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewBindingConstants.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewBindingConstants.java @@ -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"; diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java index 428cb5f895..b8bc477732 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java +++ b/bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java @@ -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; } diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties index 38a186b258..9419bceac4 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties +++ b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties @@ -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 diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview_da.properties b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview_da.properties index c245b59b96..1305b5cc55 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview_da.properties +++ b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview_da.properties @@ -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 diff --git a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/thing/thing-types.xml index 2a33e90d45..7de48494cc 100644 --- a/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/thing/thing-types.xml @@ -61,7 +61,7 @@ The secondary vertical position (on top-down/bottom-up shades) - + @@ -121,10 +121,16 @@ The opening of the slats in the shade - - Switch - - Perform calibration of the shade + + String + + Send a command to the shade + + + + + + veto