]> git.basschouten.com Git - openhab-addons.git/commitdiff
[hdpowerview] Convert calibrate to command channel. (#12138)
authorJacob Laursen <jacob-github@vindvejr.dk>
Thu, 27 Jan 2022 19:49:27 +0000 (20:49 +0100)
committerGitHub <noreply@github.com>
Thu, 27 Jan 2022 19:49:27 +0000 (20:49 +0100)
Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk>
bundles/org.openhab.binding.hdpowerview/README.md
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/HDPowerViewBindingConstants.java
bundles/org.openhab.binding.hdpowerview/src/main/java/org/openhab/binding/hdpowerview/internal/handler/HDPowerViewShadeHandler.java
bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview.properties
bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/i18n/hdpowerview_da.properties
bundles/org.openhab.binding.hdpowerview/src/main/resources/OH-INF/thing/thing-types.xml

index 694e812983dab7949ccc533af4d067d3cf78fa57..85d358fbacee7c2aed9e8e2346fa23becf45ccef 100644 (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:
index 0d45171d8adea05bb15b6eef7e6faaff9381a06a..b8800f394c1590163c37cd747d7a712215679040 100644 (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";
index 428cb5f895079eefa0bb978788f013dd90c3e629..b8bc4777322431d9dee40463e49b287d70913ed0 100644 (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;
         }
index 38a186b2589afe0671d02c5c7a9e35d1c92a2b2a..9419bceac40be324da900166abd0675a763c0ced 100644 (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
index c245b59b96eb0a50702a4d365109a9425bee0d81..1305b5cc553655f7d0d5362d42cc56ffdb58dfb7 100644 (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
 
index 2a33e90d458ba77bb19dc4bdbc762afb2b869ef0..7de48494cc1d4802183f8b7d544a300582e1a5da 100644 (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"/>
                <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">