2 * Copyright (c) 2010-2023 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.capability;
15 import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
16 import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*;
18 import java.util.List;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.binding.netatmo.internal.api.dto.WebhookEvent;
22 import org.openhab.binding.netatmo.internal.handler.CommonInterface;
23 import org.openhab.binding.netatmo.internal.handler.channelhelper.ChannelHelper;
24 import org.openhab.binding.netatmo.internal.providers.NetatmoDescriptionProvider;
25 import org.openhab.core.thing.ChannelUID;
26 import org.openhab.core.thing.ThingUID;
27 import org.openhab.core.types.UnDefType;
30 * {@link DoorbellCapability} give to handle Welcome Doorbell specifics
32 * @author Gaƫl L'hopital - Initial contribution
36 public class DoorbellCapability extends CameraCapability {
37 private final ThingUID thingUid;
39 public DoorbellCapability(CommonInterface handler, NetatmoDescriptionProvider descriptionProvider,
40 List<ChannelHelper> channelHelpers) {
41 super(handler, descriptionProvider, channelHelpers);
42 thingUid = handler.getThing().getUID();
46 public void updateWebhookEvent(WebhookEvent event) {
47 super.updateWebhookEvent(event);
49 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_TYPE),
50 toStringType(event.getEventType()));
51 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_TIME),
52 toDateTimeType(event.getTime()));
53 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_SNAPSHOT),
54 toRawType(event.getSnapshotUrl()));
55 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_SNAPSHOT_URL),
56 toStringType(event.getSnapshotUrl()));
57 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_VIGNETTE),
58 toRawType(event.getVignetteUrl()));
59 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_VIGNETTE_URL),
60 toStringType(event.getVignetteUrl()));
62 String message = event.getName();
63 handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_MESSAGE),
64 message == null || message.isBlank() ? UnDefType.NULL : toStringType(message));