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.leapmotion.internal;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.library.types.OnOffType;
17 import org.openhab.core.thing.profiles.ProfileCallback;
18 import org.openhab.core.thing.profiles.ProfileTypeUID;
19 import org.openhab.core.thing.profiles.TriggerProfile;
20 import org.openhab.core.types.State;
23 * The {@link LeapMotionSwitchProfile} class implements the behavior when being linked to a Switch item.
25 * @author Kai Kreuzer - Initial contribution
28 public class LeapMotionSwitchProfile implements TriggerProfile {
30 private ProfileCallback callback;
31 private boolean lastState = false;
33 public LeapMotionSwitchProfile(ProfileCallback callback) {
34 this.callback = callback;
38 public ProfileTypeUID getProfileTypeUID() {
39 return LeapMotionProfileFactory.UID_SWITCH;
43 public void onStateUpdateFromItem(State state) {
44 lastState = OnOffType.ON.equals(state.as(OnOffType.class));
48 public void onTriggerFromHandler(String event) {
49 if (event.equals(LeapMotionBindingConstants.GESTURE_TAP)) {
50 callback.sendCommand(OnOffType.from(!lastState));