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.*;
16 import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*;
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
21 import org.openhab.core.library.types.DateTimeType;
22 import org.openhab.core.types.State;
25 * The {@link EventDoorbellChannelHelper} handles specific channels of doorbell events
27 * @author Gaƫl L'hopital - Initial contribution
31 public class EventDoorbellChannelHelper extends EventChannelHelper {
33 public EventDoorbellChannelHelper() {
34 super(GROUP_DOORBELL_LAST_EVENT, GROUP_DOORBELL_SUB_EVENT);
38 protected @Nullable State internalGetHomeEvent(String channelId, @Nullable String groupId, HomeEvent event) {
39 if (groupId != null && GROUP_DOORBELL_SUB_EVENT.startsWith(groupId)) {
41 case CHANNEL_EVENT_TYPE:
42 return toStringType(event.getEventType());
43 case CHANNEL_EVENT_TIME:
44 return new DateTimeType(event.getTime());
45 case CHANNEL_EVENT_MESSAGE:
46 return toStringType(event.getName());
47 case CHANNEL_EVENT_SNAPSHOT:
48 return toRawType(event.getSnapshotUrl());
49 case CHANNEL_EVENT_SNAPSHOT_URL:
50 return toStringType(event.getSnapshotUrl());
51 case CHANNEL_EVENT_VIGNETTE:
52 return toRawType(event.getVignetteUrl());
53 case CHANNEL_EVENT_VIGNETTE_URL:
54 return toStringType(event.getVignetteUrl());
57 return super.internalGetHomeEvent(channelId, groupId, event);