From 85d05a1d0373af53ead1336d6e85e192d82684bd Mon Sep 17 00:00:00 2001
From: delmar <>
Date: Thu, 11 Mar 2021 10:06:43 +0000
Subject: [PATCH] 49_IPCAM: set-magic for POST data (eg resolving
[device:reading])
git-svn-id: https://svn.fhem.de/fhem/trunk@23924 2b470e98-0d58-463d-a4d8-8e2adae1ed80
---
fhem/CHANGED | 1 +
fhem/FHEM/49_IPCAM.pm | 12 +++++++++++-
2 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/fhem/CHANGED b/fhem/CHANGED
index 70a68873f..de45de7c9 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.
+ - new: 49_IPCAM: set-magic for POST data (eg resolving [device:reading])
- new: 49_IPCAM: added POST for custom commands cmd01-cmd15
- new: 49_IPCAM: imageWithCallback now also interprets [device:reading]
- bugfix: 49_IPCAM: fixed imageWithCallback using previous image
diff --git a/fhem/FHEM/49_IPCAM.pm b/fhem/FHEM/49_IPCAM.pm
index b763e3f82..5351feb80 100644
--- a/fhem/FHEM/49_IPCAM.pm
+++ b/fhem/FHEM/49_IPCAM.pm
@@ -289,6 +289,13 @@ sub SendCommand {
Log3 $name, 3, "IPCAM ($name) - sending command $commandId: $camUrl";
my $postData = AttrVal($name, $commandId.'data', undef);
if (defined $postData) {
+ my %dummy;
+ my ($err, @a) = ReplaceSetMagic(\%dummy, 0, ( $postData ) );
+ if ( $err ) {
+ Log3 $name, 0, "IPCAM ($name) - parse post data failed on ReplaceSetMagic with :$err: on :$postData:";
+ } else {
+ $postData = join(" ", @a);
+ }
$apiParam->{data} = $postData;
$apiParam->{method} = 'POST';
Log3 $name, 3, "IPCAM ($name) - post data for $commandId: $postData";
@@ -844,7 +851,10 @@ DetailFn {
You can define the POST data that is to be sent with the according cmd.
If this is defined, the request will be POST instead of GET.
Example:
- attr ipcam cmd01data [{"cmd":"Login"},{"cmd":"SetOSD"}]
+ attr ipcam cmd01data [{"cmd":"Login"},{"cmd":"SetOSD"}]
+ You can provide references to readings and internals easliy like this:
+ attr ipcam cmd01data [{"cmd":"Login"},{"cmd":"SetOSD"},{"key":"[devicename:reading]"}]
+ will be resolved into [{"cmd":"Login"},{"key":"value-from-reading"}]