mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-26 15:21:41 +01:00
[ipcamera] Add motion and alarm support for Axis branded cameras (#17419)
* Add support for Axis motion detection Signed-off-by: Matthew Skinner <matt@pcmus.com> Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
parent
8b6931cd53
commit
87303e4356
@ -129,6 +129,7 @@ public class OnvifConnection {
|
|||||||
private String imagingXAddr = "http://" + ipAddress + "/onvif/device_service";
|
private String imagingXAddr = "http://" + ipAddress + "/onvif/device_service";
|
||||||
private String ptzXAddr = "http://" + ipAddress + "/onvif/ptz_service";
|
private String ptzXAddr = "http://" + ipAddress + "/onvif/ptz_service";
|
||||||
public String subscriptionXAddr = "http://" + ipAddress + "/onvif/device_service";
|
public String subscriptionXAddr = "http://" + ipAddress + "/onvif/device_service";
|
||||||
|
public String subscriptionId = "";
|
||||||
private boolean isConnected = false;
|
private boolean isConnected = false;
|
||||||
private int mediaProfileIndex = 0;
|
private int mediaProfileIndex = 0;
|
||||||
private String rtspUri = "";
|
private String rtspUri = "";
|
||||||
@ -340,7 +341,12 @@ public class OnvifConnection {
|
|||||||
} else if (message.contains("CreatePullPointSubscriptionResponse")) {
|
} else if (message.contains("CreatePullPointSubscriptionResponse")) {
|
||||||
supportsEvents = true;
|
supportsEvents = true;
|
||||||
subscriptionXAddr = Helper.fetchXML(message, "SubscriptionReference>", "Address>");
|
subscriptionXAddr = Helper.fetchXML(message, "SubscriptionReference>", "Address>");
|
||||||
logger.debug("subscriptionXAddr={}", subscriptionXAddr);
|
int start = message.indexOf("<dom0:SubscriptionId");
|
||||||
|
int end = message.indexOf("</dom0:SubscriptionId>");
|
||||||
|
if (start > -1 && end > start) {
|
||||||
|
subscriptionId = message.substring(start, end + 22);
|
||||||
|
}
|
||||||
|
logger.debug("subscriptionXAddr={} subscriptionId={}", subscriptionXAddr, subscriptionId);
|
||||||
sendOnvifRequest(RequestType.PullMessages, subscriptionXAddr);
|
sendOnvifRequest(RequestType.PullMessages, subscriptionXAddr);
|
||||||
} else if (message.contains("GetStatusResponse")) {
|
} else if (message.contains("GetStatusResponse")) {
|
||||||
processPTZLocation(message);
|
processPTZLocation(message);
|
||||||
@ -532,7 +538,12 @@ public class OnvifConnection {
|
|||||||
+ encodeBase64(nonce)
|
+ encodeBase64(nonce)
|
||||||
+ "</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">"
|
+ "</Nonce><Created xmlns=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">"
|
||||||
+ dateTime + "</Created></UsernameToken></Security>";
|
+ dateTime + "</Created></UsernameToken></Security>";
|
||||||
headers = "<s:Header>" + security + headerTo + "</s:Header>";
|
|
||||||
|
if (requestType.equals(RequestType.PullMessages) || requestType.equals(RequestType.Renew)) {
|
||||||
|
headers = "<s:Header>" + security + headerTo + subscriptionId + "</s:Header>";
|
||||||
|
} else {
|
||||||
|
headers = "<s:Header>" + security + headerTo + "</s:Header>";
|
||||||
|
}
|
||||||
} else {// GetSystemDateAndTime must not be password protected as per spec.
|
} else {// GetSystemDateAndTime must not be password protected as per spec.
|
||||||
headers = "";
|
headers = "";
|
||||||
}
|
}
|
||||||
@ -674,10 +685,12 @@ public class OnvifConnection {
|
|||||||
ipCameraHandler.noMotionDetected(CHANNEL_MOTION_ALARM);
|
ipCameraHandler.noMotionDetected(CHANNEL_MOTION_ALARM);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "RuleEngine/tnsaxis:VMD3/vmd3_video_1":
|
||||||
|
case "RuleEngine/MotionRegionDetector/Motion":
|
||||||
case "VideoSource/MotionAlarm":
|
case "VideoSource/MotionAlarm":
|
||||||
if ("true".equals(dataValue)) {
|
if ("true".equals(dataValue) || "1".equals(dataValue)) {
|
||||||
ipCameraHandler.motionDetected(CHANNEL_MOTION_ALARM);
|
ipCameraHandler.motionDetected(CHANNEL_MOTION_ALARM);
|
||||||
} else if ("false".equals(dataValue)) {
|
} else if ("false".equals(dataValue) || "0".equals(dataValue)) {
|
||||||
ipCameraHandler.noMotionDetected(CHANNEL_MOTION_ALARM);
|
ipCameraHandler.noMotionDetected(CHANNEL_MOTION_ALARM);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -709,10 +722,11 @@ public class OnvifConnection {
|
|||||||
ipCameraHandler.changeAlarmState(CHANNEL_TAMPER_ALARM, OnOffType.OFF);
|
ipCameraHandler.changeAlarmState(CHANNEL_TAMPER_ALARM, OnOffType.OFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case "Device/tnsaxis:HardwareFailure/StorageFailure":
|
||||||
case "Device/HardwareFailure/StorageFailure":
|
case "Device/HardwareFailure/StorageFailure":
|
||||||
if ("true".equals(dataValue)) {
|
if ("true".equals(dataValue) || "1".equals(dataValue)) {
|
||||||
ipCameraHandler.changeAlarmState(CHANNEL_STORAGE_ALARM, OnOffType.ON);
|
ipCameraHandler.changeAlarmState(CHANNEL_STORAGE_ALARM, OnOffType.ON);
|
||||||
} else if ("false".equals(dataValue)) {
|
} else if ("false".equals(dataValue) || "0".equals(dataValue)) {
|
||||||
ipCameraHandler.changeAlarmState(CHANNEL_STORAGE_ALARM, OnOffType.OFF);
|
ipCameraHandler.changeAlarmState(CHANNEL_STORAGE_ALARM, OnOffType.OFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -728,9 +742,9 @@ public class OnvifConnection {
|
|||||||
case "VideoSource/GlobalSceneChange/AnalyticsService":
|
case "VideoSource/GlobalSceneChange/AnalyticsService":
|
||||||
case "VideoSource/GlobalSceneChange/ImagingService":
|
case "VideoSource/GlobalSceneChange/ImagingService":
|
||||||
case "VideoSource/GlobalSceneChange/RecordingService":
|
case "VideoSource/GlobalSceneChange/RecordingService":
|
||||||
if ("true".equals(dataValue)) {
|
if ("true".equals(dataValue) || "1".equals(dataValue)) {
|
||||||
ipCameraHandler.changeAlarmState(CHANNEL_SCENE_CHANGE_ALARM, OnOffType.ON);
|
ipCameraHandler.changeAlarmState(CHANNEL_SCENE_CHANGE_ALARM, OnOffType.ON);
|
||||||
} else if ("false".equals(dataValue)) {
|
} else if ("false".equals(dataValue) || "0".equals(dataValue)) {
|
||||||
ipCameraHandler.changeAlarmState(CHANNEL_SCENE_CHANGE_ALARM, OnOffType.OFF);
|
ipCameraHandler.changeAlarmState(CHANNEL_SCENE_CHANGE_ALARM, OnOffType.OFF);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user