From 36d6050955f7b8aa79dd5a59a3b0c3c5e82733cc Mon Sep 17 00:00:00 2001 From: nasseeder1 Date: Tue, 12 Jun 2018 17:07:37 +0000 Subject: [PATCH] 49_SSCamSTRM: new attribute "forcePageRefresh" for better control of page refresh (for e.g. Floorplan,Dashboard) git-svn-id: https://svn.fhem.de/fhem/trunk@16855 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 2 ++ fhem/FHEM/49_SSCam.pm | 49 ++++++++++++++++++----------- fhem/FHEM/49_SSCamSTRM.pm | 66 ++++++++++++++++++++++++++++++--------- 3 files changed, 85 insertions(+), 32 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index bf110905d..0ae8a0205 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,7 @@ # 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. + - change: 49_SSCamSTRM: new attribute "forcePageRefresh" for better control + of page refresh (for e.g. Floorplan,Dashboard) - feature: 89_FULLY: Added screen saver commands. - feature: 49_SSCam: V5.0.0, HLS Streaming implemented, new Streamingdevice based on module 49_SSCamSTRM, some improvements & fixes diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index 02ddc49a5..b2a6e3d40 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,7 @@ ######################################################################################################################### # Versions History: # +# 5.0.1 12.06.2018 control of page refresh improved (for e.g. Floorplan,Dashboard) # 5.0.0 11.06.2018 HLS Streaming, Buttons for Streaming-Devices, use of module SSCamSTRM for Streaming-Devices, # deletion of Streaming-devices if SSCam-device is deleted, some more improvements, minor bugfixes # 4.3.0 27.05.2018 HLS preparation changed @@ -229,7 +230,7 @@ use Time::HiRes; use HttpUtils; # no if $] >= 5.017011, warnings => 'experimental'; -my $SSCamVersion = "5.0.0"; +my $SSCamVersion = "5.0.1"; # Aufbau Errorcode-Hashes (siehe Surveillance Station Web API) my %SSCam_errauthlist = ( @@ -887,7 +888,7 @@ sub SSCam_Set($@) { } elsif ($opt eq "runView" && SSCam_IsModelCam($hash)) { if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";} - + if ($prop eq "live_open") { if ($prop1) {$hash->{HELPER}{VIEWOPENROOM} = $prop1;} else {delete $hash->{HELPER}{VIEWOPENROOM};} $hash->{HELPER}{OPENWINDOW} = 1; @@ -2027,7 +2028,7 @@ sub SSCam_runliveview($) { if (AttrVal($name,"debugactivetoken",0)) { Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}"); } - readingsSingleUpdate($hash,"state","startview",1); + readingsSingleUpdate($hash,"state","runView ".$hash->{HELPER}{RUNVIEW},1); SSCam_getapisites($hash); } else { @@ -5390,23 +5391,33 @@ return($hash,$success,$myjson); ############################################################################### # Refresh eines Raumes aus $hash->{HELPER}{STRMROOM} # bzw. Longpoll -# $hash, $pload (1=page reload), $longpoll (1=Event) +# $hash, $pload (1=Page reload), $longpoll (1=Event) ############################################################################### sub SSCam_refresh($$$) { my ($hash,$pload,$longpoll) = @_; - my $name = $hash->{NAME}; + my $name = $hash->{NAME}; + my $fpr = 0; - my $r = $hash->{HELPER}{STRMROOM}?$hash->{HELPER}{STRMROOM}:""; - Log3($name, 5, "$name - room for refresh: $r"); + # my $r = $hash->{HELPER}{STRMROOM}?$hash->{HELPER}{STRMROOM}:""; + # Kontext des SSCamSTRM-Devices speichern für SSCam_refresh + my $sd = defined($hash->{HELPER}{STRMDEV})?$hash->{HELPER}{STRMDEV}:"\"not defined\""; # Name des aufrufenden SSCamSTRM-Devices + my $sr = defined($hash->{HELPER}{STRMROOM})?$hash->{HELPER}{STRMROOM}:"\"not defined\""; # Raum aus dem das SSCamSTRM-Device die Funktion aufrief + my $sl = defined($hash->{HELPER}{STRMDETAIL})?$hash->{HELPER}{STRMDETAIL}:"\"not defined\""; # Name des SSCamSTRM-Devices (wenn Detailansicht) + $fpr = AttrVal($hash->{HELPER}{STRMDEV},"forcePageRefresh",0) if(defined $hash->{HELPER}{STRMDEV}); + Log3($name, 4, "$name - SSCam_refresh - caller: $sd, callerroom: $sr, detail: $sl, forcePageRefresh: $fpr"); - if($pload) { - if($hash->{HELPER}{STRMROOM} && $hash->{HELPER}{STRMROOM} !~ /^detail=.*$/) { - # Raumrefresh + if($pload && defined($hash->{HELPER}{STRMROOM}) && defined($hash->{HELPER}{STRMDETAIL})) { + if($hash->{HELPER}{STRMROOM} && !$hash->{HELPER}{STRMDETAIL} && !$fpr) { + # trifft zu wenn in einer Raumansicht my @rooms = split(",",$hash->{HELPER}{STRMROOM}); foreach (@rooms) { my $room = $_; - { map { FW_directNotify("FILTER=room=$room", "#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("WEB.*") } + { map { FW_directNotify("FILTER=room=$room", "#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") } } + } elsif ( !$hash->{HELPER}{STRMROOM} || $hash->{HELPER}{STRMDETAIL} || $fpr ) { + # trifft zu bei Detailansicht oder im FLOORPLAN bzw. Dashboard oder wenn Seitenrefresh mit dem + # SSCamSTRM-Attribut "forcePageRefresh" erzwungen wird + { map { FW_directNotify("#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") } } } @@ -5687,7 +5698,7 @@ return; # Methode: GetLiveViewPath ###################################################################################### sub SSCam_StreamDev($$$) { - my ($camname,$livdev,$fmt) = @_; + my ($camname,$strmdev,$fmt) = @_; my $hash = $defs{$camname}; my $wltype = $hash->{HELPER}{WLTYPE}; my $serveraddr = $hash->{SERVERADDR}; @@ -5705,17 +5716,19 @@ sub SSCam_StreamDev($$$) { my $sid = $hash->{HELPER}{SID}; my ($cause,$ret,$link,$audiolink,$devWlink,$wlhash,$alias,$wlalias); - # den Raum/Räume des Streamingdevice speichern für Refresh - $hash->{HELPER}{STRMROOM} = AttrVal($livdev,"room",undef)?AttrVal($livdev,"room",undef):$FW_webArgs{room}; + # Kontext des SSCamSTRM-Devices speichern für SSCam_refresh + $hash->{HELPER}{STRMDEV} = $strmdev; # Name des aufrufenden SSCamSTRM-Devices + $hash->{HELPER}{STRMROOM} = $FW_room?$FW_room:""; # Raum aus dem das SSCamSTRM-Device die Funktion aufrief + $hash->{HELPER}{STRMDETAIL} = $FW_detail?$FW_detail:""; # Name des SSCamSTRM-Devices (wenn Detailansicht) my $ha = AttrVal($camname, "htmlattr", 'width="500" height="325"'); # HTML Attribute der Cam - $ha = AttrVal($livdev, "htmlattr", $ha); # htmlattr mit htmattr Streaming-Device übersteuern + $ha = AttrVal($strmdev, "htmlattr", $ha); # htmlattr mit htmattr Streaming-Device übersteuern my $hlslfw = (ReadingsVal($camname,"CamStreamFormat","MJPEG") eq "HLS")?"live_fw_hls,":undef; my $StmKey = ReadingsVal($camname,"StmKey",undef); - $wlalias = AttrVal($livdev, "alias", $livdev); # Linktext als Aliasname oder Devicename setzen - $devWlink = "$wlalias"; - $wlhash = $defs{$livdev}; + $wlalias = AttrVal($strmdev, "alias", $strmdev); # Linktext als Aliasname oder Devicename setzen + $devWlink = "$wlalias"; + $wlhash = $defs{$strmdev}; # Document Division $ret = sprintf("
$devWlink"); diff --git a/fhem/FHEM/49_SSCamSTRM.pm b/fhem/FHEM/49_SSCamSTRM.pm index 597a3303a..99168367e 100644 --- a/fhem/FHEM/49_SSCamSTRM.pm +++ b/fhem/FHEM/49_SSCamSTRM.pm @@ -28,6 +28,7 @@ ######################################################################################################################### # Versions History: # +# 0.3 12.06.2018 new attribute "forcePageRefresh" # 0.2 11.06.2018 check in with SSCam 5.0.0 # 0.1 10.06.2018 initial Version @@ -38,14 +39,14 @@ use strict; use warnings; use vars qw($FW_subdir); # Sub-path in URL for extensions, e.g. 95_FLOORPLAN -my $SSCamSTRMVersion = "0.2"; +my $SSCamSTRMVersion = "0.3"; ################################################################ sub SSCamSTRM_Initialize($) { my ($hash) = @_; $hash->{DefFn} = "SSCamSTRM_Define"; - $hash->{AttrList} = "disable:0,1 htmlattr "; + $hash->{AttrList} = "disable:1,0 forcePageRefresh:1,0 htmlattr "; $hash->{FW_summaryFn} = "SSCamSTRM_FwFn"; $hash->{FW_detailFn} = "SSCamSTRM_FwFn"; $hash->{FW_atPageEnd} = 1; @@ -131,22 +132,40 @@ return $ret; Get
- + Attributes +

-
@@ -174,19 +193,38 @@ return $ret; Attributes +

-
+