]> git.basschouten.com Git - openhab-addons.git/commitdiff
[avmfritz] Decode alarm state for blinds (#13672)
authorquidam <quidam@users.noreply.github.com>
Fri, 11 Nov 2022 22:13:05 +0000 (23:13 +0100)
committerGitHub <noreply@github.com>
Fri, 11 Nov 2022 22:13:05 +0000 (23:13 +0100)
* [avmfritz] Decode alarm state for blinds
Signed-off-by: Ulrich Mertin <mail@ulrich-mertin.de>
bundles/org.openhab.binding.avmfritz/README.md
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzBindingConstants.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/dto/AlertModel.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseThingHandler.java
bundles/org.openhab.binding.avmfritz/src/main/resources/OH-INF/i18n/avmfritz.properties
bundles/org.openhab.binding.avmfritz/src/main/resources/OH-INF/thing/channel-types.xml
bundles/org.openhab.binding.avmfritz/src/main/resources/OH-INF/thing/thing-types.xml

index f3b1c9115b2929441a0c577f3d60cc4816199e11..d0421234a9fd85ba07d0de0709abca8595a07eb9 100644 (file)
@@ -199,6 +199,8 @@ The AIN (actor identification number) can be found in the FRITZ!Box interface ->
 | contact_state   | Contact                  | Contact state information (OPEN/CLOSED).                                                                                                           | HAN-FUN contact (e.g. SmartHome Tür-/Fensterkontakt or SmartHome Bewegungsmelder)- FRITZ!OS 7       |
 | last_change     | DateTime                 | States the last time the button was pressed.                                                                                                       | FRITZ!DECT 400, FRITZ!DECT 440, HAN-FUN switch (e.g. SmartHome Wandtaster) - FRITZ!OS 7             |
 | rollershutter   | Rollershutter            | Rollershutter control and status. Accepts UP/DOWN/STOP commands and the opening level in percent. States the opening level in percent.             | HAN-FUN blind (e.g. Rolltron DECT 1213) - FRITZ!OS 7                                                |
+| obstruction_alarm | Obstruction Alarm        | Rollershutter obstruction alarm (ON/OFF)                                                                                                         | HAN-FUN blind (e.g. Rolltron DECT 1213) - FRITZ!OS 7                                                |
+| temperature_alarm | Temperature Alarm        | Rollershutter temperature alarm (ON/OFF)                                                                                                    | HAN-FUN blind (e.g. Rolltron DECT 1213) - FRITZ!OS 7                                                |
 
 ### Triggers
 
index 10da4a4bf1ebbfcec1cf7980fb3128ad97766ba4..51b9a149a2c73049aa5d14f703b7746745f4127a 100644 (file)
@@ -136,6 +136,8 @@ public class AVMFritzBindingConstants {
     public static final String CHANNEL_NEXTTEMP = "next_temp";
     public static final String CHANNEL_BATTERY_LOW = "battery_low";
     public static final String CHANNEL_BATTERY = "battery_level";
+    public static final String CHANNEL_OBSTRUCTION_ALARM = "obstruction_alarm";
+    public static final String CHANNEL_TEMPERATURE_ALARM = "temperature_alarm";
     public static final String CHANNEL_CONTACT_STATE = "contact_state";
     public static final String CHANNEL_PRESS = "press";
     public static final String CHANNEL_LAST_CHANGE = "last_change";
index 3ce765eae26650300944bd35b3b417f55b056cc5..7c7df41d80e59288dd7accaab1f3affd7f7613b2 100644 (file)
@@ -41,6 +41,18 @@ public class AlertModel {
         this.state = state;
     }
 
+    public boolean hasObstructionAlarmOccurred() {
+        return (state.intValue() & 1) != 0;
+    }
+
+    public boolean hasTemperaturAlarmOccurred() {
+        return (state.intValue() & 2) != 0;
+    }
+
+    public boolean hasUnknownAlarmOccurred() {
+        return ((state.intValue() & 255) >> 2) != 0;
+    }
+
     @Override
     public String toString() {
         return new StringBuilder().append("[state=").append(state).append("]").toString();
index 6641749972c00a63d01f877b0be13ab463727fee..e901bc4fcacaf72aa9f6871ad3b3d73608083004 100644 (file)
@@ -152,7 +152,11 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
                     updateHumiditySensor(deviceModel.getHumidity());
                 }
                 if (deviceModel.isHANFUNAlarmSensor()) {
-                    updateHANFUNAlarmSensor(deviceModel.getAlert());
+                    if (deviceModel.isHANFUNBlinds()) {
+                        updateHANFUNBlindsAlarmSensor(deviceModel.getAlert());
+                    } else {
+                        updateHANFUNAlarmSensor(deviceModel.getAlert());
+                    }
                 }
                 if (deviceModel.isHANFUNBlinds()) {
                     updateLevelControl(deviceModel.getLevelControlModel());
@@ -174,6 +178,17 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
         }
     }
 
+    private void updateHANFUNBlindsAlarmSensor(@Nullable AlertModel alertModel) {
+        if (alertModel != null) {
+            updateThingChannelState(CHANNEL_OBSTRUCTION_ALARM,
+                    OnOffType.from(alertModel.hasObstructionAlarmOccurred()));
+            updateThingChannelState(CHANNEL_TEMPERATURE_ALARM, OnOffType.from(alertModel.hasTemperaturAlarmOccurred()));
+            if (alertModel.hasUnknownAlarmOccurred()) {
+                logger.warn("Unknown blinds alarm {}", alertModel.getState());
+            }
+        }
+    }
+
     protected void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
         if (temperatureModel != null) {
             updateThingChannelState(CHANNEL_TEMPERATURE,
@@ -397,6 +412,8 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
             case CHANNEL_BATTERY_LOW:
             case CHANNEL_CONTACT_STATE:
             case CHANNEL_LAST_CHANGE:
+            case CHANNEL_OBSTRUCTION_ALARM:
+            case CHANNEL_TEMPERATURE_ALARM:
                 logger.debug("Channel {} is a read-only channel and cannot handle command '{}'", channelId, command);
                 break;
             case CHANNEL_OUTLET:
index f7198f4ce5ec40f77ddc82d04b64872378308ad6..6f9ef4909952ea8a74ca3067bad944b3975311f6 100644 (file)
@@ -137,6 +137,10 @@ channel-type.avmfritz.comfort_temp.label = Comfort Temperature
 channel-type.avmfritz.comfort_temp.description = Thermostat Comfort temperature.
 channel-type.avmfritz.contact_state.label = Contact State
 channel-type.avmfritz.contact_state.description = Contact state information (OPEN/CLOSED).
+channel-type.avmfritz.obstruction_alarm.label = Obstruction Alarm
+channel-type.avmfritz.obstruction_alarm.description = Obstruction alarm of the blinds. The blinds were stopped and moved a bit in the opposite direction.
+channel-type.avmfritz.temperature_alarm.label = Temperature Alarm
+channel-type.avmfritz.temperature_alarm.description = Temperature alarm of the blinds. Indicates overheating of the motor.
 channel-type.avmfritz.device_locked.label = Locked (manual)
 channel-type.avmfritz.device_locked.description = Device is locked for switching by pressing the button on the device.
 channel-type.avmfritz.eco_temp.label = Eco Temperature
index 2c80f7ff878ec2b159ee7b211c245dd61dcaac38..69543c6c8d73518f117cf194928613d6b45b5b7a 100644 (file)
                <state pattern="%s" readOnly="true"/>
        </channel-type>
 
+       <channel-type id="obstruction_alarm">
+               <item-type>Switch</item-type>
+               <label>Obstruction Alarm</label>
+               <description>Obstruction alarm of the blinds. The blinds were stopped and moved a bit in the opposite direction.</description>
+               <state readOnly="true"/>
+       </channel-type>
+
+       <channel-type id="temperature_alarm">
+               <item-type>Switch</item-type>
+               <label>Temperature Alarm</label>
+               <description>Temperature alarm of the blinds. Indicates overheating of the motor.</description>
+               <state readOnly="true"/>
+       </channel-type>
+
        <channel-type id="last_change">
                <item-type>DateTime</item-type>
                <label>Last Change</label>
                <item-type>Rollershutter</item-type>
                <label>Rollershutter Control</label>
                <description>Controls the rollershutter and states its opening level in percent</description>
-               <category>Blinds</category>
        </channel-type>
 
 </thing:thing-descriptions>
index b6cf1e3dfeed04d366af1a4b2cc874a79ec106ee..00c37e4350d45b3a02b0e5414b9f3652a7ed0a34 100644 (file)
 
                <channels>
                        <channel id="rollershutter" typeId="rollershutter"/>
+                       <channel id="obstruction_alarm" typeId="obstruction_alarm"/>
+                       <channel id="temperature_alarm" typeId="temperature_alarm"/>
                </channels>
 
                <representation-property>ain</representation-property>