2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.enocean.internal.profiles;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.enocean.internal.config.EnOceanProfileRockerSwitchActionConfig;
18 import org.openhab.core.thing.profiles.ProfileCallback;
19 import org.openhab.core.thing.profiles.ProfileContext;
20 import org.openhab.core.thing.profiles.TriggerProfile;
21 import org.openhab.core.types.State;
24 * @author Daniel Weber - Initial contribution
27 public abstract class RockerSwitchActionBaseProfile implements TriggerProfile {
29 protected final ProfileCallback callback;
30 protected ProfileContext context;
32 protected @Nullable State previousState;
34 protected static final String ANY_DIR = "*";
36 public RockerSwitchActionBaseProfile(ProfileCallback callback, ProfileContext context) {
37 this.callback = callback;
38 this.context = context;
41 protected boolean isEventValid(String event) {
42 String[] directions = event.split("\\|");
43 if (directions.length != 2) {
47 EnOceanProfileRockerSwitchActionConfig config = context.getConfiguration()
48 .as(EnOceanProfileRockerSwitchActionConfig.class);
49 if (!(config.channelAFilter.equals(ANY_DIR) || config.channelAFilter.equals(directions[0]))) {
51 } else if (!(config.channelBFilter.equals(ANY_DIR) || config.channelBFilter.equals(directions[1]))) {