2 * Copyright (c) 2010-2022 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.netatmo.internal.handler.channelhelper;
15 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.binding.netatmo.internal.api.data.EventType;
20 import org.openhab.binding.netatmo.internal.api.data.ModuleType;
21 import org.openhab.binding.netatmo.internal.api.dto.Event;
22 import org.openhab.core.library.types.OnOffType;
23 import org.openhab.core.types.State;
26 * The {@link EventPersonChannelHelper} handles specific channels of person events
28 * @author Gaƫl L'hopital - Initial contribution
32 public class EventPersonChannelHelper extends EventChannelHelper {
33 public EventPersonChannelHelper() {
34 super(GROUP_PERSON_EVENT);
38 protected @Nullable State internalGetEvent(String channelId, Event event) {
39 EventType eventType = event.getEventType();
40 if (eventType.appliesOn(ModuleType.PERSON) && CHANNEL_PERSON_AT_HOME.equals(channelId)) {
41 return OnOffType.from(EventType.PERSON.equals(eventType) || EventType.PERSON_HOME.equals(eventType));
43 return super.internalGetEvent(channelId, event);