]> git.basschouten.com Git - openhab-addons.git/blob
ad2cf9ba197a935ed4b1d452cebf7d2f903b4c75
[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             switch (channelId) {
43                 case CHANNEL_EVENT_TYPE:
44                     return toStringType(event.getEventType());
45                 case CHANNEL_EVENT_TIME:
46                     return new DateTimeType(event.getTime());
47                 case CHANNEL_EVENT_MESSAGE:
48                     return toStringType(event.getName());
49                 case CHANNEL_EVENT_SNAPSHOT:
50                     return toRawType(event.getSnapshotUrl());
51                 case CHANNEL_EVENT_SNAPSHOT_URL:
52                     return toStringType(event.getSnapshotUrl());
53                 case CHANNEL_EVENT_VIGNETTE:
54                     return toRawType(event.getVignetteUrl());
55                 case CHANNEL_EVENT_VIGNETTE_URL:
56                     return toStringType(event.getVignetteUrl());
57             }
58         }
59         return super.internalGetHomeEvent(channelId, groupId, event);
60     }
61 }