]> git.basschouten.com Git - openhab-addons.git/blob
6348ea1d45141d39f46739ef83127f9b86521955
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 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 import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*;
17
18 import java.util.Set;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22 import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
23 import org.openhab.core.library.types.DateTimeType;
24 import org.openhab.core.types.State;
25
26 /**
27  * The {@link EventCameraChannelHelper} handles specific channels of sub-events (presence camera and doorbell).
28  *
29  * @author GaĆ«l L'hopital - Initial contribution
30  *
31  */
32 @NonNullByDefault
33 public class EventCameraChannelHelper extends EventChannelHelper {
34
35     public EventCameraChannelHelper(Set<String> providedGroups) {
36         super(providedGroups);
37     }
38
39     @Override
40     protected @Nullable State internalGetHomeEvent(String channelId, @Nullable String groupId, HomeEvent event) {
41         if (groupId != null && groupId.startsWith(GROUP_SUB_EVENT)) {
42             return switch (channelId) {
43                 case CHANNEL_EVENT_TYPE -> toStringType(event.getEventType());
44                 case CHANNEL_EVENT_TIME -> new DateTimeType(event.getTime());
45                 case CHANNEL_EVENT_MESSAGE -> toStringType(event.getName());
46                 case CHANNEL_EVENT_SNAPSHOT -> toRawType(event.getSnapshotUrl());
47                 case CHANNEL_EVENT_SNAPSHOT_URL -> toStringType(event.getSnapshotUrl());
48                 case CHANNEL_EVENT_VIGNETTE -> toRawType(event.getVignetteUrl());
49                 case CHANNEL_EVENT_VIGNETTE_URL -> toStringType(event.getVignetteUrl());
50                 default -> super.internalGetHomeEvent(channelId, groupId, event);
51             };
52         }
53         return super.internalGetHomeEvent(channelId, groupId, event);
54     }
55 }