]> git.basschouten.com Git - openhab-addons.git/blob
ff4054be66724659cb6c2d1954ce95a67b0362b5
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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.*;
16
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;
24
25 /**
26  * The {@link EventPersonChannelHelper} handles specific channels of person events
27  *
28  * @author GaĆ«l L'hopital - Initial contribution
29  *
30  */
31 @NonNullByDefault
32 public class EventPersonChannelHelper extends EventChannelHelper {
33     public EventPersonChannelHelper() {
34         super(GROUP_PERSON_EVENT);
35     }
36
37     @Override
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));
42         }
43         return super.internalGetEvent(channelId, event);
44     }
45 }