[netatmo] Adding Door/Window sensor (#13503)

* Initial PR to add NADoorTag to netatmo binding

Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
Gaël L'hopital 2022-10-08 18:49:44 +02:00 committed by GitHub
parent 61187f89a0
commit a4781b4770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 88 additions and 0 deletions

View 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:

View 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";

View 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)),

View File

@ -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;
}
}

View 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

View File

@ -37,6 +37,13 @@
<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>

View File

@ -187,6 +187,13 @@
</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>