diff --git a/CHANGED b/CHANGED
index 00ed27fd5..80c7ee7ad 100644
--- a/CHANGED
+++ b/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.
+ - new: 49_IPCAM: imageWithCallback now also interprets [device:reading]
- bugfix: 49_IPCAM: fixed imageWithCallback using previous image
- change: 49_IPCAM: added 'get imageWithCallback'
- change: 49_IPCAM: now unblocking and removed attribute 'loglevel'
diff --git a/FHEM/49_IPCAM.pm b/FHEM/49_IPCAM.pm
index 46a677815..a8d7b4847 100644
--- a/FHEM/49_IPCAM.pm
+++ b/FHEM/49_IPCAM.pm
@@ -92,6 +92,7 @@ BEGIN {
AttrTemplate_Set
urlEncode
AnalyzeCommand
+ ReplaceSetMagic
))
};
@@ -371,7 +372,7 @@ Get($@) {
my $callbackCommand = join(" ", @a);
Log3 $name, 3, "IPCAM ($name) - imageWithCallback command: $callbackCommand";
- my $camUri = getSnapshot($hash, 1);
+ my $camUri = createSnapshotUrl($hash);
Log3 $name, 3, "IPCAM ($name) - imageWithCallback camUri: $camUri";
RequestSnapshotWithCallback($hash, $camUri, $callbackCommand);
@@ -387,13 +388,18 @@ Get($@) {
}
}
+}
+sub getSnapshot($$) {
+ my ($hash) = @_;
+ my $snapshotUrl = createSnapshotUrl($hash);
+ RequestSnapshot($hash, $snapshotUrl);
}
#####################################
sub
-getSnapshot($$) {
- my ($hash, $skipRequest) = @_;
+createSnapshotUrl($) {
+ my ($hash) = @_;
my $name = $hash->{NAME};
my $camAuth = $hash->{AUTHORITY};
my $camURI;
@@ -443,16 +449,17 @@ getSnapshot($$) {
# Log3 $name, 3, "IPCAM ($name) - found reading: $1";
# }
- if (defined $skipRequest) {
- return $camURI;
- } else {
- RequestSnapshot($hash, $camURI);
- }
+# if (defined $skipRequest) {
+# return $camURI;
+# } else {
+# RequestSnapshot($hash, $camURI);
+# }
# Log3 $name, 5, "IPCAM ($name) - getSnapshot snapshot: $snapshot";
- return undef;
+ return $camURI;
}
+
sub RequestSnapshot {
my ($hash, $camUrl) = @_;
@@ -563,6 +570,14 @@ sub RequestSnapshot_Callback {
my $callbackCommand = $param->{callbackCommand};
if (defined $callbackCommand) {
+ my %dummy;
+ my ($err, @a) = ReplaceSetMagic(\%dummy, 0, ( $callbackCommand ) );
+ if ( $err ) {
+ Log3 $name, 0, "IPCAM ($name) - parse cmd failed on ReplaceSetmagic with :$err: on :$callbackCommand:";
+ } else {
+ $callbackCommand = join(" ", @a);
+ }
+
Log3 $name, 3, "IPCAM ($name) - RequestSnapshotWithCallback executing $callbackCommand";
my $error = AnalyzeCommand(undef, $callbackCommand);
@@ -786,7 +801,9 @@ DetailFn {
Allows you to eg send pictures immediately and
without creating a dedicated notify.
Example:
- get ipcam3 imageWithCallback set pushmsg msg Frontdoor Ding Dong! expire=3600 attachment='www/snapshot/ipcam3_snapshot.jpg'
+ get ipcam3 imageWithCallback set pushmsg msg Frontdoor Ding Dong! expire=3600 attachment='www/snapshot/ipcam3_snapshot.jpg'
+ The callback command can also hold references to other readings, internals, etc. The following example will lead to the same command as the first one:
+ get ipcam3 imageWithCallback set pushmsg msg Frontdoor Ding Dong! expire=3600 attachment='www/snapshot/[ipcam3:latest]'
last