]> git.basschouten.com Git - openhab-addons.git/commitdiff
[netatmo] Adding Door/Window sensor (#13503)
authorGaël L'hopital <gael@lhopital.org>
Sat, 8 Oct 2022 16:49:44 +0000 (18:49 +0200)
committerGitHub <noreply@github.com>
Sat, 8 Oct 2022 16:49:44 +0000 (18:49 +0200)
* Initial PR to add NADoorTag to netatmo binding

Signed-off-by: clinique <gael@lhopital.org>
bundles/org.openhab.binding.netatmo/README.md
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoBindingConstants.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/api/data/ModuleType.java
bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/channelhelper/DoorTagChannelHelper.java [new file with mode: 0644]
bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/i18n/netatmo.properties
bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/thing/channels.xml
bundles/org.openhab.binding.netatmo/src/main/resources/OH-INF/thing/security.xml

index 1282464776b496db78e466a97f2d259111598174..cf9214f33edb1493fb81a555ac4c0cb86e49e2f2 100644 (file)
@@ -9,6 +9,7 @@ The Netatmo binding integrates the following Netatmo products:
 - *Outdoor Camera / Presence*. Reports last event, consult picture and video from event/camera.
 - *Doorbell* 
 - *Smoke Detector*
+- *Smart Door Sensor*
 
 See https://www.netatmo.com/ for details on their product.
 
@@ -94,6 +95,7 @@ Now that you have got your bridge _ONLINE_ you can now start a scan with the bin
 | thermostat      | Thing  | NATherm1       | The Thermostat device placed in a given room.                                                        | id                                                                        |
 | room            | Thing  | NARoom         | A room in your house.                                                                                | id                                                                        |
 | valve           | Thing  | NRV            | A valve controlling a radiator.                                                                      | id                                                                        |
+| tag             | Thing  | NACamDoorTag   | A door / window sensor                                                                               | id                                                                        |
 
 
 
@@ -610,6 +612,17 @@ Note: live feeds either locally or via VPN are not available in Netatmo API.
 | battery       | low-battery       | Switch       | Read-only  | Low battery                                          |
 
 
+**Supported channels for the Door Tag thing:**
+
+| Channel Group | Channel ID        | Item Type    | Read/Write | Description                                          |
+|---------------|-------------------|--------------|------------|------------------------------------------------------|
+| tag           | status            | Contact      | Read-only  | Status of tag (OPEN,CLOSED)                          |
+| signal        | strength          | Number       | Read-only  | Signal strength (0 for no signal, 1 for weak...)     |
+| signal        | value             | Number:Power | Read-only  | Signal strength in dBm                               |
+| timestamp     | last-seen         | DateTime     | Read-only  | Last time the module reported its presence           |
+| battery       | value             | Number       | Read-only  | Battery level                                        |
+| battery       | low-battery       | Switch       | Read-only  | Low battery                                          |
+
 ### Welcome Person
 
 Netatmo API distinguishes two kinds of persons:
index 4165bb6bae235c1eb11b80e90e4d42c8898b9839..d23fcb5688ef10b9d7e4b4dbc9bca941923acc42 100644 (file)
@@ -55,6 +55,7 @@ public class NetatmoBindingConstants {
     public static final String GROUP_PRESENCE = "presence";
     public static final String GROUP_SIREN = "siren";
     public static final String GROUP_PERSON = "person";
+    public static final String GROUP_TAG = "tag";
     public static final String GROUP_PROPERTIES = "properties";
     public static final String GROUP_SETPOINT = "setpoint";
     public static final String GROUP_LOCATION = "location";
index fc313af17f5198d7518f8b285b0220a0003b90fc..58e9855104afeba00638b300e929400493f75a54 100644 (file)
@@ -41,6 +41,7 @@ import org.openhab.binding.netatmo.internal.handler.capability.WeatherCapability
 import org.openhab.binding.netatmo.internal.handler.channelhelper.AirQualityChannelHelper;
 import org.openhab.binding.netatmo.internal.handler.channelhelper.ApiBridgeChannelHelper;
 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.EventChannelHelper;
 import org.openhab.binding.netatmo.internal.handler.channelhelper.EventDoorbellChannelHelper;
@@ -80,6 +81,9 @@ public enum ModuleType {
             ChannelGroup.SIGNAL, ChannelGroup.EVENT,
             new ChannelGroup(CameraChannelHelper.class, 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)),
+
     SIREN(FeatureArea.SECURITY, "NIS", WELCOME, Set.of(ChannelHelperCapability.class), ChannelGroup.SIGNAL,
             ChannelGroup.BATTERY, ChannelGroup.TIMESTAMP, new ChannelGroup(SirenChannelHelper.class, GROUP_SIREN)),
 
diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/channelhelper/DoorTagChannelHelper.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/channelhelper/DoorTagChannelHelper.java
new file mode 100644 (file)
index 0000000..e7f9808
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * 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.channelhelper;
+
+import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.CHANNEL_STATUS;
+
+import java.util.Set;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.netatmo.internal.api.dto.HomeStatusModule;
+import org.openhab.binding.netatmo.internal.api.dto.NAThing;
+import org.openhab.core.config.core.Configuration;
+import org.openhab.core.library.types.OpenClosedType;
+import org.openhab.core.types.State;
+import org.openhab.core.types.UnDefType;
+
+/**
+ * The {@link DoorTagChannelHelper} handles channels of door sensor things.
+ *
+ * @author Gaël L'hopital - Initial contribution
+ *
+ */
+@NonNullByDefault
+public class DoorTagChannelHelper extends ChannelHelper {
+
+    public DoorTagChannelHelper(Set<String> providedGroups) {
+        super(providedGroups);
+    }
+
+    @Override
+    protected @Nullable State internalGetProperty(String channelId, NAThing naThing, Configuration config) {
+        if (naThing instanceof HomeStatusModule) {
+            HomeStatusModule doorTag = (HomeStatusModule) naThing;
+            if (CHANNEL_STATUS.equalsIgnoreCase(channelId)) {
+                return doorTag.getStatus().map(status -> (State) OpenClosedType.valueOf(status.toUpperCase()))
+                        .orElse(UnDefType.UNDEF);
+            }
+        }
+        return null;
+    }
+}
index 82cd51dc66cbc91455112f84c988c4a25b2aee53..2d075ccc0a84aa5764a8336d62247f3750d5ec29 100644 (file)
@@ -87,6 +87,7 @@ 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-group-type.netatmo.sub-event-doorbell.channel.vignette-url.description = URL of the vignette.
+channel-group-type.netatmo.tag.label = Door Tag
 channel-group-type.netatmo.temperature-extended.label = Temperature
 channel-group-type.netatmo.temperature-extended.channel.max-time.label = Today Max Timestamp
 channel-group-type.netatmo.temperature-extended.channel.max-time.description = Moment when temperature was measured at its maximum today.
@@ -301,6 +302,7 @@ channel-type.netatmo.siren-status.label = Status
 channel-type.netatmo.siren-status.description = Status of the siren
 channel-type.netatmo.siren-status.state.option.no_sound = Silent
 channel-type.netatmo.siren-status.state.option.sound = Alarm
+channel-type.netatmo.tag-status.label = Door Status
 channel-type.netatmo.th-mode.label = Thermostat Mode
 channel-type.netatmo.th-mode.description = Chosen thermostat mode (home, frost guard, manual, max).
 channel-type.netatmo.th-mode.state.option.HOME = Home
@@ -378,6 +380,8 @@ thing-type.netatmo.account.label = Netatmo Account
 thing-type.netatmo.account.description = This bridge represents an account, gateway to Netatmo API.
 thing-type.netatmo.doorbell.label = Smart Video Doorbell
 thing-type.netatmo.doorbell.description = The Netatmo Smart Video Doorbell device.
+thing-type.netatmo.tag.label = Smart Door Sensor
+thing-type.netatmo.tag.description = The Netatmo Smart Door or Window sensor.
 thing-type.netatmo.home-coach.label = Healthy Home Coach
 thing-type.netatmo.home-coach.description = Healthy home coach reporting health-index, temperature, humidity, pressure, air quality and sound level.
 thing-type.netatmo.home.label = Home
index 71c77eda4c4df6b1cc967dade13c3e08fc49b5bb..7599a195835e2386cb3a08a38367f098f8224bd6 100644 (file)
                <state readOnly="true"/>
        </channel-type>
 
+       <channel-type id="tag-status">
+               <item-type>Contact</item-type>
+               <label>Door Status</label>
+               <category>Door</category>
+               <state readOnly="true"/>
+       </channel-type>
+
        <channel-type id="anticipating-heating">
                <item-type>Switch</item-type>
                <label>Anticipated Heating</label>
index e9f9507c87a8b65253fa5729f0f96ac420494b7d..cf410d75a8a89882263f60f1d9f6661d8c8e578a 100644 (file)
                </channels>
        </channel-group-type>
 
+       <channel-group-type id="tag">
+               <label>Door Tag</label>
+               <channels>
+                       <channel id="status" typeId="tag-status"/>
+               </channels>
+       </channel-group-type>
+
        <channel-group-type id="presence">
                <label>Presence Camera</label>
                <channels>