Skip to content

Commit

Permalink
[ipcamera] Add Reolink API support (#14728)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthew Skinner <matt@pcmus.com>
  • Loading branch information
Skinah authored May 13, 2023
1 parent cd4879a commit 01add04
Show file tree
Hide file tree
Showing 11 changed files with 901 additions and 20 deletions.
12 changes: 11 additions & 1 deletion bundles/org.openhab.binding.ipcamera/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Some cameras allow the key frame to be created every second or a different amoun

These cameras do not have the ability to create H.264 streams and hence can not be used with HLS, however all other features should work.
Due to many custom firmwares available, you may need to ask the firmware developer what the URLs are for snapshots and MJPEG streams if they have changed the defaults from what the Arduino IDE sample code uses.
Another limitation is that they can only provide a single stream at a time, so you need to setup the `ffmpegInput` to use the ipcamera.mjpeg feed from the openHAB server and change `ffmpegInputOptions` to "-f mjpeg" so FFmpeg knows the input is MJPEG format and not H.264.

Example:

Expand All @@ -46,7 +47,8 @@ Thing ipcamera:generic:Esp32Cam
snapshotUrl="http://192.168.1.181/capture",
mjpegUrl="http://192.168.1.181:81/stream",
ffmpegInputOptions="-f mjpeg",
ffmpegOutput="/tmp/Esp32Camera/", ffmpegInput="http://192.168.1.181:81/stream"
ffmpegOutput="/tmp/Esp32Camera/",
ffmpegInput="http://192.168.1.3:8080/ipcamera/{cameraUID}/ipcamera.mjpeg"
]
```

Expand Down Expand Up @@ -124,6 +126,11 @@ Thing ipcamera:hikvision:West "West Camera"
- For MJPEG to work, you need to set the first sub-stream to be MJPEG format for the default settings to work, otherwise you can override the default with mjpegUrl with a valid URL for MJPEG streams.
- Be sure to update to the latest firmware for your camera as Instar have made a lot of improvements recently, including adding MQTT features (MQTT is not needed for this binding to work).

### Reolink

- NVR's made by Reolink have ONVIF disabled by default and may require a screen connected to the hardware to enable ONVIF or newer firmwares may be able to do this via their app or web UI.
- This binding will use the Reolink API for polling the alarms if the `nvrChannel` is 1 or higher and does not need ONVIF to be enabled. To use ONVIF event methods for the alarms, you can set `nvrChannel` to 0.

## Discovery

The discovery feature of openHAB can be used to find and setup any ONVIF cameras.
Expand Down Expand Up @@ -209,6 +216,7 @@ The channels are kept consistent as much as possible from brand to brand to make
|-|-|-|
| `activateAlarmOutput` | Switch | Toggles a cameras relay output 1. |
| `activateAlarmOutput2` | Switch | Toggles a cameras relay output 2. |
| `animalAlarm` | Switch | Toggles when an animal is in view. |
| `audioAlarm` | Switch (read only) | When the camera detects noise above a threshold this switch will move to ON. |
| `autoLED` | Switch | When ON this sets a cameras IR LED to automatically turn on or off. |
| `carAlarm` | Switch | When a car is detected the switch will turn ON. |
Expand All @@ -217,10 +225,12 @@ The channels are kept consistent as much as possible from brand to brand to make
| `enableAudioAlarm` | Switch | Allows the audio alarm to be turned ON or OFF. |
| `enableExternalAlarmInput` | Switch | Hikvision and Instar allow the Alarm input terminals to be disabled by this control. |
| `enableFieldDetectionAlarm` | Switch | Allows the field detection alarm to be turned ON or OFF. Some cameras will call this the Intrusion Alarm. |
| `enableFTP` | Switch | Turn the cameras internal FTP recordings ON or OFF. |
| `enableLED` | Switch | Turn the IR LED ON or OFF. Some cameras have 3 states the LED can be in, so see the `autoLED` channel. |
| `enableLineCrossingAlarm` | Switch | Turns the line crossing alarm for API cameras, ON and OFF. |
| `enableMotionAlarm` | Switch | Turns the motion alarm ON and OFF for API cameras. This will not effect FFmpeg based alarms which have their own control. |
| `enablePirAlarm` | Switch | Turn PIR sensor ON or OFF. |
| `enableRecordings` | Switch | Turn the cameras internal recordings ON or OFF. |
| `externalAlarmInput` | Switch (read only) | Reflects the status of the alarm input terminals on some cameras. |
| `externalAlarmInput2` | Switch (read only) | Reflects the status of the alarm input 2 terminals on some cameras. |
| `externalLight` | Switch | Some cameras have a dedicated relay output for turning lights on and off with. |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public class CameraConfig {
private int onvifPort;
private String username = "";
private String password = "";
public boolean useToken = true;
private int onvifMediaProfile;
private int pollTime;
private String ffmpegInput = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms

if (content.contains("</CGI_Result>")) {
ctx.close();
ipCameraHandler.logger.debug("End of FOSCAM handler reached, so closing the channel to the camera now");
}
} finally {
ReferenceCountUtil.release(msg);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class IpCameraBindingConstants {
public static final String AMCREST_HANDLER = "amcrestHandler";
public static final String COMMON_HANDLER = "commonHandler";
public static final String INSTAR_HANDLER = "instarHandler";
public static final String REOLINK_HANDLER = "reolinkHandler";

public static enum FFmpegFormat {
HLS,
Expand Down Expand Up @@ -66,10 +67,12 @@ public static enum FFmpegFormat {
public static final ThingTypeUID THING_TYPE_DAHUA = new ThingTypeUID(BINDING_ID, DAHUA_THING);
public static final String DOORBIRD_THING = "doorbird";
public static final ThingTypeUID THING_TYPE_DOORBIRD = new ThingTypeUID(BINDING_ID, DOORBIRD_THING);
public static final String REOLINK_THING = "reolink";
public static final ThingTypeUID THING_TYPE_REOLINK = new ThingTypeUID(BINDING_ID, REOLINK_THING);

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = new HashSet<ThingTypeUID>(
Arrays.asList(THING_TYPE_ONVIF, THING_TYPE_GENERIC, THING_TYPE_AMCREST, THING_TYPE_DAHUA, THING_TYPE_INSTAR,
THING_TYPE_FOSCAM, THING_TYPE_DOORBIRD, THING_TYPE_HIKVISION));
THING_TYPE_FOSCAM, THING_TYPE_DOORBIRD, THING_TYPE_HIKVISION, THING_TYPE_REOLINK));

public static final Set<ThingTypeUID> GROUP_SUPPORTED_THING_TYPES = new HashSet<ThingTypeUID>(
Arrays.asList(THING_TYPE_GROUP));
Expand Down Expand Up @@ -139,4 +142,6 @@ public static enum FFmpegFormat {
public static final String CHANNEL_CAR_ALARM = "carAlarm";
public static final String CHANNEL_HUMAN_ALARM = "humanAlarm";
public static final String CHANNEL_ANIMAL_ALARM = "animalAlarm";
public static final String CHANNEL_ENABLE_FTP = "enableFTP";
public static final String CHANNEL_ENABLE_RECORDINGS = "enableRecordings";
}
Loading

0 comments on commit 01add04

Please sign in to comment.