mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-01-31 06:39:11 +00:00
49_IPCAM: imageWithCallback now also interprets [device:reading]
git-svn-id: https://svn.fhem.de/fhem/trunk@23919 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
b62024eadd
commit
4fdc90cfc5
@ -1,5 +1,6 @@
|
|||||||
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
|
# 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.
|
# 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
|
- bugfix: 49_IPCAM: fixed imageWithCallback using previous image
|
||||||
- change: 49_IPCAM: added 'get imageWithCallback'
|
- change: 49_IPCAM: added 'get imageWithCallback'
|
||||||
- change: 49_IPCAM: now unblocking and removed attribute 'loglevel'
|
- change: 49_IPCAM: now unblocking and removed attribute 'loglevel'
|
||||||
|
@ -92,6 +92,7 @@ BEGIN {
|
|||||||
AttrTemplate_Set
|
AttrTemplate_Set
|
||||||
urlEncode
|
urlEncode
|
||||||
AnalyzeCommand
|
AnalyzeCommand
|
||||||
|
ReplaceSetMagic
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -371,7 +372,7 @@ Get($@) {
|
|||||||
my $callbackCommand = join(" ", @a);
|
my $callbackCommand = join(" ", @a);
|
||||||
Log3 $name, 3, "IPCAM ($name) - imageWithCallback command: $callbackCommand";
|
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";
|
Log3 $name, 3, "IPCAM ($name) - imageWithCallback camUri: $camUri";
|
||||||
|
|
||||||
RequestSnapshotWithCallback($hash, $camUri, $callbackCommand);
|
RequestSnapshotWithCallback($hash, $camUri, $callbackCommand);
|
||||||
@ -387,13 +388,18 @@ Get($@) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub getSnapshot($$) {
|
||||||
|
my ($hash) = @_;
|
||||||
|
my $snapshotUrl = createSnapshotUrl($hash);
|
||||||
|
RequestSnapshot($hash, $snapshotUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
#####################################
|
#####################################
|
||||||
sub
|
sub
|
||||||
getSnapshot($$) {
|
createSnapshotUrl($) {
|
||||||
my ($hash, $skipRequest) = @_;
|
my ($hash) = @_;
|
||||||
my $name = $hash->{NAME};
|
my $name = $hash->{NAME};
|
||||||
my $camAuth = $hash->{AUTHORITY};
|
my $camAuth = $hash->{AUTHORITY};
|
||||||
my $camURI;
|
my $camURI;
|
||||||
@ -443,16 +449,17 @@ getSnapshot($$) {
|
|||||||
# Log3 $name, 3, "IPCAM ($name) - found reading: $1";
|
# Log3 $name, 3, "IPCAM ($name) - found reading: $1";
|
||||||
# }
|
# }
|
||||||
|
|
||||||
if (defined $skipRequest) {
|
# if (defined $skipRequest) {
|
||||||
return $camURI;
|
# return $camURI;
|
||||||
} else {
|
# } else {
|
||||||
RequestSnapshot($hash, $camURI);
|
# RequestSnapshot($hash, $camURI);
|
||||||
}
|
# }
|
||||||
# Log3 $name, 5, "IPCAM ($name) - getSnapshot snapshot: $snapshot";
|
# Log3 $name, 5, "IPCAM ($name) - getSnapshot snapshot: $snapshot";
|
||||||
|
|
||||||
return undef;
|
return $camURI;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub RequestSnapshot {
|
sub RequestSnapshot {
|
||||||
my ($hash, $camUrl) = @_;
|
my ($hash, $camUrl) = @_;
|
||||||
|
|
||||||
@ -563,6 +570,14 @@ sub RequestSnapshot_Callback {
|
|||||||
|
|
||||||
my $callbackCommand = $param->{callbackCommand};
|
my $callbackCommand = $param->{callbackCommand};
|
||||||
if (defined $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";
|
Log3 $name, 3, "IPCAM ($name) - RequestSnapshotWithCallback executing $callbackCommand";
|
||||||
|
|
||||||
my $error = AnalyzeCommand(undef, $callbackCommand);
|
my $error = AnalyzeCommand(undef, $callbackCommand);
|
||||||
@ -786,7 +801,9 @@ DetailFn {
|
|||||||
Allows you to eg send pictures immediately and <br>
|
Allows you to eg send pictures immediately and <br>
|
||||||
without creating a dedicated notify.<br>
|
without creating a dedicated notify.<br>
|
||||||
Example:<br>
|
Example:<br>
|
||||||
<code>get ipcam3 imageWithCallback set pushmsg msg Frontdoor Ding Dong! expire=3600 attachment='www/snapshot/ipcam3_snapshot.jpg'</code>
|
<code>get ipcam3 imageWithCallback set pushmsg msg Frontdoor Ding Dong! expire=3600 attachment='www/snapshot/ipcam3_snapshot.jpg'</code><br>
|
||||||
|
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:<br>
|
||||||
|
<code>get ipcam3 imageWithCallback set pushmsg msg Frontdoor Ding Dong! expire=3600 attachment='www/snapshot/[ipcam3:latest]'</code>
|
||||||
</li>
|
</li>
|
||||||
<li><code>last</code><br>
|
<li><code>last</code><br>
|
||||||
Show the name of the last snapshot.
|
Show the name of the last snapshot.
|
||||||
|
Loading…
Reference in New Issue
Block a user