From e6e25e46dc1a0f2d96e805431d92632b9dbd3064 Mon Sep 17 00:00:00 2001 From: Sven Strohschein Date: Fri, 22 May 2020 05:41:48 +0200 Subject: [PATCH] [netatmo] Add support for the Presence camera (#3059) (#7660) * Support for the Presence camera added * Files and thing types renamed because it handles now various camera types (not only the Welcome camera) * README updated to clarify the Welcome and Presence product names * Permission configurations renamed because it handles now various camera types (not only the Welcome camera) ; Reverted. Now it is separated, so the user has explicitly to decide if he wants to grant the access to outdoor cameras. * Camera channels separated to remove "welcome" from the (Presence) channel names. The channels of the Welcome camera were not renamed to be downward compatible. * welcomeHomeEvent channel removed for the Presence camera, event handling for the Presence will get realized later Signed-off-by: Sven Strohschein --- bundles/org.openhab.binding.netatmo/README.md | 27 ++- .../netatmo/internal/ChannelTypeUtils.java | 6 +- .../internal/NetatmoBindingConstants.java | 14 +- .../internal/NetatmoHandlerFactory.java | 3 +- .../internal/camera/CameraHandler.java | 159 ++++++++++++++++++ .../config/NetatmoBridgeConfiguration.java | 1 + .../NetatmoModuleDiscoveryService.java | 3 +- .../handler/NetatmoBridgeHandler.java | 9 +- .../welcome/NAWelcomeCameraHandler.java | 86 ++-------- .../main/resources/ESH-INF/config/config.xml | 8 +- .../ESH-INF/i18n/netatmo_de.properties | 11 +- .../ESH-INF/i18n/netatmo_fr.properties | 11 +- .../thing/{welcomecamera.xml => camera.xml} | 24 ++- .../resources/ESH-INF/thing/welcomehome.xml | 2 +- 14 files changed, 267 insertions(+), 97 deletions(-) create mode 100644 bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/camera/CameraHandler.java rename bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/{welcomecamera.xml => camera.xml} (75%) diff --git a/bundles/org.openhab.binding.netatmo/README.md b/bundles/org.openhab.binding.netatmo/README.md index 9c85d3c664680..f4e26dc70f019 100644 --- a/bundles/org.openhab.binding.netatmo/README.md +++ b/bundles/org.openhab.binding.netatmo/README.md @@ -4,7 +4,8 @@ The Netatmo binding integrates the following Netatmo products: - *Personal Weather Station*. Reports temperature, humidity, air pressure, carbon dioxide concentration in the air, as well as the ambient noise level. - *Thermostat*. Reports ambient temperature, allow to check target temperature, consult and change furnace heating status. -- *Welcome Camera*. Reports last event and persons at home, consult picture and video from event/camera. +- *Indoor Camera / Welcome*. Reports last event and persons at home, consult picture and video from event/camera. +- *Outdoor Camera / Presence*. Consult picture and video from camera. The last event is also available, but without content yet, this will get enhanced later. See http://www.netatmo.com/ for details on their product. @@ -33,7 +34,7 @@ Once you will get needed informations from the Netatmo API, you will be able to E.g. ``` -Bridge netatmo:netatmoapi:home [ clientId="", clientSecret="", username = "", password = "", readStation=true|false, readHealthyHomeCoach=true|false, readThermostat=true|false, readWelcome=true|false] { +Bridge netatmo:netatmoapi:home [ clientId="", clientSecret="", username = "", password = "", readStation=true|false, readHealthyHomeCoach=true|false, readThermostat=true|false, readWelcome=true|false, readPresence=true|false] { Thing NAMain inside [ id="aa:aa:aa:aa:aa:aa" ] Thing NAModule1 outside [ id="yy:yy:yy:yy:yy:yy", parentId="aa:aa:aa:aa:aa:aa" ] Thing NHC homecoach [ id="cc:cc:cc:cc:cc:cc", [refreshInterval=60000] ] @@ -469,9 +470,14 @@ All these channels except Sp_Temperature, SetpointMode and Planning are read onl All these channels are read only. -### Welcome Camera +### Welcome and Presence Camera -**Supported channels for the Camera thing:** +All these channels are read only. + +Warning : the URL of the live snapshot is a fixed URL so the value of the channel cameraLivePictureUrl / welcomeCameraLivePictureUrl will never be updated once first set by the binding. +So to get a refreshed picture, you need to use the refresh parameter in your sitemap image element. + +**Supported channels for the Welcome Camera thing:** | Channel ID | Item Type | Description | |-----------------------------|-----------|----------------------------------------------------------| @@ -483,10 +489,17 @@ All these channels are read only. | welcomeCameraLivePictureUrl | String | Url of the live snapshot for this camera | | welcomeCameraLiveStreamUrl | String | Url of the live stream for this camera | -All these channels are read only. +**Supported channels for the Presence Camera thing:** -Warning : the URL of the live snapshot is a fixed URL so the value of the channel welcomeCameraLivePictureUrl will never be updated once first set by the binding. -So to get a refreshed picture, you need to use the refresh parameter in your sitemap image element. +| Channel ID | Item Type | Description | +|-----------------------------|-----------|----------------------------------------------------------| +| cameraStatus | Switch | State of the camera | +| cameraSdStatus | Switch | State of the SD card | +| cameraAlimStatus | Switch | State of the power connector | +| cameraIsLocal | Switch | indicates whether the camera is on the same network than the openHAB Netatmo Binding | +| cameraLivePicture | Image | Camera Live Snapshot | +| cameraLivePictureUrl | String | Url of the live snapshot for this camera | +| cameraLiveStreamUrl | String | Url of the live stream for this camera | ### Welcome Person diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java index b27d6e3554365..3217ce919279a 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/ChannelTypeUtils.java @@ -93,7 +93,11 @@ public static State toOnOffType(@Nullable String yesno) { } public static State toOnOffType(@Nullable Integer value) { - return value != null ? (value == 1 ? OnOffType.ON : OnOffType.OFF) : UnDefType.NULL; + return value != null ? (value == 1 ? OnOffType.ON : OnOffType.OFF) : UnDefType.UNDEF; + } + + public static State toOnOffType(@Nullable Boolean value) { + return value != null ? (value ? OnOffType.ON : OnOffType.OFF) : UnDefType.UNDEF; } public static State toQuantityType(@Nullable Float value, Unit unit) { diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoBindingConstants.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoBindingConstants.java index 01a71843f4239..aed882e4388af 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoBindingConstants.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoBindingConstants.java @@ -95,6 +95,8 @@ public class NetatmoBindingConstants { public static final ThingTypeUID WELCOME_HOME_THING_TYPE = new ThingTypeUID(BINDING_ID, "NAWelcomeHome"); public static final ThingTypeUID WELCOME_CAMERA_THING_TYPE = new ThingTypeUID(BINDING_ID, "NACamera"); public static final ThingTypeUID WELCOME_PERSON_THING_TYPE = new ThingTypeUID(BINDING_ID, "NAWelcomePerson"); + // Presence camera + public static final ThingTypeUID PRESENCE_CAMERA_THING_TYPE = new ThingTypeUID(BINDING_ID, "NOC"); // Weather Station Channel ids public static final String CHANNEL_TEMPERATURE = "Temperature"; @@ -254,6 +256,15 @@ public class NetatmoBindingConstants { public static final String CHANNEL_WELCOME_EVENT_MESSAGE = "welcomeEventMessage"; public static final String CHANNEL_WELCOME_EVENT_SUBTYPE = "welcomeEventSubType"; + // Camera specific channels + public static final String CHANNEL_CAMERA_STATUS = "cameraStatus"; + public static final String CHANNEL_CAMERA_SDSTATUS = "cameraSdStatus"; + public static final String CHANNEL_CAMERA_ALIMSTATUS = "cameraAlimStatus"; + public static final String CHANNEL_CAMERA_ISLOCAL = "cameraIsLocal"; + public static final String CHANNEL_CAMERA_LIVEPICTURE = "cameraLivePicture"; + public static final String CHANNEL_CAMERA_LIVEPICTURE_URL = "cameraLivePictureUrl"; + public static final String CHANNEL_CAMERA_LIVESTREAM_URL = "cameraLiveStreamUrl"; + public static final String WELCOME_PICTURE_URL = "https://api.netatmo.com/api/getcamerapicture"; public static final String WELCOME_PICTURE_IMAGEID = "image_id"; public static final String WELCOME_PICTURE_KEY = "key"; @@ -262,7 +273,8 @@ public class NetatmoBindingConstants { public static final Set SUPPORTED_DEVICE_THING_TYPES_UIDS = Stream .of(MAIN_THING_TYPE, MODULE1_THING_TYPE, MODULE2_THING_TYPE, MODULE3_THING_TYPE, MODULE4_THING_TYPE, HOMECOACH_THING_TYPE, PLUG_THING_TYPE, THERM1_THING_TYPE, WELCOME_HOME_THING_TYPE, - WELCOME_CAMERA_THING_TYPE, WELCOME_PERSON_THING_TYPE) + WELCOME_CAMERA_THING_TYPE, WELCOME_PERSON_THING_TYPE, + PRESENCE_CAMERA_THING_TYPE) .collect(Collectors.toSet()); // List of all adressable things in OH = SUPPORTED_DEVICE_THING_TYPES_UIDS + the virtual bridge diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoHandlerFactory.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoHandlerFactory.java index 88c72bdd2ede6..1bf7f184c5440 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoHandlerFactory.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/NetatmoHandlerFactory.java @@ -105,7 +105,8 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { return new NATherm1Handler(thing, stateDescriptionProvider); } else if (thingTypeUID.equals(WELCOME_HOME_THING_TYPE)) { return new NAWelcomeHomeHandler(thing); - } else if (thingTypeUID.equals(WELCOME_CAMERA_THING_TYPE)) { + } else if (thingTypeUID.equals(WELCOME_CAMERA_THING_TYPE) + || thingTypeUID.equals(PRESENCE_CAMERA_THING_TYPE)) { return new NAWelcomeCameraHandler(thing); } else if (thingTypeUID.equals(WELCOME_PERSON_THING_TYPE)) { return new NAWelcomePersonHandler(thing); diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/camera/CameraHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/camera/CameraHandler.java new file mode 100644 index 0000000000000..119bcc805652c --- /dev/null +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/camera/CameraHandler.java @@ -0,0 +1,159 @@ +/** + * Copyright (c) 2010-2020 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.camera; + +import io.swagger.client.model.NAWelcomeCamera; +import org.eclipse.jdt.annotation.NonNull; +import org.eclipse.smarthome.core.library.types.StringType; +import org.eclipse.smarthome.core.thing.Thing; +import org.eclipse.smarthome.core.types.State; +import org.eclipse.smarthome.core.types.UnDefType; +import org.eclipse.smarthome.io.net.http.HttpUtil; +import org.openhab.binding.netatmo.internal.handler.NetatmoModuleHandler; + +import static org.openhab.binding.netatmo.internal.ChannelTypeUtils.toOnOffType; +import static org.openhab.binding.netatmo.internal.ChannelTypeUtils.toStringType; +import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*; + +/** + * {@link CameraHandler} is the class used to handle Camera Data + * + * @author Sven Strohschein (partly moved code from NAWelcomeCameraHandler to introduce inheritance, see NAWelcomeCameraHandler) + * + */ +public class CameraHandler extends NetatmoModuleHandler { + + private static final String LIVE_PICTURE = "/live/snapshot_720.jpg"; + + public CameraHandler(@NonNull Thing thing) { + super(thing); + } + + @Override + protected void updateProperties(NAWelcomeCamera moduleData) { + updateProperties(null, moduleData.getType()); + } + + @SuppressWarnings("null") + @Override + protected State getNAThingProperty(String channelId) { + switch (channelId) { + case CHANNEL_CAMERA_STATUS: + return getStatusState(); + case CHANNEL_CAMERA_SDSTATUS: + return getSdStatusState(); + case CHANNEL_CAMERA_ALIMSTATUS: + return getAlimStatusState(); + case CHANNEL_CAMERA_ISLOCAL: + return getIsLocalState(); + case CHANNEL_CAMERA_LIVEPICTURE_URL: + return getLivePictureURLState(); + case CHANNEL_CAMERA_LIVEPICTURE: + return getLivePictureState(); + case CHANNEL_CAMERA_LIVESTREAM_URL: + return getLiveStreamState(); + } + return super.getNAThingProperty(channelId); + } + + protected State getStatusState() { + return module != null ? toOnOffType(module.getStatus()) : UnDefType.UNDEF; + } + + protected State getSdStatusState() { + return module != null ? toOnOffType(module.getSdStatus()) : UnDefType.UNDEF; + } + + protected State getAlimStatusState() { + return module != null ? toOnOffType(module.getAlimStatus()) : UnDefType.UNDEF; + } + + protected State getIsLocalState() { + return module != null ? toOnOffType(module.getIsLocal()) : UnDefType.UNDEF; + } + + protected State getLivePictureURLState() { + String livePictureURL = getLivePictureURL(); + return livePictureURL == null ? UnDefType.UNDEF : toStringType(livePictureURL); + } + + protected State getLivePictureState() { + String livePictureURL = getLivePictureURL(); + return livePictureURL == null ? UnDefType.UNDEF : HttpUtil.downloadImage(livePictureURL); + } + + protected State getLiveStreamState() { + String liveStreamURL = getLiveStreamURL(); + return liveStreamURL == null ? UnDefType.UNDEF : new StringType(liveStreamURL); + } + + /** + * Get the url for the live snapshot + * + * @return Url of the live snapshot + */ + private String getLivePictureURL() { + String result = getVpnUrl(); + if (result != null) { + result += LIVE_PICTURE; + } + return result; + } + + /** + * Get the url for the live stream depending wether local or not + * + * @return Url of the live stream + */ + private String getLiveStreamURL() { + String result = getVpnUrl(); + if (result == null) { + return null; + } + + StringBuilder resultStringBuilder = new StringBuilder(result); + resultStringBuilder.append("/live/index"); + if(isLocal()) { + resultStringBuilder.append("_local"); + } + resultStringBuilder.append(".m3u8"); + return resultStringBuilder.toString(); + } + + @SuppressWarnings("null") + private String getVpnUrl() { + return (module == null) ? null : module.getVpnUrl(); + } + + public String getStreamURL(String videoId) { + String result = getVpnUrl(); + if(result == null) { + return null; + } + + StringBuilder resultStringBuilder = new StringBuilder(result); + resultStringBuilder.append("/vod/"); + resultStringBuilder.append(videoId); + resultStringBuilder.append("/index"); + if(isLocal()) { + resultStringBuilder.append("_local"); + } + resultStringBuilder.append(".m3u8"); + return resultStringBuilder.toString(); + } + + @SuppressWarnings("null") + private boolean isLocal() { + return (module == null || module.getIsLocal() == null) ? false : module.getIsLocal(); + } +} diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/NetatmoBridgeConfiguration.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/NetatmoBridgeConfiguration.java index bb0d00ee8e8cc..bcf5f1ba32915 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/NetatmoBridgeConfiguration.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/config/NetatmoBridgeConfiguration.java @@ -27,6 +27,7 @@ public class NetatmoBridgeConfiguration { public Boolean readThermostat; public Boolean readHealthyHomeCoach; public Boolean readWelcome; + public Boolean readPresence; public String webHookUrl; public Integer reconnectInterval; } diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/discovery/NetatmoModuleDiscoveryService.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/discovery/NetatmoModuleDiscoveryService.java index 17bcd6381a991..ddfb2d6a53d76 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/discovery/NetatmoModuleDiscoveryService.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/discovery/NetatmoModuleDiscoveryService.java @@ -93,7 +93,8 @@ public void startScan() { }); } } - if (netatmoBridgeHandler.configuration.readWelcome) { + if (netatmoBridgeHandler.configuration.readWelcome + || netatmoBridgeHandler.configuration.readPresence) { NAWelcomeHomeData welcomeHomeData = netatmoBridgeHandler.getWelcomeDataBody(null); if (welcomeHomeData != null) { welcomeHomeData.getHomes().forEach(home -> { diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/NetatmoBridgeHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/NetatmoBridgeHandler.java index f8127209996a9..132bd0a276c83 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/NetatmoBridgeHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/handler/NetatmoBridgeHandler.java @@ -210,6 +210,11 @@ private String getApiScope() { scopes.add("write_camera"); } + if (configuration.readPresence) { + scopes.add("read_presence"); + scopes.add("access_presence"); + } + return String.join(" ", scopes); } @@ -348,7 +353,9 @@ public void webHookEvent(NAWebhookCameraEvent event) { private String getWebHookURI() { String webHookURI = null; - if (configuration.webHookUrl != null && configuration.readWelcome && webHookServlet != null) { + if (configuration.webHookUrl != null + && (configuration.readWelcome || configuration.readPresence) + && webHookServlet != null) { webHookURI = configuration.webHookUrl + webHookServlet.getPath(); } return webHookURI; diff --git a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeCameraHandler.java b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeCameraHandler.java index c13dc94bab160..c0a0c845efbec 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeCameraHandler.java +++ b/bundles/org.openhab.binding.netatmo/src/main/java/org/openhab/binding/netatmo/internal/welcome/NAWelcomeCameraHandler.java @@ -12,19 +12,12 @@ */ package org.openhab.binding.netatmo.internal.welcome; -import static org.openhab.binding.netatmo.internal.ChannelTypeUtils.*; import static org.openhab.binding.netatmo.internal.NetatmoBindingConstants.*; import org.eclipse.jdt.annotation.NonNull; -import org.eclipse.smarthome.core.library.types.OnOffType; -import org.eclipse.smarthome.core.library.types.StringType; import org.eclipse.smarthome.core.thing.Thing; import org.eclipse.smarthome.core.types.State; -import org.eclipse.smarthome.core.types.UnDefType; -import org.eclipse.smarthome.io.net.http.HttpUtil; -import org.openhab.binding.netatmo.internal.handler.NetatmoModuleHandler; - -import io.swagger.client.model.NAWelcomeCamera; +import org.openhab.binding.netatmo.internal.camera.CameraHandler; /** * {@link NAWelcomeCameraHandler} is the class used to handle the Welcome Camera Data @@ -32,86 +25,31 @@ * @author Ing. Peter Weiss - Initial contribution * */ -public class NAWelcomeCameraHandler extends NetatmoModuleHandler { - private static final String LIVE_PICTURE = "/live/snapshot_720.jpg"; +public class NAWelcomeCameraHandler extends CameraHandler { public NAWelcomeCameraHandler(@NonNull Thing thing) { super(thing); } - @Override - protected void updateProperties(NAWelcomeCamera moduleData) { - updateProperties(null, moduleData.getType()); - } - @SuppressWarnings("null") @Override - protected State getNAThingProperty(String chanelId) { - switch (chanelId) { + protected State getNAThingProperty(String channelId) { + switch (channelId) { case CHANNEL_WELCOME_CAMERA_STATUS: - return module != null ? toOnOffType(module.getStatus()) : UnDefType.UNDEF; + return getStatusState(); case CHANNEL_WELCOME_CAMERA_SDSTATUS: - return module != null ? toOnOffType(module.getSdStatus()) : UnDefType.UNDEF; + return getSdStatusState(); case CHANNEL_WELCOME_CAMERA_ALIMSTATUS: - return module != null ? toOnOffType(module.getAlimStatus()) : UnDefType.UNDEF; + return getAlimStatusState(); case CHANNEL_WELCOME_CAMERA_ISLOCAL: - return (module == null || module.getIsLocal() == null) ? UnDefType.UNDEF - : module.getIsLocal() ? OnOffType.ON : OnOffType.OFF; + return getIsLocalState(); case CHANNEL_WELCOME_CAMERA_LIVEPICTURE_URL: - return getLivePictureURL() == null ? UnDefType.UNDEF : toStringType(getLivePictureURL()); + return getLivePictureURLState(); case CHANNEL_WELCOME_CAMERA_LIVEPICTURE: - return getLivePictureURL() == null ? UnDefType.UNDEF : HttpUtil.downloadImage(getLivePictureURL()); + return getLivePictureState(); case CHANNEL_WELCOME_CAMERA_LIVESTREAM_URL: - return getLiveStreamURL() == null ? UnDefType.UNDEF : new StringType(getLiveStreamURL()); - } - return super.getNAThingProperty(chanelId); - } - - /** - * Get the url for the live snapshot - * - * @return Url of the live snapshot - */ - private String getLivePictureURL() { - String result = getVpnUrl(); - if (result != null) { - result += LIVE_PICTURE; - } - return result; - } - - /** - * Get the url for the live stream depending wether local or not - * - * @return Url of the live stream - */ - private String getLiveStreamURL() { - String result = getVpnUrl(); - if (result != null) { - result += "/live/index"; - result += isLocal() ? "_local" : ""; - result += ".m3u8"; + return getLiveStreamState(); } - return result; - } - - @SuppressWarnings("null") - private String getVpnUrl() { - return (module == null) ? null : module.getVpnUrl(); - } - - public String getStreamURL(String videoId) { - String result = getVpnUrl(); - if (result != null) { - result += "/vod/" + videoId + "/index"; - result += isLocal() ? "_local" : ""; - result += ".m3u8"; - } - return result; - } - - @SuppressWarnings("null") - private boolean isLocal() { - return (module == null || module.getIsLocal() == null) ? false : module.getIsLocal().booleanValue(); + return super.getNAThingProperty(channelId); } } diff --git a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/config/config.xml b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/config/config.xml index bc2c222b18e1e..f1b90dd46bb39 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/config/config.xml +++ b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/config/config.xml @@ -55,6 +55,12 @@ false + + + Read and Access Presence camera's data. + false + + Protocol, public IP and port to access OH2 server from Internet. @@ -142,7 +148,7 @@ - + Camera MAC Address diff --git a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_de.properties b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_de.properties index 869f8dddc7613..7de1fc8e9dc6d 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_de.properties +++ b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_de.properties @@ -31,6 +31,9 @@ thing-type.config.netatmo.bridge.readThermostat.description = Aktiviert den Zugr #thing-type.config.netatmo.bridge.readWelcome.label = Access Welcome camera #thing-type.config.netatmo.bridge.readWelcome.description = Read and Access Welcome camera's data. +#thing-type.config.netatmo.bridge.readPresence.label = Access Presence camera +#thing-type.config.netatmo.bridge.readPresence.description = Read and Access Presence camera's data. + #thing-type.config.netatmo.bridge.webHookUrl.label = Webhook address #thing-type.config.netatmo.bridge.webHookUrl.description = Protocol, public IP and port to access OH2 server from Internet. @@ -99,11 +102,11 @@ thing-type.config.netatmo.module.parentId.description = MAC-Adresse des Haupt-In #thing-type.config.netatmo.welcomehome.refreshInterval.label = Refresh Interval #thing-type.config.netatmo.welcomehome.refreshInterval.description = The refresh interval to poll Netatmo API (in ms). -#thing-type.config.netatmo.nawelcomecamera.id.label = Camera ID -#thing-type.config.netatmo.nawelcomecamera.id.description = Camera MAC Address +#thing-type.config.netatmo.camera.id.label = Camera ID +#thing-type.config.netatmo.camera.id.description = Camera MAC Address -#thing-type.config.netatmo.nawelcomecamera.parentId.label = Home ID -#thing-type.config.netatmo.nawelcomecamera.parentId.description = UUID of the home hosting the camera +#thing-type.config.netatmo.camera.parentId.label = Home ID +#thing-type.config.netatmo.camera.parentId.description = UUID of the home hosting the camera #thing-type.config.netatmo.nawelcomeperson.id.label = Person ID #thing-type.config.netatmo.nawelcomeperson.id.description = UUID of the Person diff --git a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_fr.properties b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_fr.properties index 8c89b19c838e3..6f271745df87e 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_fr.properties +++ b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/i18n/netatmo_fr.properties @@ -29,6 +29,9 @@ thing-type.config.netatmo.bridge.readThermostat.description = Acc thing-type.config.netatmo.bridge.readWelcome.label = Accès à la Camera Welcome thing-type.config.netatmo.bridge.readWelcome.description = Accède ou non aux données de la caméra Welcome. +thing-type.config.netatmo.bridge.readPresence.label = Accès à la Camera Presence +thing-type.config.netatmo.bridge.readPresence.description = Accède ou non aux données de la caméra Presence. + thing-type.config.netatmo.bridge.webHookUrl.label = Adresse Webhook thing-type.config.netatmo.bridge.webHookUrl.description = Protocole, IP publique et port pour l'accès au sereveur OH2 depuis l'Internet. @@ -97,11 +100,11 @@ thing-type.config.netatmo.welcomehome.id.description = ID de la maison thing-type.config.netatmo.welcomehome.refreshInterval.label = Fréquence de rafraîchissement thing-type.config.netatmo.welcomehome.refreshInterval.description = La fréquence d'interrogation de l'API Netatmo (en ms) -thing-type.config.netatmo.nawelcomecamera.id.label = ID caméra -thing-type.config.netatmo.nawelcomecamera.id.description = ID de la caméra (adresse MAC) +thing-type.config.netatmo.camera.id.label = ID caméra +thing-type.config.netatmo.camera.id.description = ID de la caméra (adresse MAC) -thing-type.config.netatmo.nawelcomecamera.parentId.label = ID maison -thing-type.config.netatmo.nawelcomecamera.parentId.description = ID de la maison hébergeant la caméra +thing-type.config.netatmo.camera.parentId.label = ID maison +thing-type.config.netatmo.camera.parentId.description = ID de la maison hébergeant la caméra thing-type.config.netatmo.nawelcomeperson.id.label = ID personne thing-type.config.netatmo.nawelcomeperson.id.description = ID de la personne diff --git a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomecamera.xml b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/camera.xml similarity index 75% rename from bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomecamera.xml rename to bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/camera.xml index 2e8fcd5074441..1096e91499030 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomecamera.xml +++ b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/camera.xml @@ -24,7 +24,29 @@ id - + + + + + + + + + + This represents a presence camera at home + + + + + + + + + + + + id + diff --git a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomehome.xml b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomehome.xml index 0f8d95501562a..f49c25620cc25 100644 --- a/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomehome.xml +++ b/bundles/org.openhab.binding.netatmo/src/main/resources/ESH-INF/thing/welcomehome.xml @@ -10,7 +10,7 @@ - This represents a home hosting a Welcome Camera + This represents a home hosting a camera