Added support for HAN-FUN outlets / simple on-off devices (#10760)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp
2021-05-29 14:25:36 +02:00
committed by GitHub
parent 572fd3dded
commit 04507d98fc
12 changed files with 247 additions and 82 deletions

View File

@@ -53,6 +53,7 @@ public class AVMFritzBindingConstants {
public static final String DEVICE_COMETDECT = "Comet_DECT";
public static final String DEVICE_HAN_FUN_CONTACT = "HAN_FUN_CONTACT";
public static final String DEVICE_HAN_FUN_SWITCH = "HAN_FUN_SWITCH";
public static final String DEVICE_HAN_FUN_ON_OFF = "HAN_FUN_ON_OFF";
public static final String DEVICE_HAN_FUN_BLINDS = "HAN_FUN_BLINDS";
// List of main group types
@@ -74,6 +75,7 @@ public class AVMFritzBindingConstants {
public static final ThingTypeUID COMETDECT_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_COMETDECT);
public static final ThingTypeUID HAN_FUN_CONTACT_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_HAN_FUN_CONTACT);
public static final ThingTypeUID HAN_FUN_SWITCH_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_HAN_FUN_SWITCH);
public static final ThingTypeUID HAN_FUN_ON_OFF_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_HAN_FUN_ON_OFF);
public static final ThingTypeUID HAN_FUN_BLINDS_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_HAN_FUN_BLINDS);
public static final ThingTypeUID GROUP_HEATING_THING_TYPE = new ThingTypeUID(BINDING_ID, GROUP_HEATING);
public static final ThingTypeUID GROUP_SWITCH_THING_TYPE = new ThingTypeUID(BINDING_ID, GROUP_SWITCH);
@@ -129,6 +131,7 @@ public class AVMFritzBindingConstants {
public static final String CHANNEL_PRESS = "press";
public static final String CHANNEL_LAST_CHANGE = "last_change";
public static final String CHANNEL_ROLLERSHUTTER = "rollershutter";
public static final String CHANNEL_ON_OFF = "on_off";
// List of all Channel config ids
public static final String CONFIG_CHANNEL_TEMP_OFFSET = "offset";
@@ -169,7 +172,7 @@ public class AVMFritzBindingConstants {
public static final Set<ThingTypeUID> SUPPORTED_DEVICE_THING_TYPES_UIDS = Set.of(DECT100_THING_TYPE,
DECT200_THING_TYPE, DECT210_THING_TYPE, PL546E_THING_TYPE, HAN_FUN_CONTACT_THING_TYPE,
HAN_FUN_BLINDS_THING_TYPE);
HAN_FUN_ON_OFF_THING_TYPE, HAN_FUN_BLINDS_THING_TYPE);
public static final Set<ThingTypeUID> SUPPORTED_GROUP_THING_TYPES_UIDS = Set.of(GROUP_HEATING_THING_TYPE,
GROUP_SWITCH_THING_TYPE);

View File

@@ -17,6 +17,8 @@ import java.math.BigDecimal;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import org.eclipse.jdt.annotation.Nullable;
/**
* See {@link DeviceListModel}.
*
@@ -34,6 +36,8 @@ import javax.xml.bind.annotation.XmlElement;
* <li>Bit 10: AVM DECT Repeater</li>
* <li>Bit 11: Mikrofon</li>
* <li>Bit 13: HAN-FUN Unit</li>
* <li>Bit 15: an-/ausschaltbares Gerät / Steckdose / Lampe / Aktor</li>
* <li>Bit 18: Rollladen - hoch, runter, stop und level 0% bis 100 %</li>
* </ol>
*
* @author Robert Bausdorf - Initial contribution
@@ -53,6 +57,7 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
protected static final int DECT_REPEATER_BIT = 1 << 10; // Bit 10
protected static final int MICROPHONE_BIT = 1 << 11; // Bit 11
protected static final int HAN_FUN_UNIT_BIT = 1 << 13; // Bit 13
protected static final int HAN_FUN_ON_OFF_BIT = 1 << 15; // Bit 15
protected static final int HAN_FUN_BLINDS_BIT = 1 << 18; // Bit 18
protected static final int HUMIDITY_SENSOR_BIT = 1 << 20; // Bit 20 - undocumented
@@ -89,12 +94,19 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
@XmlElement(name = "switch")
private SwitchModel switchModel;
@XmlElement(name = "simpleonoff")
private @Nullable SimpleOnOffModel simpleOnOffUnit;
@XmlElement(name = "powermeter")
private PowerMeterModel powermeterModel;
@XmlElement(name = "hkr")
private HeatingModel heatingModel;
public @Nullable SimpleOnOffModel getSimpleOnOffUnit() {
return simpleOnOffUnit;
}
public PowerMeterModel getPowermeter() {
return powermeterModel;
}
@@ -151,7 +163,7 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
return (bitmask & OUTLET_BIT) > 0;
}
public boolean isTempSensor() {
public boolean isTemperatureSensor() {
return (bitmask & TEMPERATURE_SENSOR_BIT) > 0;
}
@@ -171,7 +183,7 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
return (bitmask & HEATING_THERMOSTAT_BIT) > 0;
}
public boolean isMicrophone() {
public boolean hasMicrophone() {
return (bitmask & MICROPHONE_BIT) > 0;
}
@@ -179,6 +191,10 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
return (bitmask & HAN_FUN_UNIT_BIT) > 0;
}
public boolean isHANFUNOnOff() {
return (bitmask / HAN_FUN_ON_OFF_BIT) > 0;
}
public boolean isHANFUNBlinds() {
return (bitmask & HAN_FUN_BLINDS_BIT) > 0;
}
@@ -215,19 +231,19 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
@Override
public String toString() {
return new StringBuilder().append("[ain=").append(ident).append(",bitmask=").append(bitmask)
.append(",isHANFUNDevice=").append(isHANFUNDevice()).append(",isHANFUNButton=").append(isHANFUNButton())
return new StringBuilder("[ain=").append(ident).append(",bitmask=").append(bitmask).append(",isHANFUNDevice=")
.append(isHANFUNDevice()).append(",isHANFUNButton=").append(isHANFUNButton())
.append(",isHANFUNAlarmSensor=").append(isHANFUNAlarmSensor()).append(",isButton=").append(isButton())
.append(",isSwitchableOutlet=").append(isSwitchableOutlet()).append(",isTempSensor=")
.append(isTempSensor()).append(",isHumiditySensor=").append(isHumiditySensor()).append(",isPowermeter=")
.append(isPowermeter()).append(",isDectRepeater=").append(isDectRepeater())
.append(",isHeatingThermostat=").append(isHeatingThermostat()).append(",isMicrophone=")
.append(isMicrophone()).append(",isHANFUNUnit=").append(isHANFUNUnit()).append(",isHANFUNBlind=")
.append(isHANFUNBlinds()).append(",id=").append(deviceId).append(",manufacturer=")
.append(deviceManufacturer).append(",productname=").append(productName).append(",fwversion=")
.append(firmwareVersion).append(",present=").append(present).append(",name=").append(name)
.append(",battery=").append(getBattery()).append(",batterylow=").append(getBatterylow()).append(",")
.append(getSwitch()).append(",").append(getPowermeter()).append(",").append(getHkr()).append(",")
.toString();
.append(",isSwitchableOutlet=").append(isSwitchableOutlet()).append(",isTemperatureSensor=")
.append(isTemperatureSensor()).append(",isHumiditySensor=").append(isHumiditySensor())
.append(",isPowermeter=").append(isPowermeter()).append(",isDectRepeater=").append(isDectRepeater())
.append(",isHeatingThermostat=").append(isHeatingThermostat()).append(",hasMicrophone=")
.append(hasMicrophone()).append(",isHANFUNUnit=").append(isHANFUNUnit()).append(",isHANFUNOnOff=")
.append(isHANFUNOnOff()).append(",isHANFUNBlind=").append(isHANFUNBlinds()).append(",id=")
.append(deviceId).append(",manufacturer=").append(deviceManufacturer).append(",productname=")
.append(productName).append(",fwversion=").append(firmwareVersion).append(",present=").append(present)
.append(",name=").append(name).append(",battery=").append(getBattery()).append(",batterylow=")
.append(getBatterylow()).append(",").append(getSwitch()).append(",").append(getSimpleOnOffUnit())
.append(",").append(getPowermeter()).append(",").append(getHkr()).append(",").toString();
}
}

View File

@@ -90,25 +90,30 @@ public class DeviceModel extends AVMFritzBaseModel {
@Override
public String toString() {
return new StringBuilder().append(super.toString()).append(temperature).append(",").append(humidity).append(",")
return new StringBuilder(super.toString()).append(temperature).append(",").append(humidity).append(",")
.append(alert).append(",").append(getButtons()).append(",").append(etsiunitinfo).append("]").toString();
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "etsideviceid", "unittype", "interfaces" })
public static class ETSUnitInfoModel {
public static final String HAN_FUN_UNITTYPE_AC_OUTLET = "262";
public static final String HAN_FUN_UNITTYPE_AC_OUTLET_SIMPLE_POWER_METERING = "263";
public static final String HAN_FUN_UNITTYPE_SIMPLE_BUTTON = "273";
public static final String HAN_FUN_UNITTYPE_SIMPLE_DETECTOR = "512";
public static final String HAN_FUN_UNITTYPE_MAGNETIC_CONTACT = "513";
public static final String HAN_FUN_UNITTYPE_OPTICAL_CONTACT = "514";
public static final String HAN_FUN_UNITTYPE_DOOR_OPEN_CLOSE_DETECTOR = "513";
public static final String HAN_FUN_UNITTYPE_WINDOW_OPEN_CLOSE_DETECTOR = "514";
public static final String HAN_FUN_UNITTYPE_MOTION_DETECTOR = "515";
public static final String HAN_FUN_UNITTYPE_SMOKE_DETECTOR = "516";
public static final String HAN_FUN_UNITTYPE_SMOKE_DETECTOR = "516"; // undocumented
public static final String HAN_FUN_UNITTYPE_FLOOD_DETECTOR = "518";
public static final String HAN_FUN_UNITTYPE_GLAS_BREAK_DETECTOR = "519";
public static final String HAN_FUN_UNITTYPE_VIBRATION_DETECTOR = "520";
public static final String HAN_FUN_UNITTYPE_SIREN = "640";
public static final String HAN_FUN_INTERFACE_ALERT = "256";
public static final String HAN_FUN_INTERFACE_KEEP_ALIVE = "277";
public static final String HAN_FUN_INTERFACE_ON_OFF = "512";
public static final String HAN_FUN_INTERFACE_SIMPLE_POWER_METERING = "768"; // undocumented
public static final String HAN_FUN_INTERFACE_SIMPLE_BUTTON = "772";
private String etsideviceid;
@@ -141,8 +146,8 @@ public class DeviceModel extends AVMFritzBaseModel {
@Override
public String toString() {
return new StringBuilder().append("[etsideviceid=").append(etsideviceid).append(",unittype=")
.append(unittype).append(",interfaces=").append(interfaces).append("]").toString();
return new StringBuilder("[etsideviceid=").append(etsideviceid).append(",unittype=").append(unittype)
.append(",interfaces=").append(interfaces).append("]").toString();
}
}
}

View File

@@ -0,0 +1,34 @@
/**
* Copyright (c) 2010-2021 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.avmfritz.internal.dto;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
/**
* See {@link DeviceListModel}.
*
* @author Joshua Bacher - Initial contribution
*/
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(propOrder = { "state" })
public class SimpleOnOffModel {
public boolean state;
@Override
public String toString() {
return new StringBuilder("[state=").append(state).append(']').toString();
}
}

View File

@@ -336,6 +336,8 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
return DEVICE_HAN_FUN_CONTACT;
} else if (interfaces.contains(HAN_FUN_INTERFACE_SIMPLE_BUTTON)) {
return DEVICE_HAN_FUN_SWITCH;
} else if (interfaces.contains(HAN_FUN_INTERFACE_ON_OFF)) {
return DEVICE_HAN_FUN_ON_OFF;
}
}
return device.getProductName().replaceAll(INVALID_PATTERN, "_");

