From d906647fa366984b78889c5c897297c8edaf4411 Mon Sep 17 00:00:00 2001 From: delmar <> Date: Mon, 6 Sep 2021 08:47:51 +0000 Subject: [PATCH] 49_IPCAM: introduced attribute 'blocking' git-svn-id: https://svn.fhem.de/fhem/trunk@24924 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 1 + fhem/FHEM/49_IPCAM.pm | 20 +++++++++++++------- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 86445d07c..27ed320e8 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -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 diff --git a/fhem/FHEM/49_IPCAM.pm b/fhem/FHEM/49_IPCAM.pm index f9d8f3524..44f703805 100644 --- a/fhem/FHEM/49_IPCAM.pm +++ b/fhem/FHEM/49_IPCAM.pm @@ -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.
Example:
attr ipcam3 basicauth {USERNAME}:{PASSWORD} +
  • + blocking
    + If set to 1, FHEM will make a blocking call to the camera. Try this if getting snapshot runs into timeouts regularly.
    + Per default, this is set to 0. +
  • cmd01, cmd02, cmd03, .. cmd13, cdm14, cdm15
    It is possible to define up to 15 custom commands.