2 * Copyright (c) 2010-2024 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.*;
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;
27 * The {@link EventCameraChannelHelper} handles specific channels of sub-events (presence camera and doorbell).
29 * @author Gaƫl L'hopital - Initial contribution
33 public class EventCameraChannelHelper extends EventChannelHelper {
35 public EventCameraChannelHelper(Set<String> providedGroups) {
36 super(providedGroups);
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);
53 return super.internalGetHomeEvent(channelId, groupId, event);