]> git.basschouten.com Git - openhab-addons.git/blob
2e93b17e959e5cec48b6cd51a2644d46b7c699e9
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.netatmo.internal.handler.channelhelper;
14
15 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.CHANNEL_PERSON_AT_HOME;
16
17 import java.util.Set;
18
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.netatmo.internal.api.data.EventType;
22 import org.openhab.binding.netatmo.internal.api.dto.Event;
23 import org.openhab.core.library.types.OnOffType;
24 import org.openhab.core.types.State;
25
26 /**
27  * The {@link EventPersonChannelHelper} handles specific channels of person events
28  *
29  * @author GaĆ«l L'hopital - Initial contribution
30  *
31  */
32 @NonNullByDefault
33 public class EventPersonChannelHelper extends EventChannelHelper {
34
35     public EventPersonChannelHelper(Set<String> providedGroups) {
36         super(providedGroups);
37     }
38
39     @Override
40     protected @Nullable State internalGetEvent(String channelId, Event event) {
41         EventType eventType = event.getEventType();
42         return eventType.validFor(moduleType) && CHANNEL_PERSON_AT_HOME.equals(channelId)
43                 ? OnOffType.from(Set.of(EventType.PERSON, EventType.PERSON_HOME).contains(eventType))
44                 : super.internalGetEvent(channelId, event);
45     }
46 }