Skip to content

Commit

Permalink
[avmfritz] Decode alarm state for blinds
Browse files Browse the repository at this point in the history
  • Loading branch information
quidam committed Nov 6, 2022
1 parent 162e146 commit 51e6ef0
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 1 deletion.
2 changes: 2 additions & 0 deletions bundles/org.openhab.binding.avmfritz/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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. (OPEN/CLOSED). | HAN-FUN blind (e.g. Rolltron DECT 1213) - FRITZ!OS 7 |
| temperature_alarm | Temperature Alarm | Rollershutter temperature alarm. (OPEN/CLOSED). | HAN-FUN blind (e.g. Rolltron DECT 1213) - FRITZ!OS 7 |

### Triggers

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public void setState(BigDecimal state) {
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,11 @@ public void onDeviceUpdated(ThingUID thingUID, AVMFritzBaseModel device) {
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());
Expand All @@ -174,6 +178,18 @@ private void updateHANFUNAlarmSensor(@Nullable AlertModel alertModel) {
}
}

private void updateHANFUNBlindsAlarmSensor(@Nullable AlertModel alertModel) {
if (alertModel != null) {
updateThingChannelState(CHANNEL_OBSTRUCTION_ALARM,
alertModel.hasObstructionAlarmOccurred() ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
updateThingChannelState(CHANNEL_TEMPERATURE_ALARM,
alertModel.hasTemperaturAlarmOccurred() ? OpenClosedType.CLOSED : OpenClosedType.OPEN);
if (alertModel.hasUnknownAlarmOccurred()) {
logger.warn("Unknown blinds alarm {}", alertModel.getState());
}
}
}

protected void updateTemperatureSensor(@Nullable TemperatureModel temperatureModel) {
if (temperatureModel != null) {
updateThingChannelState(CHANNEL_TEMPERATURE,
Expand Down Expand Up @@ -397,6 +413,8 @@ public void handleCommand(ChannelUID channelUID, Command command) {
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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ channel-type.avmfritz.comfort_temp.label = Komforttemperatur
channel-type.avmfritz.comfort_temp.description = Zeigt die aktuell eingestellte Komforttemperatur des Heizkörperreglers an.
channel-type.avmfritz.contact_state.label = Tür-/Fenster-Zustand
channel-type.avmfritz.contact_state.description = Zeigt an, ob die Tür oder das Fester offen oder geschlossen ist (OPEN oder CLOSED).
channel-type.avmfritz.obstruction_alarm.label = Hindernisalarm
channel-type.avmfritz.obstruction_alarm.description = Hindernisalarm, der Rollladen wird gestoppt und ein kleines Stück in entgegengesetzte Richtung bewegt.
channel-type.avmfritz.temperature_alarm.label = Temperaturalarm
channel-type.avmfritz.temperature_alarm.description = Temperaturalarm des Rollladens, Motor überhitzt.
channel-type.avmfritz.device_locked.label = Tastensperre
channel-type.avmfritz.device_locked.description = Zeigt an, ob das Schalten per Taste am Gerät aktiviert ist.
channel-type.avmfritz.eco_temp.label = Absenktemperatur
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,22 @@
<state pattern="%s" readOnly="true"/>
</channel-type>

<channel-type id="obstruction_alarm">
<item-type>Contact</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>
<category>Blinds</category>
<state pattern="%s" readOnly="true"/>
</channel-type>

<channel-type id="temperature_alarm">
<item-type>Contact</item-type>
<label>Temperature Alarm</label>
<description>Temperature alarm of the blinds. Indicates overheating of the motor.</description>
<category>Blinds</category>
<state pattern="%s" readOnly="true"/>
</channel-type>

<channel-type id="last_change">
<item-type>DateTime</item-type>
<label>Last Change</label>
Expand Down

0 comments on commit 51e6ef0

Please sign in to comment.