View File

@@ -35,6 +35,7 @@ import org.openhab.binding.avmfritz.internal.dto.HeatingModel.NextChangeModel;
import org.openhab.binding.avmfritz.internal.dto.HumidityModel;
import org.openhab.binding.avmfritz.internal.dto.LevelcontrolModel;
import org.openhab.binding.avmfritz.internal.dto.PowerMeterModel;
import org.openhab.binding.avmfritz.internal.dto.SimpleOnOffModel;
import org.openhab.binding.avmfritz.internal.dto.SwitchModel;
import org.openhab.binding.avmfritz.internal.dto.TemperatureModel;
import org.openhab.binding.avmfritz.internal.hardware.FritzAhaStatusListener;
@@ -140,9 +141,12 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
if (device.isHeatingThermostat()) {
updateHeatingThermostat(device.getHkr());
}
if (device.isHANFUNUnit() && device.isHANFUNOnOff()) {
updateSimpleOnOffUnit(device.getSimpleOnOffUnit());
}
if (device instanceof DeviceModel) {
DeviceModel deviceModel = (DeviceModel) device;
if (deviceModel.isTempSensor()) {
if (deviceModel.isTemperatureSensor()) {
updateTemperatureSensor(deviceModel.getTemperature());
}
if (deviceModel.isHumiditySensor()) {
@@ -225,8 +229,13 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
if (lowBattery == null) {
updateThingChannelState(CHANNEL_BATTERY_LOW, UnDefType.UNDEF);
} else {
updateThingChannelState(CHANNEL_BATTERY_LOW,
BatteryModel.BATTERY_ON.equals(lowBattery) ? OnOffType.ON : OnOffType.OFF);
updateThingChannelState(CHANNEL_BATTERY_LOW, OnOffType.from(BatteryModel.BATTERY_ON.equals(lowBattery)));
}
}
private void updateSimpleOnOffUnit(@Nullable SimpleOnOffModel simpleOnOffUnit) {
if (simpleOnOffUnit != null) {
updateThingChannelState(CHANNEL_ON_OFF, OnOffType.from(simpleOnOffUnit.state));
}
}
@@ -241,7 +250,7 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
if (state == null) {
updateThingChannelState(CHANNEL_OUTLET, UnDefType.UNDEF);
} else {
updateThingChannelState(CHANNEL_OUTLET, SwitchModel.ON.equals(state) ? OnOffType.ON : OnOffType.OFF);
updateThingChannelState(CHANNEL_OUTLET, OnOffType.from(SwitchModel.ON.equals(state)));
}
}
}
@@ -370,11 +379,9 @@ public abstract class AVMFritzBaseThingHandler extends BaseThingHandler implemen
logger.debug("Channel {} is a read-only channel and cannot handle command '{}'", channelId, command);
break;
case CHANNEL_OUTLET:
case CHANNEL_ON_OFF:
if (command instanceof OnOffType) {
fritzBox.setSwitch(ain, OnOffType.ON.equals(command));
if (state != null) {
state.getSwitch().setState(OnOffType.ON.equals(command) ? SwitchModel.ON : SwitchModel.OFF);
}
}
break;
case CHANNEL_SETTEMP:

View File

@@ -66,10 +66,6 @@ public class Powerline546EHandler extends AVMFritzBaseBridgeHandler implements F
private final Logger logger = LoggerFactory.getLogger(Powerline546EHandler.class);
/**
* keeps track of the current state for handling of increase/decrease
*/
private @Nullable AVMFritzBaseModel state;
private @Nullable String identifier;
/**
@@ -128,7 +124,6 @@ public class Powerline546EHandler extends AVMFritzBaseBridgeHandler implements F
} else {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, "Device not present");
}
state = device;
updateProperties(device);
@@ -272,11 +267,8 @@ public class Powerline546EHandler extends AVMFritzBaseBridgeHandler implements F
}
break;
case CHANNEL_OUTLET:
fritzBox.setSwitch(ain, OnOffType.ON.equals(command));
if (command instanceof OnOffType) {
if (state != null) {
state.getSwitch().setState(OnOffType.ON.equals(command) ? SwitchModel.ON : SwitchModel.OFF);
}
fritzBox.setSwitch(ain, OnOffType.ON.equals(command));
}
break;
default:

View File

@@ -13,6 +13,12 @@ thing-type.avmfritz.HAN_FUN_CONTACT.description = HAN-FUN Kontakt (e.g. SmartHom
thing-type.avmfritz.HAN_FUN_SWITCH.label = HAN-FUN Schalter
thing-type.avmfritz.HAN_FUN_SWITCH.description = HAN-FUN Schalter (e.g. SmartHome Wandtaster).
thing-type.avmfritz.HAN_FUN_BLINDS.label = HAN-FUN Rollladen
thing-type.avmfritz.HAN_FUN_BLINDS.description = HAN-FUN Rollladen (z.B. Rollotron DECT 1213, Becker BoxCTRL).
thing-type.avmfritz.HAN_FUN_ON_OFF.label = HAN-FUN an-/ausschaltbares Gerät
thing-type.avmfritz.HAN_FUN_ON_OFF.description = HAN-FUN an-/ausschaltbares Gerät (e.g. SmartHome Zwischenstecker innen / SmartHome Zwischenstecker außen).
# bridge types config groups
bridge-type.config.avmfritz.fritzbox.group.network.label = Netzwerk
bridge-type.config.avmfritz.fritzbox.group.network.description = Einstellungen für das Netzwerk.
@@ -99,9 +105,6 @@ thing-type.avmfritz.FRITZ_DECT_440.description = FRITZ!DECT 440 Taster. Dient zu
thing-type.avmfritz.FRITZ_Powerline_546E.description = FRITZ!Powerline 546E schaltbare Steckdose. Dient zur Steuerung der integrierten Steckdose und liefert Daten wie z.B. Temperatur.
thing-type.avmfritz.HAN_FUN_BLINDS.label = HAN-FUN Rollladen
thing-type.avmfritz.HAN_FUN_BLINDS.description = HAN-FUN Rollladen (z.B. Rollotron DECT 1213, Becker BoxCTRL).
# thing types config groups
thing-type.avmfritz.FRITZ_GROUP_HEATING.label = Heizkörperregler
thing-type.avmfritz.FRITZ_GROUP_HEATING.description = Gruppe für Heizkörperregler. Dient zur Steuerung von Heizkörpern und liefert Daten wie z.B. Temperatur.

View File

@@ -295,6 +295,24 @@
<config-description-ref uri="thing-type:avmfritz:fritzdevice"/>
</thing-type>
<thing-type id="HAN_FUN_ON_OFF">
<supported-bridge-type-refs>
<bridge-type-ref id="fritzbox"/>
<bridge-type-ref id="FRITZ_Powerline_546E_Solo"/>
</supported-bridge-type-refs>
<label>HAN-FUN On / Off Device</label>
<description>HAN-FUN switchable device (e.g. SmartHome Zwischenstecker innen / SmartHome Zwischenstecker außen)</description>
<channels>
<channel id="on_off" typeId="system.power"/>
</channels>
<representation-property>ain</representation-property>
<config-description-ref uri="thing-type:avmfritz:fritzdevice"/>
</thing-type>
<!-- Supported FRITZ! groups and features -->
<thing-type id="FRITZ_GROUP_HEATING">
<supported-bridge-type-refs>