From 17d03903e0b305a044bcab024d09fc303211541a Mon Sep 17 00:00:00 2001 From: Ronny Grun Date: Sat, 5 Oct 2024 09:53:50 +0200 Subject: [PATCH] [ipcamera| add autoTracking channel for reolink camera (#17488) Signed-off-by: Ronny Grun Signed-off-by: Ciprian Pascu --- bundles/org.openhab.binding.ipcamera/README.md | 1 + .../ipcamera/internal/IpCameraBindingConstants.java | 1 + .../binding/ipcamera/internal/ReolinkHandler.java | 12 ++++++++++++ .../main/resources/OH-INF/i18n/ipcamera.properties | 2 ++ .../src/main/resources/OH-INF/thing/thing-types.xml | 9 ++++++++- .../main/resources/OH-INF/update/instructions.xml | 5 +++++ 6 files changed, 29 insertions(+), 1 deletion(-) diff --git a/bundles/org.openhab.binding.ipcamera/README.md b/bundles/org.openhab.binding.ipcamera/README.md index 5882b31c1a4..e0abbe6d827 100644 --- a/bundles/org.openhab.binding.ipcamera/README.md +++ b/bundles/org.openhab.binding.ipcamera/README.md @@ -220,6 +220,7 @@ The channels are kept consistent as much as possible from brand to brand to make | `animalAlarm` | Switch | RW | Toggles when an animal is in view. | | `audioAlarm` | Switch | R | When the camera detects noise above a threshold this switch will move to ON. | | `autoLED` | Switch | RW |When ON this sets a cameras IR LED to automatically turn on or off. | +| `autoTracking` | Switch | RW |Turn the automatic mode for tracking ON or OFF. | | `autoWhiteLED` | Switch | RW |When ON this sets a cameras visible white LED to automatically turn on or off. | | `carAlarm` | Switch | RW | When a car is detected the switch will turn ON. | | `cellMotionAlarm` | Switch | R | ONVIF cameras only will reflect the status of the ONVIF event of the same name. | diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/IpCameraBindingConstants.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/IpCameraBindingConstants.java index d7219fff9c9..ddbe231d115 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/IpCameraBindingConstants.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/IpCameraBindingConstants.java @@ -148,4 +148,5 @@ public class IpCameraBindingConstants { public static final String CHANNEL_ENABLE_EMAIL = "enableEmail"; public static final String CHANNEL_ENABLE_PUSH = "enablePush"; public static final String CHANNEL_ENABLE_RECORDINGS = "enableRecordings"; + public static final String CHANNEL_AUTO_TRACKING = "autoTracking"; } diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/ReolinkHandler.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/ReolinkHandler.java index 2cde80aae1b..c4f8100df3d 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/ReolinkHandler.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/ReolinkHandler.java @@ -508,6 +508,18 @@ public class ReolinkHandler extends ChannelDuplexHandler { + ipCameraHandler.cameraConfig.getNvrChannel() + ",\"mode\": 2,\"bright\": " + value + "}}}]"); } + break; + case CHANNEL_AUTO_TRACKING: + if (OnOffType.ON.equals(command)) { + ipCameraHandler.sendHttpPOST("/api.cgi?cmd=SetAiCfg" + ipCameraHandler.reolinkAuth, + "[{\"cmd\":\"SetAiCfg\",\"action\":0,\"param\":{\"bSmartTrack\":1,\"channel\": " + + ipCameraHandler.cameraConfig.getNvrChannel() + " }}]"); + } else { + ipCameraHandler.sendHttpPOST("/api.cgi?cmd=SetAiCfg" + ipCameraHandler.reolinkAuth, + "[{\"cmd\":\"SetAiCfg\",\"action\":0,\"param\":{\"bSmartTrack\":0,\"channel\": " + + ipCameraHandler.cameraConfig.getNvrChannel() + " }}]"); + } + break; } } diff --git a/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/i18n/ipcamera.properties b/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/i18n/ipcamera.properties index 351e9d39d3f..b6178ff5d05 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/i18n/ipcamera.properties +++ b/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/i18n/ipcamera.properties @@ -629,6 +629,8 @@ channel-type.ipcamera.audioAlarm.label = Audio Alarm channel-type.ipcamera.audioAlarm.description = Audio has triggered an Alarm. channel-type.ipcamera.autoLED.label = Auto LED channel-type.ipcamera.autoLED.description = Turn the automatic mode for the LED ON and OFF. +channel-type.ipcamera.autoTracking.label = Auto Tracking +channel-type.ipcamera.autoTracking.description = Turn the automatic mode for tracking ON or OFF. channel-type.ipcamera.autoWhiteLED.label = Auto White LED channel-type.ipcamera.autoWhiteLED.description = Turn the automatic mode for the visible white LED ON or OFF. channel-type.ipcamera.carAlarm.label = Car Alarm diff --git a/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/thing/thing-types.xml b/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/thing/thing-types.xml index 77d294606b3..c4c0acc6966 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/thing/thing-types.xml +++ b/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/thing/thing-types.xml @@ -2321,10 +2321,11 @@ + - 1 + 2 @@ -3074,4 +3075,10 @@ + + + Switch + + Turn the automatic mode for tracking ON or OFF. + diff --git a/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/update/instructions.xml b/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/update/instructions.xml index 267bed561ab..c4d2f4e4f7c 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/update/instructions.xml +++ b/bundles/org.openhab.binding.ipcamera/src/main/resources/OH-INF/update/instructions.xml @@ -18,6 +18,11 @@ ipcamera:enablePush + + + ipcamera:autoTracking + +