[avmfritz] Added support for DECT440 device (#8588)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
committed by
GitHub
parent
64a713e74a
commit
bff1810aec
@@ -41,6 +41,7 @@ public class AVMFritzBindingConstants {
|
||||
|
||||
// List of main device types
|
||||
public static final String DEVICE_DECT400 = "FRITZ_DECT_400";
|
||||
public static final String DEVICE_DECT440 = "FRITZ_DECT_440";
|
||||
public static final String DEVICE_DECT301 = "FRITZ_DECT_301";
|
||||
public static final String DEVICE_DECT300 = "FRITZ_DECT_300";
|
||||
public static final String DEVICE_DECT210 = "FRITZ_DECT_210";
|
||||
@@ -59,6 +60,7 @@ public class AVMFritzBindingConstants {
|
||||
// List of all Thing Type UIDs
|
||||
public static final ThingTypeUID BRIDGE_THING_TYPE = new ThingTypeUID(BINDING_ID, BRIDGE_FRITZBOX);
|
||||
public static final ThingTypeUID DECT400_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT400);
|
||||
public static final ThingTypeUID DECT440_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT440);
|
||||
public static final ThingTypeUID DECT301_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT301);
|
||||
public static final ThingTypeUID DECT300_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT300);
|
||||
public static final ThingTypeUID DECT210_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT210);
|
||||
@@ -86,6 +88,12 @@ public class AVMFritzBindingConstants {
|
||||
public static final String PROPERTY_MASTER = "master";
|
||||
public static final String PROPERTY_MEMBERS = "members";
|
||||
|
||||
// List of all channel groups
|
||||
public static final String CHANNEL_GROUP_TOP_LEFT = "top-left";
|
||||
public static final String CHANNEL_GROUP_BOTTOM_LEFT = "bottom-left";
|
||||
public static final String CHANNEL_GROUP_TOP_RIGHT = "top-right";
|
||||
public static final String CHANNEL_GROUP_BOTTOM_RIGHT = "bottom-right";
|
||||
|
||||
// List of all Channel ids
|
||||
public static final String CHANNEL_CALL_INCOMING = "incoming_call";
|
||||
public static final String CHANNEL_CALL_OUTGOING = "outgoing_call";
|
||||
@@ -145,21 +153,20 @@ public class AVMFritzBindingConstants {
|
||||
public static final String MODE_WINDOW_OPEN = "WINDOW_OPEN";
|
||||
public static final String MODE_UNKNOWN = "UNKNOWN";
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BUTTON_THING_TYPES_UIDS = Collections
|
||||
.unmodifiableSet(Stream.of(DECT400_THING_TYPE, HAN_FUN_SWITCH_THING_TYPE).collect(Collectors.toSet()));
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BUTTON_THING_TYPES_UIDS = Set.of(DECT400_THING_TYPE,
|
||||
DECT440_THING_TYPE, HAN_FUN_SWITCH_THING_TYPE);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_HEATING_THING_TYPES = Collections.unmodifiableSet(
|
||||
Stream.of(DECT300_THING_TYPE, DECT301_THING_TYPE, COMETDECT_THING_TYPE).collect(Collectors.toSet()));
|
||||
public static final Set<ThingTypeUID> SUPPORTED_HEATING_THING_TYPES = Set.of(DECT300_THING_TYPE, DECT301_THING_TYPE,
|
||||
COMETDECT_THING_TYPE);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_DEVICE_THING_TYPES_UIDS = Collections
|
||||
.unmodifiableSet(Stream.of(DECT100_THING_TYPE, DECT200_THING_TYPE, DECT210_THING_TYPE, PL546E_THING_TYPE,
|
||||
HAN_FUN_CONTACT_THING_TYPE).collect(Collectors.toSet()));
|
||||
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);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_GROUP_THING_TYPES_UIDS = Collections
|
||||
.unmodifiableSet(Stream.of(GROUP_HEATING_THING_TYPE, GROUP_SWITCH_THING_TYPE).collect(Collectors.toSet()));
|
||||
public static final Set<ThingTypeUID> SUPPORTED_GROUP_THING_TYPES_UIDS = Set.of(GROUP_HEATING_THING_TYPE,
|
||||
GROUP_SWITCH_THING_TYPE);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_THING_TYPES_UIDS = Collections
|
||||
.unmodifiableSet(Stream.of(BRIDGE_THING_TYPE, PL546E_STANDALONE_THING_TYPE).collect(Collectors.toSet()));
|
||||
public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE,
|
||||
PL546E_STANDALONE_THING_TYPE);
|
||||
|
||||
public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Collections.unmodifiableSet(Stream
|
||||
.of(SUPPORTED_BUTTON_THING_TYPES_UIDS, SUPPORTED_HEATING_THING_TYPES, SUPPORTED_DEVICE_THING_TYPES_UIDS,
|
||||
|
||||
@@ -24,8 +24,9 @@ import javax.xml.bind.annotation.XmlElement;
|
||||
*
|
||||
* <ol>
|
||||
* <li>Bit 0: HAN-FUN Gerät</li>
|
||||
* <li>Bit 3: Button</li>
|
||||
* <li>Bit 3: HAN-FUN Button - undocumented</li>
|
||||
* <li>Bit 4: Alarm-Sensor</li>
|
||||
* <li>Bit 5: AVM-Button</li>
|
||||
* <li>Bit 6: Comet DECT, Heizkörperregler</li>
|
||||
* <li>Bit 7: Energie Messgerät</li>
|
||||
* <li>Bit 8: Temperatursensor</li>
|
||||
@@ -43,7 +44,7 @@ public abstract class AVMFritzBaseModel implements BatteryModel {
|
||||
protected static final int HAN_FUN_DEVICE_BIT = 1; // Bit 0
|
||||
protected static final int HAN_FUN_BUTTON_BIT = 1 << 3; // Bit 3 - undocumented
|
||||
protected static final int HAN_FUN_ALARM_SENSOR_BIT = 1 << 4; // Bit 4
|
||||
protected static final int BUTTON_BIT = 1 << 5; // Bit 5 - undocumented
|
||||
protected static final int BUTTON_BIT = 1 << 5; // Bit 5
|
||||
protected static final int HEATING_THERMOSTAT_BIT = 1 << 6; // Bit 6
|
||||
protected static final int POWERMETER_BIT = 1 << 7; // Bit 7
|
||||
protected static final int TEMPSENSOR_BIT = 1 << 8; // Bit 8
|
||||
|
||||
@@ -18,13 +18,16 @@ import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.eclipse.jdt.annotation.Nullable;
|
||||
import org.openhab.binding.avmfritz.internal.dto.AVMFritzBaseModel;
|
||||
import org.openhab.binding.avmfritz.internal.dto.ButtonModel;
|
||||
import org.openhab.binding.avmfritz.internal.dto.DeviceModel;
|
||||
import org.openhab.core.library.types.DateTimeType;
|
||||
import org.openhab.core.thing.Channel;
|
||||
import org.openhab.core.thing.ChannelUID;
|
||||
import org.openhab.core.thing.CommonTriggerEvents;
|
||||
import org.openhab.core.thing.Thing;
|
||||
import org.openhab.core.thing.ThingUID;
|
||||
@@ -40,6 +43,11 @@ import org.slf4j.LoggerFactory;
|
||||
@NonNullByDefault
|
||||
public class AVMFritzButtonHandler extends DeviceHandler {
|
||||
|
||||
private static final String TOP_RIGHT_SUFFIX = "-1";
|
||||
private static final String BOTTOM_RIGHT_SUFFIX = "-3";
|
||||
private static final String BOTTOM_LEFT_SUFFIX = "-5";
|
||||
private static final String TOP_LEFT_SUFFIX = "-7";
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(AVMFritzButtonHandler.class);
|
||||
/**
|
||||
* keeps track of the last timestamp for handling trigger events
|
||||
@@ -67,7 +75,11 @@ public class AVMFritzButtonHandler extends DeviceHandler {
|
||||
updateHANFUNButton(deviceModel.getButtons());
|
||||
}
|
||||
if (deviceModel.isButton()) {
|
||||
updateShortLongPressButton(deviceModel.getButtons());
|
||||
if (DECT400_THING_TYPE.equals(thing.getThingTypeUID())) {
|
||||
updateShortLongPressButton(deviceModel.getButtons());
|
||||
} else if (DECT440_THING_TYPE.equals(thing.getThingTypeUID())) {
|
||||
updateButtons(deviceModel.getButtons());
|
||||
}
|
||||
updateBattery(deviceModel);
|
||||
}
|
||||
}
|
||||
@@ -88,6 +100,29 @@ public class AVMFritzButtonHandler extends DeviceHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private void updateButtons(List<ButtonModel> buttons) {
|
||||
Optional<ButtonModel> topLeft = buttons.stream().filter(b -> b.getIdentifier().endsWith(TOP_LEFT_SUFFIX))
|
||||
.findFirst();
|
||||
if (topLeft.isPresent()) {
|
||||
updateButton(topLeft.get(), CommonTriggerEvents.PRESSED, CHANNEL_GROUP_TOP_LEFT);
|
||||
}
|
||||
Optional<ButtonModel> bottomLeft = buttons.stream().filter(b -> b.getIdentifier().endsWith(BOTTOM_LEFT_SUFFIX))
|
||||
.findFirst();
|
||||
if (bottomLeft.isPresent()) {
|
||||
updateButton(bottomLeft.get(), CommonTriggerEvents.PRESSED, CHANNEL_GROUP_BOTTOM_LEFT);
|
||||
}
|
||||
Optional<ButtonModel> topRight = buttons.stream().filter(b -> b.getIdentifier().endsWith(TOP_RIGHT_SUFFIX))
|
||||
.findFirst();
|
||||
if (topRight.isPresent()) {
|
||||
updateButton(topRight.get(), CommonTriggerEvents.PRESSED, CHANNEL_GROUP_TOP_RIGHT);
|
||||
}
|
||||
Optional<ButtonModel> bottomRight = buttons.stream()
|
||||
.filter(b -> b.getIdentifier().endsWith(BOTTOM_RIGHT_SUFFIX)).findFirst();
|
||||
if (bottomRight.isPresent()) {
|
||||
updateButton(bottomRight.get(), CommonTriggerEvents.PRESSED, CHANNEL_GROUP_BOTTOM_RIGHT);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateHANFUNButton(List<ButtonModel> buttons) {
|
||||
if (!buttons.isEmpty()) {
|
||||
updateButton(buttons.get(0), CommonTriggerEvents.PRESSED);
|
||||
@@ -95,9 +130,16 @@ public class AVMFritzButtonHandler extends DeviceHandler {
|
||||
}
|
||||
|
||||
private void updateButton(ButtonModel buttonModel, String event) {
|
||||
updateButton(buttonModel, event, null);
|
||||
}
|
||||
|
||||
private void updateButton(ButtonModel buttonModel, String event, @Nullable String channelGroupId) {
|
||||
int lastPressedTimestamp = buttonModel.getLastpressedtimestamp();
|
||||
if (lastPressedTimestamp == 0) {
|
||||
updateThingChannelState(CHANNEL_LAST_CHANGE, UnDefType.UNDEF);
|
||||
updateThingChannelState(
|
||||
channelGroupId == null ? CHANNEL_LAST_CHANGE
|
||||
: channelGroupId + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_LAST_CHANGE,
|
||||
UnDefType.UNDEF);
|
||||
} else {
|
||||
ZonedDateTime timestamp = ZonedDateTime.ofInstant(Instant.ofEpochSecond(lastPressedTimestamp),
|
||||
ZoneId.systemDefault());
|
||||
@@ -106,9 +148,13 @@ public class AVMFritzButtonHandler extends DeviceHandler {
|
||||
// restart)
|
||||
if (then.isAfter(lastTimestamp)) {
|
||||
lastTimestamp = then;
|
||||
triggerThingChannel(CHANNEL_PRESS, event);
|
||||
triggerThingChannel(channelGroupId == null ? CHANNEL_PRESS
|
||||
: channelGroupId + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_PRESS, event);
|
||||
}
|
||||
updateThingChannelState(CHANNEL_LAST_CHANGE, new DateTimeType(timestamp));
|
||||
updateThingChannelState(
|
||||
channelGroupId == null ? CHANNEL_LAST_CHANGE
|
||||
: channelGroupId + ChannelUID.CHANNEL_GROUP_SEPARATOR + CHANNEL_LAST_CHANGE,
|
||||
new DateTimeType(timestamp));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -95,6 +95,8 @@ thing-type.avmfritz.Comet_DECT.description = Comet DECT Heizk
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_400.description = FRITZ!DECT 400 Taster. Dient zur komfortablen Bedienung von FRITZ! Smart-Home-Geräten.
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_440.description = FRITZ!DECT 440 Taster. Dient zur komfortablen Bedienung von FRITZ! Smart-Home-Geräten und liefert Daten wie z.B. Temperatur.
|
||||
|
||||
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 types config groups
|
||||
@@ -109,8 +111,23 @@ thing-type.config.avmfritz.fritzdevice.ain.description = Die AHA ID (AIN) zur Id
|
||||
|
||||
thing-type.config.avmfritz.fritzgroup.ain.description = Die AHA ID (AIN) zur Identifikation der FRITZ! Gruppe.
|
||||
|
||||
# channel types
|
||||
# channel group types
|
||||
channel-group-type.avmfritz.button.label = Taste
|
||||
|
||||
channel-group-type.avmfritz.device.label = Geräteinformationen
|
||||
|
||||
channel-group-type.avmfritz.sensors.label = Sensordaten
|
||||
|
||||
# channel groups
|
||||
thing-type.avmfritz.FRITZ_DECT_440.group.top-left.label = Taste Oben Links
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_440.group.top-right.label = Taste Oben Rechts
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_440.group.bottom-left.label = Taste Unten Links
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_440.group.bottom-right.label = Taste Unten Rechts
|
||||
|
||||
# channel types
|
||||
channel-type.avmfritz.incoming_call.label = Eingehender Anruf
|
||||
channel-type.avmfritz.incoming_call.description = Informationen zu anrufender und angerufener Telefonnummer.
|
||||
channel-type.avmfritz.outgoing_call.label = Ausgehender Anruf
|
||||
@@ -188,6 +205,12 @@ channel-type.avmfritz.contact_state.description = Zeigt an, ob die T
|
||||
thing-type.avmfritz.HAN_FUN_SWITCH.channel.press.label = Tastendruck
|
||||
thing-type.avmfritz.HAN_FUN_SWITCH.channel.press.description = Wird ausgelöst, wenn eine Taste gedrückt wird.
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_400.channel.press.label = Tastendruck
|
||||
thing-type.avmfritz.FRITZ_DECT_400.channel.press.description = Wird ausgelöst, wenn eine Taste gedrückt wird.
|
||||
|
||||
thing-type.avmfritz.FRITZ_DECT_440.channel.press.label = Tastendruck
|
||||
thing-type.avmfritz.FRITZ_DECT_440.channel.press.description = Wird ausgelöst, wenn eine Taste gedrückt wird.
|
||||
|
||||
channel-type.avmfritz.last_change.label = Letzte Änderung
|
||||
channel-type.avmfritz.last_change.description = Zeigt an, wann der Schalter zuletzt gedrückt wurde.
|
||||
channel-type.avmfritz.last_change.pattern = %1$td.%1$tm.%1$tY %1$tH:%1$tM:%1$tS
|
||||
|
||||
@@ -73,7 +73,34 @@
|
||||
<state pattern="%s" readOnly="true"/>
|
||||
</channel-type>
|
||||
|
||||
<!-- Channel definitions of specific FRITZ! devices -->
|
||||
<!-- Channel Group definitions of specific FRITZ! devices -->
|
||||
<channel-group-type id="button">
|
||||
<label>Button</label>
|
||||
<channels>
|
||||
<channel id="press" typeId="system.rawbutton">
|
||||
<label>Button Press</label>
|
||||
<description>Triggeres PRESSED when a button was pressed.</description>
|
||||
</channel>
|
||||
<channel id="last_change" typeId="last_change"/>
|
||||
</channels>
|
||||
</channel-group-type>
|
||||
|
||||
<channel-group-type id="device">
|
||||
<label>Device Data</label>
|
||||
<channels>
|
||||
<channel id="battery_level" typeId="system.battery-level"/>
|
||||
<channel id="battery_low" typeId="system.low-battery"/>
|
||||
</channels>
|
||||
</channel-group-type>
|
||||
|
||||
<channel-group-type id="sensors">
|
||||
<label>Sensor Data</label>
|
||||
<channels>
|
||||
<channel id="temperature" typeId="temperature"/>
|
||||
</channels>
|
||||
</channel-group-type>
|
||||
|
||||
<!-- Channel definitions of specific FRITZ! devices or Channel Groups -->
|
||||
<channel-type id="temperature">
|
||||
<item-type>Number:Temperature</item-type>
|
||||
<label>Current Temperature</label>
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
<channels>
|
||||
<channel id="press" typeId="system.button">
|
||||
<label>Button press</label>
|
||||
<description>Triggered SHORT_PRESSED or LONG_PRESSED when a button was pressed.</description>
|
||||
<label>Button Press</label>
|
||||
<description>Triggeres SHORT_PRESSED or LONG_PRESSED when a button was pressed.</description>
|
||||
</channel>
|
||||
<channel id="last_change" typeId="last_change"/>
|
||||
<channel id="battery_level" typeId="system.battery-level"/>
|
||||
@@ -29,6 +29,37 @@
|
||||
<config-description-ref uri="thing-type:avmfritz:fritzdevice"/>
|
||||
</thing-type>
|
||||
|
||||
<thing-type id="FRITZ_DECT_440">
|
||||
<supported-bridge-type-refs>
|
||||
<bridge-type-ref id="fritzbox"/>
|
||||
<bridge-type-ref id="FRITZ_Powerline_546E_Solo"/>
|
||||
</supported-bridge-type-refs>
|
||||
|
||||
<label>FRITZ!DECT 440</label>
|
||||
<description>FRITZ!DECT440 switch.</description>
|
||||
|
||||
<channel-groups>
|
||||
<channel-group id="top-left" typeId="button">
|
||||
<label>Top Left Button</label>
|
||||
</channel-group>
|
||||
<channel-group id="top-right" typeId="button">
|
||||
<label>Top Right Button</label>
|
||||
</channel-group>
|
||||
<channel-group id="bottom-left" typeId="button">
|
||||
<label>Bottom Left Button</label>
|
||||
</channel-group>
|
||||
<channel-group id="bottom-right" typeId="button">
|
||||
<label>Bottom Right Button</label>
|
||||
</channel-group>
|
||||
<channel-group id="device" typeId="device"/>
|
||||
<channel-group id="sensors" typeId="sensors"/>
|
||||
</channel-groups>
|
||||
|
||||
<representation-property>ain</representation-property>
|
||||
|
||||
<config-description-ref uri="thing-type:avmfritz:fritzdevice"/>
|
||||
</thing-type>
|
||||
|
||||
<thing-type id="Comet_DECT">
|
||||
<supported-bridge-type-refs>
|
||||
<bridge-type-ref id="fritzbox"/>
|
||||
@@ -236,7 +267,7 @@
|
||||
<channels>
|
||||
<channel id="press" typeId="system.rawbutton">
|
||||
<label>Button Press</label>
|
||||
<description>Triggered when a button was pressed.</description>
|
||||
<description>Triggeres PRESSED when a button was pressed.</description>
|
||||
</channel>
|
||||
<channel typeId="last_change" id="last_change"/>
|
||||
</channels>
|
||||
|
||||
Reference in New Issue
Block a user