**Supported trigger channels for the Security Home thing:**
-| Channel Type ID | Options | Description |
-| ---------------- | ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| cameraEvent | | A camera event is triggered with a short delay but without requiring a webhook. The information of the event can get retrieved from the other "welcomeEvent" home thing channels |
-| | HUMAN | Triggered when a human (or person) was detected |
-| | ANIMAL | Triggered when an animal was detected |
-| | MOVEMENT | Triggered when an unspecified movement was detected |
-| | VEHICLE | Triggered when a vehicle was detected |
-| welcomeHomeEvent | | A welcome home event is triggered directly via a configured webhook |
-| | PERSON | Triggered when a concrete person was detected |
-| | PERSON_AWAY | Triggered when a concrete person leaves |
-| | MOVEMENT | Triggered when a movement was detected |
-| | CONNECTION | Triggered when a camera connection gets created |
-| | DISCONNECTION | Triggered when a camera connection got lost |
-| | ON | Triggered when camera monitoring is switched on |
-| | OFF | Triggered when camera monitoring is switched off |
-| | BOOT | Triggered when a camera is booting |
-| | SD | Triggered when a camera SD card status was changed |
-| | ALIM | Triggered when a power supply status was changed |
-| | NEW_MODULE | Triggered when a new module was discovered |
-| | MODULE_CONNECT | Triggered when a module gets connected |
-| | MODULE_DISCONNECT | Triggered when a module gets disconnected |
-| | MODULE_LOW_BATTERY | Triggered when the battery of a module gets low |
-| | MODULE_END_UPDATE | Triggered when a firmware update of a module is done |
-| | TAG_BIG_MOVE | Triggered when a big movement of a tag was detected |
-| | TAG_SMALL_MOVE | Triggered when a small movement of a tag was detected |
-| | TAG_UNINSTALLED | Triggered when a tag gets uninstalled |
-| | TAG_OPEN | Triggered when an open event of a tag was detected |
+**Supported trigger channels for the Security Home, Presence and Doorbell thing:**
+
+| Channel Type ID | Options | Description |
+|-----------------|--------------------|---------------------------------------------------------------------|
+| home-event | | A welcome home event is triggered directly via a configured webhook |
+| | PERSON | Triggered when a concrete person was detected |
+| | PERSON_AWAY | Triggered when a concrete person leaves |
+| | PERSON_HOME | Triggered when a concrete person entered the home |
+| | OUTDOOR | Triggered when a event of an outdoor camera was triggered |
+| | MOVEMENT | Triggered when a movement was detected |
+| | HUMAN | Triggered when a human was detected |
+| | ANIMAL | Triggered when an animal was detected |
+| | VEHICLE | Triggered when a vehicle was detected |
+| | NEW_MODULE | Triggered when a new module was discovered |
+| | MODULE_CONNECT | Triggered when a module gets connected |
+| | MODULE_DISCONNECT | Triggered when a module gets disconnected |
+| | MODULE_LOW_BATTERY | Triggered when the battery of a module gets low |
+| | MODULE_END_UPDATE | Triggered when a firmware update of a module is done |
+| | CONNECTION | Triggered when a camera connection gets created |
+| | DISCONNECTION | Triggered when a camera connection got lost |
+| | ON | Triggered when camera monitoring is switched on |
+| | OFF | Triggered when camera monitoring is switched off |
+| | BOOT | Triggered when a camera is booting |
+| | SD | Triggered when a camera SD card status was changed |
+| | ALIM | Triggered when a power supply status was changed |
+| | ACCEPTED_CALL | Triggered when a doorbell call was accepted |
+| | INCOMING_CALL | Triggered when a doorbell call is incoming |
+| | RTC | Triggered when the doorbell button was pressed |
+| | MISSED_CALL | Triggered when a doorbell call was missed |
### Welcome, Presence and Doorbell Cameras
**Supported channels for the Welcome Camera thing:**
-| Channel Group | Channel ID | Item Type | Read/Write | Description |
-| ------------- | -------------------- | ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
-| status | monitoring | Switch | Read-write | State of the camera (video surveillance on/off) |
-| status | sd-card | String | Read-only | State of the SD card |
-| status | alim | String | Read-only | State of the power connector |
-| live | picture | Image | Read-only | Camera Live Snapshot |
-| live | local-picture-url | String | Read-only | Local Url of the live snapshot for this camera |
-| live | vpn-picture-url | String | Read-only | Url of the live snapshot for this camera through Netatmo VPN. |
-| live | local-stream-url (*) | String | Read-only | Local Url of the live stream for this camera (accessible if openhab server and camera are located on the same lan. |
-| live | vpn-stream-url (*) | String | Read-only | Url of the live stream for this camera through Netatmo VPN. |
-| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
-| signal | value | Number:Power | Read-only | Signal strength in dBm |
-| last-event | type | String | Read-only | Type of event |
-| last-event | subtype | String | Read-only | Sub-type of event |
-| last-event | time | DateTime | Read-only | Time of occurrence of event |
-| last-event | message | String | Read-only | Message sent by Netatmo corresponding to given event |
-| last-event | snapshot | Image | Read-only | picture of the last event, if it applies |
-| last-event | snapshot-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the picture URL will be available here |
-| last-event | local-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding local video URL will be available here |
-| last-event | vpn-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding VPN video URL will be available here |
-| last-event | video-status | String | Read-only | Status of the video (recording, deleted or available) |
-| last-event | person-id | String | Read-only | Id of the person the event is about (if any) |
+| Channel Group | Channel ID | Item Type | Read/Write | Description |
+|----------------| -------------------- | ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
+| security-event | home-event | | Read-only | Trigger channel which is triggered when the camera sent an event |
+| status | monitoring | Switch | Read-write | State of the camera (video surveillance on/off) |
+| status | sd-card | String | Read-only | State of the SD card |
+| status | alim | String | Read-only | State of the power connector |
+| live | picture | Image | Read-only | Camera Live Snapshot |
+| live | local-picture-url | String | Read-only | Local Url of the live snapshot for this camera |
+| live | vpn-picture-url | String | Read-only | Url of the live snapshot for this camera through Netatmo VPN. |
+| live | local-stream-url (*) | String | Read-only | Local Url of the live stream for this camera (accessible if openhab server and camera are located on the same lan. |
+| live | vpn-stream-url (*) | String | Read-only | Url of the live stream for this camera through Netatmo VPN. |
+| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
+| signal | value | Number:Power | Read-only | Signal strength in dBm |
+| last-event | type | String | Read-only | Type of event |
+| last-event | subtype | String | Read-only | Sub-type of event |
+| last-event | time | DateTime | Read-only | Time of occurrence of event |
+| last-event | message | String | Read-only | Message sent by Netatmo corresponding to given event |
+| last-event | snapshot | Image | Read-only | picture of the last event, if it applies |
+| last-event | snapshot-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the picture URL will be available here |
+| last-event | local-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding local video URL will be available here |
+| last-event | vpn-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding VPN video URL will be available here |
+| last-event | video-status | String | Read-only | Status of the video (recording, deleted or available) |
+| last-event | person-id | String | Read-only | Id of the person the event is about (if any) |
(*) This channel is configurable : low, poor, high.
- The floodlight auto-mode (auto-mode) isn't updated it is changed by another application. Therefore the binding handles its own state of the auto-mode. This has the advantage that the user can define its own floodlight switch off behaviour.
-| Channel Group | Channel ID | Item Type | Read/Write | Description |
-| ------------- | -------------------- | ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
-| status | monitoring | Switch | Read-write | State of the camera (video surveillance on/off) |
-| status | sd-card | String | Read-only | State of the SD card |
-| status | alim | String | Read-only | State of the power connector |
-| live | picture | Image | Read-only | Camera Live Snapshot |
-| live | picture-url | String | Read-only | Url of the live snapshot for this camera |
-| live | local-stream-url (*) | String | Read-only | Local Url of the live stream for this camera (accessible if openhab server and camera are located on the same lan. |
-| live | vpn-stream-url (*) | String | Read-only | Url of the live stream for this camera through Netatmo VPN. |
-| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
-| signal | value | Number:Power | Read-only | Signal strength in dBm |
-| presence | floodlight | String | Read-write | Sets the floodlight to ON/OFF/AUTO |
-| last-event | type | String | Read-only | Type of event |
-| last-event | subtype | String | Read-only | Sub-type of event |
-| last-event | time | DateTime | Read-only | Time of occurrence of event |
-| last-event | message | String | Read-only | Message sent by Netatmo corresponding to given event |
-| last-event | snapshot | Image | Read-only | picture of the last event, if it applies |
-| last-event | snapshot-url | String | Read-only | if the last event (depending upon event type) in the home lead a snapshot picture, the picture URL will be available here |
-| last-event | local-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding local video URL will be available here |
-| last-event | vpn-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding VPN video URL will be available here |
-| last-event | video-status | String | Read-only | Status of the video (recording, deleted or available) |
-| last-event | person-id | String | Read-only | Id of the person the event is about (if any) |
+| Channel Group | Channel ID | Item Type | Read/Write | Description |
+|----------------|----------------------| ------------ | ---------- |---------------------------------------------------------------------------------------------------------------------------------------------|
+| security-event | home-event | | Read-only | Trigger channel which is triggered when the camera sent an event |
+| status | monitoring | Switch | Read-write | State of the camera (video surveillance on/off) |
+| status | sd-card | String | Read-only | State of the SD card |
+| status | alim | String | Read-only | State of the power connector |
+| live | picture | Image | Read-only | Camera Live Snapshot |
+| live | picture-url | String | Read-only | Url of the live snapshot for this camera |
+| live | local-stream-url (*) | String | Read-only | Local Url of the live stream for this camera (accessible if openhab server and camera are located on the same lan. |
+| live | vpn-stream-url (*) | String | Read-only | Url of the live stream for this camera through Netatmo VPN. |
+| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
+| signal | value | Number:Power | Read-only | Signal strength in dBm |
+| presence | floodlight | String | Read-write | Sets the floodlight to ON/OFF/AUTO |
+| last-event | type | String | Read-only | Type of event |
+| last-event | subtype | String | Read-only | Sub-type of event |
+| last-event | time | DateTime | Read-only | Time of occurrence of event |
+| last-event | message | String | Read-only | Message sent by Netatmo corresponding to given event |
+| last-event | snapshot | Image | Read-only | picture of the last event, if it applies |
+| last-event | snapshot-url | String | Read-only | if the last event (depending upon event type) in the home lead a snapshot picture, the picture URL will be available here |
+| last-event | local-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding local video URL will be available here |
+| last-event | vpn-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding VPN video URL will be available here |
+| last-event | video-status | String | Read-only | Status of the video (recording, deleted or available) |
+| last-event | person-id | String | Read-only | Id of the person the event is about (if any) |
+| sub-event | type | String | Read-only | Type of sub-event |
+| sub-event | time | DateTime | Read-only | Time of occurrence of sub-event |
+| sub-event | message | String | Read-only | Message sent by Netatmo corresponding to given sub-event |
+| sub-event | snapshot-url | String | Read-only | Depending upon event type in the home, a snapshot picture of the corresponding local video URL will be available here |
+| sub-event | vignette-url | String | Read-only | A vignette representing the snapshot |
+| sub-event | snapshot | Image | Read-only | picture of the snapshot |
+| sub-event | vignette | Image | Read-only | picture of the vignette |
(*) This channel is configurable : low, poor, high.
**Supported channels for the Doorbell thing:**
-| Channel Group | Channel ID | Item Type | Read/Write | Description |
-| ------------- | ----------------- | ------------ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------- |
-| status | sd-card | String | Read-only | State of the SD card |
-| status | alim | String | Read-only | State of the power connector |
-| live | picture | Image | Read-only | Camera Live Snapshot |
-| live | local-picture-url | String | Read-only | Local Url of the live snapshot for this camera |
-| live | vpn-picture-url | String | Read-only | Url of the live snapshot for this camera through Netatmo VPN. |
-| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
-| signal | value | Number:Power | Read-only | Signal strength in dBm |
-| last-event | type | String | Read-only | Type of event |
-| last-event | video-status | String | Read-only | Status of the video (recording, deleted or available) |
-| last-event | time | DateTime | Read-only | Time of occurrence of event |
-| last-event | local-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding local video URL will be available here |
-| last-event | vpn-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding VPN video URL will be available here |
-| sub-event | type | String | Read-only | Type of sub-event |
-| sub-event | time | DateTime | Read-only | Time of occurrence of sub-event |
-| sub-event | message | String | Read-only | Message sent by Netatmo corresponding to given sub-event |
-| sub-event | snapshot-url | String | Read-only | Depending upon event type in the home, a snapshot picture of the corresponding local video URL will be available here |
-| sub-event | vignette-url | String | Read-only | A vignette representing the snapshot |
-| sub-event | snapshot | Image | Read-only | picture of the snapshot |
-| sub-event | vignet | Image | Read-only | picture of the vignette |
+| Channel Group | Channel ID | Item Type | Read/Write | Description |
+|---------------------| ----------------- |--------------| ---------- |---------------------------------------------------------------------------------------------------------------------------------------------|
+| security-event | home-event | | Read-only | Trigger channel which is triggered when the doorbell sent an event |
+| status | sd-card | String | Read-only | State of the SD card |
+| status | alim | String | Read-only | State of the power connector |
+| live | picture | Image | Read-only | Camera Live Snapshot |
+| live | local-picture-url | String | Read-only | Local Url of the live snapshot for this camera |
+| live | vpn-picture-url | String | Read-only | Url of the live snapshot for this camera through Netatmo VPN. |
+| signal | strength | Number | Read-only | Signal strength (0 for no signal, 1 for weak...) |
+| signal | value | Number:Power | Read-only | Signal strength in dBm |
+| last-event-doorbell | type | String | Read-only | Type of event |
+| last-event-doorbell | video-status | String | Read-only | Status of the video (recording, deleted or available) |
+| last-event-doorbell | time | DateTime | Read-only | Time of occurrence of event |
+| last-event-doorbell | local-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding local video URL will be available here |
+| last-event-doorbell | vpn-video-url | String | Read-only | If the last event (depending upon event type) in the home lead a snapshot picture, the corresponding VPN video URL will be available here |
+| sub-event-doorbell | type | String | Read-only | Type of sub-event |
+| sub-event-doorbell | time | DateTime | Read-only | Time of occurrence of sub-event |
+| sub-event-doorbell | message | String | Read-only | Message sent by Netatmo corresponding to given sub-event |
+| sub-event-doorbell | snapshot-url | String | Read-only | Depending upon event type in the home, a snapshot picture of the corresponding local video URL will be available here |
+| sub-event-doorbell | vignette-url | String | Read-only | A vignette representing the snapshot |
+| sub-event-doorbell | snapshot | Image | Read-only | picture of the snapshot |
+| sub-event-doorbell | vignette | Image | Read-only | picture of the vignette |
Note: live feeds either locally or via VPN are not available in Netatmo API.
}
```
+## Example Rules
+
+```java
+rule "Notification on home web hook event"
+when
+Channel "netatmo:home:mybridgeid:myclientid:home-event" triggered
+then
+logInfo("camera", "Received web hook on home level")
+end
+```
+
+```java
+rule "Notification on camera web hook event"
+when
+Channel "netatmo:presence:mybridgeid:myclientid:mythingid:home-event" triggered
+then
+logInfo("camera", "Received web hook on camera level")
+end
+```
+
## Rule Actions
Multiple actions are supported by this binding. In classic rules these are accessible as shown in this example (adjust getActions with your ThingId):
public static final String GROUP_SIGNAL = "signal";
public static final String GROUP_BATTERY = "battery";
public static final String GROUP_SECURITY = "security";
+ public static final String GROUP_SECURITY_EVENT = "security-event";
public static final String GROUP_CAM_STATUS = "status";
public static final String GROUP_CAM_LIVE = "live";
public static final String GROUP_PRESENCE = "presence";
import org.openhab.binding.netatmo.internal.handler.channelhelper.CameraChannelHelper;
import org.openhab.binding.netatmo.internal.handler.channelhelper.DoorTagChannelHelper;
import org.openhab.binding.netatmo.internal.handler.channelhelper.EnergyChannelHelper;
-import org.openhab.binding.netatmo.internal.handler.channelhelper.EventDoorbellChannelHelper;
+import org.openhab.binding.netatmo.internal.handler.channelhelper.EventCameraChannelHelper;
import org.openhab.binding.netatmo.internal.handler.channelhelper.EventPersonChannelHelper;
import org.openhab.binding.netatmo.internal.handler.channelhelper.PersonChannelHelper;
import org.openhab.binding.netatmo.internal.handler.channelhelper.PresenceChannelHelper;
HOME(FeatureArea.NONE, "NAHome", ACCOUNT,
Set.of(DeviceCapability.class, HomeCapability.class, ChannelHelperCapability.class),
- new ChannelGroup(SecurityChannelHelper.class, GROUP_SECURITY),
+ new ChannelGroup(SecurityChannelHelper.class, GROUP_SECURITY_EVENT, GROUP_SECURITY),
new ChannelGroup(EnergyChannelHelper.class, GROUP_ENERGY)),
PERSON(FeatureArea.SECURITY, "NAPerson", HOME, Set.of(PersonCapability.class, ChannelHelperCapability.class),
WELCOME(FeatureArea.SECURITY, "NACamera", HOME, Set.of(CameraCapability.class, ChannelHelperCapability.class),
ChannelGroup.SIGNAL, ChannelGroup.EVENT,
- new ChannelGroup(CameraChannelHelper.class, GROUP_CAM_STATUS, GROUP_CAM_LIVE)),
+ new ChannelGroup(CameraChannelHelper.class, GROUP_SECURITY_EVENT, GROUP_CAM_STATUS, GROUP_CAM_LIVE)),
TAG(FeatureArea.SECURITY, "NACamDoorTag", WELCOME, Set.of(ChannelHelperCapability.class), ChannelGroup.SIGNAL,
ChannelGroup.BATTERY, ChannelGroup.TIMESTAMP, new ChannelGroup(DoorTagChannelHelper.class, GROUP_TAG)),
PRESENCE(FeatureArea.SECURITY, "NOC", HOME, Set.of(PresenceCapability.class, ChannelHelperCapability.class),
ChannelGroup.SIGNAL, ChannelGroup.EVENT,
- new ChannelGroup(PresenceChannelHelper.class, GROUP_CAM_STATUS, GROUP_CAM_LIVE, GROUP_PRESENCE)),
+ new ChannelGroup(PresenceChannelHelper.class, GROUP_SECURITY_EVENT, GROUP_CAM_STATUS, GROUP_CAM_LIVE,
+ GROUP_PRESENCE),
+ new ChannelGroup(EventCameraChannelHelper.class, GROUP_SUB_EVENT)),
DOORBELL(FeatureArea.SECURITY, "NDB", HOME, Set.of(DoorbellCapability.class, ChannelHelperCapability.class),
ChannelGroup.SIGNAL,
- new ChannelGroup(CameraChannelHelper.class, GROUP_DOORBELL_STATUS, GROUP_DOORBELL_LIVE),
- new ChannelGroup(EventDoorbellChannelHelper.class, GROUP_DOORBELL_LAST_EVENT, GROUP_DOORBELL_SUB_EVENT)),
+ new ChannelGroup(CameraChannelHelper.class, GROUP_SECURITY_EVENT, GROUP_DOORBELL_STATUS,
+ GROUP_DOORBELL_LIVE),
+ new ChannelGroup(EventCameraChannelHelper.class, GROUP_DOORBELL_LAST_EVENT, GROUP_DOORBELL_SUB_EVENT)),
WEATHER_STATION(FeatureArea.WEATHER, "NAMain", ACCOUNT,
Set.of(DeviceCapability.class, WeatherCapability.class, MeasureCapability.class,
package org.openhab.binding.netatmo.internal.api.dto;
import java.time.ZonedDateTime;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.LinkedHashSet;
+import java.util.Set;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
return vignetteUrl;
}
- public List<String> getNAObjectList() {
- List<String> result = new ArrayList<>();
+ public Set<String> getNAObjectList() {
+ Set<String> result = new LinkedHashSet<>();
result.add(getCameraId());
addNotBlank(result, homeId);
addNotBlank(result, deviceId);
return result;
}
- private void addNotBlank(List<String> list, String value) {
+ private void addNotBlank(Set<String> collection, String value) {
if (!value.isBlank()) {
- list.add(value);
+ collection.add(value);
}
}
}
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 static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.toStringType;
import java.util.ArrayList;
import java.util.List;
import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
import org.openhab.binding.netatmo.internal.api.dto.HomeStatusModule;
import org.openhab.binding.netatmo.internal.api.dto.NAObject;
+import org.openhab.binding.netatmo.internal.api.dto.WebhookEvent;
import org.openhab.binding.netatmo.internal.deserialization.NAObjectMap;
import org.openhab.binding.netatmo.internal.handler.CommonInterface;
import org.openhab.binding.netatmo.internal.handler.channelhelper.CameraChannelHelper;
import org.openhab.binding.netatmo.internal.providers.NetatmoDescriptionProvider;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.thing.ChannelUID;
+import org.openhab.core.thing.ThingUID;
import org.openhab.core.types.Command;
import org.openhab.core.types.StateOption;
+import org.openhab.core.types.UnDefType;
/**
* {@link CameraCapability} give to handle Welcome Camera specifics
}
}
+ @Override
+ protected void updateWebhookEvent(WebhookEvent event) {
+ super.updateWebhookEvent(event);
+
+ final ThingUID thingUid = handler.getThing().getUID();
+ 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()));
+
+ final String message = event.getName();
+ handler.updateState(new ChannelUID(thingUid, GROUP_SUB_EVENT, CHANNEL_EVENT_MESSAGE),
+ message == null || message.isBlank() ? UnDefType.NULL : toStringType(message));
+
+ // The channel should get triggered at last (after super and sub methods), because this allows rules to access
+ // the new updated data from the other channels.
+ final String eventType = event.getEventType().name();
+ handler.getHomeHandler().ifPresent(homeHandler -> homeHandler.triggerChannel(CHANNEL_HOME_EVENT, eventType));
+ handler.triggerChannel(CHANNEL_HOME_EVENT, eventType);
+ }
+
@Override
public void handleCommand(String channelName, Command command) {
if (command instanceof OnOffType && CHANNEL_MONITORING.equals(channelName)) {
*/
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
*/
@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));
}
}
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 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.channelhelper;
+
+import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
+import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*;
+
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
+import org.openhab.core.library.types.DateTimeType;
+import org.openhab.core.types.State;
+
+/**
+ * The {@link EventCameraChannelHelper} handles specific channels of sub-events (presence camera and doorbell).
+ *
+ * @author Gaël L'hopital - Initial contribution
+ *
+ */
+@NonNullByDefault
+public class EventCameraChannelHelper extends EventChannelHelper {
+
+ public EventCameraChannelHelper(Set<String> providedGroups) {
+ super(providedGroups);
+ }
+
+ @Override
+ protected @Nullable State internalGetHomeEvent(String channelId, @Nullable String groupId, HomeEvent event) {
+ if (groupId != null && groupId.startsWith(GROUP_SUB_EVENT)) {
+ switch (channelId) {
+ case CHANNEL_EVENT_TYPE:
+ return toStringType(event.getEventType());
+ case CHANNEL_EVENT_TIME:
+ return new DateTimeType(event.getTime());
+ case CHANNEL_EVENT_MESSAGE:
+ return toStringType(event.getName());
+ case CHANNEL_EVENT_SNAPSHOT:
+ return toRawType(event.getSnapshotUrl());
+ case CHANNEL_EVENT_SNAPSHOT_URL:
+ return toStringType(event.getSnapshotUrl());
+ case CHANNEL_EVENT_VIGNETTE:
+ return toRawType(event.getVignetteUrl());
+ case CHANNEL_EVENT_VIGNETTE_URL:
+ return toStringType(event.getVignetteUrl());
+ }
+ }
+ return super.internalGetHomeEvent(channelId, groupId, event);
+ }
+}
+++ /dev/null
-/**
- * Copyright (c) 2010-2023 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.channelhelper;
-
-import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
-import static org.openhab.binding.netatmo.internal.utils.ChannelTypeUtils.*;
-
-import java.util.Set;
-
-import org.eclipse.jdt.annotation.NonNullByDefault;
-import org.eclipse.jdt.annotation.Nullable;
-import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
-import org.openhab.core.library.types.DateTimeType;
-import org.openhab.core.types.State;
-
-/**
- * The {@link EventDoorbellChannelHelper} handles specific channels of doorbell events
- *
- * @author Gaël L'hopital - Initial contribution
- *
- */
-@NonNullByDefault
-public class EventDoorbellChannelHelper extends EventChannelHelper {
-
- public EventDoorbellChannelHelper(Set<String> providedGroups) {
- super(providedGroups);
- }
-
- @Override
- protected @Nullable State internalGetHomeEvent(String channelId, @Nullable String groupId, HomeEvent event) {
- if (groupId != null && GROUP_DOORBELL_SUB_EVENT.startsWith(groupId)) {
- switch (channelId) {
- case CHANNEL_EVENT_TYPE:
- return toStringType(event.getEventType());
- case CHANNEL_EVENT_TIME:
- return new DateTimeType(event.getTime());
- case CHANNEL_EVENT_MESSAGE:
- return toStringType(event.getName());
- case CHANNEL_EVENT_SNAPSHOT:
- return toRawType(event.getSnapshotUrl());
- case CHANNEL_EVENT_SNAPSHOT_URL:
- return toStringType(event.getSnapshotUrl());
- case CHANNEL_EVENT_VIGNETTE:
- return toRawType(event.getVignetteUrl());
- case CHANNEL_EVENT_VIGNETTE_URL:
- return toStringType(event.getVignetteUrl());
- }
- }
- return super.internalGetHomeEvent(channelId, groupId, event);
- }
-}
channel-group-type.netatmo.rain.channel.sum-24.label = Rain 24h
channel-group-type.netatmo.rain.channel.sum-24.description = Quantity of water during the current day.
channel-group-type.netatmo.security.label = Home Security
+channel-group-type.netatmo.security-event.label = Home Security Event
channel-group-type.netatmo.setpoint.label = Setpoint
channel-group-type.netatmo.setpoint.channel.end.label = Setpoint End
channel-group-type.netatmo.setpoint.channel.end.description = End time of the currently applied setpoint.
channel-group-type.netatmo.siren.label = Siren Status
channel-group-type.netatmo.status-doorbell.label = Camera Status
channel-group-type.netatmo.status.label = Camera Status
+channel-group-type.netatmo.sub-event.label = Sub Event
+channel-group-type.netatmo.sub-event.channel.time.label = Sub-Event Timestamp
+channel-group-type.netatmo.sub-event.channel.time.description = Moment when the sub-event occurred.
+channel-group-type.netatmo.sub-event.channel.vignette.label = Vignette
+channel-group-type.netatmo.sub-event.channel.vignette.description = Vignette of the Snapshot.
+channel-group-type.netatmo.sub-event.channel.vignette-url.label = Vignette URL
+channel-group-type.netatmo.sub-event.channel.vignette-url.description = URL of the vignette.
channel-group-type.netatmo.sub-event-doorbell.label = Sub Event
channel-group-type.netatmo.sub-event-doorbell.channel.time.label = Sub-Event Timestamp
-channel-group-type.netatmo.sub-event-doorbell.channel.time.description = Moment when then sub-event occurred.
+channel-group-type.netatmo.sub-event-doorbell.channel.time.description = Moment when the sub-event occurred.
channel-group-type.netatmo.sub-event-doorbell.channel.vignette.label = Vignette
channel-group-type.netatmo.sub-event-doorbell.channel.vignette.description = Vignette of the Snapshot.
channel-group-type.netatmo.sub-event-doorbell.channel.vignette-url.label = Vignette URL
channel-type.netatmo.avatar-picture.description = Avatar of this person.
channel-type.netatmo.battery-status.label = Battery Status
channel-type.netatmo.battery-status.description = Description of the battery status.
-channel-type.netatmo.camera-event.label = Camera Event
channel-type.netatmo.camera-id.label = Camera ID
channel-type.netatmo.camera-id.description = ID of the camera that triggered the event.
channel-type.netatmo.co2.label = CO2
<state readOnly="true"/>
</channel-type>
- <channel-type id="camera-event">
- <kind>trigger</kind>
- <label>Camera Event</label>
- <event>
- <options>
- <option value="ANIMAL"/>
- <option value="HUMAN"/>
- <option value="MOVEMENT"/>
- <option value="VEHICLE"/>
- </options>
- </event>
- </channel-type>
-
<channel-type id="battery-status">
<item-type>String</item-type>
<label>Battery Status</label>
<channel id="person-count" typeId="person-count"/>
<channel id="unknown-person-count" typeId="unknown-person-count"/>
<channel id="unknown-person-picture" typeId="unknown-person-picture"/>
+ </channels>
+ </channel-group-type>
+
+ <channel-group-type id="security-event">
+ <label>Home Security Event</label>
+ <channels>
<channel id="home-event" typeId="home-event"/>
</channels>
</channel-group-type>
</channels>
</channel-group-type>
+ <channel-group-type id="sub-event">
+ <label>Sub Event</label>
+ <channels>
+ <channel id="type" typeId="event-type"/>
+ <channel id="time" typeId="timestamp">
+ <label>Sub-Event Timestamp</label>
+ <description>Moment when the sub-event occurred.</description>
+ </channel>
+ <channel id="message" typeId="message"/>
+ <channel id="snapshot" typeId="event-picture"/>
+ <channel id="snapshot-url" typeId="event-picture-url"/>
+ <channel id="vignette" typeId="event-picture">
+ <label>Vignette</label>
+ <description>Vignette of the Snapshot.</description>
+ </channel>
+ <channel id="vignette-url" typeId="event-picture-url">
+ <label>Vignette URL</label>
+ <description>URL of the vignette.</description>
+ </channel>
+ </channels>
+ </channel-group-type>
+
<channel-group-type id="sub-event-doorbell">
<label>Sub Event</label>
<channels>
<channel id="type" typeId="event-type"/>
<channel id="time" typeId="timestamp">
<label>Sub-Event Timestamp</label>
- <description>Moment when then sub-event occurred.</description>
+ <description>Moment when the sub-event occurred.</description>
</channel>
<channel id="message" typeId="message"/>
<channel id="snapshot" typeId="event-picture"/>
--- /dev/null
+/**
+ * Copyright (c) 2010-2023 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.channelhelper;
+
+import static org.junit.jupiter.api.Assertions.*;
+import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*;
+
+import java.util.Collections;
+
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.openhab.binding.netatmo.internal.api.data.EventType;
+import org.openhab.binding.netatmo.internal.api.dto.HomeEvent;
+import org.openhab.core.library.types.StringType;
+import org.openhab.core.types.State;
+
+/**
+ * @author Sven Strohschein - Initial contribution
+ */
+public class EventCameraChannelHelperTest {
+
+ private EventCameraChannelHelper helper;
+
+ @BeforeEach
+ public void before() {
+ helper = new EventCameraChannelHelper(Collections.emptySet());
+ }
+
+ @Test
+ public void testInternalGetHomeEventGroupSubEvent() {
+ State state = helper.internalGetHomeEvent(CHANNEL_EVENT_TYPE, GROUP_SUB_EVENT, new HomeEvent());
+ assertTrue(state instanceof StringType);
+ assertEquals(EventType.UNKNOWN.name(), state.toString());
+ }
+
+ @Test
+ public void testInternalGetHomeEventGroupDoorbellSubEvent() {
+ State state = helper.internalGetHomeEvent(CHANNEL_EVENT_TYPE, GROUP_DOORBELL_SUB_EVENT, new HomeEvent());
+ assertTrue(state instanceof StringType);
+ assertEquals(EventType.UNKNOWN.name(), state.toString());
+ }
+
+ @Test
+ public void testInternalGetHomeEventGroupDoorbellStatus() {
+ State state = helper.internalGetHomeEvent(CHANNEL_EVENT_TYPE, GROUP_DOORBELL_STATUS, new HomeEvent());
+ // Only sub-event groups are handled by EventCameraChannelHelper. GROUP_DOORBELL_STATUS isn't a sub-event group.
+ assertNull(state);
+ }
+}