forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[netatmo] Adding Webhook event support for Doorbell (openhab#12972)
* Adding Webhook event support for Doorbell * Adding doorbell rtc. * Enhancing NAPushType deserialization * Setting empty fields to NULL Signed-off-by: clinique <gael@lhopital.org>
- Loading branch information
Showing
15 changed files
with
183 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...main/java/org/openhab/binding/netatmo/internal/handler/capability/DoorbellCapability.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/** | ||
* Copyright (c) 2010-2022 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.netatmo.internal.handler.capability; | ||
|
||
import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*; | ||
import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*; | ||
|
||
import java.util.List; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.binding.netatmo.internal.api.dto.WebhookEvent; | ||
import org.openhab.binding.netatmo.internal.handler.CommonInterface; | ||
import org.openhab.binding.netatmo.internal.handler.channelhelper.ChannelHelper; | ||
import org.openhab.binding.netatmo.internal.providers.NetatmoDescriptionProvider; | ||
import org.openhab.core.thing.ChannelUID; | ||
import org.openhab.core.thing.ThingUID; | ||
import org.openhab.core.types.UnDefType; | ||
|
||
/** | ||
* {@link DoorbellCapability} give to handle Welcome Doorbell specifics | ||
* | ||
* @author Gaël L'hopital - Initial contribution | ||
* | ||
*/ | ||
@NonNullByDefault | ||
public class DoorbellCapability extends CameraCapability { | ||
private final ThingUID thingUid; | ||
|
||
public DoorbellCapability(CommonInterface handler, NetatmoDescriptionProvider descriptionProvider, | ||
List<ChannelHelper> channelHelpers) { | ||
super(handler, descriptionProvider, channelHelpers); | ||
thingUid = handler.getThing().getUID(); | ||
} | ||
|
||
@Override | ||
public void updateWebhookEvent(WebhookEvent event) { | ||
super.updateWebhookEvent(event); | ||
|
||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_TYPE), | ||
toStringType(event.getEventType())); | ||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_TIME), | ||
toDateTimeType(event.getTime())); | ||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_SNAPSHOT), | ||
toRawType(event.getSnapshotUrl())); | ||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_SNAPSHOT_URL), | ||
toStringType(event.getSnapshotUrl())); | ||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_VIGNETTE), | ||
toRawType(event.getVignetteUrl())); | ||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_VIGNETTE_URL), | ||
toStringType(event.getVignetteUrl())); | ||
|
||
String message = event.getName(); | ||
handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_MESSAGE), | ||
message == null || message.isBlank() ? UnDefType.NULL : toStringType(message)); | ||
} | ||
} |
50 changes: 0 additions & 50 deletions
50
...rc/main/java/org/openhab/binding/netatmo/internal/handler/capability/EventCapability.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.