-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[netatmo] Adding Webhook event support for Doorbell #12972
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e09f9bc
Adding Webhook event support for Doorbell
clinique 782911c
Forgot this for debug purpose
clinique 4faf648
Adding doorbell rtc.
clinique 7908d6b
Small code enhancements while working on webhooks
clinique a58363d
Setting empty fields to NULL
clinique File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it expected to add camera ID twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is. Some values may be empty. In some cases (e.g. smoke detector), the cameraId will be blank but the deviceId will be filled. Redundant entries will be ignored.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not fully convinced, there is certainly something I do not understand...
As you are apparently convinced you have to call this twice, let's go, we have no more time to debate.