49_IPCAM.pm: patch from delmar to support https (Forum #96040)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@18505 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2019-02-05 21:50:23 +00:00
parent 99efa273c5
commit 7e7040ac53

View File

@ -28,6 +28,7 @@ use warnings;
sub IPCAM_getSnapshot($); sub IPCAM_getSnapshot($);
sub IPCAM_guessFileFormat($); sub IPCAM_guessFileFormat($);
sub IPCAM_getScheme($);
my %gets = ( my %gets = (
"image" => "", "image" => "",
@ -59,7 +60,7 @@ IPCAM_Initialize($$)
"cmdPos09 cmdPos10 cmdPos11 cmdPos12 cmdPos13 cmdPos14 cmdPos15 cmdPosHome ". "cmdPos09 cmdPos10 cmdPos11 cmdPos12 cmdPos13 cmdPos14 cmdPos15 cmdPosHome ".
"cmd01 cmd02 cmd03 cmd04 cmd05 cmd06 cmd07 cmd08 ". "cmd01 cmd02 cmd03 cmd04 cmd05 cmd06 cmd07 cmd08 ".
"cmd09 cmd10 cmd11 cmd12 cmd13 cmd14 cmd15 ". "cmd09 cmd10 cmd11 cmd12 cmd13 cmd14 cmd15 ".
"do_not_notify:1,0 showtime:1,0 ". "do_not_notify:1,0 showtime:1,0 scheme:http,https ".
"loglevel:0,1,2,3,4,5,6 disable:0,1 ". "loglevel:0,1,2,3,4,5,6 disable:0,1 ".
$readingFnAttributes; $readingFnAttributes;
} }
@ -202,10 +203,12 @@ IPCAM_Set($@) {
return "Missing a path value for camURI. Please set attribute 'path', 'pathCmd' and/or 'pathPanTilt' first." return "Missing a path value for camURI. Please set attribute 'path', 'pathCmd' and/or 'pathPanTilt' first."
if(!$camPath && $cmd ne "raw"); if(!$camPath && $cmd ne "raw");
my $scheme = IPCAM_getScheme($hash);
if($basicauth) { if($basicauth) {
$camURI = "http://$basicauth" . "@" . "$camAuth/$camPath"; $camURI = "$scheme://$basicauth" . "@" . "$camAuth/$camPath";
} else { } else {
$camURI = "http://$camAuth/$camPath"; $camURI = "$scheme://$camAuth/$camPath";
} }
if($cmd eq "cmd" && defined($attr{$name}{pathCmd})) { if($cmd eq "cmd" && defined($attr{$name}{pathCmd})) {
@ -348,10 +351,11 @@ IPCAM_getSnapshot($) {
$camQuery = $attr{$name}{query} $camQuery = $attr{$name}{query}
if(defined($attr{$name}{query}) && $attr{$name}{query} ne ""); if(defined($attr{$name}{query}) && $attr{$name}{query} ne "");
my $scheme = IPCAM_getScheme($hash);
if($basicauth) { if($basicauth) {
$camURI = "http://$basicauth" . "@" . "$camAuth/$camPath"; $camURI = "$scheme://$basicauth" . "@" . "$camAuth/$camPath";
} else { } else {
$camURI = "http://$camAuth/$camPath"; $camURI = "$scheme://$camAuth/$camPath";
} }
$camURI .= "?$camQuery" if($camQuery); $camURI .= "?$camQuery" if($camQuery);
@ -439,6 +443,15 @@ IPCAM_getSnapshot($) {
return undef; return undef;
} }
#####################################
sub
IPCAM_getScheme($) {
my ($hash) = @_;
my $name = $hash->{NAME};
return AttrVal($name, 'scheme', 'http');
}
##################################### #####################################
sub sub
IPCAM_guessFileFormat($) { IPCAM_guessFileFormat($) {
@ -472,6 +485,8 @@ IPCAM_guessFileFormat($) {
1; 1;
=pod =pod
=item summary network camera device to trigger snapshots on events
=item summary_DE Anbindung von Netzwerkkameras um snapshots auszulösen
=begin html =begin html
<a name="IPCAM"></a> <a name="IPCAM"></a>
@ -729,6 +744,14 @@ IPCAM_guessFileFormat($) {
<code>attr ipcam3 pathPanTilt decoder_control.cgi?user={USERNAME}&amp;pwd={PASSWORD}</code> <code>attr ipcam3 pathPanTilt decoder_control.cgi?user={USERNAME}&amp;pwd={PASSWORD}</code>
</li> </li>
<li><a href="#showtime">showtime</a></li> <li><a href="#showtime">showtime</a></li>
<li>
scheme<br>
Defines the URI-Scheme for generating the download path.<br>
If this attribute is not defined, then the default value is http.
Default: <code>http</code><br>
Example:<br>
<code>attr ipcam3 scheme https</code>
</li>
<li> <li>
snapshots<br> snapshots<br>
Defines the total number of snapshots to be taken with the <code>get &lt;name&gt; image</code> command. Defines the total number of snapshots to be taken with the <code>get &lt;name&gt; image</code> command.