diff --git a/bundles/org.openhab.binding.netatmo/README.md b/bundles/org.openhab.binding.netatmo/README.md index 34ade1f1946..88c5ce6ba9c 100644 --- a/bundles/org.openhab.binding.netatmo/README.md +++ b/bundles/org.openhab.binding.netatmo/README.md @@ -649,18 +649,19 @@ Person things are automatically created in discovery process for all known perso **Supported channels for the Person thing:** -| Channel Group | Channel ID | Item Type | Description | -| ------------- | ------------ | --------- | ------------------------------------------------------ | -| person | avatar-url | String | URL for the avatar of this person | -| person | avatar | Image | Avatar of this person | -| person | at-home | Switch | Indicates if this person is known to be at home or not | -| person | last-seen | DateTime | Moment when this person was last seen | -| last-event | subtype | String | Sub-type of event | -| last-event | message | String | Last event message from this person | -| last-event | time | DateTime | Moment of the last event for this person | -| last-event | snapshot | Image | Picture of the last event for this person | -| last-event | snapshot-url | String | URL for the picture of the last event for this person | -| last-event | camera-id | String | ID of the camera that triggered the event | +| Channel Group | Channel ID | Item Type | Description | +| -------------- | ------------ | --------- | ------------------------------------------------------------------------------------------------- | +| security-event | home-event | | Trigger channel which is triggered by an event for this person (PERSON, PERSON_AWAY, PERSON_HOME) | +| person | avatar-url | String | URL for the avatar of this person | +| person | avatar | Image | Avatar of this person | +| person | at-home | Switch | Indicates if this person is known to be at home or not | +| person | last-seen | DateTime | Moment when this person was last seen | +| last-event | subtype | String | Sub-type of event | +| last-event | message | String | Last event message from this person | +| last-event | time | DateTime | Moment of the last event for this person | +| last-event | snapshot | Image | Picture of the last event for this person | +| last-event | snapshot-url | String | URL for the picture of the last event for this person | +| last-event | camera-id | String | ID of the camera that triggered the event | All these channels except at-home are read only. diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java index 74c5e278828..e256b287959 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java @@ -81,7 +81,7 @@ public enum ModuleType { PERSON(FeatureArea.SECURITY, "NAPerson", 1, "virtual", HOME, Set.of(PersonCapability.class, ChannelHelperCapability.class, ParentUpdateCapability.class), new ChannelGroup(PersonChannelHelper.class, GROUP_PERSON), - new ChannelGroup(EventPersonChannelHelper.class, GROUP_PERSON_LAST_EVENT)), + new ChannelGroup(EventPersonChannelHelper.class, GROUP_SECURITY_EVENT, GROUP_PERSON_LAST_EVENT)), WELCOME(FeatureArea.SECURITY, "NACamera", 1, "camera", HOME, Set.of(CameraCapability.class, ChannelHelperCapability.class, ParentUpdateCapability.class), diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/CommonInterface.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/CommonInterface.java index 68ff8086ef9..4a2e7267d03 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/CommonInterface.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/CommonInterface.java @@ -77,7 +77,7 @@ public interface CommonInterface { void setThingStatus(ThingStatus thingStatus, ThingStatusDetail thingStatusDetail, @Nullable String thingStatusReason); - void triggerChannel(String channelID, String event); + void triggerChannel(String groupID, String channelID, String event); void updateThing(Thing thing); diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/DeviceHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/DeviceHandler.java index 5db67fba77a..d5c44d054a3 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/DeviceHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/DeviceHandler.java @@ -109,8 +109,8 @@ public class DeviceHandler extends BaseBridgeHandler implements CommonInterface } @Override - public void triggerChannel(String channelID, String event) { - super.triggerChannel(channelID, event); + public void triggerChannel(String groupID, String channelID, String event) { + super.triggerChannel(new ChannelUID(this.getThing().getUID(), groupID, channelID), event); } @Override diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ModuleHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ModuleHandler.java index 9c9a99cbc95..4f5fda9a659 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ModuleHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/ModuleHandler.java @@ -113,8 +113,8 @@ public class ModuleHandler extends BaseThingHandler implements CommonInterface { } @Override - public void triggerChannel(String channelID, String event) { - super.triggerChannel(channelID, event); + public void triggerChannel(String groupID, String channelID, String event) { + super.triggerChannel(new ChannelUID(this.getThing().getUID(), groupID, channelID), event); } @Override diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/CameraCapability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/CameraCapability.java index b1d06389619..8095dad4b74 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/CameraCapability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/CameraCapability.java @@ -120,9 +120,9 @@ public class CameraCapability extends HomeSecurityThingCapability { // 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.recurseUpToHomeHandler(handler) - .ifPresent(homeHandler -> homeHandler.triggerChannel(CHANNEL_HOME_EVENT, eventType)); - handler.triggerChannel(CHANNEL_HOME_EVENT, eventType); + handler.recurseUpToHomeHandler(handler).ifPresent( + homeHandler -> homeHandler.triggerChannel(GROUP_SECURITY_EVENT, CHANNEL_HOME_EVENT, eventType)); + handler.triggerChannel(GROUP_SECURITY_EVENT, CHANNEL_HOME_EVENT, eventType); } private void updateSubGroup(WebhookEvent event, String group) { diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java index a108dec3244..3438927f2f9 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/Capability.java @@ -76,9 +76,12 @@ public class Capability { if (newData instanceof HomeEvent homeEvent) { updateHomeEvent(homeEvent); - } else if (newData instanceof WebhookEvent webhookEvent - && webhookEvent.getEventType().validFor(moduleType)) { - updateWebhookEvent(webhookEvent); + } else if (newData instanceof WebhookEvent webhookEvent) { + if (webhookEvent.getEventType().validFor(moduleType)) { + updateWebhookEvent(webhookEvent); + } else { + // dropped + } } else if (newData instanceof Event event) { updateEvent(event); } diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PersonCapability.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PersonCapability.java index da41d6444b2..f2fe9644031 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PersonCapability.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/capability/PersonCapability.java @@ -102,7 +102,7 @@ public class PersonCapability extends HomeSecurityThingCapability { return; // ignore incoming events if they are deprecated } lastEventTime = eventTime; - handler.triggerChannel(CHANNEL_HOME_EVENT, Objects.requireNonNull( + handler.triggerChannel(GROUP_SECURITY_EVENT, CHANNEL_HOME_EVENT, Objects.requireNonNull( event.getSubTypeDescription().map(EventSubType::name).orElse(event.getEventType().name()))); } diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java index b3f10bac5b1..1a7d02b927d 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/servlet/WebhookServlet.java @@ -123,6 +123,7 @@ public class WebhookServlet extends NetatmoServlet { event.getNAObjectList().forEach(id -> { Capability module = dataListeners.get(id); if (module != null) { + logger.trace("Dispatching webhook event to {}", id); module.setNewData(event); } });