49_IPCAM: introduced attribute 'blocking'

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@24924 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
delmar 2021-09-06 08:47:51 +00:00
parent 5f8f7df735
commit 63c8687cc9
2 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
- feature: 49_IPCAM: introduced attribute 'blocking'
- bugfix: 47_OBIS: Support Holley-smartmeters with negative metering
- change: 10_KNX: major rewrite of the module. pls. check forum #122582
before shutdown/restart! fixed crash using Attr KNX_toggle

View File

@ -47,7 +47,7 @@ IPCAM_Initialize($$)
"cmd01data cmd02data cmd03data cmd04data cmd05data cmd06data cmd07data ".
"cmd08data cmd09data cmd10data cmd11data cmd12data cmd13data cmd14data cmd15data ".
"model do_not_notify:1,0 showtime:1,0 scheme:http,https ".
"disable:0,1 unknownFormatRetryDelay handleAnyXmlAsSvg:0,1 unknownFormatRetryCount ".
"disable:0,1 unknownFormatRetryDelay handleAnyXmlAsSvg:0,1 unknownFormatRetryCount blocking:0,1 ".
$readingFnAttributes;
}
@ -90,6 +90,7 @@ BEGIN {
attr
TimeNow
HttpUtils_NonblockingGet
GetFileFromURLQuiet
SetExtensions
AttrTemplate_Set
urlEncode
@ -483,8 +484,9 @@ sub ExecuteSnapshotRequest {
my ($hash, $callbackCommand) = @_;
my $name = $hash->{NAME};
my $blocking = AttrVal($name, 'blocking', 0);
my $camUrl = createSnapshotUrl($hash);
Log3 $name, 3, "IPCAM ($name) - ExecuteSnapshotRequest camUrl: $camUrl";
Log3 $name, 3, "IPCAM ($name) - ExecuteSnapshotRequest blocking: $blocking, camUrl: $camUrl";
my $apiParam = {
url => $camUrl,
@ -496,12 +498,11 @@ sub ExecuteSnapshotRequest {
callbackCommand => $callbackCommand
};
# trying to fix timeouts by wrapping this in internalTimer
if (defined $callbackCommand) {
InternalTimer(gettimeofday(), "main::HttpUtils_NonblockingGet", $apiParam);
if ($blocking == 1) {
my $camret = GetFileFromURLQuiet($camUrl);
RequestSnapshot_Callback($apiParam, '', $camret);
} else {
# without callback command, the internal timer has been set before already.
HttpUtils_NonblockingGet($apiParam);
HttpUtils_NonblockingGet($apiParam);
}
return undef;
@ -880,6 +881,11 @@ DetailFn {
These placeholders will be replaced with the values from the credentials file.<br>
Example:<br> <code>attr ipcam3 basicauth {USERNAME}:{PASSWORD}</code>
</li>
<li>
blocking<br>
If set to 1, FHEM will make a blocking call to the camera. Try this if getting snapshot runs into timeouts regularly.<br>
Per default, this is set to 0.
</li>
<li>
cmd01, cmd02, cmd03, .. cmd13, cdm14, cdm15<br>
It is possible to define up to 15 custom commands.<br>