Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ipcamera]Fix SceneChange alarm not working for newer Dahua cameras #17544

Merged
merged 1 commit into from
Oct 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.ipcamera.internal.handler.IpCameraHandler;
import org.openhab.binding.ipcamera.internal.onvif.OnvifConnection.RequestType;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.OnOffType;
import org.openhab.core.library.types.PercentType;
Expand Down Expand Up @@ -156,6 +157,7 @@ private void processEvent(String content) {
ipCameraHandler.setChannelState(CHANNEL_TOO_DARK_ALARM, OnOffType.OFF);
}
break;
case "SceneChange":
case "VideoAbnormalDetection":
if ("Start".equals(action)) {
ipCameraHandler.setChannelState(CHANNEL_SCENE_CHANGE_ALARM, OnOffType.ON);
Expand Down Expand Up @@ -191,17 +193,22 @@ private void processEvent(String content) {
case "LensMaskClose":
ipCameraHandler.setChannelState(CHANNEL_ENABLE_PRIVACY_MODE, OnOffType.OFF);
break;
// Skip these so they are not logged.
case "TimeChange":
// Check updated time matches openHAB's and store the offset which is needed for ONVIF
ipCameraHandler.onvifCamera.sendOnvifRequest(RequestType.GetSystemDateAndTime,
ipCameraHandler.onvifCamera.deviceXAddr);
break;
// Skip these so they are not logged.
case "NTPAdjustTime": // will trigger a TimeChange event no need to check twice
case "IntelliFrame":
case "NTPAdjustTime":
case "StorageChange":
case "Reboot":
case "NewFile":
case "VideoMotionInfo":
case "RtspSessionDisconnect":
case "LeFunctionStatusSync":
case "RecordDelete":
case "InterVideoAccess":
break;
default:
ipCameraHandler.logger.debug("Unrecognised Dahua event, Code={}, action={}", code, action);
Expand Down Expand Up @@ -324,7 +331,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
} else if (command instanceof PercentType percentCommand) {
ipCameraHandler.sendHttpGET("/cgi-bin/configManager.cgi?action=setConfig&Lighting_V2["
+ nvrChannelAdjusted + "][0][1].Mode=Manual&Lighting_V2[" + nvrChannelAdjusted
+ "][0][1].NearLight[0].Light=" + command.toString());
+ "][0][1].NearLight[0].Light=" + percentCommand.toString());
}
return;
case CHANNEL_AUTO_WHITE_LED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ public void handleCommand(ChannelUID channelUID, Command command) {
ipCameraHandler.sendHttpPOST("/api.cgi?cmd=SetIrLights" + ipCameraHandler.reolinkAuth,
"[{\"cmd\": \"SetIrLights\",\"action\": 0,\"param\": {\"IrLights\": {\"channel\": "
+ ipCameraHandler.cameraConfig.getNvrChannel() + ",\"state\": \"Off\"}}}]");
} else if (OnOffType.ON.equals(command) || command instanceof PercentType percentCommand) {
} else if (OnOffType.ON.equals(command) || command instanceof PercentType) {
ipCameraHandler.sendHttpPOST("/api.cgi?cmd=SetIrLights" + ipCameraHandler.reolinkAuth,
"[{\"cmd\": \"SetIrLights\",\"action\": 0,\"param\": {\"IrLights\": {\"channel\": "
+ ipCameraHandler.cameraConfig.getNvrChannel() + ",\"state\": \"On\"}}}]");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms
}
if (contentType.contains("multipart")) {
boundary = Helper.searchString(contentType, "boundary=");
if (mjpegUri.equals(requestUrl)) {
if (mjpegUri.endsWith(requestUrl)) {
if (msg instanceof HttpMessage) {
// very start of stream only
mjpegContentType = contentType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public enum RequestType {
private String user = "";
private String password = "";
private int onvifPort = 80;
private String deviceXAddr = "http://" + ipAddress + "/onvif/device_service";
public String deviceXAddr = "http://" + ipAddress + "/onvif/device_service";
private String eventXAddr = "http://" + ipAddress + "/onvif/device_service";
private String mediaXAddr = "http://" + ipAddress + "/onvif/device_service";
@SuppressWarnings("unused")
Expand Down