From f41d22d78bcf08d1ee5a81557e573f203d3ce82b Mon Sep 17 00:00:00 2001 From: nasseeder1 <> Date: Thu, 28 Jan 2016 14:35:00 +0000 Subject: [PATCH] 49_SSCam: fixed the problem a recording may still stay active if fhem will be restarted after a recording was triggered and the recordtime wasn't be over, Enhancement of readings. git-svn-id: https://svn.fhem.de/fhem/trunk@10649 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/CHANGED | 4 +++ fhem/FHEM/49_SSCam.pm | 67 ++++++++++++++++++++++++++++++++++--------- 2 files changed, 57 insertions(+), 14 deletions(-) diff --git a/fhem/CHANGED b/fhem/CHANGED index 095ad2d61..cbe2b6b0d 100644 --- a/fhem/CHANGED +++ b/fhem/CHANGED @@ -1,5 +1,9 @@ # 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. + - bugfix: 49_SSCam: fixed the problem a recording may still stay active if + fhem will be restarted after a recording was triggered and + the recordtime wasn't be over, + Enhancement of readings. - change: 76_MSGMail: move email delivery from MSGMail_set to MSGMail_send to be usable from perl; use Blocking_Call to deliver email - change: 55_GDS.pm uses setKeyValue/getKeyValue for user credentials diff --git a/fhem/FHEM/49_SSCam.pm b/fhem/FHEM/49_SSCam.pm index 49f06500e..94323427b 100644 --- a/fhem/FHEM/49_SSCam.pm +++ b/fhem/FHEM/49_SSCam.pm @@ -27,6 +27,10 @@ ########################################################################################################## # Versions History: # +# 1.9 28.01.2016 fixed the problem a recording may still stay active if fhem +# will be rebooted after a recording was triggered and +# the recordtime wasn't be over, +# Enhancement of readings. # 1.8 25.01.2016 changed define in order to remove credentials from string, # added "set credentials" command to save username/password, # added Attribute "session" to make login-session selectable, @@ -77,8 +81,7 @@ sub SSCam_Initialize($) { $hash->{UndefFn} = "SSCam_Undef"; $hash->{SetFn} = "SSCam_Set"; $hash->{GetFn} = "SSCam_Get"; - $hash->{AttrFn} = "SSCam_Attr"; - + $hash->{AttrFn} = "SSCam_Attr"; $hash->{AttrList} = "httptimeout ". @@ -87,9 +90,9 @@ sub SSCam_Initialize($) { "rectime ". "session:SurveillanceStation,DSM ". "webCmd ". - $readingFnAttributes; - - return undef; + $readingFnAttributes; + +return undef; } sub SSCam_Define { @@ -127,19 +130,17 @@ sub SSCam_Define { $attr{$name}{webCmd} = "on:off:snap:enable:disable"; # initiale Webkommandos setzen $hash->{HELPER}{ACTIVE} = "off"; # Funktionstoken "off", Funktionen können sofort starten $hash->{HELPER}{OLDVALPOLLNOLOGGING} = "0"; # Loggingfunktion für Polling ist an - $hash->{STATE} = "initialized"; # Anfangsstatus der Geräte $hash->{HELPER}{RECTIME_DEF} = "15"; # Standard für rectime setzen, überschreibbar durch Attribut "rectime" bzw. beim "set .. on-for-time" - readingsSingleUpdate($hash,"Record","Stop",0); # Recordings laufen nicht readingsSingleUpdate($hash,"Availability", "", 0); # Verfügbarkeit ist unbekannt readingsSingleUpdate($hash,"PollState","Inactive",0); # es ist keine Gerätepolling aktiv getcredentials($hash,1); # Credentials lesen und in RAM laden ($boot=1) RemoveInternalTimer($hash); # alle Timer löschen - # Subroutine Watchdog-Timer starten (sollen Cam-Infos abgerufen werden ?), verzögerter zufälliger Start 0-60s InternalTimer(gettimeofday()+int(rand(60)), "watchdogpollcaminfo", $hash, 0); - + recstoponboot($hash); # check ob nach Reboot alle Recordings aus -> sonst stoppen + return undef; } @@ -243,8 +244,6 @@ sub SSCam_Set { ($success) = setcredentials($hash,$prop,$prop1); return $success ? "Username and Password saved successfully" : "Error while saving Username / Password - see logfile for details"; } - - } return undef; } @@ -273,11 +272,33 @@ sub SSCam_Get { { &getcaminfoall($hash); } - } return undef; } + +###################################################################################### +### check ob alle Recordings = Stop nach Reboot -> sonst stoppen + +sub recstoponboot ($) { + my ($hash) = @_; + my $logstr; + + if ($init_done == 1) { + if (ReadingsVal($hash->{NAME}, "Record", "Stop") eq "Start") { + # if ($hash->{STATE} eq "on") { + $logstr = "Recording of $hash->{CAMNAME} seems to be still active after FHEM restart - try to stop it now"; + &printlog($hash,$logstr,"1"); + &camstoprec($hash); + } + } + else { + InternalTimer(gettimeofday(), "recstoponboot", $hash, 0); + } + +return undef; +} + ###################################################################################### ### Username / Paßwort speichern @@ -1515,12 +1536,12 @@ sub camret_nonbl ($) { if ($OpMode eq "Start") { - # bedingt Browseraktualisierung und Status der "Lampen" $hash->{STATE} = "on"; # Setreading readingsBeginUpdate($hash); readingsBulkUpdate($hash,"Record","Start"); + # readingsBulkUpdate($hash,"state","on"); readingsBulkUpdate($hash,"Errorcode","none"); readingsBulkUpdate($hash,"Error","none"); readingsEndUpdate($hash, 1); @@ -1671,17 +1692,29 @@ sub camret_nonbl ($) { else { $camStatus = "other"; } + + my $recStatus = $data->{'data'}->{'cameras'}->[0]->{'recStatus'}; + if ($recStatus ne "0") { + $recStatus = "Start"; + } + else { + $recStatus = "Stop"; + } # Setreading readingsBeginUpdate($hash); readingsBulkUpdate($hash,"CamLiveMode",$camLiveMode); + readingsBulkUpdate($hash,"CamModel",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camModel'}); readingsBulkUpdate($hash,"CamRecShare",$data->{'data'}->{'cameras'}->[0]->{'camRecShare'}); readingsBulkUpdate($hash,"CamRecVolume",$data->{'data'}->{'cameras'}->[0]->{'camRecVolume'}); readingsBulkUpdate($hash,"CamIP",$data->{'data'}->{'cameras'}->[0]->{'host'}); + readingsBulkUpdate($hash,"CamVendor",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camVendor'}); + readingsBulkUpdate($hash,"CamPreRecTime",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camPreRecTime'}); readingsBulkUpdate($hash,"CamPort",$data->{'data'}->{'cameras'}->[0]->{'port'}); readingsBulkUpdate($hash,"Availability",$camStatus); readingsBulkUpdate($hash,"DeviceType",$deviceType); readingsBulkUpdate($hash,"LastUpdateTime",$update_time); + readingsBulkUpdate($hash,"Record",$recStatus); readingsBulkUpdate($hash,"UsedSpaceMB",$data->{'data'}->{'cameras'}->[0]->{'volume_space'}); readingsBulkUpdate($hash,"Errorcode","none"); readingsBulkUpdate($hash,"Error","none"); @@ -2435,9 +2468,12 @@ return;
  • Availability
  • - Availability of Camera (disabled, enabled, disconnected, other)
  • CamIP
  • - IP-Address of Camera
  • CamLiveMode
  • - Source of Live-View (DS, Camera) +
  • CamModel
  • - Model of camera
  • CamPort
  • - IP-Port of Camera +
  • CamPreRecTime
  • - Duration of Pre-Recording (in seconds) adjusted in SVS
  • CamRecShare
  • - shared folder on disk station for recordings
  • CamRecVolume
  • - Volume on disk station for recordings +
  • CamVendor
  • - Identifier of camera producer
  • CapAudioOut
  • - Capability to Audio Out over Surveillance Station (false/true)
  • CapChangeSpeed
  • - Capability to various motion speed
  • CapPTZAbs
  • - Capability to perform absolute PTZ action @@ -2793,9 +2829,12 @@ return;
  • Availability
  • - Verfügbarkeit der Kamera (disabled, enabled, disconnected, other)
  • CamIP
  • - IP-Adresse der Kamera
  • CamLiveMode
  • - Quelle für Live-Ansicht (DS, Camera) +
  • CamModel
  • - Kameramodell
  • CamPort
  • - IP-Port der Kamera +
  • CamPreRecTime
  • - Dauer der der Voraufzeichnung in Sekunden (Einstellung in SVS)
  • CamRecShare
  • - gemeinsamer Ordner auf der DS für Aufnahmen
  • CamRecVolume
  • - Volume auf der DS für Aufnahmen +
  • CamVendor
  • - Kamerahersteller Bezeichnung
  • CapAudioOut
  • - Fähigkeit der Kamera zur Audioausgabe über Surveillance Station (false/true)
  • CapChangeSpeed
  • - Fähigkeit der Kamera verschiedene Bewegungsgeschwindigkeiten auszuführen
  • CapPTZAbs
  • - Fähigkeit der Kamera für absolute PTZ-Aktionen @@ -2810,7 +2849,7 @@ return;
  • DeviceType
  • - Kameratyp (Camera, Video_Server, PTZ, Fisheye)
  • Error
  • - Meldungstext des letzten Fehlers
  • Errorcode
  • - Fehlercode des letzten Fehlers -
  • LastUpdateTime
  • - Datum / Zeit der letzten Aktualisierung der Kamera in der Surrveillance Station +
  • LastUpdateTime
  • - Datum / Zeit der letzten Aktualisierung der Kamera in der Synology Surveillance Station
  • Patrols
  • - in Surveillance Station voreingestellte Überwachungstouren (bei PTZ-Kameras)
  • PollState
  • - zeigt den Status des automatischen Pollings an
  • Presets
  • - in Surveillance Station voreingestellte Positionen (bei PTZ-Kameras)