49_SSCam.pm 456 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159
  1. ########################################################################################################################
  2. # $Id: 49_SSCam.pm 17654 2018-10-31 22:44:31Z DS_Starter $
  3. #########################################################################################################################
  4. # 49_SSCam.pm
  5. #
  6. # (c) 2015-2018 by Heiko Maaz
  7. # e-mail: Heiko dot Maaz at t-online dot de
  8. #
  9. # This Module can be used to operate Cameras defined in Synology Surveillance Station 7.0 or higher.
  10. # It's based on and uses Synology Surveillance Station API.
  11. #
  12. # This script is part of fhem.
  13. #
  14. # Fhem is free software: you can redistribute it and/or modify
  15. # it under the terms of the GNU General Public License as published by
  16. # the Free Software Foundation, either version 2 of the License, or
  17. # (at your option) any later version.
  18. #
  19. # Fhem is distributed in the hope that it will be useful,
  20. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. # GNU General Public License for more details.
  23. #
  24. # You should have received a copy of the GNU General Public License
  25. # along with fhem. If not, see <http://www.gnu.org/licenses/>.
  26. #
  27. #########################################################################################################################
  28. #
  29. # Definition: define <name> SSCam <camname> <ServerAddr> [ServerPort] [Protocol]
  30. #
  31. # Example of defining a Cam-device: define CamCP1 SSCAM Carport 192.168.2.20 [5000] [HTTP(S)]
  32. # Example of defining a SVS-device: define SDS1 SSCAM SVS 192.168.2.20 [5000] [HTTP(S)]
  33. #
  34. package main;
  35. use strict;
  36. use warnings;
  37. eval "use JSON qw( decode_json );1;" or my $SScamMMDBI = "JSON"; # Debian: apt-get install libjson-perl
  38. use Data::Dumper; # Perl Core module
  39. use MIME::Base64;
  40. use Time::HiRes;
  41. use HttpUtils;
  42. # no if $] >= 5.017011, warnings => 'experimental';
  43. # Versions History intern
  44. our %SSCam_vNotesIntern = (
  45. "7.3.1" => "31.10.2018 fix connection lost failure if several SSCamSTRM devices are defined and updated by longpoll from same parent device ",
  46. "7.3.0" => "28.10.2018 usage of attribute \"livestreamprefix\" changed, exec SSCam_getStmUrlPath on boot ",
  47. "7.2.1" => "23.10.2018 new routine SSCam_versionCheck, COMPATIBILITY changed to 8.2.1 ",
  48. "7.2.0" => "20.10.2018 direct help for attributes, new get versionNotes command, fix PERL WARNING: Use of uninitialized value \$small, get versionNotes ",
  49. "7.1.1" => "18.10.2018 Message of \"Your current/simulated SVS-version...\" changed, commandref corrected ",
  50. "7.1.0" => "02.09.2018 PIR Sensor enable/disable, SSCam_Set/SSCam_Get optimized ",
  51. "7.0.1" => "27.08.2018 enable/disable issue (https://forum.fhem.de/index.php/topic,45671.msg830869.html#msg830869) ",
  52. "7.0.0" => "27.07.2018 compatibility to API v2.8 ",
  53. "6.0.1" => "04.07.2018 Reading CamFirmware ",
  54. "6.0.0" => "03.07.2018 HTTPS Support, buttons for refresh SSCamSTRM-devices ",
  55. "5.3.0" => "29.06.2018 changes regarding to \"createStreamDev ... generic\", refresh reading parentState of all, SSCamSTRM devices with PARENT=SSCam-device, control elements for runView within fhemweb, new CamLive.*-Readings, minor fixes ",
  56. "5.2.7" => "26.06.2018 fix state turns to \"off\" even though cam is disabled ",
  57. "5.2.6" => "20.06.2018 running stream as human readable entry for SSCamSTRM-Device, goAbsPTZ fix set-entry für non-PTZ ",
  58. "5.2.5" => "18.06.2018 trigger lastsnap_fw to SSCamSTRM-Device only if snap was done by it. ",
  59. "5.2.4" => "17.06.2018 SSCam_composegallery added and write warning if old composegallery-weblink device is used ",
  60. "5.2.3" => "16.06.2018 no SSCamSTRM refresh when snapgetinfo was running without taken a snap by SSCamSTRM-Device ",
  61. "5.2.2" => "16.06.2018 compatibility to SSCamSTRM V 1.1.0 ",
  62. "5.2.1" => "14.06.2018 design change of SSCam_StreamDev, change in event generation for SSCam_StreamDev, fix global vars ",
  63. "5.2.0" => "14.06.2018 support longpoll refresh of SSCamSTRM-Devices ",
  64. "5.1.0" => "13.06.2018 more control elements (Start/Stop Recording, Take Snapshot) in func SSCam_StreamDev, control of detaillink is moved to SSCamSTRM-device ",
  65. "5.0.1" => "12.06.2018 control of page refresh improved (for e.g. Floorplan,Dashboard) ",
  66. "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 ",
  67. "4.3.0" => "27.05.2018 HLS preparation changed ",
  68. "4.2.0" => "22.05.2018 PTZ-Panel integrated to created StreamDevice ",
  69. "4.1.0" => "05.05.2018 use SYNO.SurveillanceStation.VideoStream instead of SYNO.SurveillanceStation.VideoStreaming, preparation for hls ",
  70. "4.0.0" => "01.05.2018 AudioStream possibility added ",
  71. "3.10.0" => "24.04.2018 createStreamDev added, new features lastrec_fw_MJPEG, lastrec_fw_MPEG4/H.264 added to playback MPEG4/H.264 videos ",
  72. "3.9.2" => "21.04.2018 minor fixes ",
  73. "3.9.1" => "20.04.2018 Attribute ptzPanel_use, initial webcommands in DeviceOverview changed, minor fixes ptzPanel ",
  74. "3.9.0" => "17.04.2018 control panel & PTZcontrol weblink device for PTZ cams ",
  75. "3.8.4" => "06.04.2018 Internal MODEL changed to SVS or \"CamVendor - CamModel\" for Cams ",
  76. "3.8.3" => "05.04.2018 bugfix V3.8.2, \$OpMode \"Start\" changed, composegallery changed ",
  77. "3.8.2" => "04.04.2018 \$attr replaced by AttrVal, SSCam_wdpollcaminfo redesigned ",
  78. "3.8.1" => "04.04.2018 some codereview like new sub SSCam_jboolmap ",
  79. "3.8.0" => "03.04.2018 new reading PresetHome, setHome command, minor fixes ",
  80. "3.7.0" => "26.03.2018 minor details of setPreset changed, new command delPreset ",
  81. "3.6.0" => "25.03.2018 setPreset command, changed SSCam_wdpollcaminfo, SSCam_getcaminfoall ",
  82. "3.5.0" => "22.03.2018 new get command listPresets ",
  83. "3.4.0" => "21.03.2018 new commands startTracking, stopTracking ",
  84. "3.3.1" => "20.03.2018 new readings CapPTZObjTracking, CapPTZPresetNumber ",
  85. "3.3.0" => "25.02.2018 code review, API bug fix of runview lastrec, commandref revised (forum:#84953) ",
  86. "1.0.0" => "12.12.2015 initial, changed completly to HttpUtils_NonblockingGet "
  87. );
  88. # Versions History extern
  89. our %SSCam_vNotesExtern = (
  90. "7.3.0" => "28.10.2018 In attribute \"livestreamprefix\" can now \"DEF\" be specified to overwrite livestream address by specification from device definition ",
  91. "7.2.1" => "23.10.2018 COMPATIBILITY changed to 8.2.1 ",
  92. "7.2.0" => "20.10.2018 direct help for attributes, new get versionNotes command, please see commandref for details ",
  93. "7.1.1" => "18.10.2018 Message of \"current/simulated SVS-version...\" changed, commandref corrected ",
  94. "7.1.0" => "02.09.2018 PIR Sensor enable/disable, SSCam_Set/SSCam_Get optimized ",
  95. "7.0.1" => "27.08.2018 enable/disable issue (https://forum.fhem.de/index.php/topic,45671.msg830869.html#msg830869) ",
  96. "7.0.0" => "27.07.2018 compatibility to API v2.8 ",
  97. "6.0.1" => "04.07.2018 Reading CamFirmware ",
  98. "6.0.0" => "03.07.2018 HTTPS Support, buttons for refresh SSCamSTRM-devices ",
  99. "5.2.7" => "26.06.2018 fix state turns to \"off\" even though cam is disabled ",
  100. "5.2.5" => "18.06.2018 trigger lastsnap_fw to SSCamSTRM-Device only if snap was done by it. ",
  101. "5.2.4" => "17.06.2018 SSCam_composegallery added and write warning if old composegallery-weblink device is used ",
  102. "5.2.2" => "16.06.2018 compatibility to SSCamSTRM V 1.1.0 ",
  103. "5.2.1" => "14.06.2018 design change of SSCam_StreamDev, change in event generation for SSCam_StreamDev, fix global vars ",
  104. "5.2.0" => "14.06.2018 support longpoll refresh of SSCamSTRM-Devices ",
  105. "5.1.0" => "13.06.2018 more control elements (Start/Stop Recording, Take Snapshot) in func SSCam_StreamDev, control of detaillink is moved to SSCamSTRM-device ",
  106. "5.0.1" => "12.06.2018 control of page refresh improved (for e.g. Floorplan,Dashboard) ",
  107. "4.2.0" => "22.05.2018 PTZ-Panel integrated to created StreamDevice ",
  108. "4.0.0" => "01.05.2018 AudioStream possibility added ",
  109. "3.10.0" => "24.04.2018 createStreamDev added, new features lastrec_fw_MJPEG, lastrec_fw_MPEG4/H.264 added to playback MPEG4/H.264 videos ",
  110. "3.9.1" => "20.04.2018 Attribute ptzPanel_use, initial webcommands in DeviceOverview changed, minor fixes ptzPanel ",
  111. "3.9.0" => "17.04.2018 control panel & PTZcontrol weblink device for PTZ cams ",
  112. "3.8.4" => "06.04.2018 Internal MODEL changed to SVS or \"CamVendor - CamModel\" for Cams ",
  113. "3.8.3" => "05.04.2018 bugfix V3.8.2, \$OpMode \"Start\" changed, composegallery changed ",
  114. "3.6.0" => "25.03.2018 setPreset command ",
  115. "3.5.0" => "22.03.2018 new get command listPresets ",
  116. "3.4.0" => "21.03.2018 new commands startTracking, stopTracking ",
  117. "3.3.1" => "20.03.2018 new readings CapPTZObjTracking, CapPTZPresetNumber ",
  118. "3.3.0" => "25.02.2018 code review, API bug fix of runview lastrec, commandref revised (forum:#84953) ",
  119. "3.2.4" => "18.11.2017 fix bug don't retrieve SSCam_getptzlistpreset if cam is disabled ",
  120. "3.2.3" => "08.10.2017 set optimizeParams, get caminfo (simple), minor bugfix, commandref revised ",
  121. "3.2.0" => "27.09.2017 new command get listLog, change to \$hash->{HELPER}{\".SNAPHASH\"} for avoid huge \"list\"-report ",
  122. "3.1.0" => "26.09.2017 move extevent from CAM to SVS model, Reading PollState enhanced for CAM-Model, minor fixes ",
  123. "3.0.0" => "23.09.2017 Internal MODEL SVS or CAM -> distinguish/support Cams and SVS in different devices new comand get storedCredentials, commandref revised ",
  124. "2.9.0" => "20.09.2017 new function get homeModeState, minor fixes at simu_SVSversion, commandref revised ",
  125. "2.6.0" => "06.08.2017 new command createSnapGallery ",
  126. "2.5.4" => "05.08.2017 analyze \$hash->{CL} in SetFn bzw. GetFn, set snapGallery only if snapGalleryBoost=1 is set, some snapGallery improvements and fixes ",
  127. "2.5.3" => "02.08.2017 implement snapGallery as set-command ",
  128. "2.2.2" => "11.06.2017 bugfix SSCam_login, SSCam_login_return, Forum: https://forum.fhem.de/index.php/topic,45671.msg646701.html#msg646701 ",
  129. "1.39.0" => "20.01.2017 compatibility to SVS 8.0.0, Version in Internals, execute SSCam_getsvsinfo after set credentials ",
  130. "1.37.0" => "10.10.2016 bugfix Experimental keys on scalar is now forbidden (Perl >= 5.23) (Forum: #msg501709) ",
  131. "1.34.0" => "15.09.2016 simu_SVSversion changed, added 407 errorcode message, external recording changed for SVS 7.2 ",
  132. "1.33.0" => "21.08.2016 function get stmUrlPath added, fit to new commandref style, attribute showStmInfoFull added ",
  133. "1.31.0" => "15.08.2016 Attr \"noQuotesForSID\" added, avoid possible 402 - permission denied problems in some SVS/DS-combinations ",
  134. "1.28.0" => "30.06.2016 Attr \"showPassInLog\" added, per default no password will be shown in log ",
  135. "1.27.0" => "29.06.2016 Attr \"simu_SVSversion\" added, sub login_nonbl changed, sub camret_nonbl changed (getlistptzpreset) due to 7.2 problem ",
  136. "1.26.2" => "05.05.2016 change: get \"snapfileinfo\" will get back an Infomessage if Reading \"LastSnapId\" isn't available ",
  137. "1.26.1" => "27.04.2016 bugfix module will not load due to Unknown warnings category 'experimental' when using an older perl version ",
  138. "1.26.0" => "22.04.2016 Attribute \"disable\" to deactivate the module added ",
  139. "1.25.0" => "18.04.2016 motion detection parameters can be entered if motion detection by camera or SVS is used ",
  140. "1.24.0" => "16.04.2016 behavior of \"set ... on\" changed, Attr \"recextend\" added, bugfix: setstate-warning if FHEM will restarted and SVS is not reachable (Forum: #308) ",
  141. "1.22.0" => "27.03.2016 bugfix \"link_open\" doesn't work after last update ",
  142. "1.21.0" => "23.03.2016 added \"lastrec\", \"lastrec_open\" to playback last recording ",
  143. "1.20.0" => "09.03.2016 command \"extevent\" added ",
  144. "1.19.3" => "07.03.2016 bugfix \"uninitialized value \$lastrecstarttime\", \"uninitialized value \$lastrecstoptime\", new attribute \"videofolderMap\" ",
  145. "1.19.2" => "06.03.2016 Reading \"CamLastRec\" added which contains Path/name of last recording ",
  146. "1.19.1" => "28.02.2016 enhanced command runView by option \"link_open\" to open a streamlink immediately ",
  147. "1.19.0" => "25.02.2016 functions for cam-livestream added ",
  148. "1.18.1" => "21.02.2016 fixed a problem that the state is \"disable\" instead of \"disabled\" if a camera is disabled and FHEM will be restarted ",
  149. "1.18.0" => "20.02.2016 function \"get ... eventlist\" added, Reading \"CamEventNum\" added which containes total number of camera events, change usage of reading \"LastUpdateTime\" ",
  150. "1.17.0" => "19.02.2016 function \"runPatrol\" added that starts predefined patrols of PTZ-cameras, Reading \"CamDetMotSc\" added ",
  151. "1.16.0" => "16.02.2016 set up of motion detection source now possible ",
  152. "1.15.0" => "15.02.2016 control of exposure mode day, night & auto is possible now ",
  153. "1.14.0" => "14.02.2016 The port in DEF-String is optional now, if not given, default port 5000 is used ",
  154. "1.13.2" => "13.02.2016 fixed a problem that manual updates using \"getcaminfoall\" are leading to additional pollingloops if polling is used, attribute \"debugactivetoken\" added for debugging-use ",
  155. "1.13.1" => "12.02.2016 fixed a problem that a usersession won't be destroyed if a function couldn't be executed successfully ",
  156. "1.12.0" => "08.02.2016 added function \"move\" for continuous PTZ action ",
  157. "1.11.0" => "05.02.2016 added function \"goPreset\" and \"goAbsPTZ\" to control the move of PTZ lense to absolute positions (http://forum.fhem.de/index.php/topic,45671.msg404275.html#msg404275), (http://forum.fhem.de/index.php/topic,45671.msg404892.html#msg404892) ",
  158. "1.10.0" => "02.02.2016 added function \"svsinfo\" to get informations about installed SVS-package, if Availability = \"disconnected\" then \"state\"-value will be \"disconnected\" too, saved Credentials were deleted from file if a device will be deleted ",
  159. "1.7.0" => "18.01.2016 Attribute \"httptimeout\" added ",
  160. "1.6.0" => "16.01.2016 Change the define-string related to rectime. (http://forum.fhem.de/index.php/topic,45671.msg391664.html#msg391664) ",
  161. "1.5.1" => "11.01.2016 Vars \"USERNAME\" and \"RECTIME\" removed from internals, Var (Internals) \"SERVERNAME\" changed to \"SERVERADDR\" ",
  162. "1.5.0" => "04.01.2016 Function \"Get\" for creating Camera-Readings integrated, Attributs pollcaminfoall, pollnologging added, Function for Polling Cam-Infos added. ",
  163. "1.4.0" => "23.12.2015 function \"enable\" and \"disable\" for SS-Cams added, changed timout of Http-calls to a higher value ",
  164. "1.3.0" => "19.12.2015 function \"snap\" for taking snapshots added, fixed a bug that functions may impact each other ",
  165. "1.0.0" => "12.12.2015 initial, changed completly to HttpUtils_NonblockingGet "
  166. );
  167. # Hint Hash en
  168. our %SSCam_vHintsExt_en = (
  169. "5" => "Find more Informations about manage users and the appropriate privilege profiles in ".
  170. "<a href=\"https://www.synology.com/en-global/knowledgebase/Surveillance/help/SurveillanceStation/user\">Surveillance Station online help</a> ",
  171. "4" => "The message Meldung \"WARNING - The current/simulated SVS-version ... may be incompatible with SSCam version...\" means that ".
  172. "the used SSCam version was currently not tested with the installed version of Synology Surveillance Station (Reading \"SVSversion\"). ".
  173. "The compatible SVS-Version is printed out in the Internal COMPATIBILITY.\n".
  174. "<b>Actions:</b> At first please update your SSCam version. If the message does appear furthermore, please inform the SSCam Maintainer. ".
  175. "To ignore this message temporary, you may reduce the verbose level of your SSCam device. ",
  176. "3" => "Link to SSCam <a href=\"https://fhem.de/commandref.html#SSCam\">english commandRef</a> ",
  177. "2" => "You can create own PTZ-control icons with a template available in SVN which can be downloaded here: <a href=\"https://svn.fhem.de/trac/browser/trunk/fhem/contrib/sscam\">contrib/sscam/black_btn_CAM_Template.pdn</a>.\n".
  178. "This template can be edited with Paint.Net for example. ",
  179. "1" => "Some helpful <a href=\"https://wiki.fhem.de/wiki/SSCAM_-_Steuerung_von_Kameras_in_Synology_Surveillance_Station\">FHEM-Wiki</a> notes"
  180. );
  181. # Hint Hash de
  182. our %SSCam_vHintsExt_de = (
  183. "5" => "Informationen zum Management von Usern und entsprechenden Rechte-Profilen sind in der ".
  184. "<a href=\"https://www.synology.com/de-de/knowledgebase/Surveillance/help/SurveillanceStation/user\">Surveillance Station Online-Hilfe</a> zu finden.",
  185. "4" => "Die Meldung \"WARNING - The current/simulated SVS-version ... may be incompatible with SSCam version...\" ist ein Hinweis darauf, dass ".
  186. "die eingesetzte SSCam Version noch nicht mit der verwendeten Version von Synology Surveillance Station (Reading \"SVSversion\") getestet ".
  187. "wurde. Die kompatible SVS-Version ist im Internal COMPATIBILITY ersichtlich.\n".
  188. "<b>Maßnahmen:</b> Bitte SSCam zunächst updaten. Sollte die Meldung weiterhin auftreten, bitte den SSCam Maintainer informieren. Zur ".
  189. "vorübergehenden Ignorierung kann der verbose Level des SSCam-Devices entsprechend reduziert werden. ",
  190. "3" => "Link zur deutschen SSCam <a href=\"https://fhem.de/commandref_DE.html#SSCam\">commandRef</a> ",
  191. "2" => "Zur Erstellung eigener PTZ-Steuericons gibt es eine Vorlage im SVN die hier <a href=\"https://svn.fhem.de/trac/browser/trunk/fhem/contrib/sscam\">contrib/sscam/black_btn_CAM_Template.pdn</a> heruntergeladen werden kann.\n".
  192. "Diese Vorlage kann zum Beispiel mit Paint.Net bearbeitet werden. ",
  193. "1" => "Hilfreiche Hinweise zu SSCam im <a href=\"https://wiki.fhem.de/wiki/SSCAM_-_Steuerung_von_Kameras_in_Synology_Surveillance_Station\">FHEM-Wiki</a>"
  194. );
  195. # getestete SVS-Version
  196. my $compstat = "8.2.1";
  197. # Aufbau Errorcode-Hashes (siehe Surveillance Station Web API)
  198. my %SSCam_errauthlist = (
  199. 100 => "Unknown error",
  200. 101 => "The account parameter is not specified",
  201. 102 => "API does not exist",
  202. 400 => "Invalid user or password",
  203. 401 => "Guest or disabled account",
  204. 402 => "Permission denied - DSM-Session: make sure user is member of Admin-group, SVS-Session: make sure SVS package is started, make sure FHEM-Server IP won't be blocked in DSM automated blocking list",
  205. 403 => "One time password not specified",
  206. 404 => "One time password authenticate failed",
  207. 405 => "method not allowd - maybe the password is too long",
  208. 407 => "Permission denied - make sure FHEM-Server IP won't be blocked in DSM automated blocking list",
  209. );
  210. my %SSCam_errlist = (
  211. 100 => "Unknown error",
  212. 101 => "Invalid parameters",
  213. 102 => "API does not exist",
  214. 103 => "Method does not exist",
  215. 104 => "This API version is not supported",
  216. 105 => "Insufficient user privilege",
  217. 106 => "Connection time out",
  218. 107 => "Multiple login detected",
  219. 117 => "need manager rights in SurveillanceStation for operation",
  220. 400 => "Execution failed",
  221. 401 => "Parameter invalid",
  222. 402 => "Camera disabled",
  223. 403 => "Insufficient license",
  224. 404 => "Codec activation failed",
  225. 405 => "CMS server connection failed",
  226. 407 => "CMS closed",
  227. 410 => "Service is not enabled",
  228. 412 => "Need to add license",
  229. 413 => "Reach the maximum of platform",
  230. 414 => "Some events not exist",
  231. 415 => "message connect failed",
  232. 417 => "Test Connection Error",
  233. 418 => "Object is not exist",
  234. 419 => "Visualstation name repetition",
  235. 439 => "Too many items selected",
  236. 502 => "Camera disconnected",
  237. 600 => "Presetname and PresetID not found in Hash",
  238. );
  239. # Standardvariablen
  240. my $SSCam_slim = 3; # default Anzahl der abzurufenden Schnappschüsse mit snapGallery
  241. my $SSCAM_snum = "1,2,3,4,5,6,7,8,9,10"; # mögliche Anzahl der abzurufenden Schnappschüsse mit snapGallery
  242. use vars qw($FW_ME); # webname (default is fhem), used by 97_GROUP/weblink
  243. use vars qw($FW_subdir); # Sub-path in URL, used by FLOORPLAN/weblink
  244. use vars qw($FW_room); # currently selected room
  245. use vars qw($FW_detail); # currently selected device for detail view
  246. sub SSCam_Initialize($) {
  247. my ($hash) = @_;
  248. $hash->{DefFn} = "SSCam_Define";
  249. $hash->{UndefFn} = "SSCam_Undef";
  250. $hash->{DeleteFn} = "SSCam_Delete";
  251. $hash->{SetFn} = "SSCam_Set";
  252. $hash->{GetFn} = "SSCam_Get";
  253. $hash->{AttrFn} = "SSCam_Attr";
  254. # Aufrufe aus FHEMWEB
  255. $hash->{FW_summaryFn} = "SSCam_FWsummaryFn";
  256. $hash->{FW_detailFn} = "SSCam_FWdetailFn";
  257. $hash->{FW_deviceOverview} = 1;
  258. $hash->{AttrList} =
  259. "disable:1,0 ".
  260. "genericStrmHtmlTag ".
  261. "httptimeout ".
  262. "htmlattr ".
  263. "livestreamprefix ".
  264. "loginRetries:1,2,3,4,5,6,7,8,9,10 ".
  265. "videofolderMap ".
  266. "pollcaminfoall ".
  267. "snapGalleryBoost:0,1 ".
  268. "snapGallerySize:Icon,Full ".
  269. "snapGalleryNumber:$SSCAM_snum ".
  270. "snapGalleryColumns ".
  271. "snapGalleryHtmlAttr ".
  272. "pollnologging:1,0 ".
  273. "debugactivetoken:1,0 ".
  274. "rectime ".
  275. "recextend:1,0 ".
  276. "noQuotesForSID:1,0 ".
  277. "session:SurveillanceStation,DSM ".
  278. "showPassInLog:1,0 ".
  279. "showStmInfoFull:1,0 ".
  280. "simu_SVSversion:7.2-xxxx,7.1-xxxx,8.0.0-xxxx,8.1.5-xxxx,8.2.0-xxxx ".
  281. "webCmd ".
  282. $readingFnAttributes;
  283. return undef;
  284. }
  285. ################################################################
  286. sub SSCam_Define($@) {
  287. # Die Define-Funktion eines Moduls wird von Fhem aufgerufen wenn der Define-Befehl für ein Gerät ausgeführt wird
  288. # Welche und wie viele Parameter akzeptiert werden ist Sache dieser Funktion. Die Werte werden nach dem übergebenen Hash in ein Array aufgeteilt
  289. # define CamCP1 SSCAM Carport 192.168.2.20 [5000]
  290. # ($hash) [1] [2] [3] [4]
  291. #
  292. my ($hash, $def) = @_;
  293. my $name = $hash->{NAME};
  294. return "Error: Perl module ".$SScamMMDBI." is missing. Install it on Debian with: sudo apt-get install libjson-perl" if($SScamMMDBI);
  295. my @a = split("[ \t][ \t]*", $def);
  296. if(int(@a) < 4) {
  297. return "You need to specify more parameters.\n". "Format: define <name> SSCAM <Cameraname> <ServerAddress> [Port]";
  298. }
  299. my $camname = $a[2];
  300. my $serveraddr = $a[3];
  301. my $serverport = $a[4] ? $a[4] : 5000;
  302. my $proto = $a[5] ? lc($a[5]) : "http";
  303. $hash->{SERVERADDR} = $serveraddr;
  304. $hash->{SERVERPORT} = $serverport;
  305. $hash->{CAMNAME} = $camname;
  306. $hash->{VERSION} = (reverse sort(keys %SSCam_vNotesIntern))[0];
  307. $hash->{MODEL} = ($camname =~ m/^SVS$/i)?"SVS":"CAM"; # initial, CAM wird später ersetzt durch CamModel
  308. $hash->{PROTOCOL} = $proto;
  309. $hash->{COMPATIBILITY} = $compstat; # getestete SVS-version Kompatibilität
  310. # benötigte API's in $hash einfügen
  311. $hash->{HELPER}{APIINFO} = "SYNO.API.Info"; # Info-Seite für alle API's, einzige statische Seite !
  312. $hash->{HELPER}{APIAUTH} = "SYNO.API.Auth"; # API used to perform session login and logout
  313. $hash->{HELPER}{APISVSINFO} = "SYNO.SurveillanceStation.Info";
  314. $hash->{HELPER}{APIEVENT} = "SYNO.SurveillanceStation.Event";
  315. $hash->{HELPER}{APIEXTREC} = "SYNO.SurveillanceStation.ExternalRecording";
  316. $hash->{HELPER}{APIEXTEVT} = "SYNO.SurveillanceStation.ExternalEvent";
  317. $hash->{HELPER}{APICAM} = "SYNO.SurveillanceStation.Camera"; # stark geändert ab API v2.8
  318. $hash->{HELPER}{APISNAPSHOT} = "SYNO.SurveillanceStation.SnapShot";
  319. $hash->{HELPER}{APIPTZ} = "SYNO.SurveillanceStation.PTZ";
  320. $hash->{HELPER}{APIPRESET} = "SYNO.SurveillanceStation.PTZ.Preset";
  321. $hash->{HELPER}{APICAMEVENT} = "SYNO.SurveillanceStation.Camera.Event";
  322. $hash->{HELPER}{APIVIDEOSTM} = "SYNO.SurveillanceStation.VideoStreaming"; # verwendet in Response von "SYNO.SurveillanceStation.Camera: GetLiveViewPath" -> StreamKey-Methode
  323. # $hash->{HELPER}{APISTM} = "SYNO.SurveillanceStation.Streaming"; # provides methods to get Live View or Event video stream, removed in API v2.8
  324. $hash->{HELPER}{APISTM} = "SYNO.SurveillanceStation.Stream"; # Beschreibung ist falsch und entspricht "SYNO.SurveillanceStation.Streaming" auch noch ab v2.8
  325. $hash->{HELPER}{APIHM} = "SYNO.SurveillanceStation.HomeMode";
  326. $hash->{HELPER}{APILOG} = "SYNO.SurveillanceStation.Log";
  327. $hash->{HELPER}{APIAUDIOSTM} = "SYNO.SurveillanceStation.AudioStream"; # Audiostream mit SID, removed in API v2.8
  328. $hash->{HELPER}{APIVIDEOSTMS} = "SYNO.SurveillanceStation.VideoStream"; # Videostream mit SID, removed in API v2.8
  329. # Startwerte setzen
  330. if(SSCam_IsModelCam($hash)) {
  331. $attr{$name}{webCmd} = "on:off:snap:enable:disable:runView:stopView"; # initiale Webkommandos setzen
  332. } else {
  333. $attr{$name}{webCmd} = "homeMode";
  334. $attr{$name}{webCmdLabel} = "HomeMode";
  335. }
  336. $hash->{HELPER}{ACTIVE} = "off"; # Funktionstoken "off", Funktionen können sofort starten
  337. $hash->{HELPER}{OLDVALPOLLNOLOGGING} = "0"; # Loggingfunktion für Polling ist an
  338. $hash->{HELPER}{OLDVALPOLL} = "0";
  339. $hash->{HELPER}{RECTIME_DEF} = "15"; # Standard für rectime setzen, überschreibbar durch Attribut "rectime" bzw. beim "set .. on-for-time"
  340. $hash->{HELPER}{OLDPTZHOME} = "";
  341. $hash->{".ptzhtml"} = "";
  342. $hash->{HELPER}{HLSSTREAM} = "inactive"; # Aktivitätsstatus HLS-Streaming
  343. $hash->{HELPER}{SNAPLIMIT} = 0; # abgerufene Anzahl Snaps
  344. $hash->{HELPER}{TOTALCNT} = 0; # totale Anzahl Snaps
  345. readingsBeginUpdate($hash);
  346. readingsBulkUpdate($hash,"PollState","Inactive"); # es ist keine Gerätepolling aktiv
  347. if(SSCam_IsModelCam($hash)) {
  348. readingsBulkUpdate($hash,"Availability", "???"); # Verfügbarkeit ist unbekannt
  349. readingsBulkUpdate($hash,"state", "off"); # Init für "state" , Problemlösung für setstate, Forum #308
  350. } else {
  351. readingsBulkUpdate($hash,"state", "Initialized"); # Init für "state" wenn SVS
  352. }
  353. readingsEndUpdate($hash,1);
  354. SSCam_getcredentials($hash,1); # Credentials lesen und in RAM laden ($boot=1)
  355. # initiale Routinen nach Restart ausführen , verzögerter zufälliger Start
  356. RemoveInternalTimer($hash, "SSCam_initonboot");
  357. InternalTimer(gettimeofday()+int(rand(30)), "SSCam_initonboot", $hash, 0);
  358. return undef;
  359. }
  360. ################################################################
  361. sub SSCam_Undef($$) {
  362. my ($hash, $arg) = @_;
  363. SSCam_logout($hash);
  364. RemoveInternalTimer($hash);
  365. return undef;
  366. }
  367. ################################################################
  368. sub SSCam_Delete($$) {
  369. my ($hash, $arg) = @_;
  370. my $index = $hash->{TYPE}."_".$hash->{NAME}."_credentials";
  371. my $name = $hash->{NAME};
  372. # gespeicherte Credentials löschen
  373. setKeyValue($index, undef);
  374. # löschen snapGallerie-Device falls vorhanden
  375. my $sgdev = "SSCam.$hash->{NAME}.snapgallery";
  376. CommandDelete($hash->{CL},"$sgdev");
  377. # alle Streaming-Devices löschen falls vorhanden
  378. CommandDelete($hash->{CL},"TYPE=SSCamSTRM:FILTER=PARENT=$name");
  379. return undef;
  380. }
  381. ################################################################
  382. sub SSCam_Attr($$$$) {
  383. my ($cmd,$name,$aName,$aVal) = @_;
  384. my $hash = $defs{$name};
  385. my ($do,$val);
  386. # $cmd can be "del" or "set"
  387. # $name is device name
  388. # aName and aVal are Attribute name and value
  389. # dynamisch PTZ-Attribute setzen (wichtig beim Start wenn Reading "DeviceType" nicht gesetzt ist)
  390. if ($cmd eq "set" && ($aName =~ m/ptzPanel_.*/)) {
  391. foreach my $n (0..9) {
  392. $n = sprintf("%2.2d",$n);
  393. addToDevAttrList($name, "ptzPanel_row$n");
  394. }
  395. addToDevAttrList($name, "ptzPanel_iconPrefix");
  396. addToDevAttrList($name, "ptzPanel_iconPath");
  397. }
  398. if($aName =~ m/ptzPanel_row.*|ptzPanel_Home|ptzPanel_use/) {
  399. InternalTimer(gettimeofday()+0.7, "SSCam_addptzattr", "$name", 0);
  400. }
  401. if ($aName eq "disable") {
  402. if($cmd eq "set") {
  403. $do = ($aVal) ? 1 : 0;
  404. }
  405. $do = 0 if($cmd eq "del");
  406. if(SSCam_IsModelCam($hash)) {
  407. $val = ($do == 1 ? "inactive" : "off");
  408. } else {
  409. $val = ($do == 1 ? "disabled" : "initialized");
  410. }
  411. readingsSingleUpdate($hash, "state", $val, 1);
  412. readingsSingleUpdate($hash, "PollState", "Inactive", 1) if($do == 1);
  413. readingsSingleUpdate($hash, "Availability", "???", 1) if($do == 1 && SSCam_IsModelCam($hash));
  414. }
  415. if ($aName eq "showStmInfoFull") {
  416. if($cmd eq "set") {
  417. $do = ($aVal) ? 1 : 0;
  418. }
  419. $do = 0 if($cmd eq "del");
  420. if ($do == 0) {
  421. delete($defs{$name}{READINGS}{StmKeymjpegHttp});
  422. delete($defs{$name}{READINGS}{LiveStreamUrl});
  423. delete($defs{$name}{READINGS}{StmKeyUnicst});
  424. delete($defs{$name}{READINGS}{StmKeyUnicstOverHttp});
  425. delete($defs{$name}{READINGS}{StmKeymxpegHttp});
  426. }
  427. }
  428. if ($aName eq "snapGallerySize") {
  429. if($cmd eq "set") {
  430. $do = ($aVal eq "Icon")?1:2;
  431. }
  432. $do = 0 if($cmd eq "del");
  433. if ($do == 0) {
  434. delete($hash->{HELPER}{".SNAPHASH"}) if(AttrVal($name,"snapGalleryBoost",0)); # Snaphash nur löschen wenn Snaps gepollt werden
  435. Log3($name, 4, "$name - Snapshot hash deleted");
  436. } elsif (AttrVal($name,"snapGalleryBoost",0)) {
  437. # snap-Infos abhängig ermitteln wenn gepollt werden soll
  438. my ($slim,$ssize);
  439. $hash->{HELPER}{GETSNAPGALLERY} = 1;
  440. $slim = AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snaps
  441. $ssize = $do;
  442. RemoveInternalTimer("SSCam_getsnapinfo");
  443. InternalTimer(gettimeofday()+0.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  444. }
  445. }
  446. if ($aName eq "snapGalleryBoost") {
  447. if($cmd eq "set") {
  448. $do = ($aVal == 1)?1:0;
  449. }
  450. $do = 0 if($cmd eq "del");
  451. if ($do == 0) {
  452. delete($hash->{HELPER}{".SNAPHASH"}); # Snaphash löschen
  453. Log3($name, 4, "$name - Snapshot hash deleted");
  454. } else {
  455. # snapgallery regelmäßig neu einlesen wenn Polling ein
  456. return "When you want activate \"snapGalleryBoost\", you have to set the attribute \"pollcaminfoall\" first because the functionality depends on retrieving snapshots periodical."
  457. if(!AttrVal($name,"pollcaminfoall",0));
  458. my ($slim,$ssize);
  459. $hash->{HELPER}{GETSNAPGALLERY} = 1;
  460. $slim = AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snaps
  461. my $sg = AttrVal($name,"snapGallerySize","Icon"); # Auflösung Image
  462. $ssize = ($sg eq "Icon")?1:2;
  463. RemoveInternalTimer("SSCam_getsnapinfo");
  464. InternalTimer(gettimeofday()+0.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  465. }
  466. }
  467. if ($aName eq "snapGalleryNumber" && AttrVal($name,"snapGalleryBoost",0)) {
  468. my ($slim,$ssize);
  469. if($cmd eq "set") {
  470. $do = ($aVal != 0)?1:0;
  471. }
  472. $do = 0 if($cmd eq "del");
  473. if ($do == 0) {
  474. $slim = 3;
  475. } else {
  476. $slim = $aVal;
  477. }
  478. $hash->{HELPER}{GETSNAPGALLERY} = 1;
  479. my $sg = AttrVal($name,"snapGallerySize","Icon"); # Auflösung Image
  480. $ssize = ($sg eq "Icon")?1:2;
  481. RemoveInternalTimer("SSCam_getsnapinfo");
  482. InternalTimer(gettimeofday()+0.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  483. }
  484. if ($aName eq "simu_SVSversion") {
  485. delete $hash->{HELPER}{APIPARSET};
  486. delete $hash->{HELPER}{SID};
  487. delete $hash->{CAMID};
  488. RemoveInternalTimer($hash, "SSCam_getcaminfoall");
  489. InternalTimer(gettimeofday()+0.5, "SSCam_getcaminfoall", $hash, 0);
  490. }
  491. if($aName =~ m/pollcaminfoall/ && $init_done == 1) {
  492. RemoveInternalTimer($hash, "SSCam_getcaminfoall");
  493. InternalTimer(gettimeofday()+1.0, "SSCam_getcaminfoall", $hash, 0);
  494. RemoveInternalTimer($hash, "SSCam_wdpollcaminfo");
  495. InternalTimer(gettimeofday()+1.5, "SSCam_wdpollcaminfo", $hash, 0);
  496. }
  497. if($aName =~ m/pollnologging/ && $init_done == 1) {
  498. RemoveInternalTimer($hash, "SSCam_wdpollcaminfo");
  499. InternalTimer(gettimeofday()+1.0, "SSCam_wdpollcaminfo", $hash, 0);
  500. }
  501. if ($cmd eq "set") {
  502. if ($aName =~ m/httptimeout|snapGalleryColumns|rectime|pollcaminfoall/) {
  503. unless ($aVal =~ /^\d+$/) { return " The Value for $aName is not valid. Use only figures 1-9 !";}
  504. }
  505. if($aName =~ m/pollcaminfoall/) {
  506. return "The value of \"$aName\" has to be greater than 10 seconds." if($aVal <= 10);
  507. }
  508. }
  509. if ($cmd eq "del") {
  510. if ($aName =~ m/pollcaminfoall/ ) {
  511. # Polling nicht ausschalten wenn snapGalleryBoost ein (regelmäßig neu einlesen)
  512. return "Please switch off \"snapGalleryBoost\" first if you want to deactivate \"pollcaminfoall\" because the functionality of \"snapGalleryBoost\" depends on retrieving snapshots periodical."
  513. if(AttrVal($name,"snapGalleryBoost",0));
  514. }
  515. }
  516. return undef;
  517. }
  518. ################################################################
  519. sub SSCam_Set($@) {
  520. my ($hash, @a) = @_;
  521. return "\"set X\" needs at least an argument" if ( @a < 2 );
  522. my $name = $a[0];
  523. my $opt = $a[1];
  524. my $prop = $a[2];
  525. my $prop1 = $a[3];
  526. my $prop2 = $a[4];
  527. my $prop3 = $a[5];
  528. my $camname = $hash->{CAMNAME};
  529. my $success;
  530. my $setlist;
  531. my @prop;
  532. return if(IsDisabled($name));
  533. if(!$hash->{CREDENTIALS}) {
  534. # initiale setlist für neue Devices
  535. $setlist = "Unknown argument $opt, choose one of ".
  536. "credentials "
  537. ;
  538. } elsif(SSCam_IsModelCam($hash)) {
  539. # selist für Cams
  540. my $hlslfw = SSCam_IsHLSCap($hash)?",live_fw_hls,":",";
  541. $setlist = "Unknown argument $opt, choose one of ".
  542. "credentials ".
  543. ((ReadingsVal("$name", "CapPTZPan", "false") ne "false") ? "delPreset:".ReadingsVal("$name","Presets","")." " : "").
  544. "expmode:auto,day,night ".
  545. "on ".
  546. "off:noArg ".
  547. "motdetsc:disable,camera,SVS ".
  548. "snap:noArg ".
  549. (AttrVal($name, "snapGalleryBoost",0)?(AttrVal($name,"snapGalleryNumber",undef) || AttrVal($name,"snapGalleryBoost",0))?"snapGallery:noArg ":"snapGallery:$SSCAM_snum ":" ").
  550. "createSnapGallery:noArg ".
  551. "createStreamDev:generic,mjpeg,switched ".
  552. ((ReadingsVal("$name", "CapPTZPan", "false") ne "false") ? "createPTZcontrol:noArg ": "").
  553. "enable:noArg ".
  554. "disable:noArg ".
  555. "optimizeParams ".
  556. ((ReadingsVal("$name", "CapPIR", "false") ne "false") ? "pirSensor:activate,deactivate ": "").
  557. "runView:live_fw".$hlslfw."live_link,live_open,lastrec_fw,lastrec_fw_MJPEG,lastrec_fw_MPEG4/H.264,lastrec_open,lastsnap_fw ".
  558. ((ReadingsVal("$name", "CapPTZPan", "false") ne "false") ? "setPreset ": "").
  559. ((ReadingsVal("$name", "CapPTZPan", "false") ne "false") ? "setHome:---currentPosition---,".ReadingsVal("$name","Presets","")." " : "").
  560. "stopView:noArg ".
  561. ((ReadingsVal("$name", "CapPTZObjTracking", "false") ne "false") ? "startTracking:noArg " : "").
  562. ((ReadingsVal("$name", "CapPTZObjTracking", "false") ne "false") ? "stopTracking:noArg " : "").
  563. ((ReadingsVal("$name", "CapPTZDirections", 0) > 0) ? "move"." " : "").
  564. ((ReadingsVal("$name", "CapPTZPan", "false") ne "false") ? "runPatrol:".ReadingsVal("$name", "Patrols", "")." " : "").
  565. ((ReadingsVal("$name", "CapPTZPan", "false") ne "false") ? "goPreset:".ReadingsVal("$name", "Presets", "")." " : "").
  566. ((ReadingsVal("$name", "CapPTZAbs", "false") ne "false") ? "goAbsPTZ"." " : "").
  567. ((ReadingsVal("$name", "CapPTZDirections", 0) > 0) ? "move"." " : "");
  568. } else {
  569. # setlist für SVS Devices
  570. $setlist = "Unknown argument $opt, choose one of ".
  571. "credentials ".
  572. "extevent:1,2,3,4,5,6,7,8,9,10 ".
  573. ($hash->{HELPER}{APIHMMAXVER}?"homeMode:on,off ": "");
  574. }
  575. if ($opt eq "credentials") {
  576. return "Credentials are incomplete, use username password" if (!$prop || !$prop1);
  577. return "Password is too long. It is limited up to and including 20 characters." if (length $prop1 > 20);
  578. delete $hash->{HELPER}{SID} if($hash->{HELPER}{SID});
  579. ($success) = SSCam_setcredentials($hash,$prop,$prop1);
  580. $hash->{HELPER}{ACTIVE} = "off";
  581. if($success) {
  582. SSCam_getcaminfoall($hash,0);
  583. RemoveInternalTimer($hash, "SSCam_getptzlistpreset");
  584. InternalTimer(gettimeofday()+11, "SSCam_getptzlistpreset", $hash, 0);
  585. RemoveInternalTimer($hash, "SSCam_getptzlistpatrol");
  586. InternalTimer(gettimeofday()+12, "SSCam_getptzlistpatrol", $hash, 0);
  587. SSCam_versionCheck($hash);
  588. return "Username and Password saved successfully";
  589. } else {
  590. return "Error while saving Username / Password - see logfile for details";
  591. }
  592. }
  593. if ($opt eq "on" && SSCam_IsModelCam($hash)) {
  594. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  595. if (defined($prop)) {
  596. unless ($prop =~ /^\d+$/) { return " The Value for \"$opt\" is not valid. Use only figures 0-9 without decimal places !";}
  597. $hash->{HELPER}{RECTIME_TEMP} = $prop;
  598. }
  599. SSCam_camstartrec($hash);
  600. } elsif ($opt eq "off" && SSCam_IsModelCam($hash)) {
  601. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  602. SSCam_camstoprec($hash);
  603. } elsif ($opt eq "snap" && SSCam_IsModelCam($hash)) {
  604. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  605. $hash->{HELPER}{SNAPBYSTRMDEV} = 1 if ($prop); # $prop wird mitgegeben durch Snap by SSCamSTRM-Device
  606. SSCam_camsnap($hash);
  607. } elsif ($opt eq "startTracking" && SSCam_IsModelCam($hash)) {
  608. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  609. if ($hash->{HELPER}{APIPTZMAXVER} < 5) {return "Function \"$opt\" needs a higher version of Surveillance Station";}
  610. SSCam_starttrack($hash);
  611. } elsif ($opt eq "stopTracking" && SSCam_IsModelCam($hash)) {
  612. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  613. if ($hash->{HELPER}{APIPTZMAXVER} < 5) {return "Function \"$opt\" needs a higher version of Surveillance Station";}
  614. SSCam_stoptrack($hash);
  615. } elsif ($opt eq "snapGallery" && SSCam_IsModelCam($hash)) {
  616. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  617. my $ret = SSCam_getclhash($hash);
  618. return $ret if($ret);
  619. if(!AttrVal($name, "snapGalleryBoost",0)) {
  620. # Snaphash ist nicht vorhanden und wird neu abgerufen und ausgegeben
  621. $hash->{HELPER}{GETSNAPGALLERY} = 1;
  622. # snap-Infos für Gallerie abrufen
  623. my ($sg,$slim,$ssize);
  624. $slim = $prop?AttrVal($name,"snapGalleryNumber",$prop):AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snapshots
  625. $ssize = (AttrVal($name,"snapGallerySize","Icon") eq "Icon")?1:2; # Image Size 1-Icon, 2-Full
  626. SSCam_getsnapinfo("$name:$slim:$ssize");
  627. } else {
  628. # Snaphash ist vorhanden und wird zur Ausgabe aufbereitet (Polling ist aktiv)
  629. my $htmlCode = SSCam_composegallery($name);
  630. for (my $k=1; (defined($hash->{HELPER}{CL}{$k})); $k++ ) {
  631. if ($hash->{HELPER}{CL}{$k}->{COMP}) {
  632. # CL zusammengestellt (Auslösung durch Notify)
  633. asyncOutput($hash->{HELPER}{CL}{$k}, "$htmlCode");
  634. } else {
  635. # Output wurde über FHEMWEB ausgelöst
  636. return $htmlCode;
  637. }
  638. }
  639. delete($hash->{HELPER}{CL});
  640. }
  641. } elsif ($opt eq "createSnapGallery" && SSCam_IsModelCam($hash)) {
  642. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  643. my ($ret,$sgdev);
  644. return "Before use \"$opt\" you have to set the attribute \"snapGalleryBoost\" first due to the technology of retrieving snapshots automatically is needed."
  645. if(!AttrVal($name,"snapGalleryBoost",0));
  646. $sgdev = "SSCamSTRM.$name.snapgallery";
  647. $ret = CommandDefine($hash->{CL},"$sgdev SSCamSTRM {SSCam_composegallery('$name','$sgdev','snapgallery')}");
  648. return $ret if($ret);
  649. my $room = "SnapGallery";
  650. $attr{$sgdev}{room} = $room;
  651. return "Snapgallery device \"$sgdev\" created and assigned to room \"$room\".";
  652. } elsif ($opt eq "createPTZcontrol" && SSCam_IsModelCam($hash)) {
  653. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  654. my $ptzcdev = "SSCamSTRM.$name.PTZcontrol";
  655. my $ret = CommandDefine($hash->{CL},"$ptzcdev SSCamSTRM {SSCam_ptzpanel('$name','$ptzcdev','ptzcontrol')}");
  656. return $ret if($ret);
  657. my $room = AttrVal($name,"room","PTZcontrol");
  658. $attr{$ptzcdev}{room} = $room;
  659. $attr{$ptzcdev}{group} = $name."_PTZcontrol";
  660. return "PTZ control device \"$ptzcdev\" created and assigned to room \"$room\".";
  661. } elsif ($opt eq "createStreamDev" && SSCam_IsModelCam($hash)) {
  662. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  663. my ($livedev,$ret);
  664. if($prop =~ /mjpeg/) {
  665. $livedev = "SSCamSTRM.$name.mjpeg";
  666. $ret = CommandDefine($hash->{CL},"$livedev SSCamSTRM {SSCam_StreamDev('$name','$livedev','mjpeg')}");
  667. return $ret if($ret);
  668. }
  669. if($prop =~ /generic/) {
  670. $livedev = "SSCamSTRM.$name.generic";
  671. $ret = CommandDefine($hash->{CL},"$livedev SSCamSTRM {SSCam_StreamDev('$name','$livedev','generic')}");
  672. return $ret if($ret);
  673. }
  674. if($prop =~ /switched/) {
  675. $livedev = "SSCamSTRM.$name.switched";
  676. $ret = CommandDefine($hash->{CL},"$livedev SSCamSTRM {SSCam_StreamDev('$name','$livedev','switched')}");
  677. return $ret if($ret);
  678. }
  679. my $room = AttrVal($name,"room","Livestream");
  680. $attr{$livedev}{room} = $room;
  681. return "Livestream device \"$livedev\" created and assigned to room \"$room\".";
  682. } elsif ($opt eq "enable" && SSCam_IsModelCam($hash)) {
  683. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  684. SSCam_camenable($hash);
  685. } elsif ($opt eq "disable" && SSCam_IsModelCam($hash)) {
  686. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  687. SSCam_camdisable($hash);
  688. } elsif ($opt eq "motdetsc" && SSCam_IsModelCam($hash)) {
  689. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  690. if (!$prop || $prop !~ /^(disable|camera|SVS)$/) { return " \"$opt\" needs one of those arguments: disable, camera, SVS !";}
  691. $hash->{HELPER}{MOTDETSC} = $prop;
  692. if ($prop1) {
  693. # check ob Zahl zwischen 1 und 99
  694. return "invalid value for sensitivity (SVS or camera) - use number between 1 - 99" if ($prop1 !~ /^([1-9]|[1-9][0-9])*$/);
  695. $hash->{HELPER}{MOTDETSC_PROP1} = $prop1;
  696. }
  697. if ($prop2) {
  698. # check ob Zahl zwischen 1 und 99
  699. return "invalid value for threshold (SVS) / object size (camera) - use number between 1 - 99" if ($prop2 !~ /^([1-9]|[1-9][0-9])*$/);
  700. $hash->{HELPER}{MOTDETSC_PROP2} = $prop2;
  701. }
  702. if ($prop3) {
  703. # check ob Zahl zwischen 1 und 99
  704. return "invalid value for threshold (SVS) / object size (camera) - use number between 1 - 99" if ($prop3 !~ /^([1-9]|[1-9][0-9])*$/);
  705. $hash->{HELPER}{MOTDETSC_PROP3} = $prop3;
  706. }
  707. SSCam_cammotdetsc($hash);
  708. } elsif ($opt eq "expmode" && SSCam_IsModelCam($hash)) {
  709. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  710. unless ($prop) { return " \"$opt\" needs one of those arguments: auto, day, night !";}
  711. $hash->{HELPER}{EXPMODE} = $prop;
  712. SSCam_camexpmode($hash);
  713. } elsif ($opt eq "homeMode" && !SSCam_IsModelCam($hash)) {
  714. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  715. unless ($prop) { return " \"$opt\" needs one of those arguments: on, off !";}
  716. $hash->{HELPER}{HOMEMODE} = $prop;
  717. SSCam_sethomemode($hash);
  718. } elsif ($opt eq "goPreset" && SSCam_IsModelCam($hash)) {
  719. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  720. if (!$prop) {return "Function \"goPreset\" needs a \"Presetname\" as an argument";}
  721. $hash->{HELPER}{GOPRESETNAME} = $prop;
  722. $hash->{HELPER}{PTZACTION} = "gopreset";
  723. SSCam_doptzaction($hash);
  724. } elsif ($opt eq "optimizeParams" && SSCam_IsModelCam($hash)) {
  725. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  726. my %cpcl = (ntp => 1, mirror => 2, flip => 4, rotate => 8);
  727. SSCam_extoptpar($hash,$prop,\%cpcl) if($prop);
  728. SSCam_extoptpar($hash,$prop1,\%cpcl) if($prop1);
  729. SSCam_extoptpar($hash,$prop2,\%cpcl) if($prop2);
  730. SSCam_setoptpar($hash);
  731. } elsif ($opt eq "pirSensor" && SSCam_IsModelCam($hash)) {
  732. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  733. if(ReadingsVal("$name", "CapPIR", "false") eq "false") {return "Function \"$opt\" not possible. Camera \"$name\" don't have a PIR sensor."}
  734. if(!$prop) {return "Function \"$opt\" needs an argument";}
  735. $hash->{HELPER}{PIRACT} = ($prop eq "activate")?0:($prop eq "deactivate")?-1:5;
  736. if($hash->{HELPER}{PIRACT} == 5) {return " Illegal argument for \"$opt\" detected, use \"activate\" or \"activate\" !";}
  737. SSCam_piract($hash);
  738. } elsif ($opt eq "runPatrol" && SSCam_IsModelCam($hash)) {
  739. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  740. if (!$prop) {return "Function \"$opt\" needs a \"Patrolname\" as an argument";}
  741. $hash->{HELPER}{GOPATROLNAME} = $prop;
  742. $hash->{HELPER}{PTZACTION} = "runpatrol";
  743. SSCam_doptzaction($hash);
  744. } elsif ($opt eq "goAbsPTZ" && SSCam_IsModelCam($hash)) {
  745. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  746. if ($prop eq "up" || $prop eq "down" || $prop eq "left" || $prop eq "right") {
  747. if ($prop eq "up") {$hash->{HELPER}{GOPTZPOSX} = 320; $hash->{HELPER}{GOPTZPOSY} = 480;}
  748. if ($prop eq "down") {$hash->{HELPER}{GOPTZPOSX} = 320; $hash->{HELPER}{GOPTZPOSY} = 0;}
  749. if ($prop eq "left") {$hash->{HELPER}{GOPTZPOSX} = 0; $hash->{HELPER}{GOPTZPOSY} = 240;}
  750. if ($prop eq "right") {$hash->{HELPER}{GOPTZPOSX} = 640; $hash->{HELPER}{GOPTZPOSY} = 240;}
  751. $hash->{HELPER}{PTZACTION} = "goabsptz";
  752. SSCam_doptzaction($hash);
  753. return undef;
  754. } else {
  755. if ($prop !~ /\d+/ || $prop1 !~ /\d+/ || abs($prop) > 640 || abs($prop1) > 480) {
  756. return "Function \"goAbsPTZ\" needs two coordinates, posX=0-640 and posY=0-480, as arguments or use up, down, left, right instead";
  757. }
  758. $hash->{HELPER}{GOPTZPOSX} = abs($prop);
  759. $hash->{HELPER}{GOPTZPOSY} = abs($prop1);
  760. $hash->{HELPER}{PTZACTION} = "goabsptz";
  761. SSCam_doptzaction($hash);
  762. return undef;
  763. }
  764. return "Function \"goAbsPTZ\" needs two coordinates, posX=0-640 and posY=0-480, as arguments or use up, down, left, right instead";
  765. } elsif ($opt eq "move" && SSCam_IsModelCam($hash)) {
  766. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  767. return "PTZ version of Synology API isn't set. Use \"get $name scanVirgin\" first." if(!$hash->{HELPER}{APIPTZMAXVER});
  768. if($hash->{HELPER}{APIPTZMAXVER} <= 4) {
  769. if (!defined($prop) || ($prop !~ /^up$|^down$|^left$|^right$|^dir_\d$/)) {return "Function \"move\" needs an argument like up, down, left, right or dir_X (X = 0 to CapPTZDirections-1)";}
  770. $hash->{HELPER}{GOMOVEDIR} = $prop;
  771. } elsif ($hash->{HELPER}{APIPTZMAXVER} >= 5) {
  772. if (!defined($prop) || ($prop !~ /^right$|^upright$|^up$|^upleft$|^left$|^downleft$|^down$|^downright$/)) {return "Function \"move\" needs an argument like right, upright, up, upleft, left, downleft, down, downright ";}
  773. my %dirs = (
  774. right => 0,
  775. upright => 4,
  776. up => 8,
  777. upleft => 12,
  778. left => 16,
  779. downleft => 20,
  780. down => 24,
  781. downright => 28,
  782. );
  783. $hash->{HELPER}{GOMOVEDIR} = $dirs{$prop};
  784. }
  785. $hash->{HELPER}{GOMOVETIME} = defined($prop1) ? $prop1 : 1;
  786. $hash->{HELPER}{PTZACTION} = "movestart";
  787. SSCam_doptzaction($hash);
  788. } elsif ($opt eq "runView" && SSCam_IsModelCam($hash)) {
  789. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  790. if ($prop eq "live_open") {
  791. if ($prop1) {$hash->{HELPER}{VIEWOPENROOM} = $prop1;} else {delete $hash->{HELPER}{VIEWOPENROOM};}
  792. $hash->{HELPER}{OPENWINDOW} = 1;
  793. $hash->{HELPER}{WLTYPE} = "link";
  794. $hash->{HELPER}{ALIAS} = "LiveView";
  795. $hash->{HELPER}{RUNVIEW} = "live_open";
  796. $hash->{HELPER}{ACTSTRM} = ""; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  797. } elsif ($prop eq "live_link") {
  798. $hash->{HELPER}{OPENWINDOW} = 0;
  799. $hash->{HELPER}{WLTYPE} = "link";
  800. $hash->{HELPER}{ALIAS} = "LiveView";
  801. $hash->{HELPER}{RUNVIEW} = "live_link";
  802. $hash->{HELPER}{ACTSTRM} = ""; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  803. } elsif ($prop eq "lastrec_open") {
  804. if ($prop1) {$hash->{HELPER}{VIEWOPENROOM} = $prop1;} else {delete $hash->{HELPER}{VIEWOPENROOM};}
  805. $hash->{HELPER}{OPENWINDOW} = 1;
  806. $hash->{HELPER}{WLTYPE} = "link";
  807. $hash->{HELPER}{ALIAS} = "LastRecording";
  808. $hash->{HELPER}{RUNVIEW} = "lastrec_open";
  809. $hash->{HELPER}{ACTSTRM} = ""; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  810. } elsif ($prop eq "lastrec_fw") { # Video in iFrame eingebettet
  811. $hash->{HELPER}{OPENWINDOW} = 0;
  812. $hash->{HELPER}{WLTYPE} = "iframe";
  813. $hash->{HELPER}{ALIAS} = " ";
  814. $hash->{HELPER}{RUNVIEW} = "lastrec";
  815. $hash->{HELPER}{ACTSTRM} = "last Recording"; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  816. } elsif ($prop eq "lastrec_fw_MJPEG") { # “video/avi” – MJPEG format event
  817. $hash->{HELPER}{OPENWINDOW} = 0;
  818. $hash->{HELPER}{WLTYPE} = "image";
  819. $hash->{HELPER}{ALIAS} = " ";
  820. $hash->{HELPER}{RUNVIEW} = "lastrec";
  821. $hash->{HELPER}{ACTSTRM} = "last Recording"; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  822. } elsif ($prop eq "lastrec_fw_MPEG4/H.264") { # “video/mp4” – MPEG4/H.264 format event
  823. $hash->{HELPER}{OPENWINDOW} = 0;
  824. $hash->{HELPER}{WLTYPE} = "video";
  825. $hash->{HELPER}{ALIAS} = " ";
  826. $hash->{HELPER}{RUNVIEW} = "lastrec";
  827. $hash->{HELPER}{ACTSTRM} = "last Recording"; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  828. } elsif ($prop eq "live_fw") {
  829. $hash->{HELPER}{OPENWINDOW} = 0;
  830. $hash->{HELPER}{WLTYPE} = "image";
  831. $hash->{HELPER}{ALIAS} = " ";
  832. $hash->{HELPER}{RUNVIEW} = "live_fw";
  833. $hash->{HELPER}{ACTSTRM} = "MJPEG Livestream"; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  834. } elsif ($prop eq "live_fw_hls") {
  835. return "API \"SYNO.SurveillanceStation.VideoStream\" is not available or Reading \"CamStreamFormat\" is not \"HLS\". May be your API version is 2.8 or higher." if(!SSCam_IsHLSCap($hash));
  836. $hash->{HELPER}{OPENWINDOW} = 0;
  837. $hash->{HELPER}{WLTYPE} = "hls";
  838. $hash->{HELPER}{ALIAS} = "View only on compatible browsers";
  839. $hash->{HELPER}{RUNVIEW} = "live_fw_hls";
  840. $hash->{HELPER}{ACTSTRM} = "HLS Livestream"; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  841. } elsif ($prop eq "lastsnap_fw") {
  842. $hash->{HELPER}{LSNAPBYSTRMDEV} = 1 if($prop1); # Anzeige durch SSCamSTRM-Device ausgelöst
  843. $hash->{HELPER}{LSNAPBYDEV} = 1 if(!$prop1); # Anzeige durch SSCam ausgelöst
  844. $hash->{HELPER}{OPENWINDOW} = 0;
  845. $hash->{HELPER}{WLTYPE} = "base64img";
  846. $hash->{HELPER}{ALIAS} = " ";
  847. $hash->{HELPER}{RUNVIEW} = "lastsnap_fw";
  848. $hash->{HELPER}{ACTSTRM} = "last Snapshot"; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  849. } else {
  850. return "$prop isn't a valid option of runview, use one of live_fw, live_link, live_open, lastrec_fw, lastrec_open, lastsnap_fw";
  851. }
  852. SSCam_runliveview($hash);
  853. } elsif ($opt eq "hlsreactivate" && SSCam_IsModelCam($hash)) {
  854. # ohne SET-Menüeintrag
  855. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  856. SSCam_hlsreactivate($hash);
  857. } elsif ($opt eq "hlsactivate" && SSCam_IsModelCam($hash)) {
  858. # ohne SET-Menüeintrag
  859. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  860. SSCam_hlsactivate($hash);
  861. } elsif ($opt eq "refresh" && SSCam_IsModelCam($hash)) {
  862. # ohne SET-Menüeintrag
  863. if($prop =~ /STRM/) {
  864. # Event in allen SSCamSTRM-Devices erzeugen um Contentwiedergabe aufzufrischen
  865. SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein SSCam-state-Event, SSCamSTRM-Event
  866. }
  867. } elsif ($opt eq "extevent" && !SSCam_IsModelCam($hash)) {
  868. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  869. $hash->{HELPER}{EVENTID} = $prop;
  870. SSCam_extevent($hash);
  871. } elsif ($opt eq "stopView" && SSCam_IsModelCam($hash)) {
  872. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  873. SSCam_stopliveview($hash);
  874. } elsif ($opt eq "setPreset" && SSCam_IsModelCam($hash)) {
  875. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  876. if (!$prop) {return "Syntax of function \"$opt\" was wrong. Please use \"set $name setPreset <PresetNumber> <PresetName> [<Speed>]\" ";}
  877. $hash->{HELPER}{PNUMBER} = $prop;
  878. $hash->{HELPER}{PNAME} = $prop1?$prop1:$prop; # wenn keine Presetname angegeben -> Presetnummer als Name verwenden
  879. $hash->{HELPER}{PSPEED} = $prop2 if($prop2);
  880. SSCam_setPreset($hash);
  881. } elsif ($opt eq "setHome" && SSCam_IsModelCam($hash)) {
  882. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  883. if (!$prop) {return "Function \"$opt\" needs a \"Presetname\" as argument";}
  884. $hash->{HELPER}{SETHOME} = $prop;
  885. SSCam_setHome($hash);
  886. } elsif ($opt eq "delPreset" && SSCam_IsModelCam($hash)) {
  887. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  888. if (!$prop) {return "Function \"$opt\" needs a \"Presetname\" as argument";}
  889. $hash->{HELPER}{DELPRESETNAME} = $prop;
  890. SSCam_delPreset($hash);
  891. } else {
  892. return "$setlist";
  893. }
  894. return;
  895. }
  896. ################################################################
  897. sub SSCam_Get($@) {
  898. my ($hash, @a) = @_;
  899. return "\"get X\" needs at least an argument" if ( @a < 2 );
  900. my $name = shift @a;
  901. my $opt = shift @a;
  902. my $arg = shift @a;
  903. my $arg1 = shift @a;
  904. my $arg2 = shift @a;
  905. my $ret = "";
  906. my $getlist;
  907. if(!$hash->{CREDENTIALS}) {
  908. return;
  909. } elsif(SSCam_IsModelCam($hash)) {
  910. # getlist für Cams
  911. $getlist = "Unknown argument $opt, choose one of ".
  912. "caminfoall:noArg ".
  913. "caminfo:noArg ".
  914. ((AttrVal($name,"snapGalleryNumber",undef) || AttrVal($name,"snapGalleryBoost",0))
  915. ?"snapGallery:noArg ":"snapGallery:$SSCAM_snum ").
  916. ((ReadingsVal("$name", "CapPTZPresetNumber", 0) != 0) ? "listPresets:noArg " : "").
  917. "snapinfo:noArg ".
  918. "svsinfo:noArg ".
  919. "snapfileinfo:noArg ".
  920. "eventlist:noArg ".
  921. "stmUrlPath:noArg ".
  922. "storedCredentials:noArg ".
  923. "scanVirgin:noArg ".
  924. "versionNotes "
  925. ;
  926. } else {
  927. # getlist für SVS Devices
  928. $getlist = "Unknown argument $opt, choose one of ".
  929. "caminfoall:noArg ".
  930. ($hash->{HELPER}{APIHMMAXVER}?"homeModeState:noArg ": "").
  931. "svsinfo:noArg ".
  932. "listLog ".
  933. "storedCredentials:noArg ".
  934. "scanVirgin:noArg ".
  935. "versionNotes "
  936. ;
  937. }
  938. return if(IsDisabled($name));
  939. if ($opt eq "caminfo") {
  940. # "1" ist Statusbit für manuelle Abfrage, kein Einstieg in Pollingroutine
  941. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  942. SSCam_getcaminfo($hash);
  943. } elsif ($opt eq "caminfoall") {
  944. # "1" ist Statusbit für manuelle Abfrage, kein Einstieg in Pollingroutine
  945. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  946. SSCam_getcaminfoall($hash,1);
  947. } elsif ($opt eq "homeModeState" && !SSCam_IsModelCam($hash)) {
  948. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  949. SSCam_gethomemodestate($hash);
  950. } elsif ($opt eq "listLog" && !SSCam_IsModelCam($hash)) {
  951. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  952. # übergebenen CL-Hash (FHEMWEB) in Helper eintragen
  953. SSCam_getclhash($hash,1);
  954. SSCam_extlogargs($hash,$arg) if($arg);
  955. SSCam_extlogargs($hash,$arg1) if($arg1);
  956. SSCam_extlogargs($hash,$arg2) if($arg2);
  957. SSCam_getsvslog($hash);
  958. } elsif ($opt eq "listPresets" && SSCam_IsModelCam($hash)) {
  959. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  960. # übergebenen CL-Hash (FHEMWEB) in Helper eintragen
  961. SSCam_getclhash($hash,1);
  962. SSCam_getpresets($hash);
  963. } elsif ($opt eq "svsinfo") {
  964. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  965. SSCam_getsvsinfo($hash);
  966. } elsif ($opt eq "storedCredentials") {
  967. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  968. # Credentials abrufen
  969. my ($success, $username, $password) = SSCam_getcredentials($hash,0);
  970. unless ($success) {return "Credentials couldn't be retrieved successfully - see logfile"};
  971. return "Stored Credentials for $name - Username: $username, Password: $password";
  972. } elsif ($opt eq "snapGallery" && SSCam_IsModelCam($hash)) {
  973. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  974. my $txt = SSCam_getclhash($hash);
  975. return $txt if($txt);
  976. if(!AttrVal($name, "snapGalleryBoost",0)) {
  977. # Snaphash ist nicht vorhanden und wird abgerufen
  978. $hash->{HELPER}{GETSNAPGALLERY} = 1;
  979. # snap-Infos für Gallerie abrufen
  980. my ($sg,$slim,$ssize);
  981. $slim = $arg?AttrVal($name,"snapGalleryNumber",$arg):AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snapshots
  982. $ssize = (AttrVal($name,"snapGallerySize","Icon") eq "Icon")?1:2; # Image Size 1-Icon, 2-Full
  983. SSCam_getsnapinfo("$name:$slim:$ssize");
  984. } else {
  985. # Snaphash ist vorhanden und wird zur Ausgabe aufbereitet
  986. my $htmlCode = SSCam_composegallery($name);
  987. for (my $k=1; (defined($hash->{HELPER}{CL}{$k})); $k++ ) {
  988. if ($hash->{HELPER}{CL}{$k}->{COMP}) {
  989. # CL zusammengestellt (Auslösung durch Notify)
  990. asyncOutput($hash->{HELPER}{CL}{$k}, "$htmlCode");
  991. } else {
  992. # Output wurde über FHEMWEB ausgelöst
  993. return $htmlCode;
  994. }
  995. }
  996. delete($hash->{HELPER}{CL});
  997. }
  998. } elsif ($opt eq "snapinfo" && SSCam_IsModelCam($hash)) {
  999. # Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
  1000. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  1001. my ($slim,$ssize) = SSCam_snaplimsize($hash);
  1002. SSCam_getsnapinfo("$name:$slim:$ssize");
  1003. } elsif ($opt eq "snapfileinfo" && SSCam_IsModelCam($hash)) {
  1004. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  1005. if (!ReadingsVal("$name", "LastSnapId", undef)) {return "Reading LastSnapId is empty - please take a snapshot before !"}
  1006. SSCam_getsnapfilename($hash);
  1007. } elsif ($opt eq "eventlist" && SSCam_IsModelCam($hash)) {
  1008. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  1009. SSCam_geteventlist ($hash);
  1010. } elsif ($opt eq "stmUrlPath" && SSCam_IsModelCam($hash)) {
  1011. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  1012. SSCam_getStmUrlPath ($hash);
  1013. } elsif ($opt eq "scanVirgin") {
  1014. if (!$hash->{CREDENTIALS}) {return "Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"";}
  1015. SSCam_sessionoff($hash);
  1016. delete $hash->{HELPER}{APIPARSET};
  1017. delete $hash->{CAMID};
  1018. # alte Readings außer state löschen
  1019. my @allrds = keys%{$defs{$name}{READINGS}};
  1020. foreach my $key(@allrds) {
  1021. # Log3 ($name, 1, "DbRep $name - Reading Schlüssel: $key");
  1022. delete($defs{$name}{READINGS}{$key}) if($key ne "state");
  1023. }
  1024. # "1" ist Statusbit für manuelle Abfrage, kein Einstieg in Pollingroutine
  1025. SSCam_getcaminfoall($hash,1);
  1026. } elsif ($opt =~ /versionNotes/) {
  1027. my $header = "<b>Module release information</b><br>";
  1028. my $header1 = "<b>Helpful hints</b><br>";
  1029. my %hs;
  1030. # Ausgabetabelle erstellen
  1031. my ($ret,$val0,$val1);
  1032. my $i = 0;
  1033. $ret = "<html>";
  1034. # Hints
  1035. if(!$arg || $arg =~ /hints/ || $arg =~ /[\d]+/) {
  1036. $ret .= sprintf("<div class=\"makeTable wide\"; style=\"text-align:left\">$header1 <br>");
  1037. $ret .= "<table class=\"block wide internals\">";
  1038. $ret .= "<tbody>";
  1039. $ret .= "<tr class=\"even\">";
  1040. if($arg && $arg =~ /[\d]+/) {
  1041. if(AttrVal("global","language","EN") eq "DE") {
  1042. %hs = ( $arg => $SSCam_vHintsExt_de{$arg} );
  1043. } else {
  1044. %hs = ( $arg => $SSCam_vHintsExt_en{$arg} );
  1045. }
  1046. } else {
  1047. if(AttrVal("global","language","EN") eq "DE") {
  1048. %hs = %SSCam_vHintsExt_de;
  1049. } else {
  1050. %hs = %SSCam_vHintsExt_en;
  1051. }
  1052. }
  1053. $i = 0;
  1054. foreach my $key (reverse sort(keys %hs)) {
  1055. $val0 = $hs{$key};
  1056. $ret .= sprintf("<td style=\"vertical-align:top\"><b>$key</b> </td><td style=\"vertical-align:top\">$val0</td>" );
  1057. $ret .= "</tr>";
  1058. $i++;
  1059. if ($i & 1) {
  1060. # $i ist ungerade
  1061. $ret .= "<tr class=\"odd\">";
  1062. } else {
  1063. $ret .= "<tr class=\"even\">";
  1064. }
  1065. }
  1066. $ret .= "</tr>";
  1067. $ret .= "</tbody>";
  1068. $ret .= "</table>";
  1069. $ret .= "</div>";
  1070. }
  1071. # Notes
  1072. if(!$arg || $arg =~ /rel/) {
  1073. $ret .= sprintf("<div class=\"makeTable wide\"; style=\"text-align:left\">$header <br>");
  1074. $ret .= "<table class=\"block wide internals\">";
  1075. $ret .= "<tbody>";
  1076. $ret .= "<tr class=\"even\">";
  1077. $i = 0;
  1078. foreach my $key (reverse sort(keys %SSCam_vNotesExtern)) {
  1079. ($val0,$val1) = split(/\s/,$SSCam_vNotesExtern{$key},2);
  1080. $ret .= sprintf("<td style=\"vertical-align:top\"><b>$key</b> </td><td style=\"vertical-align:top\">$val0 </td><td>$val1</td>" );
  1081. $ret .= "</tr>";
  1082. $i++;
  1083. if ($i & 1) {
  1084. # $i ist ungerade
  1085. $ret .= "<tr class=\"odd\">";
  1086. } else {
  1087. $ret .= "<tr class=\"even\">";
  1088. }
  1089. }
  1090. $ret .= "</tr>";
  1091. $ret .= "</tbody>";
  1092. $ret .= "</table>";
  1093. $ret .= "</div>";
  1094. }
  1095. $ret .= "</html>";
  1096. return $ret;
  1097. } else {
  1098. return "$getlist";
  1099. }
  1100. return $ret; # not generate trigger out of command
  1101. }
  1102. ######################################################################################
  1103. # Kamera Liveview Anzeige in FHEMWEB
  1104. ######################################################################################
  1105. # wird von FW aufgerufen. $FW_wname = aufrufende Webinstanz, $d = aufrufendes
  1106. # Device (z.B. CamCP1)
  1107. sub SSCam_FWsummaryFn ($$$$) {
  1108. my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn in FHEMWEB
  1109. my $hash = $defs{$d};
  1110. my $name = $hash->{NAME};
  1111. my $link = $hash->{HELPER}{LINK};
  1112. my $wltype = $hash->{HELPER}{WLTYPE};
  1113. my $ret;
  1114. my $alias;
  1115. return if(!$hash->{HELPER}{LINK} || ReadingsVal($d, "state", "") =~ /^dis.*/ || IsDisabled($name));
  1116. # Definition Tasten
  1117. my $imgblank = "<img src=\"$FW_ME/www/images/sscam/black_btn_CAMBLANK.png\">"; # nicht sichtbare Leertaste
  1118. my $cmdstop = "cmd=set $d stopView"; # Stream deaktivieren
  1119. my $imgstop = "<img src=\"$FW_ME/www/images/default/remotecontrol/black_btn_POWEROFF3.png\">";
  1120. my $cmdhlsreact = "cmd=set $d hlsreactivate"; # HLS Stream reaktivieren
  1121. my $imghlsreact = "<img src=\"$FW_ME/www/images/default/remotecontrol/black_btn_BACKDroid.png\">";
  1122. my $cmdmjpegrun = "cmd=set $d runView live_fw"; # MJPEG Stream aktivieren
  1123. my $imgmjpegrun = "<img src=\"$FW_ME/www/images/sscam/black_btn_MJPEG.png\">";
  1124. my $cmdhlsrun = "cmd=set $d runView live_fw_hls"; # HLS Stream aktivieren
  1125. my $imghlsrun = "<img src=\"$FW_ME/www/images/sscam/black_btn_HLS.png\">";
  1126. my $cmdlrirun = "cmd=set $d runView lastrec_fw"; # Last Record IFrame
  1127. my $imglrirun = "<img src=\"$FW_ME/www/images/sscam/black_btn_LASTRECIFRAME.png\">";
  1128. my $cmdlh264run = "cmd=set $d runView lastrec_fw_MPEG4/H.264"; # Last Record H.264
  1129. my $imglh264run = "<img src=\"$FW_ME/www/images/sscam/black_btn_LRECH264.png\">";
  1130. my $cmdlmjpegrun = "cmd=set $d runView lastrec_fw_MJPEG"; # Last Record MJPEG
  1131. my $imglmjpegrun = "<img src=\"$FW_ME/www/images/sscam/black_btn_LRECMJPEG.png\">";
  1132. my $cmdlsnaprun = "cmd=set $d runView lastsnap_fw STRM"; # Last SNAP
  1133. my $imglsnaprun = "<img src=\"$FW_ME/www/images/sscam/black_btn_LSNAP.png\">";
  1134. my $cmdrecendless = "cmd=set $d on 0"; # Endlosaufnahme Start
  1135. my $imgrecendless = "<img src=\"$FW_ME/www/images/sscam/black_btn_RECSTART.png\">";
  1136. my $cmdrecstop = "cmd=set $d off"; # Aufnahme Stop
  1137. my $imgrecstop = "<img src=\"$FW_ME/www/images/sscam/black_btn_RECSTOP.png\">";
  1138. my $cmddosnap = "cmd=set $d snap STRM"; # Snapshot auslösen mit Kennzeichnung "by STRM-Device"
  1139. my $imgdosnap = "<img src=\"$FW_ME/www/images/sscam/black_btn_DOSNAP.png\">";
  1140. my $attr = AttrVal($d, "htmlattr", " ");
  1141. Log3($name, 4, "$name - SSCam_FWsummaryFn called - FW_wname: $FW_wname, device: $d, room: $room, attributes: $attr");
  1142. if($wltype eq "image") {
  1143. $ret = "<img src=$link $attr><br>";
  1144. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  1145. $ret .= $imgblank;
  1146. if($hash->{HELPER}{RUNVIEW} =~ /live_fw/) {
  1147. if(ReadingsVal($d, "Record", "Stop") eq "Stop") {
  1148. # Aufnahmebutton endlos Start
  1149. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecendless')\">$imgrecendless </a>";
  1150. } else {
  1151. # Aufnahmebutton Stop
  1152. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecstop')\">$imgrecstop </a>";
  1153. }
  1154. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>";
  1155. }
  1156. $ret .= "<br>";
  1157. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($d, "CamAudioType", "Unknown") !~ /Unknown/) {
  1158. $ret .= "<audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  1159. Your browser does not support the audio element.
  1160. </audio>";
  1161. }
  1162. } elsif($wltype eq "iframe") {
  1163. $ret = "<iframe src=$link $attr controls autoplay>
  1164. Iframes disabled
  1165. </iframe>";
  1166. $ret .= "<br>";
  1167. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  1168. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($d, "CamAudioType", "Unknown") !~ /Unknown/) {
  1169. $ret .= "<audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  1170. Your browser does not support the audio element.
  1171. </audio>";
  1172. }
  1173. } elsif($wltype eq "embed") {
  1174. $ret = "<embed src=$link $attr>";
  1175. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($d, "CamAudioType", "Unknown") !~ /Unknown/) {
  1176. $ret .= "<audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  1177. Your browser does not support the audio element.
  1178. </audio>";
  1179. }
  1180. } elsif($wltype eq "link") {
  1181. $alias = $hash->{HELPER}{ALIAS};
  1182. $ret = "<a href=$link $attr>$alias</a><br>";
  1183. } elsif($wltype eq "base64img") {
  1184. $alias = $hash->{HELPER}{ALIAS};
  1185. $ret = "<img $attr alt='$alias' src='data:image/jpeg;base64,$link'><br>";
  1186. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  1187. } elsif($wltype eq "hls") {
  1188. $alias = $hash->{HELPER}{ALIAS};
  1189. $ret = "<video $attr controls autoplay>
  1190. <source src=$link type=\"application/x-mpegURL\">
  1191. <source src=$link type=\"video/MP2T\">
  1192. Your browser does not support the video tag
  1193. </video>";
  1194. $ret .= "<br>";
  1195. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  1196. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdhlsreact')\">$imghlsreact </a>";
  1197. $ret .= $imgblank;
  1198. if(ReadingsVal($d, "Record", "Stop") eq "Stop") {
  1199. # Aufnahmebutton endlos Start
  1200. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecendless')\">$imgrecendless </a>";
  1201. } else {
  1202. # Aufnahmebutton Stop
  1203. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecstop')\">$imgrecstop </a>";
  1204. }
  1205. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>";
  1206. } elsif($wltype eq "video") {
  1207. $ret = "<video $attr controls autoplay>
  1208. <source src=$link type=\"video/mp4\">
  1209. <source src=$link type=\"video/ogg\">
  1210. <source src=$link type=\"video/webm\">
  1211. Your browser does not support the video tag.
  1212. </video>";
  1213. $ret .= "<br>";
  1214. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  1215. $ret .= "<br>";
  1216. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($d, "CamAudioType", "Unknown") !~ /Unknown/) {
  1217. $ret .= "<audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  1218. Your browser does not support the audio element.
  1219. </audio>";
  1220. }
  1221. }
  1222. return $ret;
  1223. }
  1224. ######################################################################################
  1225. # PTZ-Steuerpanel in Detailanzeige darstellen
  1226. ######################################################################################
  1227. sub SSCam_FWdetailFn ($$$$) {
  1228. my ($FW_wname, $d, $room, $pageHash) = @_; # pageHash is set for summaryFn.
  1229. my $hash = $defs{$d};
  1230. return undef if(!AttrVal($d,"ptzPanel_use",1));
  1231. $hash->{".ptzhtml"} = SSCam_ptzpanel($d) if($hash->{".ptzhtml"} eq "");
  1232. if($hash->{".ptzhtml"} ne "") {
  1233. return $hash->{".ptzhtml"};
  1234. } else {
  1235. return undef;
  1236. }
  1237. }
  1238. ######################################################################################
  1239. # initiale Startroutinen nach Restart FHEM
  1240. ######################################################################################
  1241. sub SSCam_initonboot ($) {
  1242. my ($hash) = @_;
  1243. my $name = $hash->{NAME};
  1244. RemoveInternalTimer($hash, "SSCam_initonboot");
  1245. if ($init_done == 1) {
  1246. RemoveInternalTimer($hash); # alle Timer löschen
  1247. delete($defs{$name}{READINGS}{LiveStreamUrl}) if($defs{$name}{READINGS}{LiveStreamUrl}); # LiveStream URL zurücksetzen
  1248. # check ob alle Recordings = "Stop" nach Reboot -> sonst stoppen
  1249. if (ReadingsVal($hash->{NAME}, "Record", "Stop") eq "Start") {
  1250. Log3($name, 2, "$name - Recording of $hash->{CAMNAME} seems to be still active after FHEM restart - try to stop it now");
  1251. SSCam_camstoprec($hash);
  1252. }
  1253. # Konfiguration der Synology Surveillance Station abrufen
  1254. if (!$hash->{CREDENTIALS}) {
  1255. Log3($name, 2, "$name - Credentials of $name are not set - make sure you've set it with \"set $name credentials username password\"");
  1256. } else {
  1257. readingsSingleUpdate($hash, "compstate", "true", 0); # Anfangswert f. versionCheck setzen
  1258. # allg. SVS-Eigenschaften abrufen
  1259. SSCam_getsvsinfo($hash);
  1260. if(SSCam_IsModelCam($hash)) {
  1261. # Kameraspezifische Infos holen
  1262. SSCam_getcaminfo($hash);
  1263. SSCam_getcapabilities($hash);
  1264. SSCam_getStmUrlPath($hash);
  1265. # Preset/Patrollisten in Hash einlesen zur PTZ-Steuerung
  1266. SSCam_getptzlistpreset($hash);
  1267. SSCam_getptzlistpatrol($hash);
  1268. # Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
  1269. my ($slim,$ssize) = SSCam_snaplimsize($hash);
  1270. RemoveInternalTimer("SSCam_getsnapinfo");
  1271. InternalTimer(gettimeofday()+0.9, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  1272. }
  1273. SSCam_versionCheck($hash); # Einstieg in regelmäßigen Check Kompatibilität
  1274. }
  1275. # Subroutine Watchdog-Timer starten (sollen Cam-Infos regelmäßig abgerufen werden ?), verzögerter zufälliger Start 0-30s
  1276. RemoveInternalTimer($hash, "SSCam_wdpollcaminfo");
  1277. InternalTimer(gettimeofday()+int(rand(30)), "SSCam_wdpollcaminfo", $hash, 0);
  1278. } else {
  1279. InternalTimer(gettimeofday()+1, "SSCam_initonboot", $hash, 0);
  1280. }
  1281. return;
  1282. }
  1283. ###############################################################################
  1284. # Dauerschleife Kompatibilitätscheck SSCam <-> SVS
  1285. ###############################################################################
  1286. sub SSCam_versionCheck($) {
  1287. my ($hash) = @_;
  1288. my $name = $hash->{NAME};
  1289. my $rc = 21600;
  1290. RemoveInternalTimer($hash, "SSCam_versionCheck");
  1291. return if(IsDisabled($name));
  1292. my $cs = ReadingsVal($name, "compstate", "true");
  1293. if($cs eq "false") {
  1294. Log3($name, 2, "$name - WARNING - The current/simulated SVS-version ".ReadingsVal($name, "SVSversion", "").
  1295. " may be incompatible with SSCam version $hash->{VERSION}. ".
  1296. "For further information execute \"get <name> versionNotes 4\".");
  1297. }
  1298. InternalTimer(gettimeofday()+$rc, "SSCam_versionCheck", $hash, 0);
  1299. return;
  1300. }
  1301. ######################################################################################
  1302. # Username / Paßwort speichern
  1303. ######################################################################################
  1304. sub SSCam_setcredentials ($@) {
  1305. my ($hash, @credentials) = @_;
  1306. my $name = $hash->{NAME};
  1307. my $success;
  1308. my $credstr;
  1309. my $index;
  1310. my $retcode;
  1311. my (@key,$len,$i);
  1312. $credstr = encode_base64(join(':', @credentials));
  1313. # Beginn Scramble-Routine
  1314. @key = qw(1 3 4 5 6 3 2 1 9);
  1315. $len = scalar @key;
  1316. $i = 0;
  1317. $credstr = join "",
  1318. map { $i = ($i + 1) % $len;
  1319. chr((ord($_) + $key[$i]) % 256) } split //, $credstr;
  1320. # End Scramble-Routine
  1321. $index = $hash->{TYPE}."_".$hash->{NAME}."_credentials";
  1322. $retcode = setKeyValue($index, $credstr);
  1323. if ($retcode) {
  1324. Log3($name, 2, "$name - Error while saving the Credentials - $retcode");
  1325. $success = 0;
  1326. } else {
  1327. SSCam_getcredentials($hash,1); # Credentials nach Speicherung lesen und in RAM laden ($boot=1)
  1328. $success = 1;
  1329. }
  1330. return ($success);
  1331. }
  1332. ######################################################################################
  1333. # Username / Paßwort abrufen
  1334. ######################################################################################
  1335. sub SSCam_getcredentials ($$) {
  1336. my ($hash,$boot) = @_;
  1337. my $name = $hash->{NAME};
  1338. my $success;
  1339. my $username;
  1340. my $passwd;
  1341. my $index;
  1342. my ($retcode, $credstr);
  1343. my (@key,$len,$i);
  1344. if ($boot eq 1) {
  1345. # mit $boot=1 Credentials von Platte lesen und als scrambled-String in RAM legen
  1346. $index = $hash->{TYPE}."_".$hash->{NAME}."_credentials";
  1347. ($retcode, $credstr) = getKeyValue($index);
  1348. if ($retcode) {
  1349. Log3($name, 2, "$name - Unable to read password from file: $retcode");
  1350. $success = 0;
  1351. }
  1352. if ($credstr) {
  1353. # beim Boot scrambled Credentials in den RAM laden
  1354. $hash->{HELPER}{CREDENTIALS} = $credstr;
  1355. # "Credentials" wird als Statusbit ausgewertet. Wenn nicht gesetzt -> Warnmeldung und keine weitere Verarbeitung
  1356. $hash->{CREDENTIALS} = "Set";
  1357. $success = 1;
  1358. }
  1359. } else {
  1360. # boot = 0 -> Credentials aus RAM lesen, decoden und zurückgeben
  1361. $credstr = $hash->{HELPER}{CREDENTIALS};
  1362. # Beginn Descramble-Routine
  1363. @key = qw(1 3 4 5 6 3 2 1 9);
  1364. $len = scalar @key;
  1365. $i = 0;
  1366. $credstr = join "",
  1367. map { $i = ($i + 1) % $len;
  1368. chr((ord($_) - $key[$i] + 256) % 256) }
  1369. split //, $credstr;
  1370. # Ende Descramble-Routine
  1371. ($username, $passwd) = split(":",decode_base64($credstr));
  1372. my $logpw = AttrVal($name, "showPassInLog", "0") == 1 ? $passwd : "********";
  1373. Log3($name, 4, "$name - Credentials read from RAM: $username $logpw");
  1374. $success = (defined($passwd)) ? 1 : 0;
  1375. }
  1376. return ($success, $username, $passwd);
  1377. }
  1378. ######################################################################################
  1379. # Polling Überwachung
  1380. ######################################################################################
  1381. sub SSCam_wdpollcaminfo ($) {
  1382. # Überwacht die Wert von Attribut "pollcaminfoall" und Reading "PollState"
  1383. # wenn Attribut "pollcaminfoall" > 10 und "PollState"=Inactive -> start Polling
  1384. my ($hash) = @_;
  1385. my $name = $hash->{NAME};
  1386. my $camname = $hash->{CAMNAME};
  1387. my $pcia = AttrVal($name,"pollcaminfoall",0);
  1388. my $pnl = AttrVal($name,"pollnologging",0);
  1389. my $watchdogtimer = 90;
  1390. RemoveInternalTimer($hash, "SSCam_wdpollcaminfo");
  1391. # Poll-Logging prüfen
  1392. if ($hash->{HELPER}{OLDVALPOLLNOLOGGING} != $pnl) {
  1393. $hash->{HELPER}{OLDVALPOLLNOLOGGING} = $pnl; # aktuellen pollnologging-Wert in $hash eintragen für späteren Vergleich
  1394. if ($pnl) {
  1395. Log3($name, 3, "$name - Polling-Log of $camname is deactivated");
  1396. } else {
  1397. Log3($name, 3, "$name - Polling-Log of $camname is activated");
  1398. }
  1399. }
  1400. # Polling prüfen
  1401. if ($pcia && !IsDisabled($name)) {
  1402. if(ReadingsVal($name, "PollState", "Active") eq "Inactive") {
  1403. readingsSingleUpdate($hash,"PollState","Active",1); # Polling ist jetzt aktiv
  1404. readingsSingleUpdate($hash,"state","polling",1) if(!SSCam_IsModelCam($hash)); # Polling-state bei einem SVS-Device setzten
  1405. Log3($name, 3, "$name - Polling of $camname is activated - Pollinginterval: $pcia s");
  1406. $hash->{HELPER}{OLDVALPOLL} = $pcia; # in $hash eintragen für späteren Vergleich (Changes von pollcaminfoall)
  1407. SSCam_getcaminfoall($hash,0);
  1408. }
  1409. my $lupd = ReadingsVal($name, "LastUpdateTime", 0);
  1410. if ($lupd) {
  1411. my ($year, $month, $mday, $hour, $min, $sec) = ($lupd =~ /(\d+)\.(\d+)\.(\d+) \/ (\d+):(\d+):(\d+)/);
  1412. $lupd = fhemTimeGm($sec, $min, $hour, $mday, $month, $year);
  1413. }
  1414. if( gettimeofday() < ($lupd + $pcia + 20) ) {
  1415. SSCam_getcaminfoall($hash,0);
  1416. }
  1417. }
  1418. if (defined($hash->{HELPER}{OLDVALPOLL}) && $pcia) {
  1419. if ($hash->{HELPER}{OLDVALPOLL} != $pcia) {
  1420. Log3($name, 3, "$name - Pollinginterval of $camname has been changed to: $pcia s");
  1421. $hash->{HELPER}{OLDVALPOLL} = $pcia;
  1422. }
  1423. }
  1424. InternalTimer(gettimeofday()+$watchdogtimer, "SSCam_wdpollcaminfo", $hash, 0);
  1425. return undef;
  1426. }
  1427. ############################################################################################################
  1428. # OpMode-Startroutinen #
  1429. # $hash->{HELPER}{ACTIVE} = Funktionstoken #
  1430. # $hash->{HELPER}{ACTIVE} = "on" -> eine Routine läuft, Start anderer Routine erst wenn "off". #
  1431. # $hash->{HELPER}{ACTIVE} = "off" -> keine andere Routine läuft, sofortiger Start möglich #
  1432. ############################################################################################################
  1433. ###############################################################################
  1434. # Kamera Aufnahme starten
  1435. ###############################################################################
  1436. sub SSCam_camstartrec ($) {
  1437. my ($hash) = @_;
  1438. my $camname = $hash->{CAMNAME};
  1439. my $name = $hash->{NAME};
  1440. my $errorcode;
  1441. my $error;
  1442. RemoveInternalTimer($hash, "SSCam_camstartrec");
  1443. return if(IsDisabled($name));
  1444. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1445. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1446. $errorcode = "402";
  1447. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1448. $errorcode = "502";
  1449. }
  1450. # Fehlertext zum Errorcode ermitteln
  1451. $error = SSCam_experror($hash,$errorcode);
  1452. # Setreading
  1453. readingsBeginUpdate($hash);
  1454. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1455. readingsBulkUpdate($hash,"Error",$error);
  1456. readingsEndUpdate($hash, 1);
  1457. Log3($name, 2, "$name - ERROR - Start Recording of Camera $camname can't be executed - $error");
  1458. return;
  1459. }
  1460. if (ReadingsVal("$name", "Record", undef) eq "Start" and !AttrVal($name, "recextend", undef)) {
  1461. Log3($name, 3, "$name - another recording is already running - new start-command will be ignored");
  1462. return;
  1463. }
  1464. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1465. # Aufnahme starten
  1466. $hash->{OPMODE} = "Start";
  1467. $hash->{HELPER}{ACTIVE} = "on";
  1468. $hash->{HELPER}{LOGINRETRIES} = 0;
  1469. if (AttrVal($name,"debugactivetoken",0)) {
  1470. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1471. }
  1472. SSCam_getapisites($hash);
  1473. } else {
  1474. InternalTimer(gettimeofday()+0.3, "SSCam_camstartrec", $hash);
  1475. }
  1476. }
  1477. ###############################################################################
  1478. # Kamera Aufnahme stoppen
  1479. ###############################################################################
  1480. sub SSCam_camstoprec ($) {
  1481. my ($hash) = @_;
  1482. my $camname = $hash->{CAMNAME};
  1483. my $name = $hash->{NAME};
  1484. my $errorcode;
  1485. my $error;
  1486. RemoveInternalTimer($hash, "SSCam_camstoprec");
  1487. return if(IsDisabled($name));
  1488. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1489. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1490. $errorcode = "402";
  1491. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1492. $errorcode = "502";
  1493. }
  1494. # Fehlertext zum Errorcode ermitteln
  1495. $error = SSCam_experror($hash,$errorcode);
  1496. # Setreading
  1497. readingsBeginUpdate($hash);
  1498. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1499. readingsBulkUpdate($hash,"Error",$error);
  1500. readingsEndUpdate($hash, 1);
  1501. Log3($name, 2, "$name - ERROR - Stop Recording of Camera $camname can't be executed - $error");
  1502. return;
  1503. }
  1504. if (ReadingsVal("$name", "Record", undef) eq "Stop") {
  1505. Log3($name, 3, "$name - recording is already stopped - new stop-command will be ignored");
  1506. return;
  1507. }
  1508. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1509. $hash->{OPMODE} = "Stop";
  1510. $hash->{HELPER}{ACTIVE} = "on";
  1511. $hash->{HELPER}{LOGINRETRIES} = 0;
  1512. if (AttrVal($name,"debugactivetoken",0)) {
  1513. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1514. }
  1515. SSCam_getapisites($hash);
  1516. } else {
  1517. InternalTimer(gettimeofday()+0.3, "SSCam_camstoprec", $hash, 0);
  1518. }
  1519. }
  1520. ###############################################################################
  1521. # Kamera Auto / Day / Nightmode setzen
  1522. ###############################################################################
  1523. sub SSCam_camexpmode($) {
  1524. my ($hash) = @_;
  1525. my $camname = $hash->{CAMNAME};
  1526. my $name = $hash->{NAME};
  1527. my $errorcode;
  1528. my $error;
  1529. RemoveInternalTimer($hash, "SSCam_camexpmode");
  1530. return if(IsDisabled($name));
  1531. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1532. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1533. $errorcode = "402";
  1534. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1535. $errorcode = "502";
  1536. }
  1537. # Fehlertext zum Errorcode ermitteln
  1538. $error = SSCam_experror($hash,$errorcode);
  1539. # Setreading
  1540. readingsBeginUpdate($hash);
  1541. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1542. readingsBulkUpdate($hash,"Error",$error);
  1543. readingsEndUpdate($hash, 1);
  1544. Log3($name, 2, "$name - ERROR - Setting exposure mode of Camera $camname can't be executed - $error");
  1545. return;
  1546. }
  1547. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1548. $hash->{OPMODE} = "ExpMode";
  1549. $hash->{HELPER}{ACTIVE} = "on";
  1550. $hash->{HELPER}{LOGINRETRIES} = 0;
  1551. if (AttrVal($name,"debugactivetoken",0)) {
  1552. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1553. }
  1554. SSCam_getapisites($hash);
  1555. } else {
  1556. InternalTimer(gettimeofday()+0.5, "SSCam_camexpmode", $hash, 0);
  1557. }
  1558. }
  1559. ###############################################################################
  1560. # Art der Bewegungserkennung setzen
  1561. ###############################################################################
  1562. sub SSCam_cammotdetsc($) {
  1563. my ($hash) = @_;
  1564. my $camname = $hash->{CAMNAME};
  1565. my $name = $hash->{NAME};
  1566. my $errorcode;
  1567. my $error;
  1568. RemoveInternalTimer($hash, "SSCam_cammotdetsc");
  1569. return if(IsDisabled($name));
  1570. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1571. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1572. $errorcode = "402";
  1573. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1574. $errorcode = "502";
  1575. }
  1576. # Fehlertext zum Errorcode ermitteln
  1577. $error = SSCam_experror($hash,$errorcode);
  1578. # Setreading
  1579. readingsBeginUpdate($hash);
  1580. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1581. readingsBulkUpdate($hash,"Error",$error);
  1582. readingsEndUpdate($hash, 1);
  1583. Log3($name, 2, "$name - ERROR - Setting of motion detection source of Camera $camname can't be executed - $error");
  1584. return;
  1585. }
  1586. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1587. $hash->{OPMODE} = "MotDetSc";
  1588. $hash->{HELPER}{ACTIVE} = "on";
  1589. $hash->{HELPER}{LOGINRETRIES} = 0;
  1590. if (AttrVal($name,"debugactivetoken",0)) {
  1591. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1592. }
  1593. SSCam_getapisites($hash);
  1594. } else {
  1595. InternalTimer(gettimeofday()+0.5, "SSCam_cammotdetsc", $hash, 0);
  1596. }
  1597. }
  1598. ###############################################################################
  1599. # Kamera Schappschuß aufnehmen
  1600. ###############################################################################
  1601. sub SSCam_camsnap($) {
  1602. my ($hash) = @_;
  1603. my $camname = $hash->{CAMNAME};
  1604. my $name = $hash->{NAME};
  1605. my $errorcode;
  1606. my $error;
  1607. RemoveInternalTimer($hash, "SSCam_camsnap");
  1608. return if(IsDisabled($name));
  1609. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1610. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1611. $errorcode = "402";
  1612. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1613. $errorcode = "502";
  1614. }
  1615. # Fehlertext zum Errorcode ermitteln
  1616. $error = SSCam_experror($hash,$errorcode);
  1617. # Setreading
  1618. readingsBeginUpdate($hash);
  1619. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1620. readingsBulkUpdate($hash,"Error",$error);
  1621. readingsEndUpdate($hash, 1);
  1622. Log3($name, 2, "$name - ERROR - Snapshot of Camera $camname can't be executed - $error");
  1623. return;
  1624. }
  1625. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1626. # einen Schnappschuß aufnehmen
  1627. $hash->{OPMODE} = "Snap";
  1628. $hash->{HELPER}{ACTIVE} = "on";
  1629. $hash->{HELPER}{LOGINRETRIES} = 0;
  1630. if (AttrVal($name,"debugactivetoken",0)) {
  1631. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1632. }
  1633. SSCam_getapisites($hash);
  1634. } else {
  1635. InternalTimer(gettimeofday()+0.3, "SSCam_camsnap", $hash, 0);
  1636. }
  1637. }
  1638. ###############################################################################
  1639. # Start Object Tracking
  1640. ###############################################################################
  1641. sub SSCam_starttrack($) {
  1642. my ($hash) = @_;
  1643. my $camname = $hash->{CAMNAME};
  1644. my $name = $hash->{NAME};
  1645. my $errorcode;
  1646. my $error;
  1647. RemoveInternalTimer($hash, "SSCam_starttrack");
  1648. return if(IsDisabled($name));
  1649. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1650. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1651. $errorcode = "402";
  1652. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1653. $errorcode = "502";
  1654. }
  1655. # Fehlertext zum Errorcode ermitteln
  1656. $error = SSCam_experror($hash,$errorcode);
  1657. readingsBeginUpdate($hash);
  1658. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1659. readingsBulkUpdate($hash,"Error",$error);
  1660. readingsEndUpdate($hash, 1);
  1661. Log3($name, 2, "$name - ERROR - Object Tracking of Camera $camname can't switched on - $error");
  1662. return;
  1663. }
  1664. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1665. $hash->{OPMODE} = "startTrack";
  1666. $hash->{HELPER}{ACTIVE} = "on";
  1667. $hash->{HELPER}{LOGINRETRIES} = 0;
  1668. if (AttrVal($name,"debugactivetoken",0)) {
  1669. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1670. }
  1671. SSCam_getapisites($hash);
  1672. } else {
  1673. InternalTimer(gettimeofday()+0.9, "SSCam_starttrack", $hash, 0);
  1674. }
  1675. }
  1676. ###############################################################################
  1677. # Stopp Object Tracking
  1678. ###############################################################################
  1679. sub SSCam_stoptrack($) {
  1680. my ($hash) = @_;
  1681. my $camname = $hash->{CAMNAME};
  1682. my $name = $hash->{NAME};
  1683. my $errorcode;
  1684. my $error;
  1685. RemoveInternalTimer($hash, "SSCam_stoptrack");
  1686. return if(IsDisabled($name));
  1687. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1688. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1689. $errorcode = "402";
  1690. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1691. $errorcode = "502";
  1692. }
  1693. # Fehlertext zum Errorcode ermitteln
  1694. $error = SSCam_experror($hash,$errorcode);
  1695. readingsBeginUpdate($hash);
  1696. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1697. readingsBulkUpdate($hash,"Error",$error);
  1698. readingsEndUpdate($hash, 1);
  1699. Log3($name, 2, "$name - ERROR - Object Tracking of Camera $camname can't switched off - $error");
  1700. return;
  1701. }
  1702. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1703. $hash->{OPMODE} = "stopTrack";
  1704. $hash->{HELPER}{ACTIVE} = "on";
  1705. $hash->{HELPER}{LOGINRETRIES} = 0;
  1706. if (AttrVal($name,"debugactivetoken",0)) {
  1707. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1708. }
  1709. SSCam_getapisites($hash);
  1710. } else {
  1711. InternalTimer(gettimeofday()+0.9, "SSCam_stoptrack", $hash, 0);
  1712. }
  1713. }
  1714. ###############################################################################
  1715. # Preset-Array abrufen
  1716. ###############################################################################
  1717. sub SSCam_getpresets($) {
  1718. my ($hash) = @_;
  1719. my $camname = $hash->{CAMNAME};
  1720. my $name = $hash->{NAME};
  1721. my $errorcode;
  1722. my $error;
  1723. RemoveInternalTimer($hash, "SSCam_getpresets");
  1724. return if(IsDisabled($name));
  1725. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1726. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1727. $errorcode = "402";
  1728. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1729. $errorcode = "502";
  1730. }
  1731. # Fehlertext zum Errorcode ermitteln
  1732. $error = SSCam_experror($hash,$errorcode);
  1733. readingsBeginUpdate($hash);
  1734. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1735. readingsBulkUpdate($hash,"Error",$error);
  1736. readingsEndUpdate($hash, 1);
  1737. Log3($name, 2, "$name - ERROR - Preset list of Camera $camname can't be get - $error");
  1738. return;
  1739. }
  1740. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1741. $hash->{OPMODE} = "getPresets";
  1742. $hash->{HELPER}{ACTIVE} = "on";
  1743. $hash->{HELPER}{LOGINRETRIES} = 0;
  1744. if (AttrVal($name,"debugactivetoken",0)) {
  1745. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1746. }
  1747. SSCam_getapisites($hash);
  1748. } else {
  1749. InternalTimer(gettimeofday()+1.2, "SSCam_getpresets", $hash, 0);
  1750. }
  1751. }
  1752. ###############################################################################
  1753. # einen Preset setzen
  1754. ###############################################################################
  1755. sub SSCam_setPreset($) {
  1756. my ($hash) = @_;
  1757. my $camname = $hash->{CAMNAME};
  1758. my $name = $hash->{NAME};
  1759. my $errorcode;
  1760. my $error;
  1761. RemoveInternalTimer($hash, "SSCam_setPreset");
  1762. return if(IsDisabled($name));
  1763. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1764. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1765. $errorcode = "402";
  1766. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1767. $errorcode = "502";
  1768. }
  1769. # Fehlertext zum Errorcode ermitteln
  1770. $error = SSCam_experror($hash,$errorcode);
  1771. readingsBeginUpdate($hash);
  1772. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1773. readingsBulkUpdate($hash,"Error",$error);
  1774. readingsEndUpdate($hash, 1);
  1775. Log3($name, 2, "$name - ERROR - Preset of Camera $camname can't be set - $error");
  1776. return;
  1777. }
  1778. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1779. $hash->{OPMODE} = "setPreset";
  1780. $hash->{HELPER}{ACTIVE} = "on";
  1781. $hash->{HELPER}{LOGINRETRIES} = 0;
  1782. if (AttrVal($name,"debugactivetoken",0)) {
  1783. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1784. }
  1785. SSCam_getapisites($hash);
  1786. } else {
  1787. InternalTimer(gettimeofday()+1.2, "SSCam_setPreset", $hash, 0);
  1788. }
  1789. }
  1790. ###############################################################################
  1791. # einen Preset löschen
  1792. ###############################################################################
  1793. sub SSCam_delPreset($) {
  1794. my ($hash) = @_;
  1795. my $camname = $hash->{CAMNAME};
  1796. my $name = $hash->{NAME};
  1797. my $errorcode;
  1798. my $error;
  1799. RemoveInternalTimer($hash, "SSCam_delPreset");
  1800. return if(IsDisabled($name));
  1801. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1802. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1803. $errorcode = "402";
  1804. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1805. $errorcode = "502";
  1806. }
  1807. # Fehlertext zum Errorcode ermitteln
  1808. $error = SSCam_experror($hash,$errorcode);
  1809. readingsBeginUpdate($hash);
  1810. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1811. readingsBulkUpdate($hash,"Error",$error);
  1812. readingsEndUpdate($hash, 1);
  1813. Log3($name, 2, "$name - ERROR - Preset of Camera $camname can't be deleted - $error");
  1814. return;
  1815. }
  1816. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1817. $hash->{OPMODE} = "delPreset";
  1818. $hash->{HELPER}{ACTIVE} = "on";
  1819. $hash->{HELPER}{LOGINRETRIES} = 0;
  1820. if (AttrVal($name,"debugactivetoken",0)) {
  1821. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1822. }
  1823. SSCam_getapisites($hash);
  1824. } else {
  1825. InternalTimer(gettimeofday()+1.4, "SSCam_delPreset", $hash, 0);
  1826. }
  1827. }
  1828. ###############################################################################
  1829. # Preset Home setzen
  1830. ###############################################################################
  1831. sub SSCam_setHome($) {
  1832. my ($hash) = @_;
  1833. my $camname = $hash->{CAMNAME};
  1834. my $name = $hash->{NAME};
  1835. my $errorcode;
  1836. my $error;
  1837. RemoveInternalTimer($hash, "SSCam_setHome");
  1838. return if(IsDisabled($name));
  1839. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1840. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1841. $errorcode = "402";
  1842. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1843. $errorcode = "502";
  1844. }
  1845. # Fehlertext zum Errorcode ermitteln
  1846. $error = SSCam_experror($hash,$errorcode);
  1847. readingsBeginUpdate($hash);
  1848. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1849. readingsBulkUpdate($hash,"Error",$error);
  1850. readingsEndUpdate($hash, 1);
  1851. Log3($name, 2, "$name - ERROR - Home preset of Camera $camname can't be set - $error");
  1852. return;
  1853. }
  1854. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1855. $hash->{OPMODE} = "setHome";
  1856. $hash->{HELPER}{ACTIVE} = "on";
  1857. $hash->{HELPER}{LOGINRETRIES} = 0;
  1858. if (AttrVal($name,"debugactivetoken",0)) {
  1859. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1860. }
  1861. SSCam_getapisites($hash);
  1862. } else {
  1863. InternalTimer(gettimeofday()+1.2, "SSCam_setHome", $hash, 0);
  1864. }
  1865. }
  1866. ###############################################################################
  1867. # PIR Sensor aktivieren/deaktivieren
  1868. ###############################################################################
  1869. sub SSCam_piract($) {
  1870. my ($hash) = @_;
  1871. my $camname = $hash->{CAMNAME};
  1872. my $name = $hash->{NAME};
  1873. my $errorcode;
  1874. my $error;
  1875. RemoveInternalTimer($hash, "SSCam_piract");
  1876. return if(IsDisabled($name));
  1877. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1878. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1879. $errorcode = "402";
  1880. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1881. $errorcode = "502";
  1882. }
  1883. # Fehlertext zum Errorcode ermitteln
  1884. $error = SSCam_experror($hash,$errorcode);
  1885. readingsBeginUpdate($hash);
  1886. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1887. readingsBulkUpdate($hash,"Error",$error);
  1888. readingsEndUpdate($hash, 1);
  1889. Log3($name, 2, "$name - ERROR - Home preset of Camera $camname can't be set - $error");
  1890. return;
  1891. }
  1892. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1893. $hash->{OPMODE} = "piract";
  1894. $hash->{HELPER}{ACTIVE} = "on";
  1895. $hash->{HELPER}{LOGINRETRIES} = 0;
  1896. if (AttrVal($name,"debugactivetoken",0)) {
  1897. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1898. }
  1899. SSCam_getapisites($hash);
  1900. } else {
  1901. InternalTimer(gettimeofday()+1.2, "SSCam_piract", $hash, 0);
  1902. }
  1903. }
  1904. ###############################################################################
  1905. # Kamera Liveview starten
  1906. ###############################################################################
  1907. sub SSCam_runliveview($) {
  1908. my ($hash) = @_;
  1909. my $camname = $hash->{CAMNAME};
  1910. my $name = $hash->{NAME};
  1911. my $errorcode;
  1912. my $error;
  1913. RemoveInternalTimer($hash, "SSCam_runliveview");
  1914. return if(IsDisabled($name));
  1915. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1916. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1917. $errorcode = "402";
  1918. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1919. $errorcode = "502";
  1920. }
  1921. # Fehlertext zum Errorcode ermitteln
  1922. $error = &SSCam_experror($hash,$errorcode);
  1923. readingsBeginUpdate($hash);
  1924. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1925. readingsBulkUpdate($hash,"Error",$error);
  1926. readingsEndUpdate($hash, 1);
  1927. Log3($name, 2, "$name - ERROR - Liveview of Camera $camname can't be started - $error");
  1928. return;
  1929. }
  1930. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1931. # Liveview starten
  1932. $hash->{OPMODE} = "runliveview";
  1933. $hash->{HELPER}{ACTIVE} = "on";
  1934. $hash->{HELPER}{LOGINRETRIES} = 0;
  1935. # erzwingen die Camid zu ermitteln und bei login-Fehler neue SID zu holen
  1936. delete $hash->{CAMID};
  1937. if (AttrVal($name,"debugactivetoken",0)) {
  1938. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1939. }
  1940. readingsSingleUpdate($hash,"state","runView ".$hash->{HELPER}{RUNVIEW},1);
  1941. SSCam_getapisites($hash);
  1942. } else {
  1943. InternalTimer(gettimeofday()+0.5, "SSCam_runliveview", $hash, 0);
  1944. }
  1945. }
  1946. ###############################################################################
  1947. # Kamera HLS-Stream aktivieren
  1948. ###############################################################################
  1949. sub SSCam_hlsactivate($) {
  1950. my ($hash) = @_;
  1951. my $camname = $hash->{CAMNAME};
  1952. my $name = $hash->{NAME};
  1953. my $errorcode;
  1954. my $error;
  1955. RemoveInternalTimer($hash, "SSCam_hlsactivate");
  1956. return if(IsDisabled($name));
  1957. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1958. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1959. $errorcode = "402";
  1960. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  1961. $errorcode = "502";
  1962. }
  1963. # Fehlertext zum Errorcode ermitteln
  1964. $error = &SSCam_experror($hash,$errorcode);
  1965. readingsBeginUpdate($hash);
  1966. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  1967. readingsBulkUpdate($hash,"Error",$error);
  1968. readingsEndUpdate($hash, 1);
  1969. Log3($name, 2, "$name - ERROR - HLS-Stream of Camera $camname can't be activated - $error");
  1970. return;
  1971. }
  1972. if ($hash->{HELPER}{ACTIVE} eq "off") {
  1973. # Aktivierung starten
  1974. $hash->{OPMODE} = "activate_hls";
  1975. $hash->{HELPER}{ACTIVE} = "on";
  1976. $hash->{HELPER}{LOGINRETRIES} = 0;
  1977. if (AttrVal($name,"debugactivetoken",0)) {
  1978. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  1979. }
  1980. SSCam_getapisites($hash);
  1981. } else {
  1982. InternalTimer(gettimeofday()+0.3, "SSCam_hlsactivate", $hash, 0);
  1983. }
  1984. }
  1985. ###############################################################################
  1986. # HLS-Stream reaktivieren (stoppen & starten)
  1987. ###############################################################################
  1988. sub SSCam_hlsreactivate($) {
  1989. my ($hash) = @_;
  1990. my $camname = $hash->{CAMNAME};
  1991. my $name = $hash->{NAME};
  1992. my $errorcode;
  1993. my $error;
  1994. RemoveInternalTimer($hash, "SSCam_hlsreactivate");
  1995. return if(IsDisabled($name));
  1996. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  1997. if (ReadingsVal("$name", "state", "") eq "disabled") {
  1998. $errorcode = "402";
  1999. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  2000. $errorcode = "502";
  2001. }
  2002. # Fehlertext zum Errorcode ermitteln
  2003. $error = &SSCam_experror($hash,$errorcode);
  2004. readingsBeginUpdate($hash);
  2005. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  2006. readingsBulkUpdate($hash,"Error",$error);
  2007. readingsEndUpdate($hash, 1);
  2008. Log3($name, 2, "$name - ERROR - HLS-Stream of Camera $camname can't be activated - $error");
  2009. return;
  2010. }
  2011. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2012. # Aktivierung starten
  2013. $hash->{OPMODE} = "reactivate_hls";
  2014. $hash->{HELPER}{ACTIVE} = "on";
  2015. $hash->{HELPER}{LOGINRETRIES} = 0;
  2016. if (AttrVal($name,"debugactivetoken",0)) {
  2017. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2018. }
  2019. SSCam_getapisites($hash);
  2020. } else {
  2021. InternalTimer(gettimeofday()+0.4, "SSCam_hlsreactivate", $hash, 0);
  2022. }
  2023. }
  2024. ###############################################################################
  2025. # Kamera Liveview stoppen
  2026. ###############################################################################
  2027. sub SSCam_stopliveview ($) {
  2028. my ($hash) = @_;
  2029. my $camname = $hash->{CAMNAME};
  2030. my $name = $hash->{NAME};
  2031. my $errorcode;
  2032. my $error;
  2033. RemoveInternalTimer($hash, "SSCam_stopliveview");
  2034. return if(IsDisabled($name));
  2035. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2036. # Liveview stoppen
  2037. $hash->{OPMODE} = "stopliveview";
  2038. $hash->{HELPER}{ACTIVE} = "on";
  2039. $hash->{HELPER}{LOGINRETRIES} = 0;
  2040. if (AttrVal($name,"debugactivetoken",0)) {
  2041. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2042. }
  2043. # Link aus Helper-hash löschen
  2044. delete $hash->{HELPER}{LINK};
  2045. delete $hash->{HELPER}{AUDIOLINK};
  2046. delete $hash->{HELPER}{ACTSTRM}; # sprechender Name des laufenden Streamtyps für SSCamSTRM
  2047. # Reading LiveStreamUrl löschen
  2048. delete($defs{$name}{READINGS}{LiveStreamUrl}) if ($defs{$name}{READINGS}{LiveStreamUrl});
  2049. readingsSingleUpdate($hash,"state","stopview",1);
  2050. if($hash->{HELPER}{WLTYPE} eq "hls") {
  2051. # HLS Stream war aktiv, Streaming beenden
  2052. $hash->{OPMODE} = "stopliveview_hls";
  2053. SSCam_getapisites($hash);
  2054. } else {
  2055. # kein HLS Stream
  2056. SSCam_refresh($hash,0,1,1); # kein Room-Refresh, SSCam-state-Event, SSCamSTRM-Event
  2057. $hash->{HELPER}{ACTIVE} = "off";
  2058. if (AttrVal($name,"debugactivetoken",0)) {
  2059. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  2060. }
  2061. }
  2062. } else {
  2063. InternalTimer(gettimeofday()+0.5, "SSCam_stopliveview", $hash, 0);
  2064. }
  2065. }
  2066. ###############################################################################
  2067. # external Event 1-10 auslösen
  2068. ###############################################################################
  2069. sub SSCam_extevent ($) {
  2070. my ($hash) = @_;
  2071. my $name = $hash->{NAME};
  2072. RemoveInternalTimer($hash, "SSCam_extevent");
  2073. return if(IsDisabled($name));
  2074. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2075. $hash->{OPMODE} = "extevent";
  2076. $hash->{HELPER}{ACTIVE} = "on";
  2077. $hash->{HELPER}{LOGINRETRIES} = 0;
  2078. if (AttrVal($name,"debugactivetoken",0)) {
  2079. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2080. }
  2081. SSCam_getapisites($hash);
  2082. } else {
  2083. InternalTimer(gettimeofday()+0.5, "SSCam_extevent", $hash, 0);
  2084. }
  2085. }
  2086. ###############################################################################
  2087. # PTZ-Kamera auf Position fahren
  2088. ###############################################################################
  2089. sub SSCam_doptzaction ($) {
  2090. my ($hash) = @_;
  2091. my $camname = $hash->{CAMNAME};
  2092. my $name = $hash->{NAME};
  2093. my $errorcode;
  2094. my $error;
  2095. RemoveInternalTimer($hash, "SSCam_doptzaction");
  2096. return if(IsDisabled($name));
  2097. if (ReadingsVal("$name", "DeviceType", "Camera") ne "PTZ") {
  2098. Log3($name, 2, "$name - ERROR - Operation \"$hash->{HELPER}{PTZACTION}\" is only possible for cameras of DeviceType \"PTZ\" - please compare with device Readings");
  2099. return;
  2100. }
  2101. if ($hash->{HELPER}{PTZACTION} eq "goabsptz" && !ReadingsVal("$name", "CapPTZAbs", "false")) {
  2102. Log3($name, 2, "$name - ERROR - Operation \"$hash->{HELPER}{PTZACTION}\" is only possible if camera supports absolute PTZ action - please compare with device Reading \"CapPTZAbs\"");
  2103. return;
  2104. }
  2105. if ( $hash->{HELPER}{PTZACTION} eq "movestart" && ReadingsVal("$name", "CapPTZDirections", "0") < 1) {
  2106. Log3($name, 2, "$name - ERROR - Operation \"$hash->{HELPER}{PTZACTION}\" is only possible if camera supports \"Tilt\" and \"Pan\" operations - please compare with device Reading \"CapPTZDirections\"");
  2107. return;
  2108. }
  2109. if ($hash->{HELPER}{PTZACTION} eq "gopreset") {
  2110. if (!defined($hash->{HELPER}{ALLPRESETS}{$hash->{HELPER}{GOPRESETNAME}})) {
  2111. $errorcode = "600";
  2112. # Fehlertext zum Errorcode ermitteln
  2113. $error = SSCam_experror($hash,$errorcode);
  2114. # Setreading
  2115. readingsBeginUpdate($hash);
  2116. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  2117. readingsBulkUpdate($hash,"Error",$error);
  2118. readingsEndUpdate($hash, 1);
  2119. Log3($name, 2, "$name - ERROR - goPreset to position \"$hash->{HELPER}{GOPRESETNAME}\" of Camera $camname can't be executed - $error");
  2120. return;
  2121. }
  2122. }
  2123. if ($hash->{HELPER}{PTZACTION} eq "runpatrol") {
  2124. if (!defined($hash->{HELPER}{ALLPATROLS}{$hash->{HELPER}{GOPATROLNAME}})) {
  2125. $errorcode = "600";
  2126. # Fehlertext zum Errorcode ermitteln
  2127. $error = SSCam_experror($hash,$errorcode);
  2128. # Setreading
  2129. readingsBeginUpdate($hash);
  2130. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  2131. readingsBulkUpdate($hash,"Error",$error);
  2132. readingsEndUpdate($hash, 1);
  2133. Log3($name, 2, "$name - ERROR - runPatrol to patrol \"$hash->{HELPER}{GOPATROLNAME}\" of Camera $camname can't be executed - $error");
  2134. return;
  2135. }
  2136. }
  2137. if (ReadingsVal("$name", "state", "") =~ /^dis.*/) {
  2138. if (ReadingsVal("$name", "state", "") eq "disabled") {
  2139. $errorcode = "402";
  2140. } elsif (ReadingsVal("$name", "state", "") eq "disconnected") {
  2141. $errorcode = "502";
  2142. }
  2143. # Fehlertext zum Errorcode ermitteln
  2144. $error = SSCam_experror($hash,$errorcode);
  2145. # Setreading
  2146. readingsBeginUpdate($hash);
  2147. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  2148. readingsBulkUpdate($hash,"Error",$error);
  2149. readingsEndUpdate($hash, 1);
  2150. Log3($name, 2, "$name - ERROR - $hash->{HELPER}{PTZACTION} of Camera $camname can't be executed - $error");
  2151. return;
  2152. }
  2153. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2154. if ($hash->{HELPER}{PTZACTION} eq "gopreset") {
  2155. Log3($name, 4, "$name - Move Camera $camname to position \"$hash->{HELPER}{GOPRESETNAME}\" with ID \"$hash->{HELPER}{ALLPRESETS}{$hash->{HELPER}{GOPRESETNAME}}\" now");
  2156. } elsif ($hash->{HELPER}{PTZACTION} eq "runpatrol") {
  2157. Log3($name, 4, "$name - Start patrol \"$hash->{HELPER}{GOPATROLNAME}\" with ID \"$hash->{HELPER}{ALLPATROLS}{$hash->{HELPER}{GOPATROLNAME}}\" of Camera $camname now");
  2158. } elsif ($hash->{HELPER}{PTZACTION} eq "goabsptz") {
  2159. Log3($name, 4, "$name - Start move Camera $camname to position posX=\"$hash->{HELPER}{GOPTZPOSX}\" and posY=\"$hash->{HELPER}{GOPTZPOSY}\" now");
  2160. } elsif ($hash->{HELPER}{PTZACTION} eq "movestart") {
  2161. Log3($name, 4, "$name - Start move Camera $camname to direction \"$hash->{HELPER}{GOMOVEDIR}\" with duration of $hash->{HELPER}{GOMOVETIME} s");
  2162. }
  2163. if (AttrVal($name,"debugactivetoken",0)) {
  2164. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2165. }
  2166. $hash->{OPMODE} = $hash->{HELPER}{PTZACTION};
  2167. $hash->{HELPER}{ACTIVE} = "on";
  2168. $hash->{HELPER}{LOGINRETRIES} = 0;
  2169. SSCam_getapisites($hash);
  2170. } else {
  2171. InternalTimer(gettimeofday()+0.5, "SSCam_doptzaction", $hash, 0);
  2172. }
  2173. }
  2174. ###############################################################################
  2175. # stoppen continoues move
  2176. ###############################################################################
  2177. sub SSCam_movestop ($) {
  2178. my ($hash) = @_;
  2179. my $camname = $hash->{CAMNAME};
  2180. my $name = $hash->{NAME};
  2181. RemoveInternalTimer($hash, "SSCam_movestop");
  2182. return if(IsDisabled($name));
  2183. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2184. $hash->{OPMODE} = "movestop";
  2185. $hash->{HELPER}{ACTIVE} = "on";
  2186. $hash->{HELPER}{LOGINRETRIES} = 0;
  2187. if (AttrVal($name,"debugactivetoken",0)) {
  2188. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");;
  2189. }
  2190. SSCam_getapisites($hash);
  2191. } else {
  2192. InternalTimer(gettimeofday()+0.3, "SSCam_movestop", $hash, 0);
  2193. }
  2194. }
  2195. ###############################################################################
  2196. # Kamera aktivieren
  2197. ###############################################################################
  2198. sub SSCam_camenable ($) {
  2199. my ($hash) = @_;
  2200. my $camname = $hash->{CAMNAME};
  2201. my $name = $hash->{NAME};
  2202. RemoveInternalTimer($hash, "SSCam_camenable");
  2203. return if(IsDisabled($name));
  2204. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2205. # eine Kamera aktivieren
  2206. Log3($name, 4, "$name - Enable Camera $camname");
  2207. $hash->{OPMODE} = "Enable";
  2208. $hash->{HELPER}{ACTIVE} = "on";
  2209. $hash->{HELPER}{LOGINRETRIES} = 0;
  2210. if (AttrVal($name,"debugactivetoken",0)) {
  2211. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2212. }
  2213. SSCam_getapisites($hash);
  2214. } else {
  2215. InternalTimer(gettimeofday()+0.5, "SSCam_camenable", $hash, 0);
  2216. }
  2217. }
  2218. ###############################################################################
  2219. # Kamera deaktivieren
  2220. ###############################################################################
  2221. sub SSCam_camdisable ($) {
  2222. my ($hash) = @_;
  2223. my $camname = $hash->{CAMNAME};
  2224. my $name = $hash->{NAME};
  2225. RemoveInternalTimer($hash, "SSCam_camdisable");
  2226. return if(IsDisabled($name));
  2227. if ($hash->{HELPER}{ACTIVE} eq "off" and ReadingsVal("$name", "Record", "Start") ne "Start") {
  2228. # eine Kamera deaktivieren
  2229. Log3($name, 4, "$name - Disable Camera $camname");
  2230. $hash->{OPMODE} = "Disable";
  2231. $hash->{HELPER}{ACTIVE} = "on";
  2232. $hash->{HELPER}{LOGINRETRIES} = 0;
  2233. if (AttrVal($name,"debugactivetoken",0)) {
  2234. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2235. }
  2236. SSCam_getapisites($hash);
  2237. } else {
  2238. InternalTimer(gettimeofday()+0.5, "SSCam_camdisable", $hash, 0);
  2239. }
  2240. }
  2241. ###############################################################################
  2242. # Kamera alle Informationen abrufen (Get) bzw. Einstieg Polling
  2243. ###############################################################################
  2244. sub SSCam_getcaminfoall ($$) {
  2245. my ($hash,$mode) = @_;
  2246. my $camname = $hash->{CAMNAME};
  2247. my $name = $hash->{NAME};
  2248. my ($now,$new);
  2249. RemoveInternalTimer($hash, "SSCam_getcaminfoall");
  2250. return if(IsDisabled($name));
  2251. RemoveInternalTimer($hash, "SSCam_getsvsinfo");
  2252. InternalTimer(gettimeofday()+1, "SSCam_getsvsinfo", $hash, 0);
  2253. if(SSCam_IsModelCam($hash)) {
  2254. # Model ist CAM
  2255. RemoveInternalTimer($hash, "SSCam_geteventlist");
  2256. InternalTimer(gettimeofday()+0.5, "SSCam_geteventlist", $hash, 0);
  2257. RemoveInternalTimer($hash, "SSCam_getmotionenum");
  2258. InternalTimer(gettimeofday()+0.6, "SSCam_getmotionenum", $hash, 0);
  2259. RemoveInternalTimer($hash, "SSCam_getcaminfo");
  2260. InternalTimer(gettimeofday()+0.9, "SSCam_getcaminfo", $hash, 0);
  2261. RemoveInternalTimer($hash, "SSCam_getcapabilities");
  2262. InternalTimer(gettimeofday()+1.3, "SSCam_getcapabilities", $hash, 0);
  2263. RemoveInternalTimer($hash, "SSCam_getstreamformat");
  2264. InternalTimer(gettimeofday()+1.4, "SSCam_getstreamformat", $hash, 0);
  2265. # Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
  2266. my ($slim,$ssize) = SSCam_snaplimsize($hash);
  2267. RemoveInternalTimer("SSCam_getsnapinfo");
  2268. InternalTimer(gettimeofday()+1.5, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  2269. RemoveInternalTimer($hash, "SSCam_getptzlistpreset");
  2270. InternalTimer(gettimeofday()+1.6, "SSCam_getptzlistpreset", $hash, 0);
  2271. RemoveInternalTimer($hash, "SSCam_getptzlistpatrol");
  2272. InternalTimer(gettimeofday()+1.9, "SSCam_getptzlistpatrol", $hash, 0);
  2273. RemoveInternalTimer($hash, "SSCam_getStmUrlPath");
  2274. InternalTimer(gettimeofday()+2.1, "SSCam_getStmUrlPath", $hash, 0);
  2275. } else {
  2276. # Model ist SVS
  2277. RemoveInternalTimer($hash, "SSCam_gethomemodestate");
  2278. InternalTimer(gettimeofday()+0.7, "SSCam_gethomemodestate", $hash, 0);
  2279. RemoveInternalTimer($hash, "SSCam_getsvslog");
  2280. InternalTimer(gettimeofday()+0.8, "SSCam_getsvslog", $hash, 0);
  2281. }
  2282. # wenn gesetzt = manuelle Abfrage
  2283. # return if ($mode); # 24.03.2018 geänd.
  2284. my $pcia = AttrVal($name,"pollcaminfoall",0);
  2285. my $pnl = AttrVal($name,"pollnologging",0);
  2286. if ($pcia) {
  2287. $new = gettimeofday()+$pcia;
  2288. InternalTimer($new, "SSCam_getcaminfoall", $hash, 0);
  2289. $now = FmtTime(gettimeofday());
  2290. $new = FmtTime(gettimeofday()+$pcia);
  2291. readingsSingleUpdate($hash,"state","polling",1) if(!SSCam_IsModelCam($hash)); # state für SVS-Device setzen
  2292. readingsSingleUpdate($hash,"PollState","Active - next time: $new",1);
  2293. if (!$pnl) {
  2294. Log3($name, 3, "$name - Polling now: $now , next Polling: $new");
  2295. }
  2296. } else {
  2297. # Beenden Polling aller Caminfos
  2298. readingsSingleUpdate($hash,"PollState","Inactive",1);
  2299. readingsSingleUpdate($hash,"state","initialized",1) if(!SSCam_IsModelCam($hash)); # state für SVS-Device setzen
  2300. Log3($name, 3, "$name - Polling of $camname is deactivated");
  2301. }
  2302. return;
  2303. }
  2304. ###########################################################################
  2305. # Infos zu Snaps abfragen (z.B. weil nicht über SSCam ausgelöst)
  2306. ###########################################################################
  2307. sub SSCam_getsnapinfo ($) {
  2308. my ($str) = @_;
  2309. my ($name,$slim,$ssize) = split(":",$str);
  2310. my $hash = $defs{$name};
  2311. my $camname = $hash->{CAMNAME};
  2312. RemoveInternalTimer("SSCam_getsnapinfo");
  2313. return if(IsDisabled($name));
  2314. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2315. $hash->{OPMODE} = "getsnapinfo";
  2316. $hash->{OPMODE} = "getsnapgallery" if(exists($hash->{HELPER}{GETSNAPGALLERY}));
  2317. $hash->{HELPER}{ACTIVE} = "on";
  2318. $hash->{HELPER}{LOGINRETRIES} = 0;
  2319. $hash->{HELPER}{SNAPLIMIT} = $slim; # 0-alle Snapshots werden abgerufen und ausgewertet, sonst $slim
  2320. $hash->{HELPER}{SNAPIMGSIZE} = $ssize; # 0-Do not append image, 1-Icon size, 2-Full size
  2321. $hash->{HELPER}{KEYWORD} = $camname;
  2322. if (AttrVal($name,"debugactivetoken",0)) {
  2323. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2324. }
  2325. SSCam_getapisites($hash);
  2326. } else {
  2327. InternalTimer(gettimeofday()+1.7, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  2328. }
  2329. }
  2330. ###############################################################################
  2331. # Filename zu Schappschuß ermitteln
  2332. ###############################################################################
  2333. sub SSCam_getsnapfilename ($) {
  2334. my ($hash) = @_;
  2335. my $name = $hash->{NAME};
  2336. RemoveInternalTimer($hash, "SSCam_getsnapfilename");
  2337. return if(IsDisabled($name));
  2338. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2339. $hash->{OPMODE} = "getsnapfilename";
  2340. $hash->{HELPER}{ACTIVE} = "on";
  2341. $hash->{HELPER}{LOGINRETRIES} = 0;
  2342. if (AttrVal($name,"debugactivetoken",0)) {
  2343. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2344. }
  2345. SSCam_getapisites($hash);
  2346. } else {
  2347. InternalTimer(gettimeofday()+0.5, "SSCam_getsnapfilename", $hash, 0);
  2348. }
  2349. }
  2350. ###########################################################################
  2351. # allgemeine Infos über Synology Surveillance Station
  2352. ###########################################################################
  2353. sub SSCam_getsvsinfo ($) {
  2354. my ($hash) = @_;
  2355. my $camname = $hash->{CAMNAME};
  2356. my $name = $hash->{NAME};
  2357. RemoveInternalTimer($hash, "SSCam_getsvsinfo");
  2358. return if(IsDisabled($name));
  2359. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2360. $hash->{OPMODE} = "getsvsinfo";
  2361. $hash->{HELPER}{ACTIVE} = "on";
  2362. $hash->{HELPER}{LOGINRETRIES} = 0;
  2363. if (AttrVal($name,"debugactivetoken",0)) {
  2364. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2365. }
  2366. SSCam_getapisites($hash);
  2367. } else {
  2368. InternalTimer(gettimeofday()+1, "SSCam_getsvsinfo", $hash, 0);
  2369. }
  2370. }
  2371. ###########################################################################
  2372. # HomeMode setzen
  2373. ###########################################################################
  2374. sub SSCam_sethomemode ($) {
  2375. my ($hash) = @_;
  2376. my $camname = $hash->{CAMNAME};
  2377. my $name = $hash->{NAME};
  2378. RemoveInternalTimer($hash, "SSCam_sethomemode");
  2379. return if(IsDisabled($name) || !defined($hash->{HELPER}{APIHMMAXVER}));
  2380. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2381. $hash->{OPMODE} = "sethomemode";
  2382. $hash->{HELPER}{ACTIVE} = "on";
  2383. $hash->{HELPER}{LOGINRETRIES} = 0;
  2384. if (AttrVal($name,"debugactivetoken",0)) {
  2385. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2386. }
  2387. SSCam_getapisites($hash);
  2388. } else {
  2389. InternalTimer(gettimeofday()+0.6, "SSCam_sethomemode", $hash, 0);
  2390. }
  2391. }
  2392. ###########################################################################
  2393. # Optimierparameter setzen
  2394. ###########################################################################
  2395. sub SSCam_setoptpar ($) {
  2396. my ($hash) = @_;
  2397. my $camname = $hash->{CAMNAME};
  2398. my $name = $hash->{NAME};
  2399. RemoveInternalTimer($hash, "SSCam_setoptpar");
  2400. return if(IsDisabled($name));
  2401. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2402. $hash->{OPMODE} = "setoptpar";
  2403. $hash->{HELPER}{ACTIVE} = "on";
  2404. $hash->{HELPER}{LOGINRETRIES} = 0;
  2405. if (AttrVal($name,"debugactivetoken",0)) {
  2406. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2407. }
  2408. SSCam_getapisites($hash);
  2409. } else {
  2410. InternalTimer(gettimeofday()+0.6, "SSCam_setoptpar", $hash, 0);
  2411. }
  2412. }
  2413. ###########################################################################
  2414. # HomeMode Status abfragen
  2415. ###########################################################################
  2416. sub SSCam_gethomemodestate ($) {
  2417. my ($hash) = @_;
  2418. my $camname = $hash->{CAMNAME};
  2419. my $name = $hash->{NAME};
  2420. RemoveInternalTimer($hash, "SSCam_gethomemodestate");
  2421. return if(IsDisabled($name) || !defined($hash->{HELPER}{APIHMMAXVER}));
  2422. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2423. $hash->{OPMODE} = "gethomemodestate";
  2424. $hash->{HELPER}{ACTIVE} = "on";
  2425. $hash->{HELPER}{LOGINRETRIES} = 0;
  2426. if (AttrVal($name,"debugactivetoken",0)) {
  2427. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2428. }
  2429. SSCam_getapisites($hash);
  2430. } else {
  2431. InternalTimer(gettimeofday()+0.7, "SSCam_gethomemodestate", $hash, 0);
  2432. }
  2433. }
  2434. ###########################################################################
  2435. # SVS Log abrufen
  2436. ###########################################################################
  2437. sub SSCam_getsvslog ($) {
  2438. my ($hash) = @_;
  2439. my $camname = $hash->{CAMNAME};
  2440. my $name = $hash->{NAME};
  2441. RemoveInternalTimer($hash, "SSCam_getsvslog");
  2442. return if(IsDisabled($name));
  2443. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2444. $hash->{OPMODE} = "getsvslog";
  2445. $hash->{HELPER}{ACTIVE} = "on";
  2446. $hash->{HELPER}{LOGINRETRIES} = 0;
  2447. if (AttrVal($name,"debugactivetoken",0)) {
  2448. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2449. }
  2450. SSCam_getapisites($hash);
  2451. } else {
  2452. InternalTimer(gettimeofday()+0.9, "SSCam_getsvslog", $hash, 0);
  2453. }
  2454. }
  2455. ###########################################################################
  2456. # Session SSCam_logout
  2457. ###########################################################################
  2458. sub SSCam_sessionoff ($) {
  2459. my ($hash) = @_;
  2460. my $camname = $hash->{CAMNAME};
  2461. my $name = $hash->{NAME};
  2462. RemoveInternalTimer($hash, "SSCam_sessionoff");
  2463. return if(IsDisabled($name));
  2464. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2465. $hash->{OPMODE} = "logout";
  2466. $hash->{HELPER}{ACTIVE} = "on";
  2467. if (AttrVal($name,"debugactivetoken",0)) {
  2468. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2469. }
  2470. SSCam_logout($hash);
  2471. } else {
  2472. InternalTimer(gettimeofday()+1.1, "SSCam_sessionoff", $hash, 0);
  2473. }
  2474. }
  2475. ###########################################################################
  2476. # Kamera allgemeine Informationen abrufen (Get)
  2477. ###########################################################################
  2478. sub SSCam_getcaminfo($) {
  2479. my ($hash) = @_;
  2480. my $camname = $hash->{CAMNAME};
  2481. my $name = $hash->{NAME};
  2482. RemoveInternalTimer($hash, "SSCam_getcaminfo");
  2483. return if(IsDisabled($name));
  2484. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2485. $hash->{OPMODE} = "Getcaminfo";
  2486. $hash->{HELPER}{ACTIVE} = "on";
  2487. $hash->{HELPER}{LOGINRETRIES} = 0;
  2488. if (AttrVal($name,"debugactivetoken",0)) {
  2489. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2490. }
  2491. SSCam_getapisites($hash);
  2492. } else {
  2493. InternalTimer(gettimeofday()+2, "SSCam_getcaminfo", $hash, 0);
  2494. }
  2495. }
  2496. ###########################################################################
  2497. # SYNO.SurveillanceStation.VideoStream query aktuelles Streamformat
  2498. ###########################################################################
  2499. sub SSCam_getstreamformat ($) {
  2500. my ($hash) = @_;
  2501. my $camname = $hash->{CAMNAME};
  2502. my $name = $hash->{NAME};
  2503. RemoveInternalTimer($hash, "SSCam_getstreamformat");
  2504. my $apivideostmsmaxver = $hash->{HELPER}{APIVIDEOSTMSMAXVER};
  2505. return if(IsDisabled($name));
  2506. if(!$apivideostmsmaxver) {
  2507. # keine API "SYNO.SurveillanceStation.VideoStream" mehr ab API v2.8
  2508. readingsSingleUpdate($hash,"CamStreamFormat", "no API", 1);
  2509. return;
  2510. }
  2511. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2512. $hash->{OPMODE} = "getstreamformat";
  2513. $hash->{HELPER}{ACTIVE} = "on";
  2514. $hash->{HELPER}{LOGINRETRIES} = 0;
  2515. if (AttrVal($name,"debugactivetoken",0)) {
  2516. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2517. }
  2518. SSCam_getapisites($hash);
  2519. } else {
  2520. InternalTimer(gettimeofday()+1.4, "SSCam_getstreamformat", $hash, 0);
  2521. }
  2522. }
  2523. ################################################################################
  2524. # Kamera Stream Urls abrufen (Get)
  2525. ################################################################################
  2526. sub SSCam_getStmUrlPath ($) {
  2527. my ($hash) = @_;
  2528. my $camname = $hash->{CAMNAME};
  2529. my $name = $hash->{NAME};
  2530. RemoveInternalTimer($hash, "SSCam_getStmUrlPath");
  2531. return if(IsDisabled($name));
  2532. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2533. # Stream-Urls abrufen
  2534. $hash->{OPMODE} = "getStmUrlPath";
  2535. $hash->{HELPER}{ACTIVE} = "on";
  2536. $hash->{HELPER}{LOGINRETRIES} = 0;
  2537. if (AttrVal($name,"debugactivetoken",0)) {
  2538. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2539. }
  2540. SSCam_getapisites($hash);
  2541. } else {
  2542. InternalTimer(gettimeofday()+2, "SSCam_getStmUrlPath", $hash, 0);
  2543. }
  2544. }
  2545. ###########################################################################
  2546. # query SVS-Event information
  2547. ###########################################################################
  2548. sub SSCam_geteventlist ($) {
  2549. my ($hash) = @_;
  2550. my $camname = $hash->{CAMNAME};
  2551. my $name = $hash->{NAME};
  2552. RemoveInternalTimer($hash, "SSCam_geteventlist");
  2553. return if(IsDisabled($name));
  2554. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2555. $hash->{OPMODE} = "geteventlist";
  2556. $hash->{HELPER}{ACTIVE} = "on";
  2557. $hash->{HELPER}{LOGINRETRIES} = 0;
  2558. if (AttrVal($name,"debugactivetoken",0)) {
  2559. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2560. }
  2561. SSCam_getapisites($hash);
  2562. } else {
  2563. InternalTimer(gettimeofday()+2, "SSCam_geteventlist", $hash, 0);
  2564. }
  2565. }
  2566. ###########################################################################
  2567. # Enumerate motion detection parameters
  2568. ###########################################################################
  2569. sub SSCam_getmotionenum ($) {
  2570. my ($hash) = @_;
  2571. my $camname = $hash->{CAMNAME};
  2572. my $name = $hash->{NAME};
  2573. RemoveInternalTimer($hash, "SSCam_getmotionenum");
  2574. return if(IsDisabled($name));
  2575. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2576. $hash->{OPMODE} = "getmotionenum";
  2577. $hash->{HELPER}{ACTIVE} = "on";
  2578. $hash->{HELPER}{LOGINRETRIES} = 0;
  2579. if (AttrVal($name,"debugactivetoken",0)) {
  2580. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2581. }
  2582. SSCam_getapisites($hash);
  2583. } else {
  2584. InternalTimer(gettimeofday()+2, "SSCam_getmotionenum", $hash, 0);
  2585. }
  2586. }
  2587. ##########################################################################
  2588. # Capabilities von Kamera abrufen (Get)
  2589. ##########################################################################
  2590. sub SSCam_getcapabilities ($) {
  2591. my ($hash) = @_;
  2592. my $camname = $hash->{CAMNAME};
  2593. my $name = $hash->{NAME};
  2594. RemoveInternalTimer($hash, "SSCam_getcapabilities");
  2595. return if(IsDisabled($name));
  2596. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2597. $hash->{OPMODE} = "Getcapabilities";
  2598. $hash->{HELPER}{ACTIVE} = "on";
  2599. $hash->{HELPER}{LOGINRETRIES} = 0;
  2600. if (AttrVal($name,"debugactivetoken",0)) {
  2601. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2602. }
  2603. SSCam_getapisites($hash);
  2604. } else {
  2605. InternalTimer(gettimeofday()+2, "SSCam_getcapabilities", $hash, 0);
  2606. }
  2607. }
  2608. ##########################################################################
  2609. # PTZ Presets abrufen (Get)
  2610. ##########################################################################
  2611. sub SSCam_getptzlistpreset ($) {
  2612. my ($hash) = @_;
  2613. my $camname = $hash->{CAMNAME};
  2614. my $name = $hash->{NAME};
  2615. RemoveInternalTimer($hash, "SSCam_getptzlistpreset");
  2616. return if(IsDisabled($name));
  2617. if (ReadingsVal("$name", "DeviceType", "") ne "PTZ") {
  2618. Log3($name, 4, "$name - Retrieval of Presets for $camname can't be executed - $camname is not a PTZ-Camera");
  2619. return;
  2620. }
  2621. if (ReadingsVal("$name", "CapPTZTilt", "") eq "false" | ReadingsVal("$name", "CapPTZPan", "") eq "false") {
  2622. Log3($name, 4, "$name - Retrieval of Presets for $camname can't be executed - $camname has no capability to tilt/pan");
  2623. return;
  2624. }
  2625. if ($hash->{HELPER}{ACTIVE} eq "off") {
  2626. $hash->{OPMODE} = "Getptzlistpreset";
  2627. $hash->{HELPER}{ACTIVE} = "on";
  2628. $hash->{HELPER}{LOGINRETRIES} = 0;
  2629. if (AttrVal($name,"debugactivetoken",0)) {
  2630. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2631. }
  2632. SSCam_getapisites($hash);
  2633. } else {
  2634. InternalTimer(gettimeofday()+2, "SSCam_getptzlistpreset", $hash, 0);
  2635. }
  2636. }
  2637. ##########################################################################
  2638. # PTZ Patrols abrufen (Get)
  2639. ##########################################################################
  2640. sub SSCam_getptzlistpatrol ($) {
  2641. my ($hash) = @_;
  2642. my $camname = $hash->{CAMNAME};
  2643. my $name = $hash->{NAME};
  2644. RemoveInternalTimer($hash, "SSCam_getptzlistpatrol");
  2645. return if(IsDisabled($name));
  2646. if (ReadingsVal("$name", "DeviceType", "") ne "PTZ") {
  2647. Log3($name, 4, "$name - Retrieval of Patrols for $camname can't be executed - $camname is not a PTZ-Camera");
  2648. return;
  2649. }
  2650. if (ReadingsVal("$name", "CapPTZTilt", "") eq "false" | ReadingsVal("$name", "CapPTZPan", "") eq "false") {
  2651. Log3($name, 4, "$name - Retrieval of Patrols for $camname can't be executed - $camname has no capability to tilt/pan");
  2652. return;
  2653. }
  2654. if ($hash->{HELPER}{ACTIVE} ne "on") {
  2655. $hash->{OPMODE} = "Getptzlistpatrol";
  2656. $hash->{HELPER}{ACTIVE} = "on";
  2657. $hash->{HELPER}{LOGINRETRIES} = 0;
  2658. if (AttrVal($name,"debugactivetoken",0)) {
  2659. Log3($name, 3, "$name - Active-Token was set by OPMODE: $hash->{OPMODE}");
  2660. }
  2661. SSCam_getapisites($hash);
  2662. } else {
  2663. InternalTimer(gettimeofday()+2, "SSCam_getptzlistpatrol", $hash, 0);
  2664. }
  2665. }
  2666. #############################################################################################################################
  2667. ####### Begin Kameraoperationen mit NonblockingGet (nicht blockierender HTTP-Call) #######
  2668. #############################################################################################################################
  2669. sub SSCam_getapisites($) {
  2670. my ($hash) = @_;
  2671. my $serveraddr = $hash->{SERVERADDR};
  2672. my $serverport = $hash->{SERVERPORT};
  2673. my $name = $hash->{NAME};
  2674. my $apiinfo = $hash->{HELPER}{APIINFO}; # Info-Seite für alle API's, einzige statische Seite !
  2675. my $apiauth = $hash->{HELPER}{APIAUTH};
  2676. my $apiextrec = $hash->{HELPER}{APIEXTREC};
  2677. my $apiextevt = $hash->{HELPER}{APIEXTEVT};
  2678. my $apicam = $hash->{HELPER}{APICAM};
  2679. my $apitakesnap = $hash->{HELPER}{APISNAPSHOT};
  2680. my $apiptz = $hash->{HELPER}{APIPTZ};
  2681. my $apipreset = $hash->{HELPER}{APIPRESET};
  2682. my $apisvsinfo = $hash->{HELPER}{APISVSINFO};
  2683. my $apicamevent = $hash->{HELPER}{APICAMEVENT};
  2684. my $apievent = $hash->{HELPER}{APIEVENT};
  2685. my $apivideostm = $hash->{HELPER}{APIVIDEOSTM};
  2686. my $apiaudiostm = $hash->{HELPER}{APIAUDIOSTM};
  2687. my $apivideostms = $hash->{HELPER}{APIVIDEOSTMS};
  2688. my $apistm = $hash->{HELPER}{APISTM};
  2689. my $apihm = $hash->{HELPER}{APIHM};
  2690. my $apilog = $hash->{HELPER}{APILOG};
  2691. my $proto = $hash->{PROTOCOL};
  2692. my $url;
  2693. my $param;
  2694. # API-Pfade und MaxVersions ermitteln
  2695. Log3($name, 4, "$name - ####################################################");
  2696. Log3($name, 4, "$name - ### start cam operation $hash->{OPMODE} ");
  2697. Log3($name, 4, "$name - ####################################################");
  2698. Log3($name, 4, "$name - --- Begin Function SSCam_getapisites nonblocking ---");
  2699. if ($hash->{HELPER}{APIPARSET}) {
  2700. # API-Hashwerte sind bereits gesetzt -> Abruf überspringen
  2701. Log3($name, 4, "$name - API hashvalues already set - ignore get apisites");
  2702. return SSCam_checksid($hash);
  2703. }
  2704. my $httptimeout = AttrVal($name,"httptimeout",4);
  2705. Log3($name, 5, "$name - HTTP-Call will be done with httptimeout-Value: $httptimeout s");
  2706. # URL zur Abfrage der Eigenschaften der API's
  2707. $url = "$proto://$serveraddr:$serverport/webapi/query.cgi?api=$apiinfo&method=Query&version=1&query=$apiauth,$apiextrec,$apicam,$apitakesnap,$apiptz,$apipreset,$apisvsinfo,$apicamevent,$apievent,$apivideostm,$apiextevt,$apistm,$apihm,$apilog,$apiaudiostm,$apivideostms";
  2708. Log3($name, 4, "$name - Call-Out now: $url");
  2709. $param = {
  2710. url => $url,
  2711. timeout => $httptimeout,
  2712. hash => $hash,
  2713. method => "GET",
  2714. header => "Accept: application/json",
  2715. callback => \&SSCam_getapisites_parse
  2716. };
  2717. HttpUtils_NonblockingGet ($param);
  2718. }
  2719. ####################################################################################
  2720. # Auswertung Abruf apisites
  2721. ####################################################################################
  2722. sub SSCam_getapisites_parse ($) {
  2723. my ($param, $err, $myjson) = @_;
  2724. my $hash = $param->{hash};
  2725. my $name = $hash->{NAME};
  2726. my $serveraddr = $hash->{SERVERADDR};
  2727. my $serverport = $hash->{SERVERPORT};
  2728. my $apiauth = $hash->{HELPER}{APIAUTH};
  2729. my $apiextrec = $hash->{HELPER}{APIEXTREC};
  2730. my $apiextevt = $hash->{HELPER}{APIEXTEVT};
  2731. my $apicam = $hash->{HELPER}{APICAM};
  2732. my $apitakesnap = $hash->{HELPER}{APISNAPSHOT};
  2733. my $apiptz = $hash->{HELPER}{APIPTZ};
  2734. my $apipreset = $hash->{HELPER}{APIPRESET};
  2735. my $apisvsinfo = $hash->{HELPER}{APISVSINFO};
  2736. my $apicamevent = $hash->{HELPER}{APICAMEVENT};
  2737. my $apievent = $hash->{HELPER}{APIEVENT};
  2738. my $apivideostm = $hash->{HELPER}{APIVIDEOSTM};
  2739. my $apiaudiostm = $hash->{HELPER}{APIAUDIOSTM};
  2740. my $apivideostms = $hash->{HELPER}{APIVIDEOSTMS};
  2741. my $apistm = $hash->{HELPER}{APISTM};
  2742. my $apihm = $hash->{HELPER}{APIHM};
  2743. my $apilog = $hash->{HELPER}{APILOG};
  2744. my ($apicammaxver,$apicampath);
  2745. if ($err ne "") {
  2746. # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist
  2747. Log3($name, 2, "$name - error while requesting ".$param->{url}." - $err");
  2748. readingsSingleUpdate($hash, "Error", $err, 1);
  2749. # ausgeführte Funktion ist abgebrochen, Freigabe Funktionstoken
  2750. $hash->{HELPER}{ACTIVE} = "off";
  2751. if (AttrVal($name,"debugactivetoken",0)) {
  2752. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  2753. }
  2754. return;
  2755. } elsif ($myjson ne "") {
  2756. # Evaluiere ob Daten im JSON-Format empfangen wurden
  2757. ($hash, my $success) = SSCam_evaljson($hash,$myjson);
  2758. unless ($success) {
  2759. Log3($name, 4, "$name - Data returned: $myjson");
  2760. $hash->{HELPER}{ACTIVE} = "off";
  2761. if (AttrVal($name,"debugactivetoken",0)) {
  2762. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  2763. }
  2764. return;
  2765. }
  2766. my $data = decode_json($myjson);
  2767. # Logausgabe decodierte JSON Daten
  2768. Log3($name, 5, "$name - JSON returned: ". Dumper $data);
  2769. $success = $data->{'success'};
  2770. if ($success) {
  2771. my $logstr;
  2772. # Pfad und Maxversion von "SYNO.API.Auth" ermitteln
  2773. my $apiauthpath = $data->{'data'}->{$apiauth}->{'path'};
  2774. $apiauthpath =~ tr/_//d if (defined($apiauthpath));
  2775. my $apiauthmaxver = $data->{'data'}->{$apiauth}->{'maxVersion'};
  2776. $logstr = defined($apiauthpath) ? "Path of $apiauth selected: $apiauthpath" : "Path of $apiauth undefined - Surveillance Station may be stopped";
  2777. Log3($name, 4, "$name - $logstr");
  2778. $logstr = defined($apiauthmaxver) ? "MaxVersion of $apiauth selected: $apiauthmaxver" : "MaxVersion of $apiauth undefined - Surveillance Station may be stopped";
  2779. Log3($name, 4, "$name - $logstr");
  2780. # Pfad und Maxversion von "SYNO.SurveillanceStation.ExternalRecording" ermitteln
  2781. my $apiextrecpath = $data->{'data'}->{$apiextrec}->{'path'};
  2782. $apiextrecpath =~ tr/_//d if (defined($apiextrecpath));
  2783. my $apiextrecmaxver = $data->{'data'}->{$apiextrec}->{'maxVersion'};
  2784. $logstr = defined($apiextrecpath) ? "Path of $apiextrec selected: $apiextrecpath" : "Path of $apiextrec undefined - Surveillance Station may be stopped";
  2785. Log3($name, 4, "$name - $logstr");
  2786. $logstr = defined($apiextrecmaxver) ? "MaxVersion of $apiextrec selected: $apiextrecmaxver" : "MaxVersion of $apiextrec undefined - Surveillance Station may be stopped";
  2787. Log3($name, 4, "$name - $logstr");
  2788. # Pfad und Maxversion von "SYNO.SurveillanceStation.Camera" ermitteln
  2789. $apicampath = $data->{'data'}->{$apicam}->{'path'};
  2790. $apicampath =~ tr/_//d if (defined($apicampath));
  2791. $apicammaxver = $data->{'data'}->{$apicam}->{'maxVersion'};
  2792. $logstr = defined($apicampath) ? "Path of $apicam selected: $apicampath" : "Path of $apicam undefined - Surveillance Station may be stopped";
  2793. Log3($name, 4, "$name - $logstr");
  2794. $logstr = defined($apiextrecmaxver) ? "MaxVersion of $apicam: $apicammaxver" : "MaxVersion of $apicam undefined - Surveillance Station may be stopped";
  2795. Log3($name, 4, "$name - $logstr");
  2796. # Pfad und Maxversion von "SYNO.SurveillanceStation.SnapShot" ermitteln
  2797. my $apitakesnappath = $data->{'data'}->{$apitakesnap}->{'path'};
  2798. $apitakesnappath =~ tr/_//d if (defined($apitakesnappath));
  2799. my $apitakesnapmaxver = $data->{'data'}->{$apitakesnap}->{'maxVersion'};
  2800. $logstr = defined($apitakesnappath) ? "Path of $apitakesnap selected: $apitakesnappath" : "Path of $apitakesnap undefined - Surveillance Station may be stopped";
  2801. Log3($name, 4, "$name - $logstr");
  2802. $logstr = defined($apitakesnapmaxver) ? "MaxVersion of $apitakesnap: $apitakesnapmaxver" : "MaxVersion of $apitakesnap undefined - Surveillance Station may be stopped";
  2803. Log3($name, 4, "$name - $logstr");
  2804. # Pfad und Maxversion von "SYNO.SurveillanceStation.PTZ" ermitteln
  2805. my $apiptzpath = $data->{'data'}->{$apiptz}->{'path'};
  2806. $apiptzpath =~ tr/_//d if (defined($apiptzpath));
  2807. my $apiptzmaxver = $data->{'data'}->{$apiptz}->{'maxVersion'};
  2808. $logstr = defined($apiptzpath) ? "Path of $apiptz selected: $apiptzpath" : "Path of $apiptz undefined - Surveillance Station may be stopped";
  2809. Log3($name, 4, "$name - $logstr");
  2810. $logstr = defined($apiptzmaxver) ? "MaxVersion of $apiptz: $apiptzmaxver" : "MaxVersion of $apiptz undefined - Surveillance Station may be stopped";
  2811. Log3($name, 4, "$name - $logstr");
  2812. # Pfad und Maxversion von "SYNO.SurveillanceStation.PTZ.Preset" ermitteln
  2813. my $apipresetpath = $data->{'data'}->{$apipreset}->{'path'};
  2814. $apipresetpath =~ tr/_//d if (defined($apipresetpath));
  2815. my $apipresetmaxver = $data->{'data'}->{$apipreset}->{'maxVersion'};
  2816. $logstr = defined($apipresetpath) ? "Path of $apipreset selected: $apipresetpath" : "Path of $apipreset undefined - Surveillance Station may be stopped";
  2817. Log3($name, 4, "$name - $logstr");
  2818. $logstr = defined($apipresetmaxver) ? "MaxVersion of $apipreset: $apipresetmaxver" : "MaxVersion of $apipreset undefined - Surveillance Station may be stopped";
  2819. Log3($name, 4, "$name - $logstr");
  2820. # Pfad und Maxversion von "SYNO.SurveillanceStation.Info" ermitteln
  2821. my $apisvsinfopath = $data->{'data'}->{$apisvsinfo}->{'path'};
  2822. $apisvsinfopath =~ tr/_//d if (defined($apisvsinfopath));
  2823. my $apisvsinfomaxver = $data->{'data'}->{$apisvsinfo}->{'maxVersion'};
  2824. $logstr = defined($apisvsinfopath) ? "Path of $apisvsinfo selected: $apisvsinfopath" : "Path of $apisvsinfo undefined - Surveillance Station may be stopped";
  2825. Log3($name, 4, "$name - $logstr");
  2826. $logstr = defined($apisvsinfomaxver) ? "MaxVersion of $apisvsinfo: $apisvsinfomaxver" : "MaxVersion of $apisvsinfo undefined - Surveillance Station may be stopped";
  2827. Log3($name, 4, "$name - $logstr");
  2828. # Pfad und Maxversion von "SYNO.Surveillance.Camera.Event" ermitteln
  2829. my $apicameventpath = $data->{'data'}->{$apicamevent}->{'path'};
  2830. $apicameventpath =~ tr/_//d if (defined($apicameventpath));
  2831. my $apicameventmaxver = $data->{'data'}->{$apicamevent}->{'maxVersion'};
  2832. $logstr = defined($apicameventpath) ? "Path of $apicamevent selected: $apicameventpath" : "Path of $apicamevent undefined - Surveillance Station may be stopped";
  2833. Log3($name, 4, "$name - $logstr");
  2834. $logstr = defined($apicameventmaxver) ? "MaxVersion of $apicamevent: $apicameventmaxver" : "MaxVersion of $apicamevent undefined - Surveillance Station may be stopped";
  2835. Log3($name, 4, "$name - $logstr");
  2836. # Pfad und Maxversion von "SYNO.Surveillance.Event" ermitteln
  2837. my $apieventpath = $data->{'data'}->{$apievent}->{'path'};
  2838. $apieventpath =~ tr/_//d if (defined($apieventpath));
  2839. my $apieventmaxver = $data->{'data'}->{$apievent}->{'maxVersion'};
  2840. $logstr = defined($apieventpath) ? "Path of $apievent selected: $apieventpath" : "Path of $apievent undefined - Surveillance Station may be stopped";
  2841. Log3($name, 4, "$name - $logstr");
  2842. $logstr = defined($apieventmaxver) ? "MaxVersion of $apievent: $apieventmaxver" : "MaxVersion of $apievent undefined - Surveillance Station may be stopped";
  2843. Log3($name, 4, "$name - $logstr");
  2844. # Pfad und Maxversion von "SYNO.Surveillance.VideoStream" ermitteln
  2845. my $apivideostmpath = $data->{'data'}->{$apivideostm}->{'path'};
  2846. $apivideostmpath =~ tr/_//d if (defined($apivideostmpath));
  2847. my $apivideostmmaxver = $data->{'data'}->{$apivideostm}->{'maxVersion'};
  2848. $logstr = defined($apivideostmpath) ? "Path of $apivideostm selected: $apivideostmpath" : "Path of $apivideostm undefined - Surveillance Station may be stopped";
  2849. Log3($name, 4, "$name - $logstr");
  2850. $logstr = defined($apivideostmmaxver) ? "MaxVersion of $apivideostm: $apivideostmmaxver" : "MaxVersion of $apivideostm undefined - Surveillance Station may be stopped";
  2851. Log3($name, 4, "$name - $logstr");
  2852. # Pfad und Maxversion von "SYNO.SurveillanceStation.ExternalEvent" ermitteln
  2853. my $apiextevtpath = $data->{'data'}->{$apiextevt}->{'path'};
  2854. $apiextevtpath =~ tr/_//d if (defined($apiextevtpath));
  2855. my $apiextevtmaxver = $data->{'data'}->{$apiextevt}->{'maxVersion'};
  2856. $logstr = defined($apiextevtpath) ? "Path of $apiextevt selected: $apiextevtpath" : "Path of $apiextevt undefined - Surveillance Station may be stopped";
  2857. Log3($name, 4, "$name - $logstr");
  2858. $logstr = defined($apiextevtmaxver) ? "MaxVersion of $apiextevt selected: $apiextevtmaxver" : "MaxVersion of $apiextevt undefined - Surveillance Station may be stopped";
  2859. Log3($name, 4, "$name - $logstr");
  2860. # Pfad und Maxversion von "SYNO.SurveillanceStation.Streaming" ermitteln
  2861. my $apistmpath = $data->{'data'}->{$apistm}->{'path'};
  2862. $apistmpath =~ tr/_//d if (defined($apistmpath));
  2863. my $apistmmaxver = $data->{'data'}->{$apistm}->{'maxVersion'};
  2864. $logstr = defined($apistmpath) ? "Path of $apistm selected: $apistmpath" : "Path of $apistm undefined - Surveillance Station may be stopped";
  2865. Log3($name, 4, "$name - $logstr");
  2866. $logstr = defined($apistmmaxver) ? "MaxVersion of $apistm selected: $apistmmaxver" : "MaxVersion of $apistm undefined - Surveillance Station may be stopped";
  2867. Log3($name, 4, "$name - $logstr");
  2868. # Pfad und Maxversion von "SYNO.SurveillanceStation.HomeMode" ermitteln
  2869. my $apihmpath = $data->{'data'}->{$apihm}->{'path'};
  2870. $apihmpath =~ tr/_//d if (defined($apihmpath));
  2871. my $apihmmaxver = $data->{'data'}->{$apihm}->{'maxVersion'};
  2872. $logstr = defined($apihmpath) ? "Path of $apihm selected: $apihmpath" : "Path of $apihm undefined - Surveillance Station may be stopped";
  2873. Log3($name, 4, "$name - $logstr");
  2874. $logstr = defined($apihmmaxver) ? "MaxVersion of $apihm selected: $apihmmaxver" : "MaxVersion of $apihm undefined - Surveillance Station may be stopped";
  2875. Log3($name, 4, "$name - $logstr");
  2876. # Pfad und Maxversion von "SYNO.SurveillanceStation.Log" ermitteln
  2877. my $apilogpath = $data->{'data'}->{$apilog}->{'path'};
  2878. $apilogpath =~ tr/_//d if (defined($apilogpath));
  2879. my $apilogmaxver = $data->{'data'}->{$apilog}->{'maxVersion'};
  2880. $logstr = defined($apilogpath) ? "Path of $apilog selected: $apilogpath" : "Path of $apilog undefined - Surveillance Station may be stopped";
  2881. Log3($name, 4, "$name - $logstr");
  2882. $logstr = defined($apilogmaxver) ? "MaxVersion of $apilog selected: $apilogmaxver" : "MaxVersion of $apilog undefined - Surveillance Station may be stopped";
  2883. Log3($name, 4, "$name - $logstr");
  2884. # Pfad und Maxversion von "SYNO.SurveillanceStation.AudioStream" ermitteln
  2885. my $apiaudiostmpath = $data->{'data'}->{$apiaudiostm}->{'path'};
  2886. $apiaudiostmpath =~ tr/_//d if (defined($apiaudiostmpath));
  2887. my $apiaudiostmmaxver = $data->{'data'}->{$apiaudiostm}->{'maxVersion'};
  2888. $logstr = defined($apiaudiostmpath) ? "Path of $apiaudiostm selected: $apiaudiostmpath" : "Path of $apiaudiostm undefined - Surveillance Station may be stopped";
  2889. Log3($name, 4, "$name - $logstr");
  2890. $logstr = defined($apiaudiostmmaxver) ? "MaxVersion of $apiaudiostm selected: $apiaudiostmmaxver" : "MaxVersion of $apiaudiostm undefined - Surveillance Station may be stopped";
  2891. Log3($name, 4, "$name - $logstr");
  2892. # Pfad und Maxversion von "SYNO.SurveillanceStation.VideoStream" ermitteln
  2893. my $apivideostmspath = $data->{'data'}->{$apivideostms}->{'path'};
  2894. $apivideostmspath =~ tr/_//d if (defined($apivideostmspath));
  2895. my $apivideostmsmaxver = $data->{'data'}->{$apivideostms}->{'maxVersion'};
  2896. $logstr = defined($apivideostmspath) ? "Path of $apivideostms selected: $apivideostmspath" : "Path of $apivideostms undefined - Surveillance Station may be stopped";
  2897. Log3($name, 4, "$name - $logstr");
  2898. $logstr = defined($apivideostmsmaxver) ? "MaxVersion of $apivideostms selected: $apivideostmsmaxver" : "MaxVersion of $apivideostms undefined - Surveillance Station may be stopped";
  2899. Log3($name, 4, "$name - $logstr");
  2900. # aktuelle oder simulierte SVS-Version für Fallentscheidung setzen
  2901. no warnings 'uninitialized';
  2902. my $major = $hash->{HELPER}{SVSVERSION}{MAJOR};
  2903. my $minor = $hash->{HELPER}{SVSVERSION}{MINOR};
  2904. my $small = $hash->{HELPER}{SVSVERSION}{SMALL};
  2905. my $build = $hash->{HELPER}{SVSVERSION}{BUILD};
  2906. my $actvs = $major.$minor.$small.$build;
  2907. my $avsc = $major.$minor.$small; # Variable zum Version Kompatibilitätscheck
  2908. Log3($name, 4, "$name - installed SVS version is: $actvs");
  2909. use warnings;
  2910. if(AttrVal($name,"simu_SVSversion",0)) {
  2911. my @vl = split (/\.|-/,AttrVal($name, "simu_SVSversion", ""));
  2912. $actvs = $vl[0];
  2913. $actvs .= $vl[1];
  2914. $actvs .= ($vl[2] =~ /\d/)?$vl[2]."xxxx":$vl[2];
  2915. $actvs .= "-simu";
  2916. }
  2917. # Downgrades für nicht kompatible API-Versionen
  2918. # hier nur nutzen wenn API zentral downgraded werden soll
  2919. # In den neueren API-Upgrades werden nur einzelne Funktionen auf eine höhere API-Version gezogen
  2920. # -> diese Steuerung erfolgt in den einzelnen Funktionsaufrufen in SSCam_camop
  2921. Log3($name, 4, "$name - ------- Begin of adaption section -------");
  2922. #$apiptzmaxver = 4;
  2923. #Log3($name, 4, "$name - MaxVersion of $apiptz adapted to: $apiptzmaxver");
  2924. #$apicammaxver = 8;
  2925. #Log3($name, 4, "$name - MaxVersion of $apicam adapted to: $apicammaxver");
  2926. Log3($name, 4, "$name - ------- End of adaption section -------");
  2927. # Simulation anderer SVS-Versionen
  2928. Log3($name, 4, "$name - ------- Begin of simulation section -------");
  2929. if (AttrVal($name, "simu_SVSversion", undef)) {
  2930. Log3($name, 4, "$name - SVS version $actvs will be simulated");
  2931. if ($actvs =~ /^71/) {
  2932. $apicammaxver = 8;
  2933. Log3($name, 4, "$name - MaxVersion of $apicam adapted to: $apicammaxver");
  2934. $apiauthmaxver = 4;
  2935. Log3($name, 4, "$name - MaxVersion of $apiauth adapted to: $apiauthmaxver");
  2936. $apiextrecmaxver = 2;
  2937. Log3($name, 4, "$name - MaxVersion of $apiextrec adapted to: $apiextrecmaxver");
  2938. $apiptzmaxver = 4;
  2939. Log3($name, 4, "$name - MaxVersion of $apiptz adapted to: $apiptzmaxver");
  2940. } elsif ($actvs =~ /^72/) {
  2941. $apicammaxver = 8;
  2942. Log3($name, 4, "$name - MaxVersion of $apicam adapted to: $apicammaxver");
  2943. $apiauthmaxver = 6;
  2944. Log3($name, 4, "$name - MaxVersion of $apiauth adapted to: $apiauthmaxver");
  2945. $apiextrecmaxver = 3;
  2946. Log3($name, 4, "$name - MaxVersion of $apiextrec adapted to: $apiextrecmaxver");
  2947. $apiptzmaxver = 5;
  2948. Log3($name, 4, "$name - MaxVersion of $apiptz adapted to: $apiptzmaxver");
  2949. } elsif ($actvs =~ /^800/) {
  2950. $apicammaxver = 9;
  2951. Log3($name, 4, "$name - MaxVersion of $apicam adapted to: $apicammaxver");
  2952. $apiauthmaxver = 6;
  2953. Log3($name, 4, "$name - MaxVersion of $apiauth adapted to: $apiauthmaxver");
  2954. $apiextrecmaxver = 3;
  2955. Log3($name, 4, "$name - MaxVersion of $apiextrec adapted to: $apiextrecmaxver");
  2956. $apiptzmaxver = 5;
  2957. Log3($name, 4, "$name - MaxVersion of $apiptz adapted to: $apiptzmaxver");
  2958. } elsif ($actvs =~ /^815/) {
  2959. $apicammaxver = 9;
  2960. Log3($name, 4, "$name - MaxVersion of $apicam adapted to: $apicammaxver");
  2961. $apiauthmaxver = 6;
  2962. Log3($name, 4, "$name - MaxVersion of $apiauth adapted to: $apiauthmaxver");
  2963. $apiextrecmaxver = 3;
  2964. Log3($name, 4, "$name - MaxVersion of $apiextrec adapted to: $apiextrecmaxver");
  2965. $apiptzmaxver = 5;
  2966. Log3($name, 4, "$name - MaxVersion of $apiptz adapted to: $apiptzmaxver");
  2967. } elsif ($actvs =~ /^820/) {
  2968. # ab API v2.8 kein "SYNO.SurveillanceStation.VideoStream", "SYNO.SurveillanceStation.AudioStream",
  2969. # "SYNO.SurveillanceStation.Streaming" mehr enthalten
  2970. $apivideostmsmaxver = 0;
  2971. Log3($name, 4, "$name - MaxVersion of $apivideostms adapted to: $apivideostmsmaxver");
  2972. $apiaudiostmmaxver = 0;
  2973. Log3($name, 4, "$name - MaxVersion of $apiaudiostm adapted to: $apiaudiostmmaxver");
  2974. }
  2975. } else {
  2976. Log3($name, 4, "$name - no simulations done !");
  2977. }
  2978. Log3($name, 4, "$name - ------- End of simulation section -------");
  2979. # ermittelte Werte in $hash einfügen
  2980. $hash->{HELPER}{APIAUTHPATH} = $apiauthpath;
  2981. $hash->{HELPER}{APIAUTHMAXVER} = $apiauthmaxver;
  2982. $hash->{HELPER}{APIEXTRECPATH} = $apiextrecpath;
  2983. $hash->{HELPER}{APIEXTRECMAXVER} = $apiextrecmaxver;
  2984. $hash->{HELPER}{APICAMPATH} = $apicampath;
  2985. $hash->{HELPER}{APICAMMAXVER} = $apicammaxver;
  2986. $hash->{HELPER}{APITAKESNAPPATH} = $apitakesnappath;
  2987. $hash->{HELPER}{APITAKESNAPMAXVER} = $apitakesnapmaxver;
  2988. $hash->{HELPER}{APIPTZPATH} = $apiptzpath;
  2989. $hash->{HELPER}{APIPTZMAXVER} = $apiptzmaxver;
  2990. $hash->{HELPER}{APIPRESETPATH} = $apipresetpath;
  2991. $hash->{HELPER}{APIPRESETMAXVER} = $apipresetmaxver;
  2992. $hash->{HELPER}{APISVSINFOPATH} = $apisvsinfopath;
  2993. $hash->{HELPER}{APISVSINFOMAXVER} = $apisvsinfomaxver;
  2994. $hash->{HELPER}{APICAMEVENTPATH} = $apicameventpath;
  2995. $hash->{HELPER}{APICAMEVENTMAXVER} = $apicameventmaxver;
  2996. $hash->{HELPER}{APIEVENTPATH} = $apieventpath;
  2997. $hash->{HELPER}{APIEVENTMAXVER} = $apieventmaxver;
  2998. $hash->{HELPER}{APIVIDEOSTMPATH} = $apivideostmpath;
  2999. $hash->{HELPER}{APIVIDEOSTMMAXVER} = $apivideostmmaxver;
  3000. $hash->{HELPER}{APIAUDIOSTMPATH} = $apiaudiostmpath?$apiaudiostmpath:"undefinded";
  3001. $hash->{HELPER}{APIAUDIOSTMMAXVER} = $apiaudiostmmaxver?$apiaudiostmmaxver:0;
  3002. $hash->{HELPER}{APIEXTEVTPATH} = $apiextevtpath;
  3003. $hash->{HELPER}{APIEXTEVTMAXVER} = $apiextevtmaxver;
  3004. $hash->{HELPER}{APISTMPATH} = $apistmpath;
  3005. $hash->{HELPER}{APISTMMAXVER} = $apistmmaxver;
  3006. $hash->{HELPER}{APIHMPATH} = $apihmpath;
  3007. $hash->{HELPER}{APIHMMAXVER} = $apihmmaxver;
  3008. $hash->{HELPER}{APILOGPATH} = $apilogpath;
  3009. $hash->{HELPER}{APILOGMAXVER} = $apilogmaxver;
  3010. $hash->{HELPER}{APIVIDEOSTMSPATH} = $apivideostmspath?$apivideostmspath:"undefinded";
  3011. $hash->{HELPER}{APIVIDEOSTMSMAXVER} = $apivideostmsmaxver?$apivideostmsmaxver:0;
  3012. readingsBeginUpdate($hash);
  3013. readingsBulkUpdate($hash,"Errorcode","none");
  3014. readingsBulkUpdate($hash,"Error","none");
  3015. readingsEndUpdate($hash,1);
  3016. # API Hash values sind gesetzt
  3017. $hash->{HELPER}{APIPARSET} = 1;
  3018. } else {
  3019. my $error = "couldn't call API-Infosite";
  3020. readingsBeginUpdate($hash);
  3021. readingsBulkUpdate($hash,"Errorcode","none");
  3022. readingsBulkUpdate($hash,"Error",$error);
  3023. readingsEndUpdate($hash, 1);
  3024. Log3($name, 2, "$name - ERROR - the API-Query couldn't be executed successfully");
  3025. # ausgeführte Funktion ist abgebrochen, Freigabe Funktionstoken
  3026. $hash->{HELPER}{ACTIVE} = "off";
  3027. if (AttrVal($name,"debugactivetoken",0)) {
  3028. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3029. }
  3030. return;
  3031. }
  3032. }
  3033. return SSCam_checksid($hash);
  3034. }
  3035. #############################################################################################
  3036. # Check ob Session ID gesetzt ist - ggf. login
  3037. #############################################################################################
  3038. sub SSCam_checksid ($) {
  3039. my ($hash) = @_;
  3040. my $name = $hash->{NAME};
  3041. my $subref;
  3042. if(SSCam_IsModelCam($hash)) {
  3043. # Folgefunktion wenn Cam-Device
  3044. $subref = "SSCam_getcamid";
  3045. } else {
  3046. # Folgefunktion wenn SVS-Device
  3047. $subref = "SSCam_camop";
  3048. }
  3049. # SID holen bzw. login
  3050. my $sid = $hash->{HELPER}{SID};
  3051. if(!$sid) {
  3052. Log3($name, 3, "$name - no session ID found - get new one");
  3053. SSCam_login($hash,$subref);
  3054. return;
  3055. }
  3056. if(SSCam_IsModelCam($hash)) {
  3057. # Normalverarbeitung für Cams
  3058. return SSCam_getcamid($hash);
  3059. } else {
  3060. # Sprung zu SSCam_camop wenn SVS Device
  3061. return SSCam_camop($hash);
  3062. }
  3063. }
  3064. #############################################################################################
  3065. # Abruf der installierten Cams
  3066. #############################################################################################
  3067. sub SSCam_getcamid ($) {
  3068. my ($hash) = @_;
  3069. my $name = $hash->{NAME};
  3070. my $serveraddr = $hash->{SERVERADDR};
  3071. my $serverport = $hash->{SERVERPORT};
  3072. my $apicam = $hash->{HELPER}{APICAM};
  3073. my $apicampath = $hash->{HELPER}{APICAMPATH};
  3074. my $apicammaxver = $hash->{HELPER}{APICAMMAXVER};
  3075. my $sid = $hash->{HELPER}{SID};
  3076. my $proto = $hash->{PROTOCOL};
  3077. my $url;
  3078. # die Kamera-Id wird aus dem Kameranamen (Surveillance Station) ermittelt
  3079. Log3($name, 4, "$name - --- Begin Function SSCam_getcamid nonblocking ---");
  3080. if ($hash->{CAMID}) {
  3081. # Camid ist bereits ermittelt -> Abruf überspringen
  3082. Log3($name, 4, "$name - CAMID already set - ignore get camid");
  3083. return SSCam_camop($hash);
  3084. }
  3085. my $httptimeout = AttrVal($name,"httptimeout", 4);
  3086. Log3($name, 5, "$name - HTTP-Call will be done with httptimeout-Value: $httptimeout s");
  3087. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=List&basic=true&streamInfo=true&camStm=true&_sid=\"$sid\"";
  3088. if ($apicammaxver >= 9) {
  3089. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=\"List\"&basic=true&streamInfo=true&camStm=0&_sid=\"$sid\"";
  3090. }
  3091. Log3($name, 4, "$name - Call-Out now: $url");
  3092. my $param = {
  3093. url => $url,
  3094. timeout => $httptimeout,
  3095. hash => $hash,
  3096. method => "GET",
  3097. header => "Accept: application/json",
  3098. callback => \&SSCam_getcamid_parse
  3099. };
  3100. HttpUtils_NonblockingGet($param);
  3101. }
  3102. #############################################################################################
  3103. # Auswertung installierte Cams, Selektion Cam , Ausführung Operation
  3104. #############################################################################################
  3105. sub SSCam_getcamid_parse ($) {
  3106. my ($param, $err, $myjson) = @_;
  3107. my $hash = $param->{hash};
  3108. my $name = $hash->{NAME};
  3109. my $camname = $hash->{CAMNAME};
  3110. my $apicammaxver = $hash->{HELPER}{APICAMMAXVER};
  3111. my ($data,$success,$error,$errorcode,$camid);
  3112. my ($i,$n,$id);
  3113. my %allcams;
  3114. if ($err ne "") {
  3115. # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist
  3116. Log3($name, 2, "$name - error while requesting ".$param->{url}." - $err");
  3117. readingsSingleUpdate($hash, "Error", $err, 1);
  3118. return SSCam_login($hash,'SSCam_getapisites');
  3119. } elsif ($myjson ne "") {
  3120. # wenn die Abfrage erfolgreich war ($data enthält die Ergebnisdaten des HTTP Aufrufes)
  3121. # evaluiere ob Daten im JSON-Format empfangen wurden, Achtung: sehr viele Daten mit verbose=5
  3122. ($hash, $success) = SSCam_evaljson($hash,$myjson);
  3123. unless ($success) {
  3124. Log3($name, 4, "$name - Data returned: ".$myjson);
  3125. $hash->{HELPER}{ACTIVE} = "off";
  3126. if (AttrVal($name,"debugactivetoken",0)) {
  3127. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3128. }
  3129. return;
  3130. }
  3131. $data = decode_json($myjson);
  3132. # lesbare Ausgabe der decodierten JSON-Daten
  3133. Log3($name, 5, "$name - JSON returned: ". Dumper $data);
  3134. $success = $data->{'success'};
  3135. if ($success) {
  3136. # die Liste aller Kameras konnte ausgelesen werden
  3137. $i = 0;
  3138. # Namen aller installierten Kameras mit Id's in Assoziatives Array einlesen
  3139. %allcams = ();
  3140. while ($data->{'data'}->{'cameras'}->[$i]) {
  3141. if ($apicammaxver <= 8) {
  3142. $n = $data->{'data'}->{'cameras'}->[$i]->{'name'};
  3143. } else {
  3144. $n = $data->{'data'}->{'cameras'}->[$i]->{'newName'}; # Änderung ab SVS 8.0.0
  3145. }
  3146. $id = $data->{'data'}->{'cameras'}->[$i]->{'id'};
  3147. $allcams{"$n"} = "$id";
  3148. $i += 1;
  3149. }
  3150. # Ist der gesuchte Kameraname im Hash enhalten (in SVS eingerichtet ?)
  3151. if (exists($allcams{$camname})) {
  3152. $camid = $allcams{$camname};
  3153. # in hash eintragen
  3154. $hash->{CAMID} = $camid;
  3155. # Logausgabe
  3156. Log3($name, 4, "$name - Detection Camid successful - $camname ID: $camid");
  3157. } else {
  3158. # Kameraname nicht gefunden, id = ""
  3159. # Setreading
  3160. readingsBeginUpdate($hash);
  3161. readingsBulkUpdate($hash,"Errorcode","none");
  3162. readingsBulkUpdate($hash,"Error","Camera(ID) not found in Surveillance Station");
  3163. readingsEndUpdate($hash, 1);
  3164. # Logausgabe
  3165. Log3($name, 2, "$name - ERROR - Cameraname $camname wasn't found in Surveillance Station. Check Userrights, Cameraname and Spelling");
  3166. $hash->{HELPER}{ACTIVE} = "off";
  3167. if (AttrVal($name,"debugactivetoken",0)) {
  3168. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3169. }
  3170. return;
  3171. }
  3172. } else {
  3173. # Errorcode aus JSON ermitteln
  3174. $errorcode = $data->{'error'}->{'code'};
  3175. # Fehlertext zum Errorcode ermitteln
  3176. $error = SSCam_experror($hash,$errorcode);
  3177. readingsBeginUpdate($hash);
  3178. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  3179. readingsBulkUpdate($hash,"Error",$error);
  3180. readingsEndUpdate($hash, 1);
  3181. if ($errorcode =~ /(105|401)/) {
  3182. # neue Login-Versuche
  3183. Log3($name, 2, "$name - ERROR - $errorcode - $error -> try new login");
  3184. return SSCam_login($hash,'SSCam_getapisites');
  3185. } else {
  3186. # ausgeführte Funktion ist abgebrochen, Freigabe Funktionstoken
  3187. $hash->{HELPER}{ACTIVE} = "off";
  3188. if (AttrVal($name,"debugactivetoken",0)) {
  3189. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3190. }
  3191. Log3($name, 2, "$name - ERROR - ID of Camera $camname couldn't be selected. Errorcode: $errorcode - $error");
  3192. return;
  3193. }
  3194. }
  3195. }
  3196. return SSCam_camop($hash);
  3197. }
  3198. #############################################################################################
  3199. # Ausführung Operation
  3200. #############################################################################################
  3201. sub SSCam_camop ($) {
  3202. my ($hash) = @_;
  3203. my $name = $hash->{NAME};
  3204. my $apicam = $hash->{HELPER}{APICAM};
  3205. my $apicampath = $hash->{HELPER}{APICAMPATH};
  3206. my $apicammaxver = $hash->{HELPER}{APICAMMAXVER};
  3207. my $apiextrec = $hash->{HELPER}{APIEXTREC};
  3208. my $apiextrecpath = $hash->{HELPER}{APIEXTRECPATH};
  3209. my $apiextrecmaxver = $hash->{HELPER}{APIEXTRECMAXVER};
  3210. my $apiextevt = $hash->{HELPER}{APIEXTEVT};
  3211. my $apiextevtpath = $hash->{HELPER}{APIEXTEVTPATH};
  3212. my $apiextevtmaxver = $hash->{HELPER}{APIEXTEVTMAXVER};
  3213. my $apitakesnap = $hash->{HELPER}{APISNAPSHOT};
  3214. my $apitakesnappath = $hash->{HELPER}{APITAKESNAPPATH};
  3215. my $apitakesnapmaxver = $hash->{HELPER}{APITAKESNAPMAXVER};
  3216. my $apiptz = $hash->{HELPER}{APIPTZ};
  3217. my $apiptzpath = $hash->{HELPER}{APIPTZPATH};
  3218. my $apiptzmaxver = $hash->{HELPER}{APIPTZMAXVER};
  3219. my $apipreset = $hash->{HELPER}{APIPRESET};
  3220. my $apipresetpath = $hash->{HELPER}{APIPRESETPATH};
  3221. my $apipresetmaxver = $hash->{HELPER}{APIPRESETMAXVER};
  3222. my $apisvsinfo = $hash->{HELPER}{APISVSINFO};
  3223. my $apisvsinfopath = $hash->{HELPER}{APISVSINFOPATH};
  3224. my $apisvsinfomaxver = $hash->{HELPER}{APISVSINFOMAXVER};
  3225. my $apicamevent = $hash->{HELPER}{APICAMEVENT};
  3226. my $apicameventpath = $hash->{HELPER}{APICAMEVENTPATH};
  3227. my $apicameventmaxver = $hash->{HELPER}{APICAMEVENTMAXVER};
  3228. my $apievent = $hash->{HELPER}{APIEVENT};
  3229. my $apieventpath = $hash->{HELPER}{APIEVENTPATH};
  3230. my $apieventmaxver = $hash->{HELPER}{APIEVENTMAXVER};
  3231. my $apivideostm = $hash->{HELPER}{APIVIDEOSTM};
  3232. my $apivideostmpath = $hash->{HELPER}{APIVIDEOSTMPATH};
  3233. my $apivideostmmaxver = $hash->{HELPER}{APIVIDEOSTMMAXVER};
  3234. my $apiaudiostm = $hash->{HELPER}{APIAUDIOSTM};
  3235. my $apiaudiostmpath = $hash->{HELPER}{APIAUDIOSTMPATH};
  3236. my $apiaudiostmmaxver = $hash->{HELPER}{APIAUDIOSTMMAXVER};
  3237. my $apistm = $hash->{HELPER}{APISTM};
  3238. my $apistmpath = $hash->{HELPER}{APISTMPATH};
  3239. my $apistmmaxver = $hash->{HELPER}{APISTMMAXVER};
  3240. my $apihm = $hash->{HELPER}{APIHM};
  3241. my $apihmpath = $hash->{HELPER}{APIHMPATH};
  3242. my $apihmmaxver = $hash->{HELPER}{APIHMMAXVER};
  3243. my $apilog = $hash->{HELPER}{APILOG};
  3244. my $apilogpath = $hash->{HELPER}{APILOGPATH};
  3245. my $apilogmaxver = $hash->{HELPER}{APILOGMAXVER};
  3246. my $apivideostms = $hash->{HELPER}{APIVIDEOSTMS};
  3247. my $apivideostmspath = $hash->{HELPER}{APIVIDEOSTMSPATH};
  3248. my $apivideostmsmaxver = $hash->{HELPER}{APIVIDEOSTMSMAXVER};
  3249. my $sid = $hash->{HELPER}{SID};
  3250. my $OpMode = $hash->{OPMODE};
  3251. my $camid = $hash->{CAMID};
  3252. my $proto = $hash->{PROTOCOL};
  3253. my $serveraddr = $hash->{SERVERADDR};
  3254. my $serverport = $hash->{SERVERPORT};
  3255. my ($exturl,$winname,$attr,$room,$param);
  3256. my ($url,$snapid,$httptimeout,$expmode,$motdetsc);
  3257. Log3($name, 4, "$name - --- Begin Function $OpMode nonblocking ---");
  3258. $httptimeout = AttrVal($name, "httptimeout", 4);
  3259. $httptimeout = $httptimeout+90 if($OpMode =~ /setoptpar|Disable/); # setzen der Optimierungsparameter/Disable dauert lange !
  3260. Log3($name, 5, "$name - HTTP-Call will be done with httptimeout-Value: $httptimeout s");
  3261. if ($OpMode eq "Start") {
  3262. $url = "$proto://$serveraddr:$serverport/webapi/$apiextrecpath?api=$apiextrec&method=Record&version=$apiextrecmaxver&cameraId=$camid&action=start&_sid=\"$sid\"";
  3263. if($apiextrecmaxver >= 3) {
  3264. $url = "$proto://$serveraddr:$serverport/webapi/$apiextrecpath?api=$apiextrec&method=Record&version=$apiextrecmaxver&cameraIds=$camid&action=start&_sid=\"$sid\"";
  3265. }
  3266. } elsif ($OpMode eq "Stop") {
  3267. $url = "$proto://$serveraddr:$serverport/webapi/$apiextrecpath?api=$apiextrec&method=Record&version=$apiextrecmaxver&cameraId=$camid&action=stop&_sid=\"$sid\"";
  3268. if($apiextrecmaxver >= 3) {
  3269. $url = "$proto://$serveraddr:$serverport/webapi/$apiextrecpath?api=$apiextrec&method=Record&version=$apiextrecmaxver&cameraIds=$camid&action=stop&_sid=\"$sid\"";
  3270. }
  3271. } elsif ($OpMode eq "Snap") {
  3272. # ein Schnappschuß wird ausgelöst
  3273. $url = "$proto://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&dsId=\"0\"&method=\"TakeSnapshot\"&version=\"$apitakesnapmaxver\"&camId=\"$camid\"&blSave=\"true\"&_sid=\"$sid\"";
  3274. readingsSingleUpdate($hash,"state", "snap", 1);
  3275. readingsSingleUpdate($hash, "LastSnapId", "", 0);
  3276. } elsif ($OpMode eq "getsnapinfo" || $OpMode eq "getsnapgallery") {
  3277. # Informationen über den letzten oder mehrere Schnappschüsse ermitteln
  3278. my $limit = $hash->{HELPER}{SNAPLIMIT};
  3279. my $imgsize = $hash->{HELPER}{SNAPIMGSIZE};
  3280. my $keyword = $hash->{HELPER}{KEYWORD};
  3281. Log3($name,4, "$name - Call getsnapinfo with params: Image numbers => $limit, Image size => $imgsize, Keyword => $keyword");
  3282. $url = "$proto://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&method=\"List\"&version=\"$apitakesnapmaxver\"&keyword=\"$keyword\"&imgSize=\"$imgsize\"&limit=\"$limit\"&_sid=\"$sid\"";
  3283. } elsif ($OpMode eq "getsnapfilename") {
  3284. # der Filename der aktuellen Schnappschuß-ID wird ermittelt
  3285. $snapid = ReadingsVal("$name", "LastSnapId", " ");
  3286. Log3($name, 4, "$name - Get filename of present Snap-ID $snapid");
  3287. $url = "$proto://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&method=\"List\"&version=\"$apitakesnapmaxver\"&imgSize=\"0\"&idList=\"$snapid\"&_sid=\"$sid\"";
  3288. } elsif ($OpMode eq "gopreset") {
  3289. # Preset wird angefahren
  3290. $apiptzmaxver = ($apiptzmaxver >= 5)?4:$apiptzmaxver;
  3291. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"GoPreset\"&position=\"$hash->{HELPER}{ALLPRESETS}{$hash->{HELPER}{GOPRESETNAME}}\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3292. } elsif ($OpMode eq "getPresets") {
  3293. # Liste der Presets abrufen
  3294. $url = "$proto://$serveraddr:$serverport/webapi/$apipresetpath?api=\"$apipreset\"&version=\"$apipresetmaxver\"&method=\"Enum\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3295. } elsif ($OpMode eq "piract") {
  3296. # PIR Sensor aktivieren/deaktivieren
  3297. my $piract = $hash->{HELPER}{PIRACT};
  3298. $url = "$proto://$serveraddr:$serverport/webapi/$apicameventpath?api=\"$apicamevent\"&version=\"$apicameventmaxver\"&method=\"PDParamSave\"&keep=true&source=$piract&camId=\"$camid\"&_sid=\"$sid\"";
  3299. } elsif ($OpMode eq "setPreset") {
  3300. # einen Preset setzen
  3301. my $pnumber = $hash->{HELPER}{PNUMBER};
  3302. my $pname = $hash->{HELPER}{PNAME};
  3303. my $pspeed = $hash->{HELPER}{PSPEED};
  3304. if ($pspeed) {
  3305. $url = "$proto://$serveraddr:$serverport/webapi/$apipresetpath?api=\"$apipreset\"&version=\"$apipresetmaxver\"&method=\"SetPreset\"&position=$pnumber&name=\"$pname\"&speed=\"$pspeed\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3306. } else {
  3307. $url = "$proto://$serveraddr:$serverport/webapi/$apipresetpath?api=\"$apipreset\"&version=\"$apipresetmaxver\"&method=\"SetPreset\"&position=$pnumber&name=\"$pname\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3308. }
  3309. } elsif ($OpMode eq "delPreset") {
  3310. # einen Preset löschen
  3311. $url = "$proto://$serveraddr:$serverport/webapi/$apipresetpath?api=\"$apipreset\"&version=\"$apipresetmaxver\"&method=\"DelPreset\"&position=\"$hash->{HELPER}{ALLPRESETS}{$hash->{HELPER}{DELPRESETNAME}}\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3312. } elsif ($OpMode eq "setHome") {
  3313. # aktuelle Position als Home setzen
  3314. if($hash->{HELPER}{SETHOME} eq "---currentPosition---") {
  3315. $url = "$proto://$serveraddr:$serverport/webapi/$apipresetpath?api=\"$apipreset\"&version=\"$apipresetmaxver\"&method=\"SetHome\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3316. } else {
  3317. my $bindpos = $hash->{HELPER}{ALLPRESETS}{$hash->{HELPER}{SETHOME}};
  3318. $url = "$proto://$serveraddr:$serverport/webapi/$apipresetpath?api=\"$apipreset\"&version=\"$apipresetmaxver\"&method=\"SetHome\"&bindPosition=\"$bindpos\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3319. }
  3320. } elsif ($OpMode eq "startTrack") {
  3321. # Object Tracking einschalten
  3322. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"ObjTracking\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3323. } elsif ($OpMode eq "stopTrack") {
  3324. # Object Tracking stoppen
  3325. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"ObjTracking\"&moveType=\"Stop\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3326. } elsif ($OpMode eq "runpatrol") {
  3327. # eine Überwachungstour starten
  3328. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"RunPatrol\"&patrolId=\"$hash->{HELPER}{ALLPATROLS}{$hash->{HELPER}{GOPATROLNAME}}\"&cameraId=\"$camid\"&_sid=\"$sid\"";
  3329. } elsif ($OpMode eq "goabsptz") {
  3330. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"AbsPtz\"&cameraId=\"$camid\"&posX=\"$hash->{HELPER}{GOPTZPOSX}\"&posY=\"$hash->{HELPER}{GOPTZPOSY}\"&_sid=\"$sid\"";
  3331. } elsif ($OpMode eq "movestart") {
  3332. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"Move\"&cameraId=\"$camid\"&direction=\"$hash->{HELPER}{GOMOVEDIR}\"&speed=\"3\"&moveType=\"Start\"&_sid=\"$sid\"";
  3333. } elsif ($OpMode eq "movestop") {
  3334. Log3($name, 4, "$name - Stop Camera $hash->{CAMNAME} moving to direction \"$hash->{HELPER}{GOMOVEDIR}\" now");
  3335. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=\"$apiptz\"&version=\"$apiptzmaxver\"&method=\"Move\"&cameraId=\"$camid\"&direction=\"$hash->{HELPER}{GOMOVEDIR}\"&moveType=\"Stop\"&_sid=\"$sid\"";
  3336. } elsif ($OpMode eq "Enable") {
  3337. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=Enable&cameraIds=$camid&_sid=\"$sid\"";
  3338. if($apicammaxver >= 9) {
  3339. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=$apicammaxver&method=\"Enable\"&idList=\"$camid\"&_sid=\"$sid\"";
  3340. }
  3341. } elsif ($OpMode eq "Disable") {
  3342. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=Disable&cameraIds=$camid&_sid=\"$sid\"";
  3343. if($apicammaxver >= 9) {
  3344. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=$apicammaxver&method=\"Disable\"&idList=\"$camid\"&_sid=\"$sid\"";
  3345. }
  3346. } elsif ($OpMode eq "sethomemode") {
  3347. my $sw = $hash->{HELPER}{HOMEMODE}; # HomeMode on,off
  3348. $sw = ($sw eq "on")?"true":"false";
  3349. $url = "$proto://$serveraddr:$serverport/webapi/$apihmpath?on=$sw&api=$apihm&method=Switch&version=$apihmmaxver&_sid=\"$sid\"";
  3350. } elsif ($OpMode eq "gethomemodestate") {
  3351. $url = "$proto://$serveraddr:$serverport/webapi/$apihmpath?api=$apihm&method=GetInfo&version=$apihmmaxver&_sid=\"$sid\"";
  3352. } elsif ($OpMode eq "getsvslog") {
  3353. my $sev = $hash->{HELPER}{LISTLOGSEVERITY}?$hash->{HELPER}{LISTLOGSEVERITY}:"";
  3354. my $lim = $hash->{HELPER}{LISTLOGLIMIT}?$hash->{HELPER}{LISTLOGLIMIT}:0;
  3355. my $mco = $hash->{HELPER}{LISTLOGMATCH}?$hash->{HELPER}{LISTLOGMATCH}:"";
  3356. $mco = SSCam_IsModelCam($hash)?$hash->{CAMNAME}:$mco;
  3357. $lim = 1 if(!$hash->{HELPER}{CL}{1}); # Datenabruf im Hintergrund
  3358. $sev = (lc($sev) =~ /error/)?3:(lc($sev) =~ /warning/)?2:(lc($sev) =~ /info/)?1:"";
  3359. no warnings 'uninitialized';
  3360. Log3($name,4, "$name - get logList with params: severity => $hash->{HELPER}{LISTLOGSEVERITY}, limit => $lim, matchcode => $hash->{HELPER}{LISTLOGMATCH}");
  3361. use warnings;
  3362. $url = "$proto://$serveraddr:$serverport/webapi/$apilogpath?api=$apilog&version=\"2\"&method=\"List\"&time2String=\"no\"&level=\"$sev\"&limit=\"$lim\"&keyword=\"$mco\"&_sid=\"$sid\"";
  3363. delete($hash->{HELPER}{LISTLOGSEVERITY});
  3364. delete($hash->{HELPER}{LISTLOGLIMIT});
  3365. delete($hash->{HELPER}{LISTLOGMATCH});
  3366. } elsif ($OpMode eq "getsvsinfo") {
  3367. $url = "$proto://$serveraddr:$serverport/webapi/$apisvsinfopath?api=\"$apisvsinfo\"&version=\"$apisvsinfomaxver\"&method=\"GetInfo\"&_sid=\"$sid\"";
  3368. } elsif ($OpMode eq "setoptpar") {
  3369. my $mirr = $hash->{HELPER}{MIRROR}?$hash->{HELPER}{MIRROR}:ReadingsVal("$name","CamVideoMirror","");
  3370. my $flip = $hash->{HELPER}{FLIP}?$hash->{HELPER}{FLIP}:ReadingsVal("$name","CamVideoFlip","");
  3371. my $rot = $hash->{HELPER}{ROTATE}?$hash->{HELPER}{ROTATE}:ReadingsVal("$name","CamVideoRotate","");
  3372. my $ntp = $hash->{HELPER}{NTPSERV}?$hash->{HELPER}{NTPSERV}:ReadingsVal("$name","CamNTPServer","");
  3373. my $clst = $hash->{HELPER}{CHKLIST}?$hash->{HELPER}{CHKLIST}:"";
  3374. $apicammaxver = ($apicammaxver >= 9)?8:$apicammaxver;
  3375. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=\"$apicammaxver\"&method=\"SaveOptimizeParam\"&vdoMirror=$mirr&vdoRotation=$rot&vdoFlip=$flip&timeServer=\"$ntp\"&camParamChkList=$clst&cameraIds=\"$camid\"&_sid=\"$sid\"";
  3376. } elsif ($OpMode eq "Getcaminfo") {
  3377. $apicammaxver = ($apicammaxver >= 9)?8:$apicammaxver;
  3378. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=\"$apicammaxver\"&method=\"GetInfo\"&cameraIds=\"$camid\"&deviceOutCap=\"true\"&streamInfo=\"true\"&ptz=\"true\"&basic=\"true\"&camAppInfo=\"true\"&optimize=\"true\"&fisheye=\"true\"&eventDetection=\"true\"&_sid=\"$sid\"";
  3379. } elsif ($OpMode eq "getStmUrlPath") {
  3380. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=\"$apicammaxver\"&method=\"GetStmUrlPath\"&cameraIds=\"$camid\"&_sid=\"$sid\"";
  3381. if($apicammaxver >= 9) {
  3382. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&method=\"GetLiveViewPath\"&version=$apicammaxver&idList=\"$camid\"&_sid=\"$sid\"";
  3383. }
  3384. } elsif ($OpMode eq "geteventlist") {
  3385. # Abruf der Events einer Kamera
  3386. $url = "$proto://$serveraddr:$serverport/webapi/$apieventpath?api=\"$apievent\"&version=\"$apieventmaxver\"&method=\"List\"&cameraIds=\"$camid\"&locked=\"0\"&blIncludeSnapshot=\"false\"&reason=\"\"&limit=\"2\"&includeAllCam=\"false\"&_sid=\"$sid\"";
  3387. } elsif ($OpMode eq "Getptzlistpreset") {
  3388. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=$apiptz&version=$apiptzmaxver&method=ListPreset&cameraId=$camid&_sid=\"$sid\"";
  3389. } elsif ($OpMode eq "Getcapabilities") {
  3390. # Capabilities einer Cam werden abgerufen
  3391. $apicammaxver = ($apicammaxver >= 9)?8:$apicammaxver;
  3392. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=$apicam&version=$apicammaxver&method=\"GetCapabilityByCamId\"&cameraId=$camid&_sid=\"$sid\"";
  3393. } elsif ($OpMode eq "Getptzlistpatrol") {
  3394. # PTZ-ListPatrol werden abgerufen
  3395. $url = "$proto://$serveraddr:$serverport/webapi/$apiptzpath?api=$apiptz&version=$apiptzmaxver&method=ListPatrol&cameraId=$camid&_sid=\"$sid\"";
  3396. } elsif ($OpMode eq "ExpMode") {
  3397. if ($hash->{HELPER}{EXPMODE} eq "auto") {
  3398. $expmode = "0";
  3399. }
  3400. elsif ($hash->{HELPER}{EXPMODE} eq "day") {
  3401. $expmode = "1";
  3402. }
  3403. elsif ($hash->{HELPER}{EXPMODE} eq "night") {
  3404. $expmode = "2";
  3405. }
  3406. $apicammaxver = ($apicammaxver >= 9)?8:$apicammaxver;
  3407. $url = "$proto://$serveraddr:$serverport/webapi/$apicampath?api=\"$apicam\"&version=\"$apicammaxver\"&method=\"SaveOptimizeParam\"&cameraIds=\"$camid\"&expMode=\"$expmode\"&camParamChkList=32&_sid=\"$sid\"";
  3408. } elsif ($OpMode eq "MotDetSc") {
  3409. # Hash für Optionswerte sichern für Logausgabe in Befehlsauswertung
  3410. my %motdetoptions = ();
  3411. if ($hash->{HELPER}{MOTDETSC} eq "disable") {
  3412. $motdetsc = "-1";
  3413. $url = "$proto://$serveraddr:$serverport/webapi/$apicameventpath?api=\"$apicamevent\"&version=\"$apicameventmaxver\"&method=\"MDParamSave\"&camId=\"$camid\"&source=$motdetsc&keep=true&_sid=\"$sid\"";
  3414. } elsif ($hash->{HELPER}{MOTDETSC} eq "camera") {
  3415. $motdetsc = "0";
  3416. $motdetoptions{SENSITIVITY} = $hash->{'HELPER'}{'MOTDETSC_PROP1'} if ($hash->{'HELPER'}{'MOTDETSC_PROP1'});
  3417. $motdetoptions{OBJECTSIZE} = $hash->{'HELPER'}{'MOTDETSC_PROP2'} if ($hash->{'HELPER'}{'MOTDETSC_PROP2'});
  3418. $motdetoptions{PERCENTAGE} = $hash->{'HELPER'}{'MOTDETSC_PROP3'} if ($hash->{'HELPER'}{'MOTDETSC_PROP3'});
  3419. $url = "$proto://$serveraddr:$serverport/webapi/$apicameventpath?api=\"$apicamevent\"&version=\"$apicameventmaxver\"&method=\"MDParamSave\"&camId=\"$camid\"&source=$motdetsc&_sid=\"$sid\"";
  3420. if ($hash->{HELPER}{MOTDETSC_PROP1} || $hash->{HELPER}{MOTDETSC_PROP2} || $hash->{HELPER}{MOTDETSC_PROP13}) {
  3421. # umschalten und neue Werte setzen
  3422. $url .= "&keep=false";
  3423. } else {
  3424. # nur Umschaltung, alte Werte beibehalten
  3425. $url .= "&keep=true";
  3426. }
  3427. if ($hash->{HELPER}{MOTDETSC_PROP1}) {
  3428. # der Wert für Bewegungserkennung Kamera -> Empfindlichkeit ist gesetzt
  3429. my $sensitivity = delete $hash->{HELPER}{MOTDETSC_PROP1};
  3430. $url .= "&sensitivity=\"$sensitivity\"";
  3431. }
  3432. if ($hash->{HELPER}{MOTDETSC_PROP2}) {
  3433. # der Wert für Bewegungserkennung Kamera -> Objektgröße ist gesetzt
  3434. my $objectsize = delete $hash->{HELPER}{MOTDETSC_PROP2};
  3435. $url .= "&objectSize=\"$objectsize\"";
  3436. }
  3437. if ($hash->{HELPER}{MOTDETSC_PROP3}) {
  3438. # der Wert für Bewegungserkennung Kamera -> Prozentsatz für Auslösung ist gesetzt
  3439. my $percentage = delete $hash->{HELPER}{MOTDETSC_PROP3};
  3440. $url .= "&percentage=\"$percentage\"";
  3441. }
  3442. } elsif ($hash->{HELPER}{MOTDETSC} eq "SVS") {
  3443. $motdetsc = "1";
  3444. $motdetoptions{SENSITIVITY} = $hash->{'HELPER'}{'MOTDETSC_PROP1'} if ($hash->{'HELPER'}{'MOTDETSC_PROP1'});
  3445. $motdetoptions{THRESHOLD} = $hash->{'HELPER'}{'MOTDETSC_PROP2'} if ($hash->{'HELPER'}{'MOTDETSC_PROP2'});
  3446. # nur Umschaltung, alte Werte beibehalten
  3447. $url = "$proto://$serveraddr:$serverport/webapi/$apicameventpath?api=\"$apicamevent\"&version=\"$apicameventmaxver\"&method=\"MDParamSave\"&camId=\"$camid\"&source=$motdetsc&keep=true&_sid=\"$sid\"";
  3448. if ($hash->{HELPER}{MOTDETSC_PROP1}) {
  3449. # der Wert für Bewegungserkennung SVS -> Empfindlichkeit ist gesetzt
  3450. my $sensitivity = delete $hash->{HELPER}{MOTDETSC_PROP1};
  3451. $url .= "&sensitivity=\"$sensitivity\"";
  3452. }
  3453. if ($hash->{HELPER}{MOTDETSC_PROP2}) {
  3454. # der Wert für Bewegungserkennung SVS -> Schwellwert ist gesetzt
  3455. my $threshold = delete $hash->{HELPER}{MOTDETSC_PROP2};
  3456. $url .= "&threshold=\"$threshold\"";
  3457. }
  3458. }
  3459. # Optionswerte in Hash sichern für Logausgabe in Befehlsauswertung
  3460. $hash->{HELPER}{MOTDETOPTIONS} = \%motdetoptions;
  3461. } elsif ($OpMode eq "getmotionenum") {
  3462. $url = "$proto://$serveraddr:$serverport/webapi/$apicameventpath?api=\"$apicamevent\"&version=\"$apicameventmaxver\"&method=\"MotionEnum\"&camId=\"$camid\"&_sid=\"$sid\"";
  3463. } elsif ($OpMode eq "extevent") {
  3464. Log3($name, 4, "$name - trigger external event \"$hash->{HELPER}{EVENTID}\"");
  3465. $url = "$proto://$serveraddr:$serverport/webapi/$apiextevtpath?api=$apiextevt&version=$apiextevtmaxver&method=Trigger&eventId=$hash->{HELPER}{EVENTID}&eventName=$hash->{HELPER}{EVENTID}&_sid=\"$sid\"";
  3466. } elsif ($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} !~ m/snap|^live_.*hls$/) {
  3467. $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport");
  3468. $exturl = ($exturl eq "DEF")?"$proto://$serveraddr:$serverport":$exturl;
  3469. if ($hash->{HELPER}{RUNVIEW} =~ m/live/) {
  3470. if($apiaudiostmmaxver) { # API "SYNO.SurveillanceStation.AudioStream" vorhanden ? (removed ab API v2.8)
  3471. $hash->{HELPER}{AUDIOLINK} = "$proto://$serveraddr:$serverport/webapi/$apiaudiostmpath?api=$apiaudiostm&version=$apiaudiostmmaxver&method=Stream&cameraId=$camid&_sid=$sid";
  3472. } else {
  3473. delete $hash->{HELPER}{AUDIOLINK} if($hash->{HELPER}{AUDIOLINK});
  3474. }
  3475. if($apivideostmsmaxver) { # API "SYNO.SurveillanceStation.VideoStream" vorhanden ? (removed ab API v2.8)
  3476. # externe URL in Reading setzen
  3477. $exturl .= "/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=mjpeg&_sid=$sid";
  3478. # interne URL
  3479. $url = "$proto://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=mjpeg&_sid=$sid";
  3480. } elsif ($hash->{HELPER}{STMKEYMJPEGHTTP}) {
  3481. $url = $hash->{HELPER}{STMKEYMJPEGHTTP};
  3482. }
  3483. readingsSingleUpdate($hash,"LiveStreamUrl", $exturl, 1) if(AttrVal($name, "showStmInfoFull", undef));
  3484. } else {
  3485. # Abspielen der letzten Aufnahme (EventId)
  3486. # externe URL in Reading setzen
  3487. $exturl .= "/webapi/$apistmpath?api=$apistm&version=$apistmmaxver&method=EventStream&eventId=$hash->{HELPER}{CAMLASTRECID}&timestamp=1&_sid=$sid";
  3488. # interne URL
  3489. $url = "$proto://$serveraddr:$serverport/webapi/$apistmpath?api=$apistm&version=$apistmmaxver&method=EventStream&eventId=$hash->{HELPER}{CAMLASTRECID}&timestamp=1&_sid=$sid";
  3490. readingsSingleUpdate($hash,"LiveStreamUrl", $exturl, 1) if(AttrVal($name, "showStmInfoFull", undef));
  3491. }
  3492. # Liveview-Link in Hash speichern
  3493. $hash->{HELPER}{LINK} = $url;
  3494. Log3($name, 4, "$name - Set Streaming-URL: $url");
  3495. # livestream sofort in neuem Browsertab öffnen
  3496. if ($hash->{HELPER}{OPENWINDOW}) {
  3497. $winname = $name."_view";
  3498. $attr = AttrVal($name, "htmlattr", "");
  3499. # öffnen streamwindow für die Instanz die "VIEWOPENROOM" oder Attr "room" aktuell geöffnet hat
  3500. if ($hash->{HELPER}{VIEWOPENROOM}) {
  3501. $room = $hash->{HELPER}{VIEWOPENROOM};
  3502. map {FW_directNotify("FILTER=room=$room", "#FHEMWEB:$_", "window.open ('$url','$winname','$attr')", "")} devspec2array("WEB.*");
  3503. } else {
  3504. map {FW_directNotify("#FHEMWEB:$_", "window.open ('$url','$winname','$attr')", "")} devspec2array("WEB.*");
  3505. }
  3506. }
  3507. SSCam_refresh($hash,0,1,1); # kein Room-Refresh, SSCam-state-Event, SSCamSTRM-Event
  3508. $hash->{HELPER}{ACTIVE} = "off";
  3509. if (AttrVal($name,"debugactivetoken",0)) {
  3510. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3511. }
  3512. return;
  3513. } elsif ($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} =~ /snap/) {
  3514. # den letzten Schnappschuß live anzeigen
  3515. my $limit = 1; # nur 1 Snap laden, für lastsnap_fw
  3516. my $imgsize = 2; # full size image, für lastsnap_fw
  3517. my $keyword = $hash->{CAMNAME}; # nur Snaps von $camname selektieren, für lastsnap_fw
  3518. $url = "$proto://$serveraddr:$serverport/webapi/$apitakesnappath?api=\"$apitakesnap\"&method=\"List\"&version=\"$apitakesnapmaxver\"&keyword=\"$keyword\"&imgSize=\"$imgsize\"&limit=\"$limit\"&_sid=\"$sid\"";
  3519. } elsif (($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} =~ m/^live_.*hls$/) || $OpMode eq "activate_hls") {
  3520. # HLS Livestreaming aktivieren
  3521. $httptimeout = $httptimeout+90; # aktivieren HLS dauert lange !
  3522. $url = "$proto://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Open&cameraId=$camid&format=hls&_sid=$sid";
  3523. } elsif ($OpMode eq "stopliveview_hls" || $OpMode eq "reactivate_hls") {
  3524. # HLS Livestreaming deaktivieren
  3525. $url = "$proto://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Close&cameraId=$camid&format=hls&_sid=$sid";
  3526. } elsif ($OpMode eq "getstreamformat") {
  3527. # aktuelles Streamformat abfragen
  3528. $url = "$proto://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Query&cameraId=$camid&_sid=$sid";
  3529. }
  3530. Log3($name, 4, "$name - Call-Out now: $url");
  3531. $param = {
  3532. url => $url,
  3533. timeout => $httptimeout,
  3534. hash => $hash,
  3535. method => "GET",
  3536. header => "Accept: application/json",
  3537. callback => \&SSCam_camop_parse
  3538. };
  3539. HttpUtils_NonblockingGet ($param);
  3540. }
  3541. ###################################################################################
  3542. # Check ob Kameraoperation erfolgreich wie in "OpMOde" definiert
  3543. ###################################################################################
  3544. sub SSCam_camop_parse ($) {
  3545. my ($param, $err, $myjson) = @_;
  3546. my $hash = $param->{hash};
  3547. my $name = $hash->{NAME};
  3548. my $camname = $hash->{CAMNAME};
  3549. my $OpMode = $hash->{OPMODE};
  3550. my $serveraddr = $hash->{SERVERADDR};
  3551. my $serverport = $hash->{SERVERPORT};
  3552. my $camid = $hash->{CAMID};
  3553. my $apivideostms = $hash->{HELPER}{APIVIDEOSTMS};
  3554. my $apivideostmspath = $hash->{HELPER}{APIVIDEOSTMSPATH};
  3555. my $apivideostmsmaxver = $hash->{HELPER}{APIVIDEOSTMSMAXVER};
  3556. my $apicammaxver = $hash->{HELPER}{APICAMMAXVER};
  3557. my $sid = $hash->{HELPER}{SID};
  3558. my $proto = $hash->{PROTOCOL};
  3559. my ($rectime,$data,$success);
  3560. my ($error,$errorcode);
  3561. my ($snapid,$camLiveMode,$update_time);
  3562. my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst);
  3563. my ($deviceType,$camStatus);
  3564. my ($patrolcnt,$patrolid,$patrolname,@patrolkeys,$patrollist);
  3565. my ($recStatus,$exposuremode,$exposurecontrol);
  3566. my ($userPriv,$verbose,$motdetsc);
  3567. my ($sensitivity_camCap,$sensitivity_value,$sensitivity_ssCap);
  3568. my ($threshold_camCap,$threshold_value,$threshold_ssCap);
  3569. my ($percentage_camCap,$percentage_value,$percentage_ssCap);
  3570. my ($objectSize_camCap,$objectSize_value,$objectSize_ssCap);
  3571. # Einstellung für Logausgabe Pollinginfos
  3572. # wenn "pollnologging" = 1 -> logging nur bei Verbose=4, sonst 3
  3573. if (AttrVal($name, "pollnologging", 0) == 1) {
  3574. $verbose = 4;
  3575. } else {
  3576. $verbose = 3;
  3577. }
  3578. if ($err ne "") {
  3579. # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist
  3580. Log3($name, 2, "$name - error while requesting ".$param->{url}." - $err");
  3581. readingsSingleUpdate($hash, "Error", $err, 1);
  3582. # ausgeführte Funktion ist abgebrochen, Freigabe Funktionstoken
  3583. $hash->{HELPER}{ACTIVE} = "off";
  3584. if (AttrVal($name,"debugactivetoken",0)) {
  3585. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3586. }
  3587. return;
  3588. } elsif ($myjson ne "") {
  3589. # wenn die Abfrage erfolgreich war ($data enthält die Ergebnisdaten des HTTP Aufrufes)
  3590. # Evaluiere ob Daten im JSON-Format empfangen wurden
  3591. ($hash,$success,$myjson) = SSCam_evaljson($hash,$myjson);
  3592. unless ($success) {
  3593. Log3($name, 4, "$name - Data returned: ".$myjson);
  3594. # ausgeführte Funktion ist abgebrochen, Freigabe Funktionstoken
  3595. $hash->{HELPER}{ACTIVE} = "off";
  3596. if (AttrVal($name,"debugactivetoken",0)) {
  3597. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  3598. }
  3599. return;
  3600. }
  3601. $data = decode_json($myjson);
  3602. # Logausgabe decodierte JSON Daten
  3603. Log3($name, 5, "$name - JSON returned: ". Dumper $data);
  3604. $success = $data->{'success'};
  3605. if ($success) {
  3606. # Kameraoperation entsprechend "OpMode" war erfolgreich
  3607. if ($OpMode eq "Start") {
  3608. # Die Aufnahmezeit setzen
  3609. # wird "set <name> on [rectime]" verwendet -> dann [rectime] nutzen,
  3610. # sonst Attribut "rectime" wenn es gesetzt ist, falls nicht -> "RECTIME_DEF"
  3611. if (defined($hash->{HELPER}{RECTIME_TEMP})) {
  3612. $rectime = delete $hash->{HELPER}{RECTIME_TEMP};
  3613. } else {
  3614. $rectime = AttrVal($name, "rectime", $hash->{HELPER}{RECTIME_DEF});
  3615. }
  3616. if ($rectime == "0") {
  3617. Log3($name, 3, "$name - Camera $camname endless Recording started - stop it by stop-command !");
  3618. } else {
  3619. if (ReadingsVal("$name", "Record", "Stop") eq "Start") {
  3620. # Aufnahme läuft schon und wird verlängert
  3621. Log3($name, 3, "$name - running recording renewed to $rectime s");
  3622. } else {
  3623. Log3($name, 3, "$name - Camera $camname Recording with Recordtime $rectime s started");
  3624. }
  3625. }
  3626. readingsBeginUpdate($hash);
  3627. readingsBulkUpdate($hash,"Record","Start");
  3628. readingsBulkUpdate($hash,"state","on");
  3629. readingsBulkUpdate($hash,"Errorcode","none");
  3630. readingsBulkUpdate($hash,"Error","none");
  3631. readingsEndUpdate($hash, 1);
  3632. if ($rectime != 0) {
  3633. # Stop der Aufnahme nach Ablauf $rectime, wenn rectime = 0 -> endlose Aufnahme
  3634. RemoveInternalTimer($hash, "SSCam_camstoprec");
  3635. InternalTimer(gettimeofday()+$rectime, "SSCam_camstoprec", $hash);
  3636. }
  3637. SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein SSCam-state-Event, SSCamSTRM-Event
  3638. } elsif ($OpMode eq "Stop") {
  3639. readingsBeginUpdate($hash);
  3640. readingsBulkUpdate($hash,"Record","Stop");
  3641. readingsBulkUpdate($hash,"state","off");
  3642. readingsBulkUpdate($hash,"Errorcode","none");
  3643. readingsBulkUpdate($hash,"Error","none");
  3644. readingsEndUpdate($hash, 1);
  3645. # Logausgabe
  3646. Log3($name, 3, "$name - Camera $camname Recording stopped");
  3647. SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein SSCam-state-Event, SSCamSTRM-Event
  3648. # Aktualisierung Eventlist der letzten Aufnahme
  3649. SSCam_geteventlist($hash);
  3650. } elsif ($OpMode eq "ExpMode") {
  3651. readingsBeginUpdate($hash);
  3652. readingsBulkUpdate($hash,"Errorcode","none");
  3653. readingsBulkUpdate($hash,"Error","none");
  3654. readingsEndUpdate($hash, 1);
  3655. # Logausgabe
  3656. Log3($name, 3, "$name - Camera $camname exposure mode was set to \"$hash->{HELPER}{EXPMODE}\"");
  3657. } elsif ($OpMode eq "sethomemode") {
  3658. readingsBeginUpdate($hash);
  3659. readingsBulkUpdate($hash,"Errorcode","none");
  3660. readingsBulkUpdate($hash,"Error","none");
  3661. readingsEndUpdate($hash, 1);
  3662. Log3($name, 3, "$name - HomeMode was set to \"$hash->{HELPER}{HOMEMODE}\" ");
  3663. # Token freigeben vor nächstem Kommando
  3664. $hash->{HELPER}{ACTIVE} = "off";
  3665. # neuen HomeModeState abrufen
  3666. SSCam_gethomemodestate($hash);
  3667. } elsif ($OpMode eq "gethomemodestate") {
  3668. my $hmst = $data->{'data'}{'on'};
  3669. my $hmststr = ($hmst == 1)?"on":"off";
  3670. readingsBeginUpdate($hash);
  3671. readingsBulkUpdate($hash,"HomeModeState",$hmststr);
  3672. readingsBulkUpdate($hash,"Errorcode","none");
  3673. readingsBulkUpdate($hash,"Error","none");
  3674. readingsEndUpdate($hash, 1);
  3675. } elsif ($OpMode eq "getsvslog") {
  3676. my $lec = $data->{'data'}{'total'}; # abgerufene Anzahl von Log-Einträgen
  3677. my $log = '<html>';
  3678. my $log0 = "";
  3679. my $i = 0;
  3680. while ($data->{'data'}->{'log'}->[$i]) {
  3681. my $id = $data->{'data'}->{'log'}->[$i]{'id'};
  3682. my $un = $data->{'data'}->{'log'}->[$i]{'user_name'};
  3683. my $desc = $data->{'data'}->{'log'}->[$i]{'desc'};
  3684. my $level = $data->{'data'}->{'log'}->[$i]{'type'};
  3685. $level = ($level == 3)?"Error":($level == 2)?"Warning":"Information";
  3686. my $time = $data->{'data'}->{'log'}->[$i]{'time'};
  3687. $time = FmtDateTime($time);
  3688. $log0 = $time." - ".$level." - ".$desc if($i == 0);
  3689. $log .= "$time - $level - $desc<br>";
  3690. $i++;
  3691. }
  3692. $log = "<html><b>Surveillance Station Server \"$hash->{SERVERADDR}\" Log</b> ( $i/$lec entries are displayed )<br><br>$log</html>";
  3693. # asyncOutput kann normalerweise etwa 100k uebertragen (siehe fhem.pl/addToWritebuffer() fuer Details)
  3694. # bzw. https://forum.fhem.de/index.php/topic,77310.0.html
  3695. # $log = "Too much log data were selected. Please reduce amount of data by specifying all or one of 'severity', 'limit', 'match'" if (length($log) >= 102400);
  3696. readingsBeginUpdate($hash);
  3697. readingsBulkUpdate($hash,"LastLogEntry",$log0) if(!$hash->{HELPER}{CL}{1}); # Datenabruf im Hintergrund;
  3698. readingsBulkUpdate($hash,"Errorcode","none");
  3699. readingsBulkUpdate($hash,"Error","none");
  3700. readingsEndUpdate($hash, 1);
  3701. # Ausgabe Popup der Log-Daten (nach readingsEndUpdate positionieren sonst "Connection lost, trying reconnect every 5 seconds" wenn > 102400 Zeichen)
  3702. asyncOutput($hash->{HELPER}{CL}{1},"$log");
  3703. delete($hash->{HELPER}{CL});
  3704. } elsif ($OpMode eq "getPresets") {
  3705. my %ap = ();
  3706. my $i = 0;
  3707. while ($data->{'data'}->{'preset'}->[$i]) {
  3708. my $pname = $data->{'data'}->{'preset'}->[$i]{'name'};
  3709. my $ptype = $data->{'data'}->{'preset'}->[$i]{'type'};
  3710. my $ppos = $data->{'data'}->{'preset'}->[$i]{'position'};
  3711. my $pspeed = $data->{'data'}->{'preset'}->[$i]{'speed'};
  3712. my $pextra = $data->{'data'}->{'preset'}->[$i]{'extra'};
  3713. $ptype = ($ptype == 1)?"Home":"Normal";
  3714. $ap{$ppos} = "Name: $pname, Speed: $pspeed, Type: $ptype";
  3715. $i++;
  3716. }
  3717. my $enum;
  3718. foreach my $key (sort{$a <=>$b}keys%ap) {
  3719. $enum .= $key." => ".$ap{$key}."<br>";
  3720. }
  3721. $enum = "<html><b>Preset positions saved of camera \"$hash->{CAMNAME}\" </b> ".
  3722. "(PresetNumber => Name: ..., Speed: ..., Type: ...) <br><br>$enum</html>";
  3723. # asyncOutput kann normalerweise etwa 100k uebertragen (siehe fhem.pl/addToWritebuffer() fuer Details)
  3724. # bzw. https://forum.fhem.de/index.php/topic,77310.0.html
  3725. readingsBeginUpdate($hash);
  3726. readingsBulkUpdate($hash,"Errorcode","none");
  3727. readingsBulkUpdate($hash,"Error","none");
  3728. readingsEndUpdate($hash, 1);
  3729. # Ausgabe Popup der Daten (nach readingsEndUpdate positionieren sonst
  3730. # "Connection lost, trying reconnect every 5 seconds" wenn > 102400 Zeichen)
  3731. asyncOutput($hash->{HELPER}{CL}{1},"$enum");
  3732. delete($hash->{HELPER}{CL});
  3733. } elsif ($OpMode eq "setPreset") {
  3734. readingsBeginUpdate($hash);
  3735. readingsBulkUpdate($hash,"Errorcode","none");
  3736. readingsBulkUpdate($hash,"Error","none");
  3737. readingsEndUpdate($hash, 1);
  3738. my $pnumber = delete($hash->{HELPER}{PNUMBER});
  3739. my $pname = delete($hash->{HELPER}{PNAME});
  3740. my $pspeed = delete($hash->{HELPER}{PSPEED});
  3741. $pspeed = $pspeed?$pspeed:"not set";
  3742. # Logausgabe
  3743. Log3($name, 3, "$name - Camera \"$camname\" preset \"$pname\" was saved to number $pnumber with speed $pspeed");
  3744. SSCam_getptzlistpreset($hash);
  3745. } elsif ($OpMode eq "delPreset") {
  3746. readingsBeginUpdate($hash);
  3747. readingsBulkUpdate($hash,"Errorcode","none");
  3748. readingsBulkUpdate($hash,"Error","none");
  3749. readingsEndUpdate($hash, 1);
  3750. my $dp = $hash->{HELPER}{DELPRESETNAME};
  3751. Log3($name, 3, "$name - Preset \"$dp\" of camera \"$camname\" was deleted successfully");
  3752. SSCam_getptzlistpreset($hash);
  3753. } elsif ($OpMode eq "piract") {
  3754. readingsBeginUpdate($hash);
  3755. readingsBulkUpdate($hash,"Errorcode","none");
  3756. readingsBulkUpdate($hash,"Error","none");
  3757. readingsEndUpdate($hash, 1);
  3758. # Logausgabe
  3759. my $piract = ($hash->{HELPER}{PIRACT} == 0)?"activated":"deactivated";
  3760. Log3($name, 3, "$name - PIR sensor $piract");
  3761. } elsif ($OpMode eq "setHome") {
  3762. readingsBeginUpdate($hash);
  3763. readingsBulkUpdate($hash,"Errorcode","none");
  3764. readingsBulkUpdate($hash,"Error","none");
  3765. readingsEndUpdate($hash, 1);
  3766. my $sh = $hash->{HELPER}{SETHOME};
  3767. Log3($name, 3, "$name - Preset \"$sh\" of camera \"$camname\" was set as Home position");
  3768. SSCam_getptzlistpreset($hash);
  3769. } elsif ($OpMode eq "setoptpar") {
  3770. my $rid = $data->{'data'}{'id'}; # Cam ID return wenn i.O.
  3771. my $ropt = $rid == $hash->{CAMID}?"none":"error in operation";
  3772. delete($hash->{HELPER}{NTPSERV});
  3773. delete($hash->{HELPER}{MIRROR});
  3774. delete($hash->{HELPER}{FLIP});
  3775. delete($hash->{HELPER}{ROTATE});
  3776. delete($hash->{HELPER}{CHKLIST});
  3777. readingsBeginUpdate($hash);
  3778. readingsBulkUpdate($hash,"Errorcode","none");
  3779. readingsBulkUpdate($hash,"Error",$ropt);
  3780. readingsEndUpdate($hash, 1);
  3781. # Token freigeben vor Abruf caminfo
  3782. $hash->{HELPER}{ACTIVE} = "off";
  3783. RemoveInternalTimer($hash, "SSCam_getcaminfo");
  3784. InternalTimer(gettimeofday()+0.5, "SSCam_getcaminfo", $hash, 0);
  3785. } elsif ($OpMode eq "MotDetSc") {
  3786. readingsBeginUpdate($hash);
  3787. readingsBulkUpdate($hash,"Errorcode","none");
  3788. readingsBulkUpdate($hash,"Error","none");
  3789. readingsEndUpdate($hash, 1);
  3790. # Logausgabe
  3791. my $sensitivity;
  3792. if ($hash->{HELPER}{MOTDETSC} eq "SVS" && keys %{$hash->{HELPER}{MOTDETOPTIONS}}) {
  3793. # Optionen für "SVS" sind gesetzt
  3794. $sensitivity = ($hash->{HELPER}{MOTDETOPTIONS}{SENSITIVITY}) ? ($hash->{HELPER}{MOTDETOPTIONS}{SENSITIVITY}) : "-";
  3795. my $threshold = ($hash->{HELPER}{MOTDETOPTIONS}{THRESHOLD}) ? ($hash->{HELPER}{MOTDETOPTIONS}{THRESHOLD}) : "-";
  3796. Log3($name, 3, "$name - Camera $camname motion detection source set to \"$hash->{HELPER}{MOTDETSC}\" with options sensitivity: $sensitivity, threshold: $threshold");
  3797. } elsif ($hash->{HELPER}{MOTDETSC} eq "camera" && keys %{$hash->{HELPER}{MOTDETOPTIONS}}) {
  3798. # Optionen für "camera" sind gesetzt
  3799. $sensitivity = ($hash->{HELPER}{MOTDETOPTIONS}{SENSITIVITY}) ? ($hash->{HELPER}{MOTDETOPTIONS}{SENSITIVITY}) : "-";
  3800. my $objectSize = ($hash->{HELPER}{MOTDETOPTIONS}{OBJECTSIZE}) ? ($hash->{HELPER}{MOTDETOPTIONS}{OBJECTSIZE}) : "-";
  3801. my $percentage = ($hash->{HELPER}{MOTDETOPTIONS}{PERCENTAGE}) ? ($hash->{HELPER}{MOTDETOPTIONS}{PERCENTAGE}) : "-";
  3802. Log3($name, 3, "$name - Camera $camname motion detection source set to \"$hash->{HELPER}{MOTDETSC}\" with options sensitivity: $sensitivity, objectSize: $objectSize, percentage: $percentage");
  3803. } else {
  3804. # keine Optionen Bewegungserkennung wurden gesetzt
  3805. Log3($name, 3, "$name - Camera $camname motion detection source set to \"$hash->{HELPER}{MOTDETSC}\" ");
  3806. }
  3807. } elsif ($OpMode eq "Snap") {
  3808. # ein Schnapschuß wurde aufgenommen
  3809. # falls Aufnahme noch läuft -> state = on setzen
  3810. SSCam_refresh($hash,0,0,0); # kein Room-Refresh, kein SSCam-state-Event, kein SSCamSTRM-Event
  3811. $snapid = $data->{data}{'id'};
  3812. readingsBeginUpdate($hash);
  3813. readingsBulkUpdate($hash,"Errorcode","none");
  3814. readingsBulkUpdate($hash,"Error","none");
  3815. readingsEndUpdate($hash, 1);
  3816. # Logausgabe
  3817. Log3($name, 3, "$name - Snapshot of Camera $camname has been done successfully");
  3818. # Token freigeben vor nächstem Kommando
  3819. $hash->{HELPER}{ACTIVE} = "off";
  3820. # Schnappschußgalerie abrufen (snapGalleryBoost) oder nur Info des letzten Snaps
  3821. my ($slim,$ssize) = SSCam_snaplimsize($hash);
  3822. RemoveInternalTimer("SSCam_getsnapinfo");
  3823. InternalTimer(gettimeofday()+0.6, "SSCam_getsnapinfo", "$name:$slim:$ssize", 0);
  3824. } elsif ($OpMode eq "getsnapinfo" || $OpMode eq "getsnapgallery" || ($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} =~ /snap/)) {
  3825. # Informationen zu einem oder mehreren Schnapschüssen wurde abgerufen bzw. Lifeanzeige Schappschuß
  3826. my $lsid = exists($data->{data}{data}[0]{id})?$data->{data}{data}[0]{id}:"n.a.";
  3827. my $lfname = exists($data->{data}{data}[0]{fileName})?$data->{data}{data}[0]{fileName}:"n.a.";
  3828. my $lstime;
  3829. if(exists($data->{data}{data}[0]{createdTm})) {
  3830. $lstime = $data->{data}{data}[0]{createdTm};
  3831. my @t = split(" ", FmtDateTime($lstime));
  3832. my @d = split("-", $t[0]);
  3833. $lstime = "$d[2].$d[1].$d[0] / $t[1]";
  3834. } else {
  3835. $lstime = "n.a.";
  3836. }
  3837. Log3($name,4, "$name - Snap [0]: ID => $lsid, File => $lfname, Created => $lstime");
  3838. readingsBeginUpdate($hash);
  3839. readingsBulkUpdate($hash,"Errorcode","none");
  3840. readingsBulkUpdate($hash,"Error","none");
  3841. readingsBulkUpdate($hash,"LastSnapId",$lsid);
  3842. readingsBulkUpdate($hash,"LastSnapFilename", $lfname);
  3843. readingsBulkUpdate($hash,"LastSnapTime", $lstime);
  3844. readingsEndUpdate($hash, 1);
  3845. # Schnapschuss soll als liveView angezeigt werden (mindestens 1 Bild vorhanden)
  3846. Log3($name, 3, "$name - There is no snapshot of camera $camname to display ! Take one snapshot before.")
  3847. if(exists($hash->{HELPER}{RUNVIEW}) && $hash->{HELPER}{RUNVIEW} =~ /snap/ && !exists($data->{'data'}{'data'}[0]{imageData}));
  3848. if (exists($hash->{HELPER}{RUNVIEW}) && $hash->{HELPER}{RUNVIEW} =~ /snap/ && exists($data->{'data'}{'data'}[0]{imageData})) {
  3849. delete $hash->{HELPER}{RUNVIEW};
  3850. $hash->{HELPER}{LINK} = $data->{data}{data}[0]{imageData};
  3851. }
  3852. if($OpMode eq "getsnapgallery") {
  3853. # es soll eine Schnappschußgallerie bereitgestellt (Attr snapGalleryBoost=1) bzw. gleich angezeigt werden (Attr snapGalleryBoost=0)
  3854. my $i = 0;
  3855. my $sn = 0;
  3856. my %allsnaps = (); # Schnappschuss Hash wird leer erstellt
  3857. $hash->{HELPER}{TOTALCNT} = $data->{data}{total}; # total Anzahl Schnappschüsse
  3858. while ($data->{'data'}{'data'}[$i]) {
  3859. if($data->{'data'}{'data'}[$i]{'camName'} ne $camname) {
  3860. $i += 1;
  3861. next;
  3862. }
  3863. $snapid = $data->{data}{data}[$i]{id};
  3864. my $createdTm = $data->{data}{data}[$i]{createdTm};
  3865. my $fileName = $data->{data}{data}[$i]{fileName};
  3866. my $imageData = $data->{data}{data}[$i]{imageData}; # Image data of snapshot in base64 format
  3867. $allsnaps{$sn}{snapid} = $snapid;
  3868. my @t = split(" ", FmtDateTime($createdTm));
  3869. my @d = split("-", $t[0]);
  3870. $createdTm = "$d[2].$d[1].$d[0] / $t[1]";
  3871. $allsnaps{$sn}{createdTm} = $createdTm;
  3872. $allsnaps{$sn}{fileName} = $fileName;
  3873. $allsnaps{$sn}{imageData} = $imageData;
  3874. Log3($name,4, "$name - Snap '$sn' added to gallery hash: ID => $allsnaps{$sn}{snapid}, File => $allsnaps{$sn}{fileName}, Created => $allsnaps{$sn}{createdTm}");
  3875. $sn += 1;
  3876. $i += 1;
  3877. }
  3878. # Hash der Schnapschüsse erstellen
  3879. $hash->{HELPER}{".SNAPHASH"} = \%allsnaps;
  3880. # Direktausgabe Snaphash wenn nicht gepollt wird
  3881. if(!AttrVal($name, "snapGalleryBoost",0)) {
  3882. my $htmlCode = SSCam_composegallery($name);
  3883. for (my $k=1; (defined($hash->{HELPER}{CL}{$k})); $k++ ) {
  3884. asyncOutput($hash->{HELPER}{CL}{$k},"$htmlCode");
  3885. }
  3886. delete($hash->{HELPER}{".SNAPHASH"}); # Snaphash löschen wenn nicht gepollt wird
  3887. delete($hash->{HELPER}{CL});
  3888. }
  3889. delete($hash->{HELPER}{GETSNAPGALLERY}); # Steuerbit getsnapgallery statt getsnapinfo
  3890. }
  3891. if ($hash->{HELPER}{SNAPBYSTRMDEV} || $hash->{HELPER}{LSNAPBYSTRMDEV}) {
  3892. # Snap durch SSCamSTRM-Device ausgelöst
  3893. SSCam_refresh($hash,0,0,1); # kein Room-Refresh, kein SSCam-state-Event, SSCamSTRM-Event
  3894. delete $hash->{HELPER}{SNAPBYSTRMDEV};
  3895. delete $hash->{HELPER}{LSNAPBYSTRMDEV};
  3896. } elsif ($hash->{HELPER}{LSNAPBYDEV}) {
  3897. SSCam_refresh($hash,0,1,0); # kein Room-Refresh, SSCam-state-Event, kein SSCamSTRM-Event
  3898. delete $hash->{HELPER}{LSNAPBYDEV};
  3899. } else {
  3900. SSCam_refresh($hash,0,0,0); # kein Room-Refresh, SSCam-state-Event, SSCamSTRM-Event
  3901. }
  3902. Log3($name, $verbose, "$name - Snapinfos of camera $camname retrieved");
  3903. } elsif ($OpMode eq "runliveview" && $hash->{HELPER}{RUNVIEW} =~ m/^live_.*hls$/) {
  3904. # HLS Streaming wurde aktiviert
  3905. $hash->{HELPER}{HLSSTREAM} = "active";
  3906. # externe LivestreamURL setzen
  3907. my $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport");
  3908. $exturl .= "/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=hls&_sid=$sid";
  3909. readingsSingleUpdate($hash,"LiveStreamUrl", $exturl, 1) if(AttrVal($name, "showStmInfoFull", undef));
  3910. my $url = "$proto://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=hls&_sid=$sid";
  3911. # Liveview-Link in Hash speichern und Aktivitätsstatus speichern
  3912. $hash->{HELPER}{LINK} = $url;
  3913. Log3($name, 4, "$name - HLS Streaming of camera \"$name\" activated, Streaming-URL: $url") if(AttrVal($name,"verbose",3) == 4);
  3914. Log3($name, 3, "$name - HLS Streaming of camera \"$name\" activated") if(AttrVal($name,"verbose",3) == 3);
  3915. SSCam_refresh($hash,0,1,1); # kein Room-Refresh, SSCam-state-Event, SSCamSTRM-Event
  3916. } elsif ($OpMode eq "stopliveview_hls") {
  3917. # HLS Streaming wurde deaktiviert, Aktivitätsstatus speichern
  3918. $hash->{HELPER}{HLSSTREAM} = "inactive";
  3919. Log3($name, 3, "$name - HLS Streaming of camera \"$name\" deactivated");
  3920. SSCam_refresh($hash,0,1,1); # kein Room-Refresh, SSCam-state-Event, SSCamSTRM-Event
  3921. } elsif ($OpMode eq "reactivate_hls") {
  3922. # HLS Streaming wurde deaktiviert, Aktivitätsstatus speichern
  3923. $hash->{HELPER}{HLSSTREAM} = "inactive";
  3924. Log3($name, 4, "$name - HLS Streaming of camera \"$name\" deactivated for streaming device");
  3925. # Token freigeben vor hlsactivate
  3926. $hash->{HELPER}{ACTIVE} = "off";
  3927. SSCam_hlsactivate($hash);
  3928. } elsif ($OpMode eq "activate_hls") {
  3929. # HLS Streaming wurde aktiviert, Aktivitätsstatus speichern
  3930. $hash->{HELPER}{HLSSTREAM} = "active";
  3931. Log3($name, 4, "$name - HLS Streaming of camera \"$name\" activated for streaming device");
  3932. SSCam_refresh($hash,0,1,1); # kein Room-Refresh, SSCam-state-Event, SSCamSTRM-Event
  3933. } elsif ($OpMode eq "getsnapfilename") {
  3934. # den Filenamen eines Schnapschusses ermitteln
  3935. $snapid = ReadingsVal("$name", "LastSnapId", " ");
  3936. readingsBeginUpdate($hash);
  3937. readingsBulkUpdate($hash,"Errorcode","none");
  3938. readingsBulkUpdate($hash,"Error","none");
  3939. readingsBulkUpdate($hash,"LastSnapFilename", $data->{'data'}{'data'}[0]{'fileName'});
  3940. readingsEndUpdate($hash, 1);
  3941. # Logausgabe
  3942. Log3($name, 4, "$name - Filename of Snap-ID $snapid is \"$data->{'data'}{'data'}[0]{'fileName'}\"") if($data->{'data'}{'data'}[0]{'fileName'});
  3943. } elsif ($OpMode eq "getstreamformat") {
  3944. # aktuelles Streamformat abgefragt
  3945. my $sformat = SSCam_jboolmap($data->{'data'}->{'format'});
  3946. readingsBeginUpdate($hash);
  3947. readingsBulkUpdate($hash,"Errorcode","none");
  3948. readingsBulkUpdate($hash,"Error","none");
  3949. readingsBulkUpdate($hash,"CamStreamFormat", uc($sformat)) if($sformat);
  3950. readingsEndUpdate($hash, 1);
  3951. } elsif ($OpMode eq "gopreset") {
  3952. # eine Presetposition wurde angefahren
  3953. # falls Aufnahme noch läuft -> state = on setzen
  3954. my $st = (ReadingsVal("$name", "Record", "Stop") eq "Start")?"on":"off";
  3955. readingsSingleUpdate($hash,"state", $st, 0);
  3956. DoTrigger($name,"move stop");
  3957. readingsBeginUpdate($hash);
  3958. readingsBulkUpdate($hash,"Errorcode","none");
  3959. readingsBulkUpdate($hash,"Error","none");
  3960. readingsEndUpdate($hash, 1);
  3961. # Logausgabe
  3962. Log3($name, 3, "$name - Camera $camname has been moved to position \"$hash->{HELPER}{GOPRESETNAME}\"");
  3963. } elsif ($OpMode eq "runpatrol") {
  3964. # eine Tour wurde gestartet
  3965. # falls Aufnahme noch läuft -> state = on setzen
  3966. my $st = (ReadingsVal("$name", "Record", "Stop") eq "Start")?"on":"off";
  3967. readingsSingleUpdate($hash,"state", $st, 0);
  3968. DoTrigger($name,"patrol started");
  3969. readingsBeginUpdate($hash);
  3970. readingsBulkUpdate($hash,"Errorcode","none");
  3971. readingsBulkUpdate($hash,"Error","none");
  3972. readingsEndUpdate($hash, 1);
  3973. # Logausgabe
  3974. Log3($name, 3, "$name - Patrol \"$hash->{HELPER}{GOPATROLNAME}\" of camera $camname has been started successfully");
  3975. } elsif ($OpMode eq "goabsptz") {
  3976. # eine absolute PTZ-Position wurde angefahren
  3977. # falls Aufnahme noch läuft -> state = on setzen
  3978. my $st = (ReadingsVal("$name", "Record", "Stop") eq "Start")?"on":"off";
  3979. readingsSingleUpdate($hash,"state", $st, 0);
  3980. DoTrigger($name,"move stop");
  3981. readingsBeginUpdate($hash);
  3982. readingsBulkUpdate($hash,"Errorcode","none");
  3983. readingsBulkUpdate($hash,"Error","none");
  3984. readingsEndUpdate($hash, 1);
  3985. # Logausgabe
  3986. Log3($name, 3, "$name - Camera $camname has been moved to absolute position \"posX=$hash->{HELPER}{GOPTZPOSX}\" and \"posY=$hash->{HELPER}{GOPTZPOSY}\"");
  3987. } elsif ($OpMode eq "startTrack") {
  3988. # Object Tracking wurde eingeschaltet
  3989. readingsBeginUpdate($hash);
  3990. readingsBulkUpdate($hash,"Errorcode","none");
  3991. readingsBulkUpdate($hash,"Error","none");
  3992. readingsEndUpdate($hash, 1);
  3993. # Logausgabe
  3994. Log3($name, 3, "$name - Object tracking of Camera $camname has been switched on");
  3995. } elsif ($OpMode eq "stopTrack") {
  3996. # Object Tracking wurde eingeschaltet
  3997. readingsBeginUpdate($hash);
  3998. readingsBulkUpdate($hash,"Errorcode","none");
  3999. readingsBulkUpdate($hash,"Error","none");
  4000. readingsEndUpdate($hash, 1);
  4001. # Logausgabe
  4002. Log3($name, 3, "$name - Object tracking of Camera $camname has been stopped");
  4003. } elsif ($OpMode eq "movestart") {
  4004. # ein "Move" in eine bestimmte Richtung wird durchgeführt
  4005. readingsBeginUpdate($hash);
  4006. readingsBulkUpdate($hash,"Errorcode","none");
  4007. readingsBulkUpdate($hash,"Error","none");
  4008. readingsEndUpdate($hash, 1);
  4009. # Logausgabe
  4010. Log3($name, 3, "$name - Camera $camname started move to direction \"$hash->{HELPER}{GOMOVEDIR}\" with duration of $hash->{HELPER}{GOMOVETIME} s");
  4011. RemoveInternalTimer($hash, "SSCam_movestop");
  4012. InternalTimer(gettimeofday()+($hash->{HELPER}{GOMOVETIME}), "SSCam_movestop", $hash);
  4013. } elsif ($OpMode eq "movestop") {
  4014. # ein "Move" in eine bestimmte Richtung wurde durchgeführt
  4015. # falls Aufnahme noch läuft -> state = on setzen
  4016. my $st = (ReadingsVal("$name", "Record", "Stop") eq "Start")?"on":"off";
  4017. readingsSingleUpdate($hash,"state", $st, 0);
  4018. DoTrigger($name,"move stop");
  4019. readingsBeginUpdate($hash);
  4020. readingsBulkUpdate($hash,"Errorcode","none");
  4021. readingsBulkUpdate($hash,"Error","none");
  4022. readingsEndUpdate($hash, 1);
  4023. Log3($name, 3, "$name - Camera $camname stopped move to direction \"$hash->{HELPER}{GOMOVEDIR}\"");
  4024. } elsif ($OpMode eq "Enable") {
  4025. # Kamera wurde aktiviert, sonst kann nichts laufen -> "off"
  4026. readingsBeginUpdate($hash);
  4027. readingsBulkUpdate($hash,"Availability","enabled");
  4028. readingsBulkUpdate($hash,"state","off");
  4029. readingsBulkUpdate($hash,"Errorcode","none");
  4030. readingsBulkUpdate($hash,"Error","none");
  4031. readingsEndUpdate($hash, 1);
  4032. # Logausgabe
  4033. Log3($name, 3, "$name - Camera $camname has been enabled successfully");
  4034. } elsif ($OpMode eq "Disable") {
  4035. # Kamera wurde deaktiviert
  4036. readingsBeginUpdate($hash);
  4037. readingsBulkUpdate($hash,"Availability","disabled");
  4038. readingsBulkUpdate($hash,"state","disabled");
  4039. readingsBulkUpdate($hash,"Errorcode","none");
  4040. readingsBulkUpdate($hash,"Error","none");
  4041. readingsEndUpdate($hash, 1);
  4042. # Logausgabe
  4043. Log3($name, 3, "$name - Camera $camname has been disabled successfully");
  4044. } elsif ($OpMode eq "getsvsinfo") {
  4045. # Parse SVS-Infos
  4046. $userPriv = $data->{'data'}{'userPriv'};
  4047. if (defined($userPriv)) {
  4048. if ($userPriv eq "0") {
  4049. $userPriv = "No Access";
  4050. } elsif ($userPriv eq "1") {
  4051. $userPriv = "Admin";
  4052. } elsif ($userPriv eq "2") {
  4053. $userPriv = "Manager";
  4054. } elsif ($userPriv eq "4") {
  4055. $userPriv = "Viewer";
  4056. }
  4057. }
  4058. # "my" nicht am Anfang deklarieren, sonst wird Hash %version wieder geleert !
  4059. my %version = (
  4060. MAJOR => $data->{'data'}{'version'}{'major'},
  4061. MINOR => $data->{'data'}{'version'}{'minor'},
  4062. SMALL => $data->{'data'}{'version'}{'small'},
  4063. BUILD => $data->{'data'}{'version'}{'build'}
  4064. );
  4065. # Werte in $hash zur späteren Auswertung einfügen
  4066. $hash->{HELPER}{SVSVERSION} = \%version;
  4067. my $major = $version{"MAJOR"};
  4068. my $minor = $version{"MINOR"};
  4069. my $small = $version{"SMALL"};
  4070. my $build = $version{"BUILD"};
  4071. # simulieren einer anderen SVS-Version
  4072. if (AttrVal($name, "simu_SVSversion", undef)) {
  4073. Log3($name, 4, "$name - another SVS-version ".AttrVal($name, "simu_SVSversion", undef)." will be simulated");
  4074. #delete $version{"SMALL"} if ($version{"SMALL"});
  4075. my @vl = split (/\.|-/,AttrVal($name, "simu_SVSversion", ""));
  4076. $major = $vl[0];
  4077. $minor = $vl[1];
  4078. $small = ($vl[2] =~ /\d/)?$vl[2]:'';
  4079. $build = "xxxx-simu";
  4080. }
  4081. # Kompatibilitätscheck
  4082. my $avsc = $major.$minor.(($small=~/\d/)?$small:0);
  4083. my $avcomp = $hash->{COMPATIBILITY};
  4084. $avcomp =~ s/\.//g;
  4085. my $compstate;
  4086. if($avsc <= $avcomp) {
  4087. $compstate = "true";
  4088. } else {
  4089. $compstate = "false";
  4090. }
  4091. readingsSingleUpdate($hash, "compstate", $compstate, 1);
  4092. if (!exists($data->{'data'}{'customizedPortHttp'})) {
  4093. delete $defs{$name}{READINGS}{SVScustomPortHttp};
  4094. }
  4095. if (!exists($data->{'data'}{'customizedPortHttps'})) {
  4096. delete $defs{$name}{READINGS}{SVScustomPortHttps};
  4097. }
  4098. readingsBeginUpdate($hash);
  4099. readingsBulkUpdate($hash,"SVScustomPortHttp",$data->{'data'}{'customizedPortHttp'});
  4100. readingsBulkUpdate($hash,"SVScustomPortHttps",$data->{'data'}{'customizedPortHttps'});
  4101. readingsBulkUpdate($hash,"SVSlicenseNumber",$data->{'data'}{'liscenseNumber'});
  4102. readingsBulkUpdate($hash,"SVSuserPriv",$userPriv);
  4103. if(defined($small)) {
  4104. readingsBulkUpdate($hash,"SVSversion",$major.".".$minor.".".$small."-".$build);
  4105. } else {
  4106. readingsBulkUpdate($hash,"SVSversion",$major.".".$minor."-".$build);
  4107. }
  4108. readingsBulkUpdate($hash,"Errorcode","none");
  4109. readingsBulkUpdate($hash,"Error","none");
  4110. readingsEndUpdate($hash, 1);
  4111. Log3($name, $verbose, "$name - Informations related to Surveillance Station retrieved");
  4112. } elsif ($OpMode eq "getStmUrlPath") {
  4113. # Parse SVS-Infos
  4114. my($camforcemcast,$mjpegHttp,$multicst,$mxpegHttp,$unicastOverHttp,$unicastPath);
  4115. if($apicammaxver < 9) {
  4116. $camforcemcast = SSCam_jboolmap($data->{'data'}{'pathInfos'}[0]{'forceEnableMulticast'});
  4117. $mjpegHttp = $data->{'data'}{'pathInfos'}[0]{'mjpegHttpPath'};
  4118. $multicst = $data->{'data'}{'pathInfos'}[0]{'multicstPath'};
  4119. $mxpegHttp = $data->{'data'}{'pathInfos'}[0]{'mxpegHttpPath'};
  4120. $unicastOverHttp = $data->{'data'}{'pathInfos'}[0]{'unicastOverHttpPath'};
  4121. $unicastPath = $data->{'data'}{'pathInfos'}[0]{'unicastPath'};
  4122. }
  4123. if($apicammaxver >= 9) {
  4124. $mjpegHttp = $data->{'data'}[0]{'mjpegHttpPath'};
  4125. $multicst = $data->{'data'}[0]{'multicstPath'};
  4126. $mxpegHttp = $data->{'data'}[0]{'mxpegHttpPath'};
  4127. $unicastOverHttp = $data->{'data'}[0]{'rtspOverHttpPath'};
  4128. $unicastPath = $data->{'data'}[0]{'rtspPath'};
  4129. }
  4130. # Rewrite Url's falls livestreamprefix ist gesetzt
  4131. if (AttrVal($name, "livestreamprefix", undef)) {
  4132. my $exturl = AttrVal($name, "livestreamprefix", "$proto://$serveraddr:$serverport");
  4133. $exturl = ($exturl eq "DEF")?"$proto://$serveraddr:$serverport":$exturl;
  4134. my @mjh = split(/\//, $mjpegHttp, 4);
  4135. $mjpegHttp = $exturl."/".$mjh[3];
  4136. my @mxh = split(/\//, $mxpegHttp, 4);
  4137. $mxpegHttp = $exturl."/".$mxh[3];
  4138. if($unicastPath) {
  4139. my @ucp = split(/[@\|:]/, $unicastPath);
  4140. my @lspf = split(/[\/\/\|:]/, AttrVal($name, "livestreamprefix", undef));
  4141. $unicastPath = $ucp[0].":".$ucp[1].":".$ucp[2]."@".$lspf[3].":".$ucp[4];
  4142. }
  4143. }
  4144. # StmKey extrahieren
  4145. my @sk = split(/&StmKey=/, $mjpegHttp);
  4146. my $stmkey = $sk[1];
  4147. $stmkey =~ tr/"//d;
  4148. # Quotes in StmKey entfernen falls noQuotesForSID gesezt
  4149. $mjpegHttp =~ tr/"//d if(AttrVal($name, "noQuotesForSID",0));
  4150. # Readings löschen falls sie nicht angezeigt werden sollen (showStmInfoFull)
  4151. #if (!AttrVal($name,"showStmInfoFull",0)) {
  4152. # delete($defs{$name}{READINGS}{StmKeymjpegHttp});
  4153. #delete($defs{$name}{READINGS}{StmKeyUnicstOverHttp});
  4154. #}
  4155. # Streaminginfos in Helper speichern
  4156. $hash->{HELPER}{STMKEYMJPEGHTTP} = $mjpegHttp if($mjpegHttp);
  4157. $hash->{HELPER}{STMKEYMXPEGHTTP} = $mxpegHttp if($mxpegHttp);
  4158. $hash->{HELPER}{STMKEYUNICSTOVERHTTP} = $unicastOverHttp if($unicastOverHttp);
  4159. $hash->{HELPER}{STMKEYUNICST} = $unicastPath if($unicastPath);
  4160. readingsBeginUpdate($hash);
  4161. readingsBulkUpdate($hash,"CamForceEnableMulticast",$camforcemcast) if($camforcemcast);
  4162. readingsBulkUpdate($hash,"StmKey",$stmkey);
  4163. readingsBulkUpdate($hash,"StmKeymjpegHttp",$mjpegHttp) if(AttrVal($name,"showStmInfoFull",0));
  4164. readingsBulkUpdate($hash,"StmKeymxpegHttp",$mxpegHttp) if(AttrVal($name,"showStmInfoFull",0));
  4165. readingsBulkUpdate($hash,"StmKeyUnicstOverHttp",$unicastOverHttp) if(AttrVal($name,"showStmInfoFull",0) && $unicastOverHttp);
  4166. readingsBulkUpdate($hash,"StmKeyUnicst",$unicastPath) if(AttrVal($name,"showStmInfoFull",0) && $unicastPath);
  4167. readingsBulkUpdate($hash,"Errorcode","none");
  4168. readingsBulkUpdate($hash,"Error","none");
  4169. readingsEndUpdate($hash, 1);
  4170. # Logausgabe
  4171. Log3($name, $verbose, "$name - Stream-URLs of camera $camname retrieved");
  4172. } elsif ($OpMode eq "Getcaminfo") {
  4173. # Parse Caminfos
  4174. $camLiveMode = $data->{'data'}->{'cameras'}->[0]->{'camLiveMode'};
  4175. if ($camLiveMode eq "0") {$camLiveMode = "Liveview from DS";}elsif ($camLiveMode eq "1") {$camLiveMode = "Liveview from Camera";}
  4176. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;
  4177. $update_time = sprintf "%02d.%02d.%04d / %02d:%02d:%02d" , $mday , $mon+=1 ,$year+=1900 , $hour , $min , $sec ;
  4178. $deviceType = $data->{'data'}->{'cameras'}->[0]->{'deviceType'};
  4179. if ($deviceType eq "1") {
  4180. $deviceType = "Camera";
  4181. } elsif ($deviceType eq "2") {
  4182. $deviceType = "Video_Server";
  4183. } elsif ($deviceType eq "4") {
  4184. $deviceType = "PTZ";
  4185. } elsif ($deviceType eq "8") {
  4186. $deviceType = "Fisheye";
  4187. }
  4188. $camStatus = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'camStatus'});
  4189. if ($camStatus eq "1") {
  4190. $camStatus = "enabled";
  4191. # falls Aufnahme noch läuft -> STATE = on setzen
  4192. if (ReadingsVal("$name", "Record", "Stop") eq "Start") {
  4193. readingsSingleUpdate($hash,"state", "on", 0);
  4194. } else {
  4195. readingsSingleUpdate($hash,"state", "off", 0);
  4196. }
  4197. } elsif ($camStatus eq "3") {
  4198. $camStatus = "disconnected";
  4199. readingsSingleUpdate($hash,"state", "disconnected", 0);
  4200. } elsif ($camStatus eq "7") {
  4201. $camStatus = "disabled";
  4202. readingsSingleUpdate($hash,"state", "disabled", 0);
  4203. } else {
  4204. $camStatus = "other";
  4205. }
  4206. $recStatus = $data->{'data'}->{'cameras'}->[0]->{'recStatus'};
  4207. if ($recStatus ne "0") {
  4208. $recStatus = "Start";
  4209. } else {
  4210. $recStatus = "Stop";
  4211. }
  4212. my $rotate = $data->{'data'}->{'cameras'}->[0]->{'video_rotation'};
  4213. $rotate = $rotate == 1?"true":"false";
  4214. $exposuremode = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'exposure_mode'});
  4215. if ($exposuremode == 0) {
  4216. $exposuremode = "Auto";
  4217. } elsif ($exposuremode == 1) {
  4218. $exposuremode = "Day";
  4219. } elsif ($exposuremode == 2) {
  4220. $exposuremode = "Night";
  4221. } elsif ($exposuremode == 3) {
  4222. $exposuremode = "Schedule";
  4223. } elsif ($exposuremode == 4) {
  4224. $exposuremode = "Unknown";
  4225. }
  4226. $exposurecontrol = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'exposure_control'});
  4227. if ($exposurecontrol == 0) {
  4228. $exposurecontrol = "Auto";
  4229. } elsif ($exposurecontrol == 1) {
  4230. $exposurecontrol = "50HZ";
  4231. } elsif ($exposurecontrol == 2) {
  4232. $exposurecontrol = "60HZ";
  4233. } elsif ($exposurecontrol == 3) {
  4234. $exposurecontrol = "Hold";
  4235. } elsif ($exposurecontrol == 4) {
  4236. $exposurecontrol = "Outdoor";
  4237. } elsif ($exposurecontrol == 5) {
  4238. $exposurecontrol = "None";
  4239. } elsif ($exposurecontrol == 6) {
  4240. $exposurecontrol = "Unknown";
  4241. }
  4242. my $camaudiotype = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camAudioType'});
  4243. if ($camaudiotype == 0) {
  4244. $camaudiotype = "Unknown";
  4245. } elsif ($camaudiotype == 1) {
  4246. $camaudiotype = "PCM";
  4247. } elsif ($camaudiotype == 2) {
  4248. $camaudiotype = "G711";
  4249. } elsif ($camaudiotype == 3) {
  4250. $camaudiotype = "G726";
  4251. } elsif ($camaudiotype == 4) {
  4252. $camaudiotype = "AAC";
  4253. } elsif ($camaudiotype == 5) {
  4254. $camaudiotype = "AMR";
  4255. }
  4256. my $pdcap = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'PDCap'});
  4257. if (!$pdcap || $pdcap == 0) {
  4258. $pdcap = "false";
  4259. } else {
  4260. $pdcap = "true";
  4261. }
  4262. $data->{'data'}->{'cameras'}->[0]->{'video_flip'} = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'video_flip'});
  4263. $data->{'data'}->{'cameras'}->[0]->{'video_mirror'} = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'video_mirror'});
  4264. $data->{'data'}->{'cameras'}->[0]->{'blPresetSpeed'} = SSCam_jboolmap($data->{'data'}->{'cameras'}->[0]->{'blPresetSpeed'});
  4265. my $clstrmno = $data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camLiveStreamNo'};
  4266. $clstrmno++ if($clstrmno == 0);
  4267. my $fw = $data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camFirmware'};
  4268. readingsBeginUpdate($hash);
  4269. readingsBulkUpdate($hash,"CamAudioType",$camaudiotype);
  4270. readingsBulkUpdate($hash,"CamFirmware",$fw) if($fw);
  4271. readingsBulkUpdate($hash,"CamLiveMode",$camLiveMode);
  4272. readingsBulkUpdate($hash,"CamLiveFps",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camLiveFps'});
  4273. readingsBulkUpdate($hash,"CamLiveResolution",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camLiveResolution'});
  4274. readingsBulkUpdate($hash,"CamLiveQuality",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camLiveQuality'});
  4275. readingsBulkUpdate($hash,"CamLiveStreamNo",$clstrmno);
  4276. readingsBulkUpdate($hash,"CamExposureMode",$exposuremode);
  4277. readingsBulkUpdate($hash,"CamExposureControl",$exposurecontrol);
  4278. readingsBulkUpdate($hash,"CamModel",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camModel'});
  4279. readingsBulkUpdate($hash,"CamRecShare",$data->{'data'}->{'cameras'}->[0]->{'camRecShare'});
  4280. readingsBulkUpdate($hash,"CamRecVolume",$data->{'data'}->{'cameras'}->[0]->{'camRecVolume'});
  4281. readingsBulkUpdate($hash,"CamIP",$data->{'data'}->{'cameras'}->[0]->{'host'});
  4282. readingsBulkUpdate($hash,"CamNTPServer",$data->{'data'}->{'cameras'}->[0]->{'time_server'}) if($data->{'data'}->{'cameras'}->[0]->{'time_server'});
  4283. readingsBulkUpdate($hash,"CamVendor",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camVendor'});
  4284. readingsBulkUpdate($hash,"CamVideoType",$data->{'data'}->{'cameras'}->[0]->{'camVideoType'});
  4285. readingsBulkUpdate($hash,"CamPreRecTime",$data->{'data'}->{'cameras'}->[0]->{'detailInfo'}{'camPreRecTime'});
  4286. readingsBulkUpdate($hash,"CamPort",$data->{'data'}->{'cameras'}->[0]->{'port'});
  4287. readingsBulkUpdate($hash,"CamPtSpeed",$data->{'data'}->{'cameras'}->[0]->{'ptSpeed'}) if($deviceType =~ /PTZ/);
  4288. readingsBulkUpdate($hash,"CamblPresetSpeed",$data->{'data'}->{'cameras'}->[0]->{'blPresetSpeed'});
  4289. readingsBulkUpdate($hash,"CamVideoMirror",$data->{'data'}->{'cameras'}->[0]->{'video_mirror'});
  4290. readingsBulkUpdate($hash,"CamVideoFlip",$data->{'data'}->{'cameras'}->[0]->{'video_flip'});
  4291. readingsBulkUpdate($hash,"CamVideoRotate",$rotate);
  4292. readingsBulkUpdate($hash,"CapPIR",$pdcap);
  4293. readingsBulkUpdate($hash,"Availability",$camStatus);
  4294. readingsBulkUpdate($hash,"DeviceType",$deviceType);
  4295. readingsBulkUpdate($hash,"LastUpdateTime",$update_time);
  4296. readingsBulkUpdate($hash,"Record",$recStatus);
  4297. readingsBulkUpdate($hash,"UsedSpaceMB",$data->{'data'}->{'cameras'}->[0]->{'volume_space'});
  4298. readingsBulkUpdate($hash,"VideoFolder",AttrVal($name, "videofolderMap", undef) ? AttrVal($name, "videofolderMap", undef) : $data->{'data'}->{'cameras'}->[0]->{'folder'});
  4299. readingsBulkUpdate($hash,"Errorcode","none");
  4300. readingsBulkUpdate($hash,"Error","none");
  4301. readingsEndUpdate($hash, 1);
  4302. $hash->{MODEL} = ReadingsVal($name,"CamVendor","")." - ".ReadingsVal($name,"CamModel","CAM") if(SSCam_IsModelCam($hash));
  4303. Log3($name, $verbose, "$name - Informations of camera $camname retrieved");
  4304. } elsif ($OpMode eq "geteventlist") {
  4305. my $eventnum = $data->{'data'}{'total'};
  4306. my $lastrecord = $data->{'data'}{'events'}[0]{name};
  4307. $hash->{HELPER}{CAMLASTRECID} = $data->{'data'}{'events'}[0]{'eventId'};
  4308. my ($lastrecstarttime,$lastrecstoptime);
  4309. if ($eventnum > 0) {
  4310. $lastrecstarttime = $data->{'data'}{'events'}[0]{startTime};
  4311. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($lastrecstarttime);
  4312. $lastrecstarttime = sprintf "%02d.%02d.%04d / %02d:%02d:%02d" , $mday , $mon+=1 ,$year+=1900 , $hour , $min , $sec ;
  4313. $lastrecstoptime = $data->{'data'}{'events'}[0]{stopTime};
  4314. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime($lastrecstoptime);
  4315. $lastrecstoptime = sprintf "%02d:%02d:%02d" , $hour , $min , $sec ;
  4316. }
  4317. readingsBeginUpdate($hash);
  4318. readingsBulkUpdate($hash,"CamEventNum",$eventnum);
  4319. readingsBulkUpdate($hash,"CamLastRec",$lastrecord);
  4320. if ($lastrecstarttime) {readingsBulkUpdate($hash,"CamLastRecTime",$lastrecstarttime." - ". $lastrecstoptime);}
  4321. readingsBulkUpdate($hash,"Errorcode","none");
  4322. readingsBulkUpdate($hash,"Error","none");
  4323. readingsEndUpdate($hash, 1);
  4324. # Logausgabe
  4325. Log3($name, $verbose, "$name - Query eventlist of camera $camname retrieved");
  4326. } elsif ($OpMode eq "getmotionenum") {
  4327. $motdetsc = $data->{'data'}{'MDParam'}{'source'};
  4328. $sensitivity_camCap = $data->{'data'}{'MDParam'}{'sensitivity'}{'camCap'};
  4329. $sensitivity_value = $data->{'data'}{'MDParam'}{'sensitivity'}{'value'};
  4330. $sensitivity_ssCap = $data->{'data'}{'MDParam'}{'sensitivity'}{'ssCap'};
  4331. $threshold_camCap = $data->{'data'}{'MDParam'}{'threshold'}{'camCap'};
  4332. $threshold_value = $data->{'data'}{'MDParam'}{'threshold'}{'value'};
  4333. $threshold_ssCap = $data->{'data'}{'MDParam'}{'threshold'}{'ssCap'};
  4334. $percentage_camCap = $data->{'data'}{'MDParam'}{'percentage'}{'camCap'};
  4335. $percentage_value = $data->{'data'}{'MDParam'}{'percentage'}{'value'};
  4336. $percentage_ssCap = $data->{'data'}{'MDParam'}{'percentage'}{'ssCap'};
  4337. $objectSize_camCap = $data->{'data'}{'MDParam'}{'objectSize'}{'camCap'};
  4338. $objectSize_value = $data->{'data'}{'MDParam'}{'objectSize'}{'value'};
  4339. $objectSize_ssCap = $data->{'data'}{'MDParam'}{'objectSize'}{'ssCap'};
  4340. if ($motdetsc == -1) {
  4341. $motdetsc = "disabled";
  4342. }
  4343. elsif ($motdetsc == 0) {
  4344. $motdetsc = "Camera";
  4345. if ($sensitivity_camCap) {
  4346. $motdetsc .= ", sensitivity: $sensitivity_value";
  4347. }
  4348. if ($threshold_camCap) {
  4349. $motdetsc .= ", threshold: $threshold_value";
  4350. }
  4351. if ($percentage_camCap) {
  4352. $motdetsc .= ", percentage: $percentage_value";
  4353. }
  4354. if ($objectSize_camCap) {
  4355. $motdetsc .= ", objectSize: $objectSize_value";
  4356. }
  4357. }
  4358. elsif ($motdetsc == 1) {
  4359. $motdetsc = "SVS";
  4360. if ($sensitivity_ssCap) {
  4361. $motdetsc .= ", sensitivity: $sensitivity_value";
  4362. }
  4363. if ($threshold_ssCap) {
  4364. $motdetsc .= ", threshold: $threshold_value";
  4365. }
  4366. if ($percentage_ssCap) {
  4367. $motdetsc .= ", percentage: $percentage_value";
  4368. }
  4369. if ($objectSize_ssCap) {
  4370. $motdetsc .= ", objectSize: $objectSize_value";
  4371. }
  4372. }
  4373. # Setreading
  4374. readingsBeginUpdate($hash);
  4375. readingsBulkUpdate($hash,"CamMotDetSc",$motdetsc);
  4376. readingsBulkUpdate($hash,"Errorcode","none");
  4377. readingsBulkUpdate($hash,"Error","none");
  4378. readingsEndUpdate($hash, 1);
  4379. # Logausgabe
  4380. Log3($name, $verbose, "$name - Enumerate motion detection parameters of camera $camname retrieved");
  4381. } elsif ($OpMode eq "Getcapabilities") {
  4382. # Parse Infos
  4383. my $ptzfocus = $data->{'data'}{'ptzFocus'};
  4384. if ($ptzfocus eq "0") {
  4385. $ptzfocus = "false";
  4386. }
  4387. elsif ($ptzfocus eq "1") {
  4388. $ptzfocus = "support step operation";
  4389. }
  4390. elsif ($ptzfocus eq "2") {
  4391. $ptzfocus = "support continuous operation";
  4392. }
  4393. my $ptztilt = $data->{'data'}{'ptzTilt'};
  4394. if ($ptztilt eq "0") {
  4395. $ptztilt = "false";
  4396. }
  4397. elsif ($ptztilt eq "1") {
  4398. $ptztilt = "support step operation";
  4399. }
  4400. elsif ($ptztilt eq "2") {
  4401. $ptztilt = "support continuous operation";
  4402. }
  4403. my $ptzzoom = $data->{'data'}{'ptzZoom'};
  4404. if ($ptzzoom eq "0") {
  4405. $ptzzoom = "false";
  4406. }
  4407. elsif ($ptzzoom eq "1") {
  4408. $ptzzoom = "support step operation";
  4409. }
  4410. elsif ($ptzzoom eq "2") {
  4411. $ptzzoom = "support continuous operation";
  4412. }
  4413. my $ptzpan = $data->{'data'}{'ptzPan'};
  4414. if ($ptzpan eq "0") {
  4415. $ptzpan = "false";
  4416. }
  4417. elsif ($ptzpan eq "1") {
  4418. $ptzpan = "support step operation";
  4419. }
  4420. elsif ($ptzpan eq "2") {
  4421. $ptzpan = "support continuous operation";
  4422. }
  4423. my $ptziris = $data->{'data'}{'ptzIris'};
  4424. if ($ptziris eq "0") {
  4425. $ptziris = "false";
  4426. }
  4427. elsif ($ptziris eq "1") {
  4428. $ptziris = "support step operation";
  4429. }
  4430. elsif ($ptziris eq "2") {
  4431. $ptziris = "support continuous operation";
  4432. }
  4433. $data->{'data'}{'ptzHasObjTracking'} = SSCam_jboolmap($data->{'data'}{'ptzHasObjTracking'});
  4434. $data->{'data'}{'audioOut'} = SSCam_jboolmap($data->{'data'}{'audioOut'});
  4435. $data->{'data'}{'ptzSpeed'} = SSCam_jboolmap($data->{'data'}{'ptzSpeed'});
  4436. $data->{'data'}{'ptzAbs'} = SSCam_jboolmap($data->{'data'}{'ptzAbs'});
  4437. $data->{'data'}{'ptzAutoFocus'} = SSCam_jboolmap($data->{'data'}{'ptzAutoFocus'});
  4438. $data->{'data'}{'ptzHome'} = SSCam_jboolmap($data->{'data'}{'ptzHome'});
  4439. # Setreading
  4440. readingsBeginUpdate($hash);
  4441. readingsBulkUpdate($hash,"CapPTZAutoFocus",$data->{'data'}{'ptzAutoFocus'});
  4442. readingsBulkUpdate($hash,"CapAudioOut",$data->{'data'}{'audioOut'});
  4443. readingsBulkUpdate($hash,"CapChangeSpeed",$data->{'data'}{'ptzSpeed'});
  4444. readingsBulkUpdate($hash,"CapPTZHome",$data->{'data'}{'ptzHome'});
  4445. readingsBulkUpdate($hash,"CapPTZAbs",$data->{'data'}{'ptzAbs'});
  4446. readingsBulkUpdate($hash,"CapPTZDirections",$data->{'data'}{'ptzDirection'});
  4447. readingsBulkUpdate($hash,"CapPTZFocus",$ptzfocus);
  4448. readingsBulkUpdate($hash,"CapPTZIris",$ptziris);
  4449. readingsBulkUpdate($hash,"CapPTZObjTracking",$data->{'data'}{'ptzHasObjTracking'});
  4450. readingsBulkUpdate($hash,"CapPTZPan",$ptzpan);
  4451. readingsBulkUpdate($hash,"CapPTZPresetNumber",$data->{'data'}{'ptzPresetNumber'});
  4452. readingsBulkUpdate($hash,"CapPTZTilt",$ptztilt);
  4453. readingsBulkUpdate($hash,"CapPTZZoom",$ptzzoom);
  4454. readingsBulkUpdate($hash,"Errorcode","none");
  4455. readingsBulkUpdate($hash,"Error","none");
  4456. readingsEndUpdate($hash, 1);
  4457. # Logausgabe
  4458. Log3($name, $verbose, "$name - Capabilities of camera $camname retrieved");
  4459. } elsif ($OpMode eq "Getptzlistpreset") {
  4460. # Parse PTZ-ListPresets
  4461. my $presetcnt = $data->{'data'}->{'total'};
  4462. my $cnt = 0;
  4463. # alle Presets der Kamera mit Id's in Assoziatives Array einlesen
  4464. # "my" nicht am Anfang deklarieren, sonst wird Hash %allpresets wieder geleert !
  4465. my %allpresets;
  4466. my $home = "not set";
  4467. while ($cnt < $presetcnt) {
  4468. # my $presid = $data->{'data'}->{'presets'}->[$cnt]->{'id'};
  4469. my $presid = $data->{'data'}->{'presets'}->[$cnt]->{'position'};
  4470. my $presname = $data->{'data'}->{'presets'}->[$cnt]->{'name'};
  4471. $allpresets{$presname} = "$presid";
  4472. my $ptype = $data->{'data'}->{'presets'}->[$cnt]->{'type'};
  4473. if ($ptype) {
  4474. $home = $presname;
  4475. }
  4476. $cnt += 1;
  4477. }
  4478. # Presethash in $hash einfügen
  4479. $hash->{HELPER}{ALLPRESETS} = \%allpresets;
  4480. my @preskeys = sort(keys(%allpresets));
  4481. my $presetlist = join(",",@preskeys);
  4482. # Setreading
  4483. readingsBeginUpdate($hash);
  4484. readingsBulkUpdate($hash,"Presets",$presetlist);
  4485. readingsBulkUpdate($hash,"PresetHome",$home);
  4486. readingsBulkUpdate($hash,"Errorcode","none");
  4487. readingsBulkUpdate($hash,"Error","none");
  4488. readingsEndUpdate($hash, 1);
  4489. # spezifische Attribute für PTZ-Cams verfügbar machen
  4490. SSCam_addptzattr($name);
  4491. # Logausgabe
  4492. Log3($name, $verbose, "$name - PTZ Presets of camera $camname retrieved");
  4493. } elsif ($OpMode eq "Getptzlistpatrol") {
  4494. # Parse PTZ-ListPatrols
  4495. $patrolcnt = $data->{'data'}->{'total'};
  4496. my $cnt = 0;
  4497. # alle Patrols der Kamera mit Id's in Assoziatives Array einlesen
  4498. # "my" nicht am Anfang deklarieren, sonst wird Hash %allpatrols wieder geleert !
  4499. my %allpatrols = ();
  4500. while ($cnt < $patrolcnt) {
  4501. $patrolid = $data->{'data'}->{'patrols'}->[$cnt]->{'id'};
  4502. $patrolname = $data->{'data'}->{'patrols'}->[$cnt]->{'name'};
  4503. $allpatrols{$patrolname} = $patrolid;
  4504. $cnt += 1;
  4505. }
  4506. # Presethash in $hash einfügen
  4507. $hash->{HELPER}{ALLPATROLS} = \%allpatrols;
  4508. @patrolkeys = sort(keys(%allpatrols));
  4509. $patrollist = join(",",@patrolkeys);
  4510. # print "ID von Tour1 ist : ". %allpatrols->{Tour1};
  4511. # print "aus Hash: ".$hash->{HELPER}{ALLPRESETS}{Tour1};
  4512. readingsBeginUpdate($hash);
  4513. readingsBulkUpdate($hash,"Patrols",$patrollist);
  4514. readingsBulkUpdate($hash,"Errorcode","none");
  4515. readingsBulkUpdate($hash,"Error","none");
  4516. readingsEndUpdate($hash, 1);
  4517. # Logausgabe
  4518. Log3($name, $verbose, "$name - PTZ Patrols of camera $camname retrieved");
  4519. }
  4520. } else {
  4521. # die API-Operation war fehlerhaft
  4522. # Errorcode aus JSON ermitteln
  4523. $errorcode = $data->{'error'}->{'code'};
  4524. # Fehlertext zum Errorcode ermitteln
  4525. $error = SSCam_experror($hash,$errorcode);
  4526. # Setreading
  4527. readingsBeginUpdate($hash);
  4528. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  4529. readingsBulkUpdate($hash,"Error",$error);
  4530. readingsEndUpdate($hash, 1);
  4531. if ($errorcode =~ /105/) {
  4532. Log3($name, 2, "$name - ERROR - $errorcode - $error in operation $OpMode -> try new login");
  4533. return SSCam_login($hash,'SSCam_getapisites');
  4534. }
  4535. # Logausgabe
  4536. Log3($name, 2, "$name - ERROR - Operation $OpMode of Camera $camname was not successful. Errorcode: $errorcode - $error");
  4537. }
  4538. }
  4539. # Token freigeben
  4540. $hash->{HELPER}{ACTIVE} = "off";
  4541. if (AttrVal($name,"debugactivetoken",0)) {
  4542. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  4543. }
  4544. return;
  4545. }
  4546. #############################################################################################################################
  4547. ######### Hilfsroutinen #############
  4548. #############################################################################################################################
  4549. ####################################################################################
  4550. # Login in SVS wenn kein oder ungültige Session-ID vorhanden ist
  4551. sub SSCam_login ($$) {
  4552. my ($hash,$fret) = @_;
  4553. my $name = $hash->{NAME};
  4554. my $serveraddr = $hash->{SERVERADDR};
  4555. my $serverport = $hash->{SERVERPORT};
  4556. my $apiauth = $hash->{HELPER}{APIAUTH};
  4557. my $apiauthpath = $hash->{HELPER}{APIAUTHPATH};
  4558. my $apiauthmaxver = $hash->{HELPER}{APIAUTHMAXVER};
  4559. my $proto = $hash->{PROTOCOL};
  4560. my $lrt = AttrVal($name,"loginRetries",3);
  4561. my ($url,$param);
  4562. delete $hash->{HELPER}{SID} if($hash->{HELPER}{SID});
  4563. # Login und SID ermitteln
  4564. Log3($name, 4, "$name - --- Begin Function SSCam_login ---");
  4565. # Credentials abrufen
  4566. my ($success, $username, $password) = SSCam_getcredentials($hash,0);
  4567. unless ($success) {
  4568. Log3($name, 2, "$name - Credentials couldn't be retrieved successfully - make sure you've set it with \"set $name credentials <username> <password>\"");
  4569. $hash->{HELPER}{ACTIVE} = "off";
  4570. if (AttrVal($name,"debugactivetoken",0)) {
  4571. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  4572. }
  4573. return;
  4574. }
  4575. if($hash->{HELPER}{LOGINRETRIES} >= $lrt) {
  4576. # login wird abgebrochen, Freigabe Funktionstoken
  4577. $hash->{HELPER}{ACTIVE} = "off";
  4578. if (AttrVal($name,"debugactivetoken",0)) {
  4579. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  4580. }
  4581. Log3($name, 2, "$name - ERROR - Login or privilege of user $username unsuccessful");
  4582. return;
  4583. }
  4584. my $httptimeout = AttrVal($name,"httptimeout",4);
  4585. Log3($name, 5, "$name - HTTP-Call login will be done with httptimeout-Value: $httptimeout s");
  4586. my $urlwopw; # nur zur Anzeige bei verbose >= 4 und "showPassInLog" == 0
  4587. # sid in Quotes einschliessen oder nicht -> bei Problemen mit 402 - Permission denied
  4588. my $sid = AttrVal($name, "noQuotesForSID", "0") == 1 ? "sid" : "\"sid\"";
  4589. if (AttrVal($name,"session","DSM") eq "SurveillanceStation") {
  4590. $url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&session=SurveillanceStation&format=$sid";
  4591. $urlwopw = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=*****&session=SurveillanceStation&format=$sid";
  4592. } else {
  4593. $url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=$password&format=$sid";
  4594. $urlwopw = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Login&account=$username&passwd=*****&format=$sid";
  4595. }
  4596. AttrVal($name, "showPassInLog", "0") == 1 ? Log3($name, 4, "$name - Call-Out now: $url") : Log3($name, 4, "$name - Call-Out now: $urlwopw");
  4597. $hash->{HELPER}{LOGINRETRIES}++;
  4598. $param = {
  4599. url => $url,
  4600. timeout => $httptimeout,
  4601. hash => $hash,
  4602. user => $username,
  4603. funcret => $fret,
  4604. method => "GET",
  4605. header => "Accept: application/json",
  4606. callback => \&SSCam_login_return
  4607. };
  4608. HttpUtils_NonblockingGet ($param);
  4609. }
  4610. sub SSCam_login_return ($) {
  4611. my ($param, $err, $myjson) = @_;
  4612. my $hash = $param->{hash};
  4613. my $name = $hash->{NAME};
  4614. my $username = $param->{user};
  4615. my $fret = $param->{funcret};
  4616. my $subref = \&$fret;
  4617. my $success;
  4618. # Verarbeitung der asynchronen Rückkehrdaten aus sub "login_nonbl"
  4619. if ($err ne "") {
  4620. # ein Fehler bei der HTTP Abfrage ist aufgetreten
  4621. Log3($name, 2, "$name - error while requesting ".$param->{url}." - $err");
  4622. readingsSingleUpdate($hash, "Error", $err, 1);
  4623. return SSCam_login($hash,$fret);
  4624. } elsif ($myjson ne "") {
  4625. # wenn die Abfrage erfolgreich war ($data enthält die Ergebnisdaten des HTTP Aufrufes)
  4626. # Evaluiere ob Daten im JSON-Format empfangen wurden
  4627. ($hash, $success) = SSCam_evaljson($hash,$myjson);
  4628. unless ($success) {
  4629. Log3($name, 4, "$name - no JSON-Data returned: ".$myjson);
  4630. $hash->{HELPER}{ACTIVE} = "off";
  4631. if (AttrVal($name,"debugactivetoken",0)) {
  4632. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  4633. }
  4634. return;
  4635. }
  4636. my $data = decode_json($myjson);
  4637. # Logausgabe decodierte JSON Daten
  4638. Log3($name, 5, "$name - JSON decoded: ". Dumper $data);
  4639. $success = $data->{'success'};
  4640. if ($success) {
  4641. # login war erfolgreich
  4642. my $sid = $data->{'data'}->{'sid'};
  4643. # Session ID in hash eintragen
  4644. $hash->{HELPER}{SID} = $sid;
  4645. # Setreading
  4646. readingsBeginUpdate($hash);
  4647. readingsBulkUpdate($hash,"Errorcode","none");
  4648. readingsBulkUpdate($hash,"Error","none");
  4649. readingsEndUpdate($hash, 1);
  4650. # Logausgabe
  4651. Log3($name, 4, "$name - Login of User $username successful - SID: $sid");
  4652. return &$subref($hash);
  4653. } else {
  4654. # Errorcode aus JSON ermitteln
  4655. my $errorcode = $data->{'error'}->{'code'};
  4656. # Fehlertext zum Errorcode ermitteln
  4657. my $error = SSCam_experrorauth($hash,$errorcode);
  4658. # Setreading
  4659. readingsBeginUpdate($hash);
  4660. readingsBulkUpdate($hash,"Errorcode",$errorcode);
  4661. readingsBulkUpdate($hash,"Error",$error);
  4662. readingsEndUpdate($hash, 1);
  4663. # Logausgabe
  4664. Log3($name, 3, "$name - Login of User $username unsuccessful. Code: $errorcode - $error - try again");
  4665. return SSCam_login($hash,$fret);
  4666. }
  4667. }
  4668. return SSCam_login($hash,$fret);
  4669. }
  4670. ###################################################################################
  4671. # Funktion logout
  4672. ###################################################################################
  4673. sub SSCam_logout ($) {
  4674. my ($hash) = @_;
  4675. my $name = $hash->{NAME};
  4676. my $serveraddr = $hash->{SERVERADDR};
  4677. my $serverport = $hash->{SERVERPORT};
  4678. my $apiauth = $hash->{HELPER}{APIAUTH};
  4679. my $apiauthpath = $hash->{HELPER}{APIAUTHPATH};
  4680. my $apiauthmaxver = $hash->{HELPER}{APIAUTHMAXVER};
  4681. my $sid = $hash->{HELPER}{SID};
  4682. my $proto = $hash->{PROTOCOL};
  4683. my $url;
  4684. my $param;
  4685. my $httptimeout;
  4686. Log3($name, 4, "$name - ####################################################");
  4687. Log3($name, 4, "$name - ### start cam operation $hash->{OPMODE} ");
  4688. Log3($name, 4, "$name - ####################################################");
  4689. Log3($name, 4, "$name - --- Begin Function SSCam_logout nonblocking ---");
  4690. $httptimeout = AttrVal($name,"httptimeout",4);
  4691. Log3($name, 5, "$name - HTTP-Call will be done with httptimeout-Value: $httptimeout s");
  4692. if (AttrVal($name,"session","DSM") eq "SurveillanceStation") {
  4693. $url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Logout&session=SurveillanceStation&_sid=$sid";
  4694. } else {
  4695. $url = "$proto://$serveraddr:$serverport/webapi/$apiauthpath?api=$apiauth&version=$apiauthmaxver&method=Logout&_sid=$sid";
  4696. }
  4697. $param = {
  4698. url => $url,
  4699. timeout => $httptimeout,
  4700. hash => $hash,
  4701. method => "GET",
  4702. header => "Accept: application/json",
  4703. callback => \&SSCam_logout_return
  4704. };
  4705. HttpUtils_NonblockingGet ($param);
  4706. }
  4707. sub SSCam_logout_return ($) {
  4708. my ($param, $err, $myjson) = @_;
  4709. my $hash = $param->{hash};
  4710. my $name = $hash->{NAME};
  4711. my $sid = $hash->{HELPER}{SID};
  4712. my ($success, $username) = SSCam_getcredentials($hash,0);
  4713. my $OpMode = $hash->{OPMODE};
  4714. my $data;
  4715. my $error;
  4716. my $errorcode;
  4717. if($err ne "") {
  4718. # wenn ein Fehler bei der HTTP Abfrage aufgetreten ist
  4719. Log3($name, 2, "$name - error while requesting ".$param->{url}." - $err");
  4720. readingsSingleUpdate($hash, "Error", $err, 1);
  4721. } elsif($myjson ne "") {
  4722. # wenn die Abfrage erfolgreich war ($data enthält die Ergebnisdaten des HTTP Aufrufes)
  4723. Log3($name, 4, "$name - URL-Call: ".$param->{url});
  4724. # Evaluiere ob Daten im JSON-Format empfangen wurden
  4725. ($hash, $success) = SSCam_evaljson($hash,$myjson);
  4726. unless ($success) {
  4727. Log3($name, 4, "$name - Data returned: ".$myjson);
  4728. $hash->{HELPER}{ACTIVE} = "off";
  4729. if (AttrVal($name,"debugactivetoken",0)) {
  4730. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  4731. }
  4732. return;
  4733. }
  4734. $data = decode_json($myjson);
  4735. # Logausgabe decodierte JSON Daten
  4736. Log3($name, 4, "$name - JSON returned: ". Dumper $data);
  4737. $success = $data->{'success'};
  4738. if ($success) {
  4739. # die Logout-URL konnte erfolgreich aufgerufen werden
  4740. Log3($name, 4, "$name - Session of User $username has ended - SID: \"$sid\" has been deleted");
  4741. } else {
  4742. # Errorcode aus JSON ermitteln
  4743. $errorcode = $data->{'error'}->{'code'};
  4744. # Fehlertext zum Errorcode ermitteln
  4745. $error = &SSCam_experrorauth($hash,$errorcode);
  4746. Log3($name, 2, "$name - ERROR - Logout of User $username was not successful, however SID: \"$sid\" has been deleted. Errorcode: $errorcode - $error");
  4747. }
  4748. }
  4749. # Session-ID aus Helper-hash löschen
  4750. delete $hash->{HELPER}{SID};
  4751. # ausgeführte Funktion ist erledigt (auch wenn logout nicht erfolgreich), Freigabe Funktionstoken
  4752. $hash->{HELPER}{ACTIVE} = "off";
  4753. if (AttrVal($name,"debugactivetoken",0)) {
  4754. Log3($name, 3, "$name - Active-Token deleted by OPMODE: $hash->{OPMODE}");
  4755. }
  4756. return;
  4757. }
  4758. ###############################################################################
  4759. # Test ob JSON-String empfangen wurde
  4760. ###############################################################################
  4761. sub SSCam_evaljson($$) {
  4762. my ($hash,$myjson) = @_;
  4763. my $OpMode = $hash->{OPMODE};
  4764. my $name = $hash->{NAME};
  4765. my $success = 1;
  4766. eval {decode_json($myjson)} or do
  4767. {
  4768. if($hash->{HELPER}{RUNVIEW} =~ m/^live_.*hls$/ || $OpMode =~ m/^.*_hls$/) {
  4769. # HLS aktivate/deaktivate bringt kein JSON wenn bereits aktiviert/deaktiviert
  4770. Log3($name, 5, "$name - HLS-activation data return: $myjson");
  4771. if ($myjson =~ m/{"success":true}/) {
  4772. $success = 1;
  4773. $myjson = '{"success":true}';
  4774. }
  4775. } else {
  4776. $success = 0;
  4777. # Setreading
  4778. readingsBeginUpdate($hash);
  4779. readingsBulkUpdate($hash,"Errorcode","none");
  4780. readingsBulkUpdate($hash,"Error","malformed JSON string received");
  4781. readingsEndUpdate($hash, 1);
  4782. }
  4783. };
  4784. return($hash,$success,$myjson);
  4785. }
  4786. ######################################################################################################
  4787. # Refresh eines Raumes aus $hash->{HELPER}{STRMROOM}
  4788. # bzw. Longpoll von SSCam bzw. eines SSCamSTRM Devices wenn
  4789. # $hash->{HELPER}{STRMDEV} gefüllt
  4790. # $hash, $pload (1=Page reload), SSCam-state-Event(1=Event), SSCamSTRM-Event (1=Event)
  4791. ######################################################################################################
  4792. sub SSCam_refresh($$$$) {
  4793. my ($hash,$pload,$lpoll_scm,$lpoll_strm) = @_;
  4794. my $name;
  4795. if (ref $hash ne "HASH")
  4796. {
  4797. ($name,$pload,$lpoll_scm,$lpoll_strm) = split ",",$hash;
  4798. $hash = $defs{$name};
  4799. } else {
  4800. $name = $hash->{NAME};
  4801. }
  4802. my $fpr = 0;
  4803. # Kontext des SSCamSTRM-Devices speichern für Refresh
  4804. my $sd = $hash->{HELPER}{STRMDEV}?$hash->{HELPER}{STRMDEV}:"\"n.a.\""; # Name des aufrufenden SSCamSTRM-Devices
  4805. my $sr = $hash->{HELPER}{STRMROOM}?$hash->{HELPER}{STRMROOM}:"\"n.a.\""; # Raum aus dem das SSCamSTRM-Device die Funktion aufrief
  4806. my $sl = $hash->{HELPER}{STRMDETAIL}?$hash->{HELPER}{STRMDETAIL}:"\"n.a.\""; # Name des SSCamSTRM-Devices (wenn Detailansicht)
  4807. $fpr = AttrVal($hash->{HELPER}{STRMDEV},"forcePageRefresh",0) if($hash->{HELPER}{STRMDEV});
  4808. Log3($name, 4, "$name - SSCam_refresh - caller: $sd, callerroom: $sr, detail: $sl, pload: $pload, forcePageRefresh: $fpr");
  4809. # Page-Reload
  4810. if($pload && $hash->{HELPER}{STRMROOM} && $hash->{HELPER}{STRMDETAIL}) {
  4811. if($hash->{HELPER}{STRMROOM} && !$hash->{HELPER}{STRMDETAIL} && !$fpr) {
  4812. Log3($name, 4, "$name - SSCam_refresh jetzt");
  4813. # trifft zu wenn in einer Raumansicht
  4814. my @rooms = split(",",$hash->{HELPER}{STRMROOM});
  4815. foreach (@rooms) {
  4816. my $room = $_;
  4817. { map { FW_directNotify("FILTER=room=$room", "#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") }
  4818. }
  4819. } elsif ( !$hash->{HELPER}{STRMROOM} || $hash->{HELPER}{STRMDETAIL} || $fpr ) {
  4820. # trifft zu bei Detailansicht oder im FLOORPLAN bzw. Dashboard oder wenn Seitenrefresh mit dem
  4821. # SSCamSTRM-Attribut "forcePageRefresh" erzwungen wird
  4822. { map { FW_directNotify("#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") }
  4823. }
  4824. } elsif ($fpr) {
  4825. # Seitenrefresh durch SSCamSTRM-Attribut "forcePageRefresh" erzwungen
  4826. { map { FW_directNotify("#FHEMWEB:$_", "location.reload('true')", "") } devspec2array("TYPE=FHEMWEB") }
  4827. }
  4828. # Aufnahmestatus/Disabledstatus in state abbilden & SSCam-Device state setzen (mit/ohne Event)
  4829. my $st = (ReadingsVal($name, "Availability", "enabled") eq "disabled")?"disabled":(ReadingsVal($name, "Record", "") eq "Start")?"on":"off";
  4830. if($lpoll_scm) {
  4831. readingsSingleUpdate($hash,"state", $st, 1);
  4832. } else {
  4833. readingsSingleUpdate($hash,"state", $st, 0);
  4834. }
  4835. # parentState des SSCamSTRM-Device mit Opmode updaten (mit/ohne Event)
  4836. if($hash->{HELPER}{STRMDEV}) {
  4837. my $strmhash = $defs{$hash->{HELPER}{STRMDEV}};
  4838. if($lpoll_strm) {
  4839. readingsSingleUpdate($strmhash,"parentState", $hash->{OPMODE}, 1);
  4840. } else {
  4841. readingsSingleUpdate($strmhash,"parentState", $hash->{OPMODE}, 0);
  4842. }
  4843. }
  4844. return;
  4845. }
  4846. ###############################################################################
  4847. # Test ob MODEL=SVS (sonst ist es eine Cam)
  4848. ###############################################################################
  4849. sub SSCam_IsModelCam($){
  4850. my ($hash)= @_;
  4851. my $m = ($hash->{MODEL} ne "SVS")?1:0;
  4852. return($m);
  4853. }
  4854. ###############################################################################
  4855. # JSON Boolean Test und Mapping
  4856. ###############################################################################
  4857. sub SSCam_jboolmap($){
  4858. my ($bool)= @_;
  4859. if(JSON::is_bool($bool)) {
  4860. $bool = $bool?"true":"false";
  4861. }
  4862. return $bool;
  4863. }
  4864. ###############################################################################
  4865. # Schnappschußgalerie abrufen (snapGalleryBoost) o. nur Info des letzten Snaps
  4866. ###############################################################################
  4867. sub SSCam_snaplimsize ($) {
  4868. my ($hash)= @_;
  4869. my $name = $hash->{NAME};
  4870. my ($slim,$ssize);
  4871. if(!AttrVal($name,"snapGalleryBoost",0)) {
  4872. $slim = 1;
  4873. $ssize = 0;
  4874. } else {
  4875. $hash->{HELPER}{GETSNAPGALLERY} = 1;
  4876. $slim = AttrVal($name,"snapGalleryNumber",$SSCam_slim); # Anzahl der abzurufenden Snaps
  4877. my $sg = AttrVal($name,"snapGallerySize","Icon"); # Auflösung Image
  4878. $ssize = ($sg eq "Icon")?1:2;
  4879. }
  4880. return ($slim,$ssize);
  4881. }
  4882. ###############################################################################
  4883. # Helper für listLog-Argumente extrahieren
  4884. ###############################################################################
  4885. sub SSCam_extlogargs ($$) {
  4886. my ($hash,$a) = @_;
  4887. $hash->{HELPER}{LISTLOGSEVERITY} = (split("severity:",$a))[1] if(lc($a) =~ m/^severity:.*/);
  4888. $hash->{HELPER}{LISTLOGLIMIT} = (split("limit:",$a))[1] if(lc($a) =~ m/^limit:.*/);
  4889. $hash->{HELPER}{LISTLOGMATCH} = (split("match:",$a))[1] if(lc($a) =~ m/^match:.*/);
  4890. return;
  4891. }
  4892. ###############################################################################
  4893. # Helper für optimizeParams-Argumente extrahieren
  4894. ###############################################################################
  4895. sub SSCam_extoptpar($$$) {
  4896. my ($hash,$a,$cpcl) = @_;
  4897. $hash->{HELPER}{MIRROR} = (split("mirror:",$a))[1] if(lc($a) =~ m/^mirror:.*/);
  4898. $hash->{HELPER}{FLIP} = (split("flip:",$a))[1] if(lc($a) =~ m/^flip:.*/);
  4899. $hash->{HELPER}{ROTATE} = (split("rotate:",$a))[1] if(lc($a) =~ m/^rotate:.*/);
  4900. $hash->{HELPER}{NTPSERV} = (split("ntp:",$a))[1] if(lc($a) =~ m/^ntp:.*/);
  4901. $hash->{HELPER}{CHKLIST} = ($hash->{HELPER}{NTPSERV}?$cpcl->{ntp}:0)+
  4902. ($hash->{HELPER}{MIRROR}?$cpcl->{mirror}:0)+
  4903. ($hash->{HELPER}{FLIP}?$cpcl->{flip}:0)+
  4904. ($hash->{HELPER}{ROTATE}?$cpcl->{rotate}:0);
  4905. return;
  4906. }
  4907. ###############################################################################
  4908. # Helper für HLS Lieferfähigkeit
  4909. # HLS kann geliefert werden wenn "SYNO.SurveillanceStation.VideoStream"
  4910. # existiert und Reading CamStreamFormat "HLS" ist
  4911. ###############################################################################
  4912. sub SSCam_IsHLSCap($) {
  4913. my ($hash) = @_;
  4914. my $name = $hash->{NAME};
  4915. my $ret = 0;
  4916. my $api = $hash->{HELPER}{APIVIDEOSTMSMAXVER};
  4917. my $csf = (ReadingsVal($name,"CamStreamFormat","MJPEG") eq "HLS")?1:0;
  4918. $ret = 1 if($api && $csf);
  4919. return $ret;
  4920. }
  4921. ###############################################################################
  4922. # Clienthash übernehmen oder zusammenstellen
  4923. # Identifikation ob über FHEMWEB ausgelöst oder nicht -> erstellen $hash->CL
  4924. sub SSCam_getclhash($;$$) {
  4925. my ($hash,$nobgd)= @_;
  4926. my $name = $hash->{NAME};
  4927. my $ret;
  4928. if($nobgd) {
  4929. # nur übergebenen CL-Hash speichern,
  4930. # keine Hintergrundverarbeitung bzw. synthetische Erstellung CL-Hash
  4931. $hash->{HELPER}{CL}{1} = $hash->{CL};
  4932. return undef;
  4933. }
  4934. if (!defined($hash->{CL})) {
  4935. # Clienthash wurde nicht übergeben und wird erstellt (FHEMWEB Instanzen mit canAsyncOutput=1 analysiert)
  4936. my $outdev;
  4937. my @webdvs = devspec2array("TYPE=FHEMWEB:FILTER=canAsyncOutput=1:FILTER=STATE=Connected");
  4938. my $i = 1;
  4939. foreach (@webdvs) {
  4940. $outdev = $_;
  4941. next if(!$defs{$outdev});
  4942. $hash->{HELPER}{CL}{$i}->{NAME} = $defs{$outdev}{NAME};
  4943. $hash->{HELPER}{CL}{$i}->{NR} = $defs{$outdev}{NR};
  4944. $hash->{HELPER}{CL}{$i}->{COMP} = 1;
  4945. $i++;
  4946. }
  4947. } else {
  4948. # übergebenen CL-Hash in Helper eintragen
  4949. $hash->{HELPER}{CL}{1} = $hash->{CL};
  4950. }
  4951. # Clienthash auflösen zur Fehlersuche (aufrufende FHEMWEB Instanz
  4952. if (defined($hash->{HELPER}{CL}{1})) {
  4953. for (my $k=1; (defined($hash->{HELPER}{CL}{$k})); $k++ ) {
  4954. Log3($name, 4, "$name - Clienthash number: $k");
  4955. while (my ($key,$val) = each(%{$hash->{HELPER}{CL}{$k}})) {
  4956. $val = $val?$val:" ";
  4957. Log3($name, 4, "$name - Clienthash: $key -> $val");
  4958. }
  4959. }
  4960. } else {
  4961. Log3($name, 2, "$name - Clienthash was neither delivered nor created !");
  4962. $ret = "Clienthash was neither delivered nor created. Can't use asynchronous output for function.";
  4963. }
  4964. return ($ret);
  4965. }
  4966. ###############################################################################
  4967. # konvertiere alle ptzPanel_rowXX-attribute zu html-Code für
  4968. # das generierte Widget und das weblink-Device ptzpanel_$name
  4969. ###############################################################################
  4970. sub SSCam_ptzpanel($;$$) {
  4971. my ($name,$ptzcdev,$ptzcontrol) = @_;
  4972. my $hash = $defs{$name};
  4973. my $iconpath = AttrVal("$name","ptzPanel_iconPath","www/images/sscam");
  4974. my $iconprefix = AttrVal("$name","ptzPanel_iconPrefix","black_btn_");
  4975. my $rowisset = 0;
  4976. my $ptz_ret;
  4977. my $row;
  4978. my @vl = split (/\.|-/,ReadingsVal($name, "SVSversion", ""));
  4979. if(@vl) {
  4980. my $actvs = $vl[0];
  4981. $actvs .= $vl[1];
  4982. return "" if($actvs <= 71);
  4983. }
  4984. $ptz_ret = "<div class=\"ptzpanel\">";
  4985. $ptz_ret.= '<table class="rc_body">';
  4986. foreach my $rownr (0..9) {
  4987. $rownr = sprintf("%2.2d",$rownr);
  4988. $row = AttrVal("$name","ptzPanel_row$rownr",undef);
  4989. next if (!$row);
  4990. $rowisset = 1;
  4991. $ptz_ret .= "<tr>";
  4992. my @btn = split (",",$row); # die Anzahl Buttons in einer Reihe
  4993. foreach my $btnnr (0..$#btn) {
  4994. $ptz_ret .= '<td class="rc_button">';
  4995. if ($btn[$btnnr] ne "") {
  4996. my $cmd;
  4997. my $img;
  4998. if ($btn[$btnnr] =~ /(.*?):(.*)/) { # enthält Komando -> <command>:<image>
  4999. $cmd = $1;
  5000. $img = $2;
  5001. } else { # button has format <command> or is empty
  5002. $cmd = $btn[$btnnr];
  5003. $img = $btn[$btnnr];
  5004. }
  5005. if ($img =~ m/\.svg/) { # Verwendung für SVG's
  5006. $img = FW_makeImage($img, $cmd, "rc-button");
  5007. } else {
  5008. $img = "<img src=\"$FW_ME/$iconpath/$iconprefix$img\">"; # $FW_ME = URL-Pfad unter dem der FHEMWEB-Server via HTTP erreichbar ist, z.B. /fhem
  5009. }
  5010. if ($cmd || $cmd eq "0") {
  5011. $cmd = "cmd=set $name $cmd";
  5012. $ptz_ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmd')\">$img</a>"; # $FW_subdir = Sub-path in URL, used by FLOORPLAN/weblink
  5013. } else {
  5014. $ptz_ret .= $img;
  5015. }
  5016. }
  5017. $ptz_ret .= "</td>";
  5018. $ptz_ret .= "\n";
  5019. }
  5020. $ptz_ret .= "</tr>\n";
  5021. }
  5022. $ptz_ret .= "</table>";
  5023. $ptz_ret .= "</div>";
  5024. if ($rowisset) {
  5025. return $ptz_ret;
  5026. } else {
  5027. return "";
  5028. }
  5029. }
  5030. ###############################################################################
  5031. # spezielle Attribute für PTZ-ControlPanel verfügbar machen
  5032. ###############################################################################
  5033. sub SSCam_addptzattr($) {
  5034. my ($name) = @_;
  5035. my $hash = $defs{$name};
  5036. my $actvs;
  5037. my @vl = split (/\.|-/,ReadingsVal($name, "SVSversion", ""));
  5038. if(@vl) {
  5039. $actvs = $vl[0];
  5040. $actvs.= $vl[1];
  5041. }
  5042. return if(ReadingsVal($name,"DeviceType","Camera") ne "PTZ" || $actvs <= 71);
  5043. foreach my $n (0..9) {
  5044. $n = sprintf("%2.2d",$n);
  5045. addToDevAttrList($name, "ptzPanel_row$n");
  5046. }
  5047. if(ReadingsVal("$name","Presets","") ne "") {
  5048. $attr{$name}{userattr} =~ s/ptzPanel_Home:$hash->{HELPER}{OLDPRESETS}//g if($hash->{HELPER}{OLDPRESETS} && ReadingsVal("$name","Presets","") ne $hash->{HELPER}{OLDPRESETS});
  5049. $hash->{HELPER}{OLDPRESETS} = ReadingsVal("$name","Presets","");
  5050. addToDevAttrList($name, "ptzPanel_Home:".ReadingsVal("$name","Presets",""));
  5051. }
  5052. addToDevAttrList($name, "ptzPanel_iconPrefix");
  5053. addToDevAttrList($name, "ptzPanel_iconPath");
  5054. addToDevAttrList($name, "ptzPanel_use:0,1");
  5055. # PTZ Panel Widget initial generieren
  5056. my $upleftfast = "move upleft";
  5057. my $upfast = "move up";
  5058. my $uprightfast = "move upright";
  5059. my $upleft = "move upleft 0.5";
  5060. my $up = "move up 0.5";
  5061. my $upright = "move upright 0.5";
  5062. my $leftfast = "move left";
  5063. my $left = "move left 0.5";
  5064. my $home = "goPreset ".AttrVal($name,"ptzPanel_Home",ReadingsVal($name,"PresetHome",""));
  5065. my $right = "move right 0.5";
  5066. my $rightfast = "move right";
  5067. my $downleft = "move downleft 0.5";
  5068. my $down = "move down 0.5";
  5069. my $downright = "move downright 0.5";
  5070. my $downleftfast = "move downleft";
  5071. my $downfast = "move down";
  5072. my $downrightfast = "move downright";
  5073. $attr{$name}{ptzPanel_row00} = "$upleftfast:CAMUPLEFTFAST.png,:CAMBLANK.png,$upfast:CAMUPFAST.png,:CAMBLANK.png,$uprightfast:CAMUPRIGHTFAST.png"
  5074. if(!AttrVal($name,"ptzPanel_row00",undef));
  5075. $attr{$name}{ptzPanel_row01} = ":CAMBLANK.png,$upleft:CAMUPLEFT.png,$up:CAMUP.png,$upright:CAMUPRIGHT.png"
  5076. if(!AttrVal($name,"ptzPanel_row01",undef));
  5077. $attr{$name}{ptzPanel_row02} = "$leftfast:CAMLEFTFAST.png,$left:CAMLEFT.png,$home:CAMHOME.png,$right:CAMRIGHT.png,$rightfast:CAMRIGHTFAST.png"
  5078. if(!AttrVal($name,"ptzPanel_row02",undef) || $home ne $hash->{HELPER}{OLDPTZHOME});
  5079. $attr{$name}{ptzPanel_row03} = ":CAMBLANK.png,$downleft:CAMDOWNLEFT.png,$down:CAMDOWN.png,$downright:CAMDOWNRIGHT.png"
  5080. if(!AttrVal($name,"ptzPanel_row03",undef));
  5081. $attr{$name}{ptzPanel_row04} = "$downleftfast:CAMDOWNLEFTFAST.png,:CAMBLANK.png,$downfast:CAMDOWNFAST.png,:CAMBLANK.png,$downrightfast:CAMDOWNRIGHTFAST.png"
  5082. if(!AttrVal($name,"ptzPanel_row04",undef));
  5083. $hash->{HELPER}{OLDPTZHOME} = $home;
  5084. $hash->{".ptzhtml"} = ""; # SSCam_ptzpanel wird neu durchlaufen
  5085. return;
  5086. }
  5087. ######################################################################################
  5088. # Stream einer Kamera - Kamera Liveview weblink device
  5089. # API: SYNO.SurveillanceStation.VideoStreaming
  5090. # Methode: GetLiveViewPath
  5091. ######################################################################################
  5092. sub SSCam_StreamDev($$$) {
  5093. my ($camname,$strmdev,$fmt) = @_;
  5094. my $hash = $defs{$camname};
  5095. my $wltype = $hash->{HELPER}{WLTYPE};
  5096. my $serveraddr = $hash->{SERVERADDR};
  5097. my $serverport = $hash->{SERVERPORT};
  5098. my $apivideostm = $hash->{HELPER}{APIVIDEOSTM};
  5099. my $apivideostmpath = $hash->{HELPER}{APIVIDEOSTMPATH};
  5100. my $apivideostmmaxver = $hash->{HELPER}{APIVIDEOSTMMAXVER};
  5101. my $apiaudiostm = $hash->{HELPER}{APIAUDIOSTM};
  5102. my $apiaudiostmpath = $hash->{HELPER}{APIAUDIOSTMPATH};
  5103. my $apiaudiostmmaxver = $hash->{HELPER}{APIAUDIOSTMMAXVER};
  5104. my $apivideostms = $hash->{HELPER}{APIVIDEOSTMS};
  5105. my $apivideostmspath = $hash->{HELPER}{APIVIDEOSTMSPATH};
  5106. my $apivideostmsmaxver = $hash->{HELPER}{APIVIDEOSTMSMAXVER};
  5107. my $camid = $hash->{CAMID};
  5108. my $sid = $hash->{HELPER}{SID};
  5109. my $proto = $hash->{PROTOCOL};
  5110. my ($cause,$ret,$link,$audiolink,$devWlink,$wlhash,$alias,$wlalias);
  5111. # Kontext des SSCamSTRM-Devices speichern für SSCam_refresh
  5112. $hash->{HELPER}{STRMDEV} = $strmdev; # Name des aufrufenden SSCamSTRM-Devices
  5113. $hash->{HELPER}{STRMROOM} = $FW_room?$FW_room:""; # Raum aus dem das SSCamSTRM-Device die Funktion aufrief
  5114. $hash->{HELPER}{STRMDETAIL} = $FW_detail?$FW_detail:""; # Name des SSCamSTRM-Devices (wenn Detailansicht)
  5115. # Definition Tasten
  5116. my $imgblank = "<img src=\"$FW_ME/www/images/sscam/black_btn_CAMBLANK.png\">"; # nicht sichtbare Leertaste
  5117. my $cmdstop = "cmd=set $camname stopView"; # Stream deaktivieren
  5118. my $imgstop = "<img src=\"$FW_ME/www/images/default/remotecontrol/black_btn_POWEROFF3.png\">";
  5119. my $cmdhlsreact = "cmd=set $camname hlsreactivate"; # HLS Stream reaktivieren
  5120. my $imghlsreact = "<img src=\"$FW_ME/www/images/default/remotecontrol/black_btn_BACKDroid.png\">";
  5121. my $cmdmjpegrun = "cmd=set $camname runView live_fw"; # MJPEG Stream aktivieren
  5122. my $imgmjpegrun = "<img src=\"$FW_ME/www/images/sscam/black_btn_MJPEG.png\">";
  5123. my $cmdhlsrun = "cmd=set $camname runView live_fw_hls"; # HLS Stream aktivieren
  5124. my $imghlsrun = "<img src=\"$FW_ME/www/images/sscam/black_btn_HLS.png\">";
  5125. my $cmdlrirun = "cmd=set $camname runView lastrec_fw"; # Last Record IFrame
  5126. my $imglrirun = "<img src=\"$FW_ME/www/images/sscam/black_btn_LASTRECIFRAME.png\">";
  5127. my $cmdlh264run = "cmd=set $camname runView lastrec_fw_MPEG4/H.264"; # Last Record H.264
  5128. my $imglh264run = "<img src=\"$FW_ME/www/images/sscam/black_btn_LRECH264.png\">";
  5129. my $cmdlmjpegrun = "cmd=set $camname runView lastrec_fw_MJPEG"; # Last Record MJPEG
  5130. my $imglmjpegrun = "<img src=\"$FW_ME/www/images/sscam/black_btn_LRECMJPEG.png\">";
  5131. my $cmdlsnaprun = "cmd=set $camname runView lastsnap_fw STRM"; # Last SNAP
  5132. my $imglsnaprun = "<img src=\"$FW_ME/www/images/sscam/black_btn_LSNAP.png\">";
  5133. my $cmdrecendless = "cmd=set $camname on 0"; # Endlosaufnahme Start
  5134. my $imgrecendless = "<img src=\"$FW_ME/www/images/sscam/black_btn_RECSTART.png\">";
  5135. my $cmdrecstop = "cmd=set $camname off"; # Aufnahme Stop
  5136. my $imgrecstop = "<img src=\"$FW_ME/www/images/sscam/black_btn_RECSTOP.png\">";
  5137. my $cmddosnap = "cmd=set $camname snap STRM"; # Snapshot auslösen mit Kennzeichnung "by STRM-Device"
  5138. my $imgdosnap = "<img src=\"$FW_ME/www/images/sscam/black_btn_DOSNAP.png\">";
  5139. my $cmdrefresh = "cmd=set $camname refresh STRM"; # Refresh in SSCamSTRM-Devices
  5140. my $imgrefresh = "<img src=\"$FW_ME/www/images/default/Restart.png\">";
  5141. my $ha = AttrVal($camname, "htmlattr", 'width="500" height="325"'); # HTML Attribute der Cam
  5142. $ha = AttrVal($strmdev, "htmlattr", $ha); # htmlattr mit htmattr Streaming-Device übersteuern
  5143. my $StmKey = ReadingsVal($camname,"StmKey",undef);
  5144. $ret = "";
  5145. $ret .= '<table class="block wide internals">';
  5146. $ret .= '<tbody>';
  5147. $ret .= '<tr class="odd">';
  5148. if(!$StmKey || ReadingsVal($camname, "Availability", "") ne "enabled" || IsDisabled($camname)) {
  5149. # Ausgabe bei Fehler
  5150. my $cam = AttrVal($camname, "alias", $camname);
  5151. $cause = !$StmKey?"Cam $cam has no Reading \"StmKey\" set !":"Cam \"$cam\" is disabled";
  5152. $cause = "Cam \"$cam\" is disabled" if(IsDisabled($camname));
  5153. $ret .= "<td> <br> <b> $cause </b> <br><br></td>";
  5154. $ret .= '</tr>';
  5155. $ret .= '</tbody>';
  5156. $ret .= '</table>';
  5157. $ret .= '</div>';
  5158. return $ret;
  5159. }
  5160. if($fmt =~ /mjpeg/) {
  5161. if($apivideostmsmaxver) { # keine API "SYNO.SurveillanceStation.VideoStream" mehr ab API v2.8
  5162. $link = "$proto://$serveraddr:$serverport/webapi/$apivideostmspath?api=$apivideostms&version=$apivideostmsmaxver&method=Stream&cameraId=$camid&format=mjpeg&_sid=$sid";
  5163. } elsif ($hash->{HELPER}{STMKEYMJPEGHTTP}) {
  5164. $link = $hash->{HELPER}{STMKEYMJPEGHTTP};
  5165. }
  5166. if($apiaudiostmmaxver) { # keine API "SYNO.SurveillanceStation.AudioStream" mehr ab API v2.8
  5167. $audiolink = "$proto://$serveraddr:$serverport/webapi/$apiaudiostmpath?api=$apiaudiostm&version=$apiaudiostmmaxver&method=Stream&cameraId=$camid&_sid=$sid";
  5168. }
  5169. $ret .= "<td><img src=$link $ha><br>";
  5170. if(ReadingsVal($camname, "Record", "Stop") eq "Stop") {
  5171. # Aufnahmebutton endlos Start
  5172. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecendless')\">$imgrecendless </a>";
  5173. } else {
  5174. # Aufnahmebutton Stop
  5175. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecstop')\">$imgrecstop </a>";
  5176. }
  5177. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>";
  5178. $ret .= "</td>";
  5179. if(AttrVal($camname,"ptzPanel_use",1)) {
  5180. my $ptz_ret = SSCam_ptzpanel($camname);
  5181. if($ptz_ret) {
  5182. $ret .= "<td>$ptz_ret</td>";
  5183. }
  5184. }
  5185. if($audiolink && ReadingsVal($camname, "CamAudioType", "Unknown") !~ /Unknown/) {
  5186. $ret .= '</tr>';
  5187. $ret .= '<tr class="odd">';
  5188. $ret .= "<td><audio src=$audiolink preload='none' volume='0.5' controls>
  5189. Your browser does not support the audio element.
  5190. </audio>";
  5191. $ret .= "</td>";
  5192. }
  5193. } elsif($fmt =~ /generic/) {
  5194. my $htag = AttrVal($camname,"genericStrmHtmlTag","");
  5195. if( $htag =~ m/^\s*(.*)\s*$/s ) {
  5196. $htag = $1;
  5197. $htag =~ s/\$NAME/$camname/g;
  5198. $htag =~ s/\$HTMLATTR/$ha/g;
  5199. }
  5200. if(!$htag) {
  5201. $ret .= "<td> <br> <b> Set attribute \"genericStrmHtmlTag\" in device <a href=\"/fhem?detail=$camname\">$camname</a></b> <br><br></td>";
  5202. $ret .= '</tr>';
  5203. $ret .= '</tbody>';
  5204. $ret .= '</table>';
  5205. $ret .= '</div>';
  5206. return $ret;
  5207. }
  5208. $ret .= "<td>";
  5209. $ret .= "$htag";
  5210. $ret .= "<br>";
  5211. Log3($strmdev, 4, "$strmdev - generic Stream params:\n$htag");
  5212. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrefresh')\">$imgrefresh </a>";
  5213. $ret .= $imgblank;
  5214. if(ReadingsVal($camname, "Record", "Stop") eq "Stop") {
  5215. # Aufnahmebutton endlos Start
  5216. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecendless')\">$imgrecendless </a>";
  5217. } else {
  5218. # Aufnahmebutton Stop
  5219. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecstop')\">$imgrecstop </a>";
  5220. }
  5221. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>";
  5222. $ret .= "</td>";
  5223. if(AttrVal($camname,"ptzPanel_use",1)) {
  5224. my $ptz_ret = SSCam_ptzpanel($camname);
  5225. if($ptz_ret) {
  5226. $ret .= "<td>$ptz_ret</td>";
  5227. }
  5228. }
  5229. } elsif($fmt =~ /switched/) {
  5230. my $wltype = $hash->{HELPER}{WLTYPE};
  5231. $link = $hash->{HELPER}{LINK};
  5232. if($link && $wltype =~ /image|iframe|video|base64img|embed|hls/) {
  5233. if($wltype =~ /image/) {
  5234. $ret .= "<td><img src=$link $ha><br>";
  5235. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  5236. $ret .= $imgblank;
  5237. if($hash->{HELPER}{RUNVIEW} =~ /live_fw/) {
  5238. if(ReadingsVal($camname, "Record", "Stop") eq "Stop") {
  5239. # Aufnahmebutton endlos Start
  5240. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecendless')\">$imgrecendless </a>";
  5241. } else {
  5242. # Aufnahmebutton Stop
  5243. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecstop')\">$imgrecstop </a>";
  5244. }
  5245. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>";
  5246. }
  5247. $ret .= "</td>";
  5248. if(AttrVal($camname,"ptzPanel_use",1) && $hash->{HELPER}{RUNVIEW} =~ /live_fw/) {
  5249. my $ptz_ret = SSCam_ptzpanel($camname);
  5250. if($ptz_ret) {
  5251. $ret .= "<td>$ptz_ret</td>";
  5252. }
  5253. }
  5254. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($camname, "CamAudioType", "Unknown") !~ /Unknown/) {
  5255. $ret .= "</tr>";
  5256. $ret .= '<tr class="odd">';
  5257. $ret .= "<td><audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  5258. Your browser does not support the audio element.
  5259. </audio>";
  5260. }
  5261. } elsif ($wltype =~ /iframe/) {
  5262. $ret .= "<td><iframe src=$link $ha controls autoplay>
  5263. Iframes disabled
  5264. </iframe><br>";
  5265. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  5266. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrefresh')\">$imgrefresh </a>";
  5267. $ret .= "</td>";
  5268. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($camname, "CamAudioType", "Unknown") !~ /Unknown/) {
  5269. $ret .= '</tr>';
  5270. $ret .= '<tr class="odd">';
  5271. $ret .= "<td><audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  5272. Your browser does not support the audio element.
  5273. </audio>";
  5274. $ret .= "</td>";
  5275. }
  5276. } elsif ($wltype =~ /video/) {
  5277. $ret .= "<td><video $ha controls autoplay>
  5278. <source src=$link type=\"video/mp4\">
  5279. <source src=$link type=\"video/ogg\">
  5280. <source src=$link type=\"video/webm\">
  5281. Your browser does not support the video tag
  5282. </video><br>";
  5283. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  5284. $ret .= "</td>";
  5285. if($hash->{HELPER}{AUDIOLINK} && ReadingsVal($camname, "CamAudioType", "Unknown") !~ /Unknown/) {
  5286. $ret .= '</tr>';
  5287. $ret .= '<tr class="odd">';
  5288. $ret .= "<td><audio src=$hash->{HELPER}{AUDIOLINK} preload='none' volume='0.5' controls>
  5289. Your browser does not support the audio element.
  5290. </audio>";
  5291. $ret .= "</td>";
  5292. }
  5293. } elsif($wltype =~ /base64img/) {
  5294. $ret .= "<td><img src='data:image/jpeg;base64,$link' $ha><br>";
  5295. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  5296. $ret .= "</td>";
  5297. } elsif($wltype =~ /embed/) {
  5298. $ret .= "<td><embed src=$link $ha></td>";
  5299. } elsif($wltype =~ /hls/) {
  5300. $ret .= "<td><video $ha controls autoplay>
  5301. <source src=$link type=\"application/x-mpegURL\">
  5302. <source src=$link type=\"video/MP2T\">
  5303. Your browser does not support the video tag
  5304. </video><br>";
  5305. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdstop')\">$imgstop </a>";
  5306. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrefresh')\">$imgrefresh </a>";
  5307. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdhlsreact')\">$imghlsreact </a>";
  5308. $ret .= $imgblank;
  5309. if(ReadingsVal($camname, "Record", "Stop") eq "Stop") {
  5310. # Aufnahmebutton endlos Start
  5311. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecendless')\">$imgrecendless </a>";
  5312. } else {
  5313. # Aufnahmebutton Stop
  5314. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdrecstop')\">$imgrecstop </a>";
  5315. }
  5316. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>";
  5317. $ret .= "</td>";
  5318. if(AttrVal($camname,"ptzPanel_use",1)) {
  5319. my $ptz_ret = SSCam_ptzpanel($camname);
  5320. if($ptz_ret) {
  5321. $ret .= "<td>$ptz_ret</td>";
  5322. }
  5323. }
  5324. }
  5325. } else {
  5326. my $cam = AttrVal($camname, "alias", $camname);
  5327. $cause = "Playback cam \"$cam\" switched off";
  5328. $ret .= "<td> <br> <b> $cause </b> <br><br>";
  5329. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdmjpegrun')\">$imgmjpegrun </a>";
  5330. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdhlsrun')\">$imghlsrun </a>" if(SSCam_IsHLSCap($hash));
  5331. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdlrirun')\">$imglrirun </a>";
  5332. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdlh264run')\">$imglh264run </a>";
  5333. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdlmjpegrun')\">$imglmjpegrun </a>";
  5334. $ret .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmdlsnaprun')\">$imglsnaprun </a>";
  5335. $ret .= "</td>";
  5336. }
  5337. } else {
  5338. $cause = "Videoformat not supported";
  5339. $ret .= "<td> <br> <b> $cause </b> <br><br></td>";
  5340. }
  5341. $ret .= '</tr>';
  5342. $ret .= '</tbody>';
  5343. $ret .= '</table>';
  5344. Log3($strmdev, 4, "$strmdev - Link called: $link") if($link);
  5345. return $ret;
  5346. }
  5347. ###############################################################################
  5348. # Schnappschußgalerie zusammenstellen
  5349. ###############################################################################
  5350. sub composegallery ($;$$) {
  5351. my ($name,$strmdev,$model) = @_;
  5352. Log3($name, 1, "$name - SSCam will change the internal Code soon. Please delete your old Snapgallery-Device and create a new one by \"set $name createSnapGallery\" ");
  5353. my $htmlCode = SSCam_composegallery($name,$strmdev,$model);
  5354. return $htmlCode;
  5355. }
  5356. ###############################################################################
  5357. # Schnappschußgalerie zusammenstellen
  5358. ###############################################################################
  5359. sub SSCam_composegallery ($;$$) {
  5360. my ($name,$strmdev,$model) = @_;
  5361. my $hash = $defs{$name};
  5362. my $camname = $hash->{CAMNAME};
  5363. my $allsnaps = $hash->{HELPER}{".SNAPHASH"}; # = \%allsnaps
  5364. my $sgc = AttrVal($name,"snapGalleryColumns",3); # Anzahl der Images in einer Tabellenzeile
  5365. my $lss = ReadingsVal($name, "LastSnapTime", " "); # Zeitpunkt neueste Aufnahme
  5366. my $lang = AttrVal("global","language","EN"); # Systemsprache
  5367. my $limit = $hash->{HELPER}{SNAPLIMIT}; # abgerufene Anzahl Snaps
  5368. my $totalcnt = $hash->{HELPER}{TOTALCNT}; # totale Anzahl Snaps
  5369. $limit = $totalcnt if ($limit > $totalcnt); # wenn weniger Snaps vorhanden sind als $limit -> Text in Anzeige korrigieren
  5370. my $lupt = ((ReadingsTimestamp($name,"LastSnapTime"," ") gt ReadingsTimestamp($name,"LastUpdateTime"," "))
  5371. ? ReadingsTimestamp($name,"LastSnapTime"," ")
  5372. : ReadingsTimestamp($name,"LastUpdateTime"," ")); # letzte Aktualisierung
  5373. $lupt =~ s/ / \/ /;
  5374. my $cmddosnap = "cmd=set $name snap STRM"; # Snapshot auslösen mit Kennzeichnung "by STRM-Device"
  5375. my $imgdosnap = "<img src=\"$FW_ME/www/images/sscam/black_btn_DOSNAP.png\">";
  5376. my $ha = AttrVal($name, "snapGalleryHtmlAttr", AttrVal($name, "htmlattr", 'width="500" height="325"'));
  5377. # falls "SSCam_composegallery" durch ein SSCamSTRM-Device aufgerufen wird
  5378. my $devWlink = "";
  5379. if ($strmdev) {
  5380. my $wlha = AttrVal($strmdev, "htmlattr", undef);
  5381. $ha = (defined($wlha))?$wlha:$ha; # htmlattr vom SSCamSTRM-Device übernehmen falls von SSCamSTRM-Device aufgerufen und gesetzt
  5382. }
  5383. # wenn SSCamSTRM-device genutzt wird und attr "snapGalleryBoost" nicht gesetzt ist -> Warnung in Gallerie ausgeben
  5384. my $sgbnote = " ";
  5385. if($strmdev && !AttrVal($name,"snapGalleryBoost",0)) {
  5386. $sgbnote = "<b>CAUTION</b> - No snapshots can be retrieved. Please set the attribute \"snapGalleryBoost=1\" in device <a href=\"/fhem?detail=$name\">$name</a>" if ($lang eq "EN");
  5387. $sgbnote = "<b>ACHTUNG</b> - Es können keine Schnappschüsse abgerufen werden. Bitte setzen sie das Attribut \"snapGalleryBoost=1\" im Device <a href=\"/fhem?detail=$name\">$name</a>" if ($lang eq "DE");
  5388. }
  5389. my $header;
  5390. if ($lang eq "EN") {
  5391. $header = "Snapshots ($limit/$totalcnt) of camera <b>$camname</b> - newest Snapshot: $lss<br>";
  5392. $header .= " (Possibly another snapshots are available. Last recall: $lupt)<br>" if(AttrVal($name,"snapGalleryBoost",0));
  5393. } else {
  5394. $header = "Schnappschüsse ($limit/$totalcnt) von Kamera <b>$camname</b> - neueste Aufnahme: $lss <br>";
  5395. $header .= " (Eventuell sind neuere Aufnahmen verfügbar. Letzter Abruf: $lupt)<br>" if(AttrVal($name,"snapGalleryBoost",0));
  5396. }
  5397. $header .= $sgbnote;
  5398. my $gattr = (AttrVal($name,"snapGallerySize","Icon") eq "Full")?$ha:" ";
  5399. my @as = sort{$a <=>$b}keys%{$allsnaps};
  5400. # Ausgabetabelle erstellen
  5401. my ($htmlCode,$ct);
  5402. $htmlCode = "<html>";
  5403. $htmlCode .= sprintf("$devWlink <div class=\"makeTable wide\"; style=\"text-align:center\"> $header <br>");
  5404. $htmlCode .= "<table class=\"block wide internals\">";
  5405. $htmlCode .= "<tbody>";
  5406. $htmlCode .= "<tr class=\"odd\">";
  5407. my $cell = 1;
  5408. foreach my $key (@as) {
  5409. $ct = $allsnaps->{$key}{createdTm};
  5410. my $html = sprintf("<td>$ct<br /> <img $gattr src=\"data:image/jpeg;base64,$allsnaps->{$key}{imageData}\" /> </td>" );
  5411. $cell++;
  5412. if ( $cell == $sgc+1 ) {
  5413. $htmlCode .= $html;
  5414. $htmlCode .= "</tr>";
  5415. $htmlCode .= "<tr class=\"odd\">";
  5416. $cell = 1;
  5417. } else {
  5418. $htmlCode .= $html;
  5419. }
  5420. }
  5421. if ( $cell == 2 ) {
  5422. $htmlCode .= "<td> </td>";
  5423. }
  5424. $htmlCode .= "</tr>";
  5425. $htmlCode .= "</tbody>";
  5426. $htmlCode .= "</table>";
  5427. $htmlCode .= "</div>";
  5428. $htmlCode .= "<a onClick=\"FW_cmd('$FW_ME$FW_subdir?XHR=1&$cmddosnap')\">$imgdosnap </a>" if($strmdev);
  5429. $htmlCode .= "</html>";
  5430. return $htmlCode;
  5431. }
  5432. ##############################################################################
  5433. # Auflösung Errorcodes bei Login / Logout
  5434. ##############################################################################
  5435. sub SSCam_experrorauth {
  5436. # Übernahmewerte sind $hash, $errorcode
  5437. my ($hash,@errorcode) = @_;
  5438. my $device = $hash->{NAME};
  5439. my $errorcode = shift @errorcode;
  5440. my $error;
  5441. unless (exists($SSCam_errauthlist{"$errorcode"})) {$error = "Message of errorcode \"$errorcode\" not found. Please turn to Synology Web API-Guide."; return ($error);}
  5442. # Fehlertext aus Hash-Tabelle %errorauthlist ermitteln
  5443. $error = $SSCam_errauthlist{"$errorcode"};
  5444. return ($error);
  5445. }
  5446. ##############################################################################
  5447. # Auflösung Errorcodes SVS API
  5448. sub SSCam_experror {
  5449. # Übernahmewerte sind $hash, $errorcode
  5450. my ($hash,@errorcode) = @_;
  5451. my $device = $hash->{NAME};
  5452. my $errorcode = shift @errorcode;
  5453. my $error;
  5454. unless (exists($SSCam_errlist{"$errorcode"})) {$error = "Message of errorcode $errorcode not found. Please turn to Synology Web API-Guide."; return ($error);}
  5455. # Fehlertext aus Hash-Tabelle %errorlist ermitteln
  5456. $error = $SSCam_errlist{"$errorcode"};
  5457. return ($error);
  5458. }
  5459. 1;
  5460. =pod
  5461. =item summary Camera module to control the Synology Surveillance Station
  5462. =item summary_DE Kamera-Modul für die Steuerung der Synology Surveillance Station
  5463. =begin html
  5464. <a name="SSCam"></a>
  5465. <h3>SSCam</h3>
  5466. <ul>
  5467. Using this Module you are able to operate cameras which are defined in Synology Surveillance Station (SVS) and execute
  5468. functions of the SVS. It is based on the SVS API and supports the SVS version 7 and above.<br>
  5469. At present the following functions are available: <br><br>
  5470. <ul>
  5471. <ul>
  5472. <li>Start a Recording</li>
  5473. <li>Stop a Recording (using command or automatically after the &lt;RecordTime&gt; period</li>
  5474. <li>Trigger a Snapshot </li>
  5475. <li>Deaktivate a Camera in Synology Surveillance Station</li>
  5476. <li>Activate a Camera in Synology Surveillance Station</li>
  5477. <li>Control of the exposure modes day, night and automatic </li>
  5478. <li>switchover the motion detection by camera, by SVS or deactivate it </li>
  5479. <li>control of motion detection parameters sensitivity, threshold, object size and percentage for release </li>
  5480. <li>Retrieval of Camera Properties (also by Polling) as well as informations about the installed SVS-package</li>
  5481. <li>Move to a predefined Preset-position (at PTZ-cameras) </li>
  5482. <li>Start a predefined Patrol (at PTZ-cameras) </li>
  5483. <li>Positioning of PTZ-cameras to absolute X/Y-coordinates </li>
  5484. <li>continuous moving of PTZ-camera lense </li>
  5485. <li>trigger of external events 1-10 (action rules in SVS) </li>
  5486. <li>start and stop of camera livestreams incl. audio replay, show the last recording and snapshot </li>
  5487. <li>fetch of livestream-Url's with key (login not needed in that case) </li>
  5488. <li>playback of last recording and playback the last snapshot </li>
  5489. <li>switch the Surveillance Station HomeMode on/off and retrieve the HomeModeState </li>
  5490. <li>show the stored credentials of a device </li>
  5491. <li>fetch the Surveillance Station Logs, exploit the newest entry as reading </li>
  5492. <li>create a gallery of the last 1-10 snapshots (as Popup or in a discrete device) </li>
  5493. <li>Start/Stop Object Tracking (only supported PTZ-Cams with this capability) </li>
  5494. <li>set/delete a Preset (at PTZ-cameras) </li>
  5495. <li>set a Preset or current position as Home Preset (at PTZ-cameras) </li>
  5496. <li>provides a panel for camera control (at PTZ-cameras) </li>
  5497. <li>create different types of discrete Streaming-Devices (createStreamDev) </li>
  5498. <li>Activation / Deactivation of a camera integrated PIR sensor </li>
  5499. </ul>
  5500. </ul>
  5501. <br>
  5502. The recordings and snapshots will be stored in Synology Surveillance Station (SVS) and are managed like the other (normal) recordings / snapshots defined by Surveillance Station rules.<br>
  5503. For example the recordings are stored for a defined time in Surveillance Station and will be deleted after that period.<br><br>
  5504. If you like to discuss or help to improve this module please use FHEM-Forum with link: <br>
  5505. <a href="http://forum.fhem.de/index.php/topic,45671.msg374390.html#msg374390">49_SSCam: Fragen, Hinweise, Neuigkeiten und mehr rund um dieses Modul</a>.<br><br>
  5506. <b> Prerequisites </b> <br><br>
  5507. This module uses the Perl-module JSON. <br>
  5508. On Debian-Linux based systems this module can be installed by: <br><br>
  5509. <code>sudo apt-get install libjson-perl</code> <br><br>
  5510. SSCam is completely using the nonblocking functions of HttpUtils respectively HttpUtils_NonblockingGet. <br>
  5511. In DSM respectively in Synology Surveillance Station an User has to be created. The login credentials are needed later when using a set-command to assign the login-data to a device. <br>
  5512. Further informations could be find among <a href="#SSCam_Credentials">Credentials</a>. <br><br>
  5513. Overview which Perl-modules SSCam is using: <br><br>
  5514. JSON <br>
  5515. Data::Dumper <br>
  5516. MIME::Base64 <br>
  5517. Time::HiRes <br>
  5518. HttpUtils (FHEM-module) <br><br>
  5519. <a name="SSCamdefine"></a>
  5520. <b>Define</b>
  5521. <ul>
  5522. <br>
  5523. There is a distinction between the definition of a camera-device and the definition of a Surveillance Station (SVS)
  5524. device, that means the application on the discstation itself.
  5525. Dependend on the type of defined device the internal MODEL will be set to "&lt;vendor&gt; - &lt;camera type&gt;"
  5526. or "SVS" and a proper subset of the described set/get-commands are assigned to the device. <br>
  5527. The scope of application of set/get-commands is denoted to every particular command (valid for CAM, SVS, CAM/SVS).
  5528. <br><br>
  5529. A <b>camera</b> is defined by: <br><br>
  5530. <ul>
  5531. <b><code>define &lt;Name&gt; SSCAM &lt;camera name in SVS&gt; &lt;ServerAddr&gt; [Port] [Protocol]</code></b> <br><br>
  5532. </ul>
  5533. At first the devices have to be set up and has to be operable in Synology Surveillance Station 7.0 and above. <br><br>
  5534. A <b>SVS-device</b> to control functions of the Surveillance Station (SVS) is defined by: <br><br>
  5535. <ul>
  5536. <b><code>define &lt;Name&gt; SSCAM SVS &lt;ServerAddr&gt; [Port] [Protocol] </code></b> <br><br>
  5537. </ul>
  5538. In that case the term &lt;camera name in SVS&gt; become replaced by <b>SVS</b> only. <br><br>
  5539. The Modul SSCam ist based on functions of Synology Surveillance Station API. <br><br>
  5540. The parameters are in detail:
  5541. <br>
  5542. <br>
  5543. <table>
  5544. <colgroup> <col width=15%> <col width=85%> </colgroup>
  5545. <tr><td><b>Name</b> </td><td>the name of the new device to use in FHEM</td></tr>
  5546. <tr><td><b>Cameraname</b> </td><td>camera name as defined in Synology Surveillance Station if camera-device, "SVS" if SVS-Device. Spaces are not allowed in camera name. </td></tr>
  5547. <tr><td><b>ServerAddr</b> </td><td>IP-address of Synology Surveillance Station Host. <b>Note:</b> avoid using hostnames because of DNS-Calls are not unblocking in FHEM </td></tr>
  5548. <tr><td><b>Port</b> </td><td>optional - the port of synology disc station. If not set, the default "5000" is used</td></tr>
  5549. <tr><td><b>Protocol</b> </td><td>optional - the protocol (http or https) to access the synology disc station. If not set, the default "http" is used</td></tr>
  5550. </table>
  5551. <br><br>
  5552. <b>Examples:</b>
  5553. <pre>
  5554. <code>define CamCP SSCAM Carport 192.168.2.20 [5000] [http]</code>
  5555. <code>define CamCP SSCAM Carport 192.168.2.20 [5001] [https]</code>
  5556. # creates a new camera device CamCP
  5557. <code>define DS1 SSCAM SVS 192.168.2.20 [5000] [http]</code>
  5558. <code>define DS1 SSCAM SVS 192.168.2.20 [5001] [https]</code>
  5559. # creares a new SVS device DS1
  5560. </pre>
  5561. When a new Camera is defined, as a start the recordingtime of 15 seconds will be assigned to the device.<br>
  5562. Using the <a href="#SSCamattr">attribute</a> "rectime" you can adapt the recordingtime for every camera individually.<br>
  5563. The value of "0" for rectime will lead to an endless recording which has to be stopped by a "set &lt;name&gt; off" command.<br>
  5564. Due to a Log-Entry with a hint to that circumstance will be written. <br><br>
  5565. If the <a href="#SSCamattr">attribute</a> "rectime" would be deleted again, the default-value for recording-time (15s) become active.<br><br>
  5566. With <a href="#SSCamset">command</a> <b>"set &lt;name&gt; on [rectime]"</b> a temporary recordingtime is determinded which would overwrite the dafault-value of recordingtime <br>
  5567. and the attribute "rectime" (if it is set) uniquely. <br><br>
  5568. In that case the command <b>"set &lt;name&gt; on 0"</b> leads also to an endless recording as well.<br><br>
  5569. If you have specified a pre-recording time in SVS it will be considered too. <br><br>
  5570. If the module recognizes the defined camera as a PTZ-device (Reading "DeviceType = PTZ"), then a control panel is
  5571. created automatically in the detal view. This panel requires SVS >= 7.1. The properties and the behave of the
  5572. panel can be affected by <a href="#SSCamattr">attributes</a> "ptzPanel_.*". <br>
  5573. Please see also <a href="#SSCamset">command</a> <b>"set &lt;name&gt; createPTZcontrol"</b> in this context.
  5574. <br><br><br>
  5575. </ul>
  5576. <a name="SSCam_Credentials"></a>
  5577. <b>Credentials </b><br><br>
  5578. <ul>
  5579. After a camera-device is defined, firstly it is needed to save the credentials. This will be done with command:
  5580. <pre>
  5581. set &lt;name&gt; credentials &lt;username&gt; &lt;password&gt;
  5582. </pre>
  5583. The password length has a maximum of 20 characters. <br>
  5584. The operator can, dependend on what functions are planned to execute, create an user in DSM respectively in Synology
  5585. Surveillance Station as well. <br>
  5586. If the user is member of admin-group, he has access to all module functions. Without this membership the user can only
  5587. execute functions with lower need of rights. <br>
  5588. The required minimum rights to execute functions are listed in a table further down. <br>
  5589. Alternatively to DSM-user a user created in SVS can be used. Also in that case a user of type "manager" has the right to
  5590. execute all functions, <br>
  5591. whereat the access to particular cameras can be restricted by the privilege profile (please see help function in SVS for
  5592. details). <br>
  5593. As best practice it is proposed to create an user in DSM as well as in SVS too: <br><br>
  5594. <ul>
  5595. <li>DSM-User as member of admin group: unrestricted test of all module functions -&gt; session: DSM </li>
  5596. <li>SVS-User as Manager or observer: adjusted privilege profile -&gt; session: SurveillanceStation </li>
  5597. </ul>
  5598. <br>
  5599. Using the <a href="#SSCamattr">Attribute</a> "session" can be selected, if the session should be established to DSM or the
  5600. SVS instead. Further informations about user management in SVS are available by execute
  5601. "get &lt;name&gt; versionNotes 5".<br>
  5602. If the session will be established to DSM, SVS Web-API methods are available as well as further API methods of other API's
  5603. what possibly needed for processing. <br><br>
  5604. After device definition the default is "login to DSM", that means credentials with admin rights can be used to test all camera-functions firstly. <br>
  5605. After this the credentials can be switched to a SVS-session with a restricted privilege profile as needed on dependency what module functions are want to be executed. <br><br>
  5606. The following list shows the <b>minimum rights</b> that the particular module function needs. <br><br>
  5607. <ul>
  5608. <table>
  5609. <colgroup> <col width=20%> <col width=80%> </colgroup>
  5610. <tr><td><li>set ... on </td><td> session: ServeillanceStation - observer with enhanced privilege "manual recording" </li></td></tr>
  5611. <tr><td><li>set ... off </td><td> session: ServeillanceStation - observer with enhanced privilege "manual recording" </li></td></tr>
  5612. <tr><td><li>set ... snap </td><td> session: ServeillanceStation - observer </li></td></tr>
  5613. <tr><td><li>set ... delPreset </td><td> session: ServeillanceStation - observer </li></td></tr>
  5614. <tr><td><li>set ... disable </td><td> session: ServeillanceStation - manager </li></td></tr>
  5615. <tr><td><li>set ... enable </td><td> session: ServeillanceStation - manager </li></td></tr>
  5616. <tr><td><li>set ... expmode </td><td> session: ServeillanceStation - manager </li></td></tr>
  5617. <tr><td><li>set ... extevent </td><td> session: DSM - user as member of admin-group </li></td></tr>
  5618. <tr><td><li>set ... goPreset </td><td> session: ServeillanceStation - observer with privilege objective control of camera </li></td></tr>
  5619. <tr><td><li>set ... homeMode </td><td> ssession: ServeillanceStation - observer with privilege Home Mode switch (valid for <b>SVS-device ! </b>) </li></td></tr>
  5620. <tr><td><li>set ... motdetsc </td><td> session: ServeillanceStation - manager </li></td></tr>
  5621. <tr><td><li>set ... runPatrol </td><td> session: ServeillanceStation - observer with privilege objective control of camera </li></td></tr>
  5622. <tr><td><li>set ... goAbsPTZ </td><td> session: ServeillanceStation - observer with privilege objective control of camera </li></td></tr>
  5623. <tr><td><li>set ... move </td><td> session: ServeillanceStation - observer with privilege objective control of camera </li></td></tr>
  5624. <tr><td><li>set ... runView </td><td> session: ServeillanceStation - observer with privilege liveview of camera </li></td></tr>
  5625. <tr><td><li>set ... setHome </td><td> session: ServeillanceStation - observer </li></td></tr>
  5626. <tr><td><li>set ... setPreset </td><td> session: ServeillanceStation - observer </li></td></tr>
  5627. <tr><td><li>set ... snap </td><td> session: ServeillanceStation - observer </li></td></tr>
  5628. <tr><td><li>set ... snapGallery </td><td> session: ServeillanceStation - observer </li></td></tr>
  5629. <tr><td><li>set ... stopView </td><td> - </li></td></tr>
  5630. <tr><td><li>set ... credentials </td><td> - </li></td></tr>
  5631. <tr><td><li>get ... caminfo[all] </td><td> session: ServeillanceStation - observer </li></td></tr>
  5632. <tr><td><li>get ... eventlist </td><td> session: ServeillanceStation - observer </li></td></tr>
  5633. <tr><td><li>get ... listLog </td><td> session: ServeillanceStation - observer </li></td></tr>
  5634. <tr><td><li>get ... listPresets </td><td> session: ServeillanceStation - observer </li></td></tr>
  5635. <tr><td><li>get ... scanVirgin </td><td> session: ServeillanceStation - observer </li></td></tr>
  5636. <tr><td><li>get ... svsinfo </td><td> session: ServeillanceStation - observer </li></td></tr>
  5637. <tr><td><li>get ... snapfileinfo </td><td> session: ServeillanceStation - observer </li></td></tr>
  5638. <tr><td><li>get ... snapinfo </td><td> session: ServeillanceStation - observer </li></td></tr>
  5639. <tr><td><li>get ... stmUrlPath </td><td> session: ServeillanceStation - observer </li></td></tr>
  5640. </table>
  5641. </ul>
  5642. <br><br>
  5643. </ul>
  5644. <a name="SSCam_HTTPTimeout"></a>
  5645. <b>HTTP-Timeout Settings</b><br><br>
  5646. <ul>
  5647. All functions of SSCam use HTTP-calls to SVS Web API. <br>
  5648. The default-value of HTTP-Timeout amounts 4 seconds. You can set the <a href="#SSCamattr">attribute</a> "httptimeout" > 0 to adjust the value as needed in your technical environment. <br>
  5649. </ul>
  5650. <br><br><br>
  5651. <a name="SSCamset"></a>
  5652. <b>Set </b>
  5653. <ul>
  5654. <br>
  5655. The specified set-commands are available for CAM/SVS-devices or only valid for CAM-devices or rather for SVS-Devices.
  5656. They can be selected in the drop-down-menu of the particular device. <br><br>
  5657. <ul>
  5658. <a name="SSCamcreateStreamDev"></a>
  5659. <li><b> set &lt;name&gt; createStreamDev [generic | mjpeg | switched] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5660. A separate Streaming-Device (type SSCamSTRM) will be created. This device can be used as a discrete device in a dashboard for example.
  5661. The current room of the parent camera device is assigned to the new device if it is set there.
  5662. <br><br>
  5663. <ul>
  5664. <table>
  5665. <colgroup> <col width=10%> <col width=90%> </colgroup>
  5666. <tr><td>generic </td><td>- the streaming device playback a content determined by attribute "genericStrmHtmlTag" </td></tr>
  5667. <tr><td>mjpeg </td><td>- the streaming device playback a permanent MJPEG video stream (Streamkey method) </td></tr>
  5668. <tr><td>switched </td><td>- playback of different streaming types. Buttons for mode control are provided. </td></tr>
  5669. </table>
  5670. </ul>
  5671. <br><br>
  5672. You can control the design with HTML tags in <a href="#SSCamattr">attribute</a> "htmlattr" of the camera device or by the
  5673. specific attributes of the SSCamSTRM-device itself. <br>
  5674. In "switched"-Devices are buttons provided for mode control. <br>
  5675. If HLS (HTTP Live Streaming) is used in Streaming-Device of type "switched", then the camera has to be set to video format
  5676. H.264 in the Synology Surveillance Station and the SVS-Version has to support the HLS format.
  5677. Therefore the selection button of HLS is only provided by the Streaming-Device if the Reading "CamStreamFormat" contains
  5678. "HLS". <br>
  5679. HTTP Live Streaming is currently only available on Mac Safari or modern mobile iOS/Android devices. <br>
  5680. In devices of type "switched" buttons for controlling the media type to start are provided. <br>
  5681. A Streaming-Device of type "generic" needs the complete definition of HTML-Tags by the attribute "genericStrmHtmlTag".
  5682. These tags specify the content to playback. <br><br>
  5683. <ul>
  5684. <b>Example:</b>
  5685. <pre>
  5686. attr &lt;name&gt; genericStrmHtmlTag &lt;video $HTMLATTR controls autoplay&gt;
  5687. &lt;source src='http://192.168.2.10:32000/$NAME.m3u8' type='application/x-mpegURL'&gt;
  5688. &lt;/video&gt;
  5689. </pre>
  5690. The variables $HTMLATTR, $NAME are placeholder and absorb the attribute "htmlattr" (if set) respectively the SSCam-Devicename.
  5691. </ul>
  5692. </ul>
  5693. <br><br>
  5694. <ul>
  5695. <li><b> set &lt;name&gt; createPTZcontrol </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for PTZ-CAM)</li> <br>
  5696. A separate PTZ-control panel will be created (type SSCamSTRM). The current room of the parent camera device is
  5697. assigned if it is set there.
  5698. With the "ptzPanel_.*"-<a href="#SSCamattr">attributes</a> or respectively the specific attributes of the SSCamSTRM-device
  5699. the properties of the control panel can be affected. <br>
  5700. <br><br>
  5701. </ul>
  5702. <ul>
  5703. <li><b> set &lt;name&gt; createSnapGallery </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5704. A snapshot gallery will be created as a separate device (type SSCamSTRM). The device will be provided in
  5705. room "SnapGallery".
  5706. With the "snapGallery..."-<a href="#SSCamattr">attributes</a> respectively the specific attributes of the SSCamSTRM-device
  5707. you are able to manipulate the properties of the new snapshot gallery device. <br>
  5708. <br><br>
  5709. </ul>
  5710. <ul>
  5711. <li><b> set &lt;name&gt; credentials &lt;username&gt; &lt;password&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM/SVS)</li> <br>
  5712. set username / password combination for access the Synology Surveillance Station.
  5713. See <a href="#SSCam_Credentials">Credentials</a><br> for further informations.
  5714. <br><br>
  5715. </ul>
  5716. <ul>
  5717. <li><b> set &lt;name&gt; delPreset &lt;PresetName&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for PTZ-CAM)</li> <br>
  5718. Deletes a preset "&lt;PresetName&gt;". In FHEMWEB a drop-down list with current available presets is provieded.
  5719. </ul>
  5720. <br><br>
  5721. <ul>
  5722. <li><b> set &lt;name&gt; [enable|disable] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5723. For <b>deactivating / activating</b> a list of cameras or all cameras by Regex-expression, subsequent two
  5724. examples using "at":
  5725. <pre>
  5726. define a13 at 21:46 set CamCP1,CamFL,CamHE1,CamTER disable (enable)
  5727. define a14 at 21:46 set Cam.* disable (enable)
  5728. </pre>
  5729. A bit more convenient is it to use a dummy-device for enable/disable all available cameras in Surveillance Station.<br>
  5730. At first the Dummy will be created.
  5731. <pre>
  5732. define allcams dummy
  5733. attr allcams eventMap on:enable off:disable
  5734. attr allcams room Cams
  5735. attr allcams webCmd enable:disable
  5736. </pre>
  5737. With combination of two created notifies, respectively one for "enable" and one for "diasble", you are able to switch all cameras into "enable" or "disable" state at the same time if you set the dummy to "enable" or "disable".
  5738. <pre>
  5739. define all_cams_disable notify allcams:.*off set CamCP1,CamFL,CamHE1,CamTER disable
  5740. attr all_cams_disable room Cams
  5741. define all_cams_enable notify allcams:on set CamCP1,CamFL,CamHE1,CamTER enable
  5742. attr all_cams_enable room Cams
  5743. </pre>
  5744. </ul>
  5745. <br><br>
  5746. <ul>
  5747. <li><b> set &lt;name&gt; expmode [day|night|auto] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5748. With this command you are able to control the exposure mode and can set it to day, night or automatic mode.
  5749. Thereby, for example, the behavior of camera LED's will be suitable controlled.
  5750. The successful switch will be reported by the reading CamExposureMode (command "get ... caminfoall"). <br><br>
  5751. <b> Note: </b><br>
  5752. The successfully execution of this function depends on if SVS supports that functionality of the connected camera.
  5753. Is the field for the Day/Night-mode shown greyed in SVS -&gt; IP-camera -&gt; optimization -&gt; exposure mode, this function will be probably unsupported.
  5754. </ul>
  5755. <br><br>
  5756. <ul>
  5757. <li><b> set &lt;name&gt; extevent [ 1-10 ] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for SVS)</li> <br>
  5758. This command triggers an external event (1-10) in SVS.
  5759. The actions which will are used have to be defined in the actionrule editor of SVS at first. There are the events 1-10 possible.
  5760. In the message application of SVS you may select Email, SMS or Mobil (DS-Cam) messages to release if an external event has been triggerd.
  5761. Further informations can be found in the online help of the actionrule editor.
  5762. The used user needs to be a member of the admin-group and DSM-session is needed too.
  5763. </ul>
  5764. <br><br>
  5765. <ul>
  5766. <li><b> set &lt;name&gt; goAbsPTZ [ X Y | up | down | left | right ] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5767. This command can be used to move a PTZ-camera to an arbitrary absolute X/Y-coordinate, or to absolute position using up/down/left/right.
  5768. The option is only available for cameras which are having the Reading "CapPTZAbs=true". The property of a camera can be requested with "get &lt;name&gt; caminfoall" .
  5769. <br><br>
  5770. Example for a control to absolute X/Y-coordinates: <br>
  5771. <pre>
  5772. set &lt;name&gt; goAbsPTZ 120 450
  5773. </pre>
  5774. In this example the camera lense moves to position X=120 und Y=450. <br>
  5775. The valuation is:
  5776. <pre>
  5777. X = 0 - 640 (0 - 319 moves lense left, 321 - 640 moves lense right, 320 don't move lense)
  5778. Y = 0 - 480 (0 - 239 moves lense down, 241 - 480 moves lense up, 240 don't move lense)
  5779. </pre>
  5780. The lense can be moved in smallest steps to very large steps into the desired direction.
  5781. If necessary the procedure has to be repeated to bring the lense into the desired position. <br><br>
  5782. If the motion should be done with the largest possible increment the following command can be used for simplification:
  5783. <pre>
  5784. set &lt;name&gt; goAbsPTZ up [down|left|right]
  5785. </pre>
  5786. In this case the lense will be moved with largest possible increment into the given absolute position.
  5787. Also in this case the procedure has to be repeated to bring the lense into the desired position if necessary.
  5788. </ul>
  5789. <br><br>
  5790. <ul>
  5791. <li><b> set &lt;name&gt; goPreset &lt;Preset&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5792. Using this command you can move PTZ-cameras to a predefined position. <br>
  5793. The Preset-positions have to be defined first of all in the Synology Surveillance Station. This usually happens in the PTZ-control of IP-camera setup in SVS.
  5794. The Presets will be read ito FHEM with command "get &lt;name&gt; caminfoall" (happens automatically when FHEM restarts). The import process can be repeated regular by camera polling.
  5795. A long polling interval is recommendable in this case because of the Presets are only will be changed if the user change it in the IP-camera setup itself.
  5796. <br><br>
  5797. Here it is an example of a PTZ-control depended on IR-motiondetector event:
  5798. <pre>
  5799. define CamFL.Preset.Wandschrank notify MelderTER:on.* set CamFL goPreset Wandschrank, ;; define CamFL.Preset.record at +00:00:10 set CamFL on 5 ;;;; define s3 at +*{3}00:00:05 set CamFL snap ;; define CamFL.Preset.back at +00:00:30 set CamFL goPreset Home
  5800. </pre>
  5801. Operating Mode: <br>
  5802. The IR-motiondetector registers a motion. Hereupon the camera "CamFL" moves to Preset-posion "Wandschrank". A recording with the length of 5 seconds starts 10 seconds later.
  5803. Because of the prerecording time of the camera is set to 10 seconds (cf. Reading "CamPreRecTime"), the effectice recording starts when the camera move begins. <br>
  5804. When the recording starts 3 snapshots with an interval of 5 seconds will be taken as well. <br>
  5805. After a time of 30 seconds in position "Wandschrank" the camera moves back to postion "Home". <br><br>
  5806. An extract of the log illustrates the process:
  5807. <pre>
  5808. 2016.02.04 15:02:14 2: CamFL - Camera Flur_Vorderhaus has moved to position "Wandschrank"
  5809. 2016.02.04 15:02:24 2: CamFL - Camera Flur_Vorderhaus Recording with Recordtime 5s started
  5810. 2016.02.04 15:02:29 2: CamFL - Snapshot of Camera Flur_Vorderhaus has been done successfully
  5811. 2016.02.04 15:02:30 2: CamFL - Camera Flur_Vorderhaus Recording stopped
  5812. 2016.02.04 15:02:34 2: CamFL - Snapshot of Camera Flur_Vorderhaus has been done successfully
  5813. 2016.02.04 15:02:39 2: CamFL - Snapshot of Camera Flur_Vorderhaus has been done successfully
  5814. 2016.02.04 15:02:44 2: CamFL - Camera Flur_Vorderhaus has moved to position "Home"
  5815. </pre>
  5816. </ul>
  5817. <br><br>
  5818. <ul>
  5819. <li><b> set &lt;name&gt; homeMode [on|off] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for SVS)</li> <br>
  5820. Switch the HomeMode of the Surveillance Station on or off.
  5821. Further informations about HomeMode you can find in the <a href="https://www.synology.com/en-global/knowledgebase/Surveillance/help/SurveillanceStation/home_mode">Synology Onlinehelp</a>.
  5822. <br><br>
  5823. </ul>
  5824. <ul>
  5825. <li><b> set &lt;name&gt; motdetsc [camera|SVS|disable] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5826. The command "motdetsc" (stands for "motion detection source") switchover the motion detection to the desired mode.
  5827. If motion detection will be done by camera / SVS without any parameters, the original camera motion detection settings are kept.
  5828. The successful execution of that opreration one can retrace by the state in SVS -&gt; IP-camera -&gt; event detection -&gt; motion. <br><br>
  5829. For the motion detection further parameter can be specified. The available options for motion detection by SVS are "sensitivity" and "threshold". <br><br>
  5830. <ul>
  5831. <table>
  5832. <colgroup> <col width=50%> <col width=50%> </colgroup>
  5833. <tr><td>set &lt;name&gt; motdetsc SVS [sensitivity] [threshold] </td><td># command pattern </td></tr>
  5834. <tr><td>set &lt;name&gt; motdetsc SVS 91 30 </td><td># set the sensitivity to 91 and threshold to 30 </td></tr>
  5835. <tr><td>set &lt;name&gt; motdetsc SVS 0 40 </td><td># keep the old value of sensitivity, set threshold to 40 </td></tr>
  5836. <tr><td>set &lt;name&gt; motdetsc SVS 15 </td><td># set the sensitivity to 15, threshold keep unchanged </td></tr>
  5837. </table>
  5838. </ul>
  5839. <br><br>
  5840. If the motion detection is used by camera, there are the options "sensitivity", "object size", "percentage for release" available. <br><br>
  5841. <ul>
  5842. <table>
  5843. <colgroup> <col width=50%> <col width=50%> </colgroup>
  5844. <tr><td>set &lt;name&gt; motdetsc camera [sensitivity] [threshold] [percentage] </td><td># command pattern </td></tr>
  5845. <tr><td>set &lt;name&gt; motdetsc camera 89 0 20 </td><td># set the sensitivity to 89, percentage to 20 </td></tr>
  5846. <tr><td>set &lt;name&gt; motdetsc camera 0 40 10 </td><td># keep old value for sensitivity, set threshold to 40, percentage to 10 </td></tr>
  5847. <tr><td>set &lt;name&gt; motdetsc camera 30 </td><td># set the sensitivity to 30, other values keep unchanged </td></tr>
  5848. </table>
  5849. </ul>
  5850. <br><br>
  5851. Please consider always the sequence of parameters. Unwanted options have to be set to "0" if further options which have to be changed are follow (see example above).
  5852. The numerical values are between 1 - 99 (except special case "0"). <br><br>
  5853. The each available options are dependend of camera type respectively the supported functions by SVS. Only the options can be used they are available in
  5854. SVS -&gt; edit camera -&gt; motion detection. Further informations please read in SVS online help. <br><br>
  5855. With the command "get &lt;name&gt; caminfoall" the <a href="#SSCamreadings">Reading</a> "CamMotDetSc" also will be updated which documents the current setup of motion detection.
  5856. Only the parameters and parameter values supported by SVS at present will be shown. The camera itself may offer further options to adjust. <br><br>
  5857. Example:
  5858. <pre>
  5859. CamMotDetSc SVS, sensitivity: 76, threshold: 55
  5860. </pre>
  5861. </ul>
  5862. <br><br>
  5863. <ul>
  5864. <li><b> set &lt;name&gt; move [ right | up | down | left | dir_X ] [Sekunden] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM up to SVS version 7.1)</li>
  5865. <b> set &lt;name&gt; move [ right | upright | up | upleft | left | downleft | down | downright ] [Sekunden] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM and SVS Version 7.2 and above) <br><br>
  5866. With this command a continuous move of a PTZ-camera will be started. In addition to the four basic directions up/down/left/right is it possible to use angular dimensions
  5867. "dir_X". The grain size of graduation depends on properties of the camera and can be identified by the Reading "CapPTZDirections". <br><br>
  5868. The radian measure of 360 degrees will be devided by the value of "CapPTZDirections" and describes the move drections starting with "0=right" counterclockwise.
  5869. That means, if a camera Reading is "CapPTZDirections = 8" it starts with dir_0 = right, dir_2 = top, dir_4 = left, dir_6 = bottom and respectively dir_1, dir_3, dir_5 and dir_7
  5870. the appropriate directions between. The possible moving directions of cameras with "CapPTZDirections = 32" are correspondingly divided into smaller sections. <br><br>
  5871. In opposite to the "set &lt;name&gt; goAbsPTZ"-command starts "set &lt;name&gt; move" a continuous move until a stop-command will be received.
  5872. The stop-command will be generated after the optional assignable time of [seconds]. If that retention period wouldn't be set by the command, a time of 1 second will be set implicit. <br><br>
  5873. Examples: <br>
  5874. <pre>
  5875. set &lt;name&gt; move up 0.5 : moves PTZ 0,5 Sek. (plus processing time) to the top
  5876. set &lt;name&gt; move dir_1 1.5 : moves PTZ 1,5 Sek. (plus processing time) to top-right
  5877. set &lt;name&gt; move dir_20 0.7 : moves PTZ 1,5 Sek. (plus processing time) to left-bottom ("CapPTZDirections = 32)"
  5878. </pre>
  5879. </ul>
  5880. <br><br>
  5881. <ul>
  5882. <li><b>set &lt;name&gt; [on [&lt;rectime&gt;] | off] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5883. The command "set &lt;name&gt; on" starts a recording. The default recording time takes 15 seconds. It can be changed by
  5884. the <a href="#SSCamattr">attribute</a> "rectime" individualy.
  5885. With the <a href="#SSCamattr">attribute</a> (respectively the default value) provided recording time can be overwritten
  5886. once by "set &lt;name&gt; on &lt;rectime&gt;".
  5887. The recording will be stopped after processing time "rectime"automatically.<br>
  5888. A special case is start recording by "set &lt;name&gt; on 0" respectively the attribute value "rectime = 0". In that case
  5889. a endless-recording will be started. One have to stop this recording by command "set &lt;name&gt; off" explicitely.<br>
  5890. The recording behavior can be impacted with <a href="#SSCamattr">attribute</a> "recextend" furthermore as explained as follows.<br><br>
  5891. <b>Attribute "recextend = 0" or not set (default):</b><br><br>
  5892. <ul>
  5893. <li> if, for example, a recording with rectimeme=22 is started, no other startcommand (for a recording) will be accepted until this started recording is finished.
  5894. A hint will be logged in case of verboselevel = 3. </li>
  5895. </ul>
  5896. <br>
  5897. <b>Attribute "recextend = 1" is set:</b><br><br>
  5898. <ul>
  5899. <li> a before started recording will be extend by the recording time "rectime" if a new start command is received. That means, the timer for the automatic stop-command will be
  5900. renewed to "rectime" given bei the command, attribute or default value. This procedure will be repeated every time a new start command for recording is received.
  5901. Therefore a running recording will be extended until no start command will be get. </li>
  5902. <li> a before started endless-recording will be stopped after recordingtime 2rectime" if a new "set <name> on"-command is received (new set of timer). If it is unwanted make sure you
  5903. don't set the <a href="#SSCamattr">attribute</a> "recextend" in case of endless-recordings. </li>
  5904. </ul>
  5905. <br>
  5906. Examples for simple <b>Start/Stop a Recording</b>: <br><br>
  5907. <table>
  5908. <colgroup> <col width=20%> <col width=80%> </colgroup>
  5909. <tr><td>set &lt;name&gt; on [rectime] </td><td>starts a recording of camera &lt;name&gt;, stops automatically after [rectime] (default 15s or defined by <a href="#SSCamattr">attribute</a>) </td></tr>
  5910. <tr><td>set &lt;name&gt; off </td><td>stops the recording of camera &lt;name&gt;</td></tr>
  5911. </table>
  5912. </ul>
  5913. <br><br>
  5914. <ul>
  5915. <li><b> set &lt;name&gt; optimizeParams [mirror:&lt;value&gt;] [flip:&lt;value&gt;] [rotate:&lt;value&gt;] [ntp:&lt;value&gt;]</b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  5916. Set one or several properties of the camera. The video can be mirrored (mirror), turned upside down (flip) or
  5917. rotated (rotate). Specified properties must be supported by the camera type. With "ntp" you can set a time server the camera
  5918. use for time synchronization. <br><br>
  5919. &lt;value&gt; can be for: <br>
  5920. <ul>
  5921. <li> <b>mirror, flip, rotate: </b> true | false </li>
  5922. <li> <b>ntp: </b> the name or the IP-address of time server </li>
  5923. </ul>
  5924. <br><br>
  5925. <b>Examples:</b> <br>
  5926. <code> set &lt;name&gt; optimizeParams mirror:true flip:true ntp:time.windows.com </code><br>
  5927. # The video will be mirrored, turned upside down and the time server is set to "time.windows.com".<br>
  5928. <code> set &lt;name&gt; optimizeParams ntp:Surveillance%20Station </code><br>
  5929. # The Surveillance Station is set as time server. (NTP-service has to be activated in DSM) <br>
  5930. <code> set &lt;name&gt; optimizeParams mirror:true flip:false rotate:true </code><br>
  5931. # The video will be mirrored and rotated round 90 degrees. <br>
  5932. <br><br>
  5933. </ul>
  5934. <ul>
  5935. <li><b> set &lt;name&gt; pirSensor [activate | deactivate] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5936. Activates / deactivates the infrared sensor of the camera (only posible if the camera has got a PIR sensor).
  5937. </ul>
  5938. <br><br>
  5939. <ul>
  5940. <li><b> set &lt;name&gt; runPatrol &lt;Patrolname&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5941. This commans starts a predefined patrol (tour) of a PTZ-camera. <br>
  5942. At first the patrol has to be predefined in the Synology Surveillance Station. It can be done in the PTZ-control of IP-Kamera Setup -&gt; PTZ-control -&gt; patrol.
  5943. The patrol tours will be read with command "get &lt;name&gt; caminfoall" which is be executed automatically when FHEM restarts.
  5944. The import process can be repeated regular by camera polling. A long polling interval is recommendable in this case because of the patrols are only will be changed
  5945. if the user change it in the IP-camera setup itself.
  5946. Further informations for creating patrols you can get in the online-help of Surveillance Station.
  5947. </ul>
  5948. <br><br>
  5949. <ul>
  5950. <li><b> set &lt;name&gt; runView [live_fw | live_link | live_open [&lt;room&gt;] | lastrec_fw | lastrec_fw_MJPEG | lastrec_fw_MPEG4/H.264 | lastrec_open [&lt;room&gt;] | lastsnap_fw] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  5951. <ul>
  5952. <table>
  5953. <colgroup> <col width=25%> <col width=75%> </colgroup>
  5954. <tr><td>live_fw </td><td>- MJPEG-Livestream. Audio playback is provided if possible. </td></tr>
  5955. <tr><td>live_fw_hls </td><td>- HLS-Livestream (currently only Mac Safari Browser and mobile iOS/Android-Devices) </td></tr>
  5956. <tr><td>live_link </td><td>- Link of a MJPEG-Livestream </td></tr>
  5957. <tr><td>live_open [&lt;room&gt;] </td><td>- opens MJPEG-Livestream in separate Browser window </td></tr>
  5958. <tr><td>lastrec_fw </td><td>- playback last recording as iFrame object </td></tr>
  5959. <tr><td>lastrec_fw_MJPEG </td><td>- usable if last recording has format MJPEG </td></tr>
  5960. <tr><td>lastrec_fw_MPEG4/H.264 </td><td>- usable if last recording has format MPEG4/H.264 </td></tr>
  5961. <tr><td>lastrec_open [&lt;room&gt;] </td><td>- playback last recording in a separate Browser window </td></tr>
  5962. <tr><td>lastsnap_fw </td><td>- playback last snapshot </td></tr>
  5963. </table>
  5964. </ul>
  5965. <br><br>
  5966. With <b>"live_fw, live_link"</b> a MJPEG-Livestream will be started, either as an embedded image
  5967. or as a generated link. <br>
  5968. The option <b>"live_open"</b> starts a new browser window with a MJPEG-Livestream. If the optional "&lt;room&gt;" is set, the
  5969. window will only be started if the specified room is currently opened in a FHEMWEB-session. <br>
  5970. If a HLS-Stream by <b>"live_fw_hls"</b> is requested, the camera has to be setup to video format H.264 (not MJPEG) in the
  5971. Synology Surveillance Station and the SVS-Version has to support the HLS format.
  5972. Therefore this possibility is only present if the Reading "CamStreamFormat" is set to "HLS".
  5973. <br><br>
  5974. Access to the last recording of a camera can be done using <b>"lastrec_fw.*"</b> respectively <b>"lastrec_open"</b>.
  5975. By <b>"lastrec_fw"</b> the recording will be opened in an iFrame. There are some control elements provided if available. <br>
  5976. The <b>"lastrec_open"</b> command can be extended optionally by a room. In this case the new window opens only, if the
  5977. room is the same as a FHEMWEB-session has currently opened. <br>
  5978. The command <b>"set &lt;name&gt; runView lastsnap_fw"</b> shows the last snapshot of the camera embedded. <br>
  5979. The Streaming-Device properties can be affected by HTML-tags in <a href="#SSCamattr">attribute</a> "htmlattr".
  5980. <br><br>
  5981. <b>Examples:</b><br>
  5982. <pre>
  5983. attr &lt;name&gt; htmlattr width="500" height="375"
  5984. attr &lt;name&gt; htmlattr width="700",height="525",top="200",left="300"
  5985. </pre>
  5986. The command <b>"set &lt;name&gt; runView live_open"</b> starts the stream immediately in a new browser window.
  5987. A browser window will be initiated to open for every FHEMWEB-session which is active. If you want to change this behavior,
  5988. you can use command <b>"set &lt;name&gt; runView live_open &lt;room&gt;"</b>. In this case the new window opens only, if the
  5989. room is the same as a FHEMWEB-session has currently opened. <br>
  5990. The settings of <a href="#SSCamattr">attribute</a> "livestreamprefix" overwrite the data for protocol, servername and
  5991. port in <a href="#SSCamreadings">reading</a> "LiveStreamUrl".
  5992. By "livestreamprefix" the LivestreamURL (is shown if <a href="#SSCamattr">attribute</a> "showStmInfoFull" is set) can
  5993. be modified and used for distribution and external access to the Livestream. <br><br>
  5994. <b>Example:</b><br>
  5995. <pre>
  5996. attr &lt;name&gt; livestreamprefix https://&lt;Servername&gt;:&lt;Port&gt;
  5997. </pre>
  5998. The livestream can be stopped again by command <b>"set &lt;name&gt; stopView"</b>.
  5999. The "runView" function also switches Streaming-Devices of type "switched" into the appropriate mode. <br><br>
  6000. Dependend of the content to playback, different control buttons are provided: <br><br>
  6001. <ul>
  6002. <table>
  6003. <colgroup> <col width=25%> <col width=75%> </colgroup>
  6004. <tr><td> Start Recording </td><td>- starts an endless recording </td></tr>
  6005. <tr><td> Stop Recording </td><td>- stopps the recording </td></tr>
  6006. <tr><td> Take Snapshot </td><td>- take a snapshot </td></tr>
  6007. <tr><td> Switch off </td><td>- stops a running playback </td></tr>
  6008. </table>
  6009. </ul>
  6010. <br>
  6011. <b>Note for HLS (HTTP Live Streaming):</b> <br>
  6012. The video starts with a technology caused delay. Every stream will be segemented into some little video files
  6013. (with a lenth of approximately 10 seconds) and is than delivered to the client.
  6014. The video format of the camera has to be set to H.264 in the Synology Surveillance Station and not every camera type is
  6015. a proper device for HLS-Streaming.
  6016. At the time only the Mac Safari Browser and modern mobile iOS/Android-Devices are able to playback HLS-Streams.
  6017. </ul>
  6018. <br><br>
  6019. <ul>
  6020. <li><b> set &lt;name&gt; setHome &lt;PresetName&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for PTZ-CAM)</li> <br>
  6021. Set the Home-preset to a predefined preset name "&lt;PresetName&gt;" or the current position of the camera.
  6022. </ul>
  6023. <br><br>
  6024. <ul>
  6025. <li><b> set &lt;name&gt; setPreset &lt;PresetNumber&gt; [&lt;PresetName&gt;] [&lt;Speed&gt;] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for PTZ-CAM)</li> <br>
  6026. Sets a Preset with name "&lt;PresetName&gt;" to the current postion of the camera. The speed can be defined
  6027. optionally (&lt;Speed&gt;). If no PresetName is specified, the PresetNummer is used as name.
  6028. For this reason &lt;PresetName&gt; is defined as optional, but should usually be set.
  6029. </ul>
  6030. <br><br>
  6031. <ul>
  6032. <li><b> set &lt;name&gt; snap </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6033. A snapshot can be triggered with:
  6034. <pre>
  6035. set &lt;name&gt; snap
  6036. </pre>
  6037. Subsequent some Examples for <b>taking snapshots</b>: <br><br>
  6038. If a serial of snapshots should be released, it can be done using the following notify command.
  6039. For the example a serial of snapshots are to be triggerd if the recording of a camera starts. <br>
  6040. When the recording of camera "CamHE1" starts (Attribut event-on-change-reading -> "Record" has to be set), then 3 snapshots at intervals of 2 seconds are triggered.
  6041. <pre>
  6042. define he1_snap_3 notify CamHE1:Record.*on define h3 at +*{3}00:00:02 set CamHE1 snap
  6043. </pre>
  6044. Release of 2 Snapshots of camera "CamHE1" at intervals of 6 seconds after the motion sensor "MelderHE1" has sent an event, <br>
  6045. can be done e.g. with following notify-command:
  6046. <pre>
  6047. define he1_snap_2 notify MelderHE1:on.* define h2 at +*{2}00:00:06 set CamHE1 snap
  6048. </pre>
  6049. The ID and the filename of the last snapshot will be displayed as value of variable "LastSnapId" respectively "LastSnapFilename" in the device-Readings. <br><br>
  6050. </ul>
  6051. <br><br>
  6052. <ul>
  6053. <li><b> set &lt;name&gt; snapGallery [1-10] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6054. The command is only available if the attribute "snapGalleryBoost=1" is set. <br>
  6055. It creates an output of the last [x] snapshots as well as "get ... snapGallery". But differing from "get" with
  6056. <a href="#SSCamattr">attribute</a> "snapGalleryBoost=1" no popup will be created. The snapshot gallery will be depicted as
  6057. an browserpage instead. All further functions and attributes are appropriate the <a href="#SSCamget">"get &lt;name&gt; snapGallery"</a>
  6058. command. <br>
  6059. If you want create a snapgallery output by triggering, e.g. with an "at" or "notify", you should use the
  6060. <a href="#SSCamget">"get &lt;name&gt; snapGallery"</a> command instead of "set".
  6061. </ul>
  6062. <br><br>
  6063. <ul>
  6064. <li><b> set &lt;name&gt; startTracking </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM with tracking capability)</li> <br>
  6065. Starts object tracking of camera.
  6066. The command is only available if surveillance station has recognised the object tracking capability of camera
  6067. (Reading "CapPTZObjTracking").
  6068. </ul>
  6069. <br><br>
  6070. <ul>
  6071. <li><b> set &lt;name&gt; stopTracking </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM with tracking capability)</li> <br>
  6072. Stops object tracking of camera.
  6073. The command is only available if surveillance station has recognised the object tracking capability of camera
  6074. (Reading "CapPTZObjTracking").
  6075. </ul>
  6076. <br><br>
  6077. </ul>
  6078. <br>
  6079. <a name="SSCamget"></a>
  6080. <b>Get</b>
  6081. <ul>
  6082. <br>
  6083. With SSCam the properties of SVS and defined Cameras could be retrieved. <br>
  6084. The specified get-commands are available for CAM/SVS-devices or only valid for CAM-devices or rather for SVS-Devices.
  6085. They can be selected in the drop-down-menu of the particular device. <br><br>
  6086. <ul>
  6087. <li><b> get &lt;name&gt; caminfoall </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM/SVS)</li>
  6088. <b> get &lt;name&gt; caminfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM) <br><br>
  6089. Dependend of the type of camera (e.g. Fix- or PTZ-Camera) the available properties are retrieved and provided as Readings.<br>
  6090. For example the Reading "Availability" will be set to "disconnected" if the camera would be disconnected from Synology
  6091. Surveillance Station and can't be used for further processing like creating events. <br>
  6092. "getcaminfo" retrieves a subset of "getcaminfoall".
  6093. </ul>
  6094. <br><br>
  6095. <ul>
  6096. <li><b> get &lt;name&gt; eventlist </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6097. The <a href="#SSCamreadings">Reading</a> "CamEventNum" and "CamLastRecord" will be refreshed which containes the total number
  6098. of in SVS registered camera events and the path/name of the last recording.
  6099. This command will be implicit executed when "get &lt;name&gt; caminfoall" is running. <br>
  6100. The <a href="#SSCamattr">attribute</a> "videofolderMap" replaces the content of reading "VideoFolder". You can use it for
  6101. example if you have mounted the videofolder of SVS under another name or path and want to access by your local pc.
  6102. </ul>
  6103. <br><br>
  6104. <ul>
  6105. <li><b> get &lt;name&gt; homeModeState </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for SVS)</li> <br>
  6106. HomeMode-state of the Surveillance Station will be retrieved.
  6107. </ul>
  6108. <br><br>
  6109. <ul>
  6110. <li><b> get &lt;name&gt; listLog [severity:&lt;Loglevel&gt;] [limit:&lt;Number of lines&gt;] [match:&lt;Searchstring&gt;] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for SVS)</li> <br>
  6111. Fetches the Surveillance Station Log from Synology server. Without any further options the whole log will be retrieved. <br>
  6112. You can specify all or any of the following options: <br><br>
  6113. <ul>
  6114. <li> &lt;Loglevel&gt; - Information, Warning or Error. Only datasets having this severity are retrieved (default: all) </li>
  6115. <li> &lt;Number of lines&gt; - the specified number of lines (newest) of the log are retrieved (default: all) </li>
  6116. <li> &lt;Searchstring&gt; - only log entries containing the searchstring are retrieved (Note: no Regex possible, the searchstring will be given into the call to SVS) </li>
  6117. </ul>
  6118. <br>
  6119. <b>Examples</b> <br>
  6120. <ul>
  6121. <code>get &lt;name&gt; listLog severity:Error limit:5 </code> <br>
  6122. Reports the last 5 Log entries with severity "Error" <br>
  6123. <code>get &lt;name&gt; listLog severity:Information match:Carport </code> <br>
  6124. Reports all Log entries with severity "Information" and containing the string "Carport" <br>
  6125. <code>get &lt;name&gt; listLog severity:Warning </code> <br>
  6126. Reports all Log entries with severity "Warning" <br><br>
  6127. </ul>
  6128. If the polling of SVS is activated by setting the <a href="#SSCamattr">attribute</a> "pollcaminfoall", the <a href="#SSCamreadings">reading</a>
  6129. "LastLogEntry" will be created. <br>
  6130. In the protocol-setup of the SVS you can adjust what data you want to log. For further informations please have a look at
  6131. <a href="https://www.synology.com/en-uk/knowledgebase/Surveillance/help/SurveillanceStation/log_advanced">Synology Online-Help</a>.
  6132. </ul>
  6133. <br><br>
  6134. <ul>
  6135. <li><b> get &lt;name&gt; listPresets </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for PTZ-CAM)</li> <br>
  6136. Get a popup with a lists of presets saved for the camera.
  6137. </ul>
  6138. <br><br>
  6139. <ul>
  6140. <li><b> get &lt;name&gt; scanVirgin </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM/SVS)</li> <br>
  6141. This command is similar to get caminfoall, informations relating to SVS and the camera will be retrieved.
  6142. In difference to caminfoall in either case a new session ID will be generated (do a new login), the camera ID will be
  6143. new identified and all necessary API-parameters will be new investigated.
  6144. </ul>
  6145. <br><br>
  6146. <ul>
  6147. <li><b> get &lt;name&gt; snapGallery [1-10] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6148. A popup with the last [x] snapshots will be created. If the <a href="#SSCamattr">attribute</a> "snapGalleryBoost" is set,
  6149. the last snapshots (default 3) are requested by polling and they will be stored in the FHEM-servers main memory.
  6150. This method is helpful to speed up the output especially in case of full size images, but it can be possible
  6151. that NOT the newest snapshots are be shown if they have not be initialized by the SSCAm-module itself. <br>
  6152. The function can also be triggered, e.g. by an "at" or "notify". In that case the snapshotgallery will be displayed on all
  6153. connected FHEMWEB instances as a popup. <br><br>
  6154. To control this function behavior there are further <a href="#SSCamattr">attributes</a>: <br><br>
  6155. <ul>
  6156. <li>snapGalleryBoost </li>
  6157. <li>snapGalleryColumns </li>
  6158. <li>snapGalleryHtmlAttr </li>
  6159. <li>snapGalleryNumber </li>
  6160. <li>snapGallerySize </li>
  6161. </ul> <br>
  6162. available.
  6163. </ul> <br>
  6164. <ul>
  6165. <b>Note:</b><br>
  6166. Depended from quantity and resolution (quality) of the snapshot images adequate CPU and/or main memory
  6167. ressources are needed.
  6168. </ul>
  6169. <br><br>
  6170. <ul>
  6171. <li><b> get &lt;name&gt; snapfileinfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6172. The filename of the last snapshot will be retrieved. This command will be executed with <b>"get &lt;name&gt; snap"</b>
  6173. automatically.
  6174. </ul>
  6175. <br><br>
  6176. <ul>
  6177. <li><b> get &lt;name&gt; snapinfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6178. Informations about snapshots will be retrieved. Heplful if snapshots are not triggerd by SSCam, but by motion detection of the camera or surveillance
  6179. station instead.
  6180. </ul>
  6181. <br><br>
  6182. <ul>
  6183. <li><b> get &lt;name&gt; stmUrlPath </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM)</li> <br>
  6184. This command is to fetch the streamkey information and streamurl using that streamkey. The reading "StmKey" will be filled when this command will be executed and can be used
  6185. to send it and run by your own application like a browser (see example).
  6186. If the <a href="#SSCamattr">attribute</a> "showStmInfoFull" is set, additional stream readings like "StmKeyUnicst", "StmKeymjpegHttp" will be shown and can be used to run the
  6187. appropriate livestream without session id. Is the attribute "livestreamprefix" (usage: "http(s)://&lt;hostname&gt;&lt;port&gt;) used, the servername / port will be replaced if necessary.
  6188. The strUrlPath function will be included automatically if polling is used.
  6189. <br><br>
  6190. Example to create an http-call to a livestream using StmKey: <br>
  6191. <pre>
  6192. http(s)://&lt;hostname&gt;&lt;port&gt;/webapi/entry.cgi?api=SYNO.SurveillanceStation.VideoStreaming&version=1&method=Stream&format=mjpeg&cameraId=5&StmKey="31fd87279976d89bb98409728cced890"
  6193. </pre>
  6194. cameraId (Internal CAMID) and StmKey has to be replaced by valid values. <br><br>
  6195. <b>Note:</b> <br>
  6196. If you use the stream-call from external and replace hostname / port with valid values and open your router ip ports, please
  6197. make shure that no unauthorized person could get this sensible data !
  6198. </ul>
  6199. <br><br>
  6200. <ul>
  6201. <li><b> get &lt;name&gt; storedCredentials </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM/SVS)</li> <br>
  6202. Shows the stored login credentials in a popup as plain text.
  6203. </ul>
  6204. <br><br>
  6205. <ul>
  6206. <li><b> get &lt;name&gt; svsinfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM/SVS)</li> <br>
  6207. Determines common informations about the installed SVS-version and other properties. <br>
  6208. </ul>
  6209. <br><br>
  6210. <ul>
  6211. <li><b> get &lt;name&gt; versionNotes [hints | rel | &lt;key&gt;] </b> &nbsp;&nbsp;&nbsp;&nbsp;(valid for CAM/SVS)</li> <br>
  6212. Shows realease informations and/or hints about the module. It contains only main release informations for module users. <br>
  6213. If no options are specified, both release informations and hints will be shown. "rel" shows only release informations and
  6214. "hints" shows only hints. By the &lt;key&gt;-specification only the hint with the specified number is shown.
  6215. </ul>
  6216. <br><br>
  6217. <a name="SSCamPolling"></a>
  6218. <b>Polling of Camera/SVS-Properties</b><br><br>
  6219. <ul>
  6220. Retrieval of Camera-Properties can be done automatically if the attribute "pollcaminfoall" will be set to a value &gt; 10. <br>
  6221. As default that attribute "pollcaminfoall" isn't be set and the automatic polling isn't be active. <br>
  6222. The value of that attribute determines the interval of property-retrieval in seconds. If that attribute isn't be set or &lt; 10 the automatic polling won't be started <br>
  6223. respectively stopped when the value was set to &gt; 10 before. <br><br>
  6224. The attribute "pollcaminfoall" is monitored by a watchdog-timer. Changes of the attribute-value will be checked every 90 seconds and transact corresponding. <br>
  6225. Changes of the pollingstate and pollinginterval will be reported in FHEM-Logfile. The reporting can be switched off by setting the attribute "pollnologging=1". <br>
  6226. Thereby the needless growing of the logfile can be avoided. But if verbose level is set to 4 or above even though the attribute "pollnologging" is set as well, the polling <br>
  6227. will be actived due to analysis purposes. <br><br>
  6228. If FHEM will be restarted, the first data retrieval will be done within 60 seconds after start. <br><br>
  6229. The state of automatic polling will be displayed by reading "PollState": <br><br>
  6230. <ul>
  6231. <li><b> PollState = Active </b> - automatic polling will be executed with interval correspondig value of attribute "pollcaminfoall" </li>
  6232. <li><b> PollState = Inactive </b> - automatic polling won't be executed </li>
  6233. </ul>
  6234. <br>
  6235. The readings are described <a href="#SSCamreadings">here</a>. <br><br>
  6236. <b>Notes:</b> <br><br>
  6237. If polling is used, the interval should be adjusted only as short as needed due to the detected camera values are predominantly static. <br>
  6238. A feasible guide value for attribute "pollcaminfoall" could be between 600 - 1800 (s). <br>
  6239. Per polling call and camera approximately 10 - 20 Http-calls will are stepped against Surveillance Station. <br>
  6240. Because of that if HTTP-Timeout (pls. refer <a href="#SSCamattr">Attribut</a> "httptimeout") is set to 4 seconds, the theoretical processing time couldn't be higher than 80 seconds. <br>
  6241. Considering a safety margin, in that example you shouldn't set the polling interval lower than 160 seconds. <br><br>
  6242. If several Cameras are defined in SSCam, attribute "pollcaminfoall" of every Cameras shouldn't be set exactly to the same value to avoid processing bottlenecks <br>
  6243. and thereby caused potential source of errors during request Synology Surveillance Station. <br>
  6244. A marginal difference between the polling intervals of the defined cameras, e.g. 1 second, can already be faced as
  6245. sufficient value. <br><br>
  6246. </ul>
  6247. </ul>
  6248. <a name="SSCaminternals"></a>
  6249. <b>Internals</b> <br><br>
  6250. <ul>
  6251. The meaning of used Internals is depicted in following list: <br><br>
  6252. <ul>
  6253. <li><b>CAMID</b> - the ID of camera defined in SVS, the value will be retrieved automatically on the basis of SVS-cameraname </li>
  6254. <li><b>CAMNAME</b> - the name of the camera in SVS </li>
  6255. <li><b>COMPATIBILITY</b> - information up to which SVS-version the module version is currently released/tested (see also Reading "compstate") </li>
  6256. <li><b>CREDENTIALS</b> - the value is "Set" if Credentials are set </li>
  6257. <li><b>NAME</b> - the cameraname in FHEM </li>
  6258. <li><b>MODEL</b> - distinction between camera device (CAM) and Surveillance Station device (SVS) </li>
  6259. <li><b>OPMODE</b> - the last executed operation of the module </li>
  6260. <li><b>SERVERADDR</b> - IP-Address of SVS Host </li>
  6261. <li><b>SERVERPORT</b> - SVS-Port </li>
  6262. <br><br>
  6263. </ul>
  6264. </ul>
  6265. <a name="SSCamattr"></a>
  6266. <b>Attributes</b>
  6267. <br><br>
  6268. <ul>
  6269. <ul>
  6270. <a name="debugactivetoken"></a>
  6271. <li><b>debugactivetoken</b><br>
  6272. if set the state of active token will be logged - only for debugging, don't use it in normal operation ! </li><br>
  6273. <a name="disable"></a>
  6274. <li><b>disable</b><br>
  6275. deactivates the device definition </li><br>
  6276. <a name="genericStrmHtmlTag"></a>
  6277. <li><b>genericStrmHtmlTag</b><br>
  6278. This attribute contains HTML-Tags for video-specification in a Streaming-Device of type "generic".
  6279. (see also "set &lt;name&gt; createStreamDev generic") <br><br>
  6280. <ul>
  6281. <b>Example:</b>
  6282. <pre>
  6283. attr &lt;name&gt; genericStrmHtmlTag &lt;video $HTMLATTR controls autoplay&gt;
  6284. &lt;source src='http://192.168.2.10:32000/$NAME.m3u8' type='application/x-mpegURL'&gt;
  6285. &lt;/video&gt;
  6286. </pre>
  6287. The variables $HTMLATTR, $NAME are placeholder and absorb the attribute "htmlattr" (if set) respectively the SSCam-Devicename.
  6288. </ul>
  6289. <br><br>
  6290. </li>
  6291. <a name="httptimeout"></a>
  6292. <li><b>httptimeout</b><br>
  6293. Timeout-Value of HTTP-Calls to Synology Surveillance Station, Default: 4 seconds (if httptimeout = "0"
  6294. or not set) </li><br>
  6295. <a name="htmlattr"></a>
  6296. <li><b>htmlattr</b><br>
  6297. additional specifications to inline oictures to manipulate the behavior of stream, e.g. size of the image. </li><br>
  6298. <ul>
  6299. <b>Example:</b><br>
  6300. attr &lt;name&gt; htmlattr width="500" height="325" top="200" left="300"
  6301. </ul>
  6302. <br>
  6303. <a name="livestreamprefix"></a>
  6304. <li><b>livestreamprefix</b><br>
  6305. Overwrites the specifications of protocol, servername and port for further use in livestream address and
  6306. StmKey.*-readings , e.g. as a link for external use. <br>
  6307. It can be specified of two ways as follows: <br><br>
  6308. <table>
  6309. <colgroup> <col width=25%> <col width=75%> </colgroup>
  6310. <tr><td> <b>DEF</b> </td><td>: the protocol, servername and port as specified in device
  6311. definition is used </td></tr>
  6312. <tr><td> <b>http(s)://&lt;servername&gt;:&lt;port&gt;</b> </td><td>: your own address specification is used </td></tr>
  6313. </table>
  6314. <br>
  6315. Servername can be the name or the IP-address of your Synology Surveillance Station.
  6316. </li><br>
  6317. <a name="loginRetries"></a>
  6318. <li><b>loginRetries</b><br>
  6319. set the amount of login-repetitions in case of failure (default = 3) </li><br>
  6320. <a name="noQuotesForSID"></a>
  6321. <li><b>noQuotesForSID</b><br>
  6322. this attribute may be helpful in some cases to avoid errormessage "402 - permission denied" and makes login
  6323. possible. </li><br>
  6324. <a name="pollcaminfoall"></a>
  6325. <li><b>pollcaminfoall</b><br>
  6326. Interval of automatic polling the Camera properties (if <= 10: no polling, if &gt; 10: polling with interval) </li><br>
  6327. <a name="pollnologging"></a>
  6328. <li><b>pollnologging</b><br>
  6329. "0" resp. not set = Logging device polling active (default), "1" = Logging device polling inactive</li><br>
  6330. <a name="ptzPanel_Home"></a>
  6331. <li><b>ptzPanel_Home</b><br>
  6332. In the PTZ-control panel the Home-Icon (in attribute "ptzPanel_row02") is automatically assigned to the value of
  6333. Reading "PresetHome".
  6334. With "ptzPanel_Home" you can change the assignment to another preset from the available Preset list. </li><br>
  6335. <a name="ptzPanel_iconPath"></a>
  6336. <li><b>ptzPanel_iconPath</b><br>
  6337. Path for icons used in PTZ-control panel, default is "www/images/sscam".
  6338. The attribute value will be used for all icon-files except *.svg. </li><br>
  6339. <a name="ptzPanel_iconPrefix"></a>
  6340. <li><b>ptzPanel_iconPrefix</b><br>
  6341. Prefix for icons used in PTZ-control panel, default is "black_btn_".
  6342. The attribute value will be used for all icon-files except *.svg. <br>
  6343. If the used icon-files begin with e.g. "black_btn_" ("black_btn_CAMDOWN.png"), the icon needs to be defined in
  6344. attributes "ptzPanel_row[00-09]" just with the subsequent part of name, e.g. "CAMDOWN.png".
  6345. </li><br>
  6346. <a name="ptzPanel_row00"></a>
  6347. <li><b>ptzPanel_row[00-09] &lt;command&gt;:&lt;icon&gt;,&lt;command&gt;:&lt;icon&gt;,... </b><br>
  6348. For PTZ-cameras the attributes "ptzPanel_row00" to "ptzPanel_row04" are created automatically for usage by
  6349. the PTZ-control panel. <br>
  6350. The attributes contain a comma spareated list of command:icon-combinations (buttons) each panel line.
  6351. One panel line can contain a random number of buttons. The attributes "ptzPanel_row00" to "ptzPanel_row04" can't be
  6352. deleted because of they are created automatically again in that case.
  6353. The user can change or complement the attribute values. These changes are conserved. <br>
  6354. If needed the assignment for Home-button in "ptzPanel_row02" can be changed by attribute "ptzPanel_Home". <br>
  6355. The icons are searched in path "ptzPanel_iconPath". The value of "ptzPanel_iconPrefix" is prepend to the icon filename.
  6356. Own extensions of the PTZ-control panel can be done using the attributes "ptzPanel_row05" to "ptzPanel_row09".
  6357. For creation of own icons a template is provided in the SVN. Further information can be get by "get &lt;name&gt; versionNotes 2".
  6358. <br><br>
  6359. <b>Note:</b> <br>
  6360. For an empty field please use ":CAMBLANK.png" respectively ":CAMBLANK.png,:CAMBLANK.png,:CAMBLANK.png,..." for an empty
  6361. line.
  6362. <br><br>
  6363. <ul>
  6364. <b>Example:</b><br>
  6365. attr &lt;name&gt; ptzPanel_row00 move upleft:CAMUPLEFTFAST.png,:CAMBLANK.png,move up:CAMUPFAST.png,:CAMBLANK.png,move upright:CAMUPRIGHTFAST.png <br>
  6366. # The command "move upleft" is transmitted to the camera by pressing the button(icon) "CAMUPLEFTFAST.png". <br>
  6367. </ul>
  6368. <br>
  6369. </li><br>
  6370. <a name="ptzPanel_use"></a>
  6371. <li><b>ptzPanel_use</b><br>
  6372. Switch the usage of a PTZ-control panel in detail view respectively a created StreamDevice off or on
  6373. (default: on). </li><br>
  6374. <a name="rectime"></a>
  6375. <li><b>rectime</b><br>
  6376. determines the recordtime when a recording starts. If rectime = 0 an endless recording will be started. If
  6377. it isn't defined, the default recordtime of 15s is activated </li><br>
  6378. <a name="recextend"></a>
  6379. <li><b>recextend</b><br>
  6380. "rectime" of a started recording will be set new. Thereby the recording time of the running recording will be
  6381. extended </li><br>
  6382. <a name="session"></a>
  6383. <li><b>session</b><br>
  6384. selection of login-Session. Not set or set to "DSM" -&gt; session will be established to DSM (Sdefault).
  6385. "SurveillanceStation" -&gt; session will be established to SVS. <br>
  6386. For establish a sesion with Surveillance Station you have to create a user with suitable privilege profile in SVS.
  6387. If you need more infomations please execute "get &lt;name&gt; versionNotes 5". </li><br>
  6388. <a name="simu_SVSversion"></a>
  6389. <li><b>simu_SVSversion</b><br>
  6390. simulates another SVS version. (only a lower version than the installed one is possible !) </li><br>
  6391. <a name="snapGalleryBoost"></a>
  6392. <li><b>snapGalleryBoost</b><br>
  6393. If set, the last snapshots (default 3) will be retrieved by Polling, will be stored in the FHEM-servers main memory
  6394. and can be displayed by the "set/get ... snapGallery" command. <br>
  6395. This mode is helpful if many or full size images shall be displayed.
  6396. If the attribute is set, you can't specify arguments in addition to the "set/get ... snapGallery" command.
  6397. (see also attribut "snapGalleryNumber") </li><br>
  6398. <a name="snapGalleryColumns"></a>
  6399. <li><b>snapGalleryColumns</b><br>
  6400. The number of snapshots which shall appear in one row of the gallery popup (default 3). </li><br>
  6401. <a name="snapGalleryHtmlAttr"></a>
  6402. <li><b>snapGalleryHtmlAttr</b><br>
  6403. the image parameter can be controlled by this attribute. <br>
  6404. If the attribute isn't set, the value of attribute "htmlattr" will be used. <br>
  6405. If "htmlattr" is also not set, default parameters are used instead (width="500" height="325"). <br><br>
  6406. <ul>
  6407. <b>Example:</b><br>
  6408. attr &lt;name&gt; snapGalleryHtmlAttr width="325" height="225"
  6409. </ul>
  6410. <br>
  6411. </li>
  6412. <a name="snapGalleryNumber"></a>
  6413. <li><b>snapGalleryNumber</b><br>
  6414. The number of snapshots to retrieve (default 3). </li><br>
  6415. <a name="snapGallerySize"></a>
  6416. <li><b>snapGallerySize</b><br>
  6417. By this attribute the quality of the snapshot images can be controlled (default "Icon"). <br>
  6418. If mode "Full" is set, the images are retrieved with their original available resolution. That requires more ressources
  6419. and may slow down the display. By setting attribute "snapGalleryBoost=1" the display may accelerated, because in that case
  6420. the images will be retrieved by continuous polling and need only bring to display. </li><br>
  6421. <a name="showStmInfoFull"></a>
  6422. <li><b>showStmInfoFull</b><br>
  6423. additional stream informations like LiveStreamUrl, StmKeyUnicst, StmKeymjpegHttp will be created </li><br>
  6424. <a name="showPassInLog"></a>
  6425. <li><b>showPassInLog</b><br>
  6426. if set the used password will be shown in logfile with verbose 4. (default = 0) </li><br>
  6427. <a name="videofolderMap"></a>
  6428. <li><b>videofolderMap</b><br>
  6429. replaces the content of reading "VideoFolder", Usage if e.g. folders are mountet with different names than original
  6430. (SVS) </li><br>
  6431. <a name="verbose"></a>
  6432. <li><b>verbose</b></li><br>
  6433. <ul>
  6434. Different Verbose-Level are supported.<br>
  6435. Those are in detail:
  6436. <table>
  6437. <colgroup> <col width=5%> <col width=95%> </colgroup>
  6438. <tr><td> 0 </td><td>- Start/Stop-Event will be logged </td></tr>
  6439. <tr><td> 1 </td><td>- Error messages will be logged </td></tr>
  6440. <tr><td> 2 </td><td>- messages according to important events were logged </td></tr>
  6441. <tr><td> 3 </td><td>- sended commands will be logged </td></tr>
  6442. <tr><td> 4 </td><td>- sended and received informations will be logged </td></tr>
  6443. <tr><td> 5 </td><td>- all outputs will be logged for error-analyses. <b>Caution:</b> a lot of data could be written into logfile ! </td></tr>
  6444. </table>
  6445. </ul>
  6446. <br>
  6447. <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
  6448. </ul>
  6449. </ul>
  6450. <br><br>
  6451. <a name="SSCamreadings"></a>
  6452. <b>Readings</b>
  6453. <ul>
  6454. <br>
  6455. Using the polling mechanism or retrieval by "get"-call readings are provieded, The meaning of the readings are listed in subsequent table: <br>
  6456. The transfered Readings can be deversified dependend on the type of camera.<br><br>
  6457. <ul>
  6458. <table>
  6459. <colgroup> <col width=5%> <col width=95%> </colgroup>
  6460. <tr><td><li>CamAudioType</li> </td><td>- Indicating audio type </td></tr>
  6461. <tr><td><li>Availability</li> </td><td>- Availability of Camera (disabled, enabled, disconnected, other) </td></tr>
  6462. <tr><td><li>CamEventNum</li> </td><td>- delivers the total number of in SVS registered events of the camera </td></tr>
  6463. <tr><td><li>CamExposureControl</li> </td><td>- indicating type of exposure control </td></tr>
  6464. <tr><td><li>CamExposureMode</li> </td><td>- current exposure mode (Day, Night, Auto, Schedule, Unknown) </td></tr>
  6465. <tr><td><li>CamForceEnableMulticast</li> </td><td>- Is the camera forced to enable multicast. </td></tr>
  6466. <tr><td><li>CamIP</li> </td><td>- IP-Address of Camera </td></tr>
  6467. <tr><td><li>CamLastRec</li> </td><td>- Path / name of the last recording </td></tr>
  6468. <tr><td><li>CamLastRecTime</li> </td><td>- date / starttime / endtime of the last recording </td></tr>
  6469. <tr><td><li>CamLiveFps</li> </td><td>- Frames per second of Live-Stream </td></tr>
  6470. <tr><td><li>CamLiveMode</li> </td><td>- Source of Live-View (DS, Camera) </td></tr>
  6471. <tr><td><li>camLiveQuality</li> </td><td>- Live-Stream quality set in SVS </td></tr>
  6472. <tr><td><li>camLiveResolution</li> </td><td>- Live-Stream resolution set in SVS </td></tr>
  6473. <tr><td><li>camLiveStreamNo</li> </td><td>- used Stream-number for Live-Stream </td></tr>
  6474. <tr><td><li>CamModel</li> </td><td>- Model of camera </td></tr>
  6475. <tr><td><li>CamMotDetSc</li> </td><td>- state of motion detection source (disabled, by camera, by SVS) and their parameter </td></tr>
  6476. <tr><td><li>CamNTPServer</li> </td><td>- set time server </td></tr>
  6477. <tr><td><li>CamPort</li> </td><td>- IP-Port of Camera </td></tr>
  6478. <tr><td><li>CamPreRecTime</li> </td><td>- Duration of Pre-Recording (in seconds) adjusted in SVS </td></tr>
  6479. <tr><td><li>CamPtSpeed</li> </td><td>- adjusted value of Pan/Tilt-activities (setup in SVS) </td></tr>
  6480. <tr><td><li>CamRecShare</li> </td><td>- shared folder on disk station for recordings </td></tr>
  6481. <tr><td><li>CamRecVolume</li> </td><td>- Volume on disk station for recordings </td></tr>
  6482. <tr><td><li>CamStreamFormat</li> </td><td>- the current format of video streaming </td></tr>
  6483. <tr><td><li>CamVideoType</li> </td><td>- Indicating video type </td></tr>
  6484. <tr><td><li>CamVendor</li> </td><td>- Identifier of camera producer </td></tr>
  6485. <tr><td><li>CamVideoFlip</li> </td><td>- Is the video flip </td></tr>
  6486. <tr><td><li>CamVideoMirror</li> </td><td>- Is the video mirror </td></tr>
  6487. <tr><td><li>CamVideoRotate</li> </td><td>- Is the video rotate </td></tr>
  6488. <tr><td><li>CapAudioOut</li> </td><td>- Capability to Audio Out over Surveillance Station (false/true) </td></tr>
  6489. <tr><td><li>CapChangeSpeed</li> </td><td>- Capability to various motion speed </td></tr>
  6490. <tr><td><li>CapPIR</li> </td><td>- has the camera a PIR sensor feature </td></tr>
  6491. <tr><td><li>CapPTZAbs</li> </td><td>- Capability to perform absolute PTZ action </td></tr>
  6492. <tr><td><li>CapPTZAutoFocus</li> </td><td>- Capability to perform auto focus action </td></tr>
  6493. <tr><td><li>CapPTZDirections</li> </td><td>- the PTZ directions that camera support </td></tr>
  6494. <tr><td><li>CapPTZFocus</li> </td><td>- mode of support for focus action </td></tr>
  6495. <tr><td><li>CapPTZHome</li> </td><td>- Capability to perform home action </td></tr>
  6496. <tr><td><li>CapPTZIris</li> </td><td>- mode of support for iris action </td></tr>
  6497. <tr><td><li>CapPTZObjTracking</li> </td><td>- Capability to perform objekt-tracking </td></tr>
  6498. <tr><td><li>CapPTZPan</li> </td><td>- Capability to perform pan action </td></tr>
  6499. <tr><td><li>CapPTZPresetNumber</li> </td><td>- The maximum number of preset supported by the model. 0 stands for preset incapability </td></tr>
  6500. <tr><td><li>CapPTZTilt</li> </td><td>- mode of support for tilt action </td></tr>
  6501. <tr><td><li>CapPTZZoom</li> </td><td>- Capability to perform zoom action </td></tr>
  6502. <tr><td><li>DeviceType</li> </td><td>- device type (Camera, Video_Server, PTZ, Fisheye) </td></tr>
  6503. <tr><td><li>Error</li> </td><td>- message text of last error </td></tr>
  6504. <tr><td><li>Errorcode</li> </td><td>- error code of last error </td></tr>
  6505. <tr><td><li>HomeModeState</li> </td><td>- HomeMode-state (SVS-version 8.1.0 and above) </td></tr>
  6506. <tr><td><li>LastLogEntry</li> </td><td>- the neweset entry of Surveillance Station Log (only if SVS-device and if attribute pollcaminfoall is set) </td></tr>
  6507. <tr><td><li>LastSnapFilename</li> </td><td>- the filename of the last snapshot </td></tr>
  6508. <tr><td><li>LastSnapId</li> </td><td>- the ID of the last snapshot </td></tr>
  6509. <tr><td><li>LastSnapTime</li> </td><td>- timestamp of the last snapshot </td></tr>
  6510. <tr><td><li>LastUpdateTime</li> </td><td>- date / time the last update of readings by "caminfoall" </td></tr>
  6511. <tr><td><li>LiveStreamUrl </li> </td><td>- the livestream URL if stream is started (is shown if <a href="#SSCamattr">attribute</a> "showStmInfoFull" is set) </td></tr>
  6512. <tr><td><li>Patrols</li> </td><td>- in Synology Surveillance Station predefined patrols (at PTZ-Cameras) </td></tr>
  6513. <tr><td><li>PollState</li> </td><td>- shows the state of automatic polling </td></tr>
  6514. <tr><td><li>PresetHome</li> </td><td>- Name of Home-position (at PTZ-Cameras) </td></tr>
  6515. <tr><td><li>Presets</li> </td><td>- in Synology Surveillance Station predefined Presets (at PTZ-Cameras) </td></tr>
  6516. <tr><td><li>Record</li> </td><td>- if recording is running = Start, if no recording is running = Stop </td></tr>
  6517. <tr><td><li>StmKey</li> </td><td>- current streamkey. it can be used to open livestreams without session id </td></tr>
  6518. <tr><td><li>StmKeyUnicst</li> </td><td>- Uni-cast stream path of the camera. (<a href="#SSCamattr">attribute</a> "showStmInfoFull" has to be set) </td></tr>
  6519. <tr><td><li>StmKeymjpegHttp</li> </td><td>- Mjpeg stream path(over http) of the camera (<a href="#SSCamattr">attribute</a> "showStmInfoFull" has to be set) </td></tr>
  6520. <tr><td><li>SVScustomPortHttp</li> </td><td>- Customized port of Surveillance Station (HTTP) (to get with "svsinfo") </td></tr>
  6521. <tr><td><li>SVScustomPortHttps</li> </td><td>- Customized port of Surveillance Station (HTTPS) (to get with "svsinfo") </td></tr>
  6522. <tr><td><li>SVSlicenseNumber</li> </td><td>- The total number of installed licenses (to get with "svsinfo") </td></tr>
  6523. <tr><td><li>SVSuserPriv</li> </td><td>- The effective rights of the user used for log in (to get with "svsinfo") </td></tr>
  6524. <tr><td><li>SVSversion</li> </td><td>- package version of the installed Surveillance Station (to get with "svsinfo") </td></tr>
  6525. <tr><td><li>UsedSpaceMB</li> </td><td>- used disk space of recordings by Camera </td></tr>
  6526. <tr><td><li>VideoFolder</li> </td><td>- Path to the recorded video </td></tr>
  6527. <tr><td><li>compstate</li> </td><td>- state of compatibility (compares current/simulated SVS-version with Internal COMPATIBILITY) </td></tr>
  6528. </table>
  6529. </ul>
  6530. <br><br>
  6531. </ul>
  6532. </ul>
  6533. =end html
  6534. =begin html_DE
  6535. <a name="SSCam"></a>
  6536. <h3>SSCam</h3>
  6537. <ul>
  6538. Mit diesem Modul können Operationen von in der Synology Surveillance Station (SVS) definierten Kameras und Funktionen
  6539. der SVS ausgeführt werden. Es basiert auf der SVS API und unterstützt die SVS ab Version 7. <br>
  6540. Zur Zeit werden folgende Funktionen unterstützt: <br><br>
  6541. <ul>
  6542. <ul>
  6543. <li>Start einer Aufnahme</li>
  6544. <li>Stop einer Aufnahme (per Befehl bzw. automatisch nach Ablauf der Aufnahmedauer) </li>
  6545. <li>Aufnehmen eines Schnappschusses und Ablage in der Synology Surveillance Station </li>
  6546. <li>Deaktivieren einer Kamera in Synology Surveillance Station</li>
  6547. <li>Aktivieren einer Kamera in Synology Surveillance Station</li>
  6548. <li>Steuerung der Belichtungsmodi Tag, Nacht bzw. Automatisch </li>
  6549. <li>Umschaltung der Ereigniserkennung durch Kamera, durch SVS oder deaktiviert </li>
  6550. <li>steuern der Erkennungsparameterwerte Empfindlichkeit, Schwellwert, Objektgröße und Prozentsatz für Auslösung </li>
  6551. <li>Abfrage von Kameraeigenschaften (auch mit Polling) sowie den Eigenschaften des installierten SVS-Paketes</li>
  6552. <li>Bewegen an eine vordefinierte Preset-Position (bei PTZ-Kameras) </li>
  6553. <li>Start einer vordefinierten Überwachungstour (bei PTZ-Kameras) </li>
  6554. <li>Positionieren von PTZ-Kameras zu absoluten X/Y-Koordinaten </li>
  6555. <li>kontinuierliche Bewegung von PTZ-Kameras </li>
  6556. <li>auslösen externer Ereignisse 1-10 (Aktionsregel SVS) </li>
  6557. <li>starten und beenden von Kamera-Livestreams incl. Audiowiedergabe, anzeigen der letzten Aufnahme oder des letzten Schnappschusses </li>
  6558. <li>Abruf und Ausgabe der Kamera Streamkeys sowie Stream-Urls (Nutzung von Kamera-Livestreams ohne Session Id) </li>
  6559. <li>abspielen der letzten Aufnahme bzw. Anzeige des letzten Schnappschusses </li>
  6560. <li>anzeigen der gespeicherten Anmeldeinformationen (Credentials) </li>
  6561. <li>Ein- bzw. Ausschalten des Surveillance Station HomeMode und abfragen des HomeMode-Status </li>
  6562. <li>abrufen des Surveillance Station Logs, auswerten des neuesten Eintrags als Reading </li>
  6563. <li>erzeugen einer Gallerie der letzten 1-10 Schnappschüsse (als Popup oder permanentes Device) </li>
  6564. <li>Start bzw. Stop Objekt Tracking (nur unterstützte PTZ-Kameras mit dieser Fähigkeit) </li>
  6565. <li>Setzen/Löschen eines Presets (bei PTZ-Kameras) </li>
  6566. <li>Setzen der Home-Position (bei PTZ-Kameras) </li>
  6567. <li>erstellen eines Paneels zur Kamera-Steuerung. (bei PTZ-Kameras) </li>
  6568. <li>erzeugen unterschiedlicher Typen von separaten Streaming-Devices (createStreamDev) </li>
  6569. <li>Aktivierung / Deaktivierung eines kamerainternen PIR-Sensors </li>
  6570. </ul>
  6571. </ul>
  6572. <br>
  6573. Die Aufnahmen stehen in der Synology Surveillance Station (SVS) zur Verfügung und unterliegen, wie jede andere Aufnahme, den in der Synology Surveillance Station eingestellten Regeln. <br>
  6574. So werden zum Beispiel die Aufnahmen entsprechend ihrer Archivierungsfrist gespeichert und dann gelöscht. <br><br>
  6575. Wenn sie über dieses Modul diskutieren oder zur Verbesserung des Moduls beitragen möchten, ist im FHEM-Forum ein Sammelplatz unter:<br>
  6576. <a href="http://forum.fhem.de/index.php/topic,45671.msg374390.html#msg374390">49_SSCam: Fragen, Hinweise, Neuigkeiten und mehr rund um dieses Modul</a>.<br><br>
  6577. Weitere Infomationen zum Modul sind im FHEM-Wiki zu finden:<br>
  6578. <a href="http://www.fhemwiki.de/wiki/SSCAM_-_Steuerung_von_Kameras_in_Synology_Surveillance_Station">SSCAM - Steuerung von Kameras in Synology Surveillance Station</a>.<br><br>
  6579. <b>Vorbereitung </b> <br><br>
  6580. <ul>
  6581. Dieses Modul nutzt das Perl-Modul JSON. <br>
  6582. Auf Debian-Linux basierenden Systemen kann es installiert werden mit: <br><br>
  6583. <code>sudo apt-get install libjson-perl</code> <br><br>
  6584. Das Modul verwendet für HTTP-Calls die nichtblockierenden Funktionen von HttpUtils bzw. HttpUtils_NonblockingGet. <br>
  6585. Im DSM bzw. der Synology Surveillance Station muß ein Nutzer angelegt sein. Die Zugangsdaten werden später über ein Set-Kommando dem angelegten Gerät zugewiesen. <br>
  6586. Nähere Informationen dazu unter <a href="#SSCam_Credentials">Credentials</a><br><br>
  6587. Überblick über die Perl-Module welche von SSCam genutzt werden: <br><br>
  6588. JSON <br>
  6589. Data::Dumper <br>
  6590. MIME::Base64 <br>
  6591. Time::HiRes <br>
  6592. HttpUtils (FHEM-Modul) <br><br>
  6593. </ul>
  6594. <a name="SSCamdefine"></a>
  6595. <b>Definition</b>
  6596. <ul>
  6597. <br>
  6598. Bei der Definition wird zwischen einer Kamera-Definition und der Definition einer Surveillance Station (SVS), d.h.
  6599. der Applikation selbst auf der Diskstation, unterschieden.
  6600. Abhängig von der Art des definierten Devices wird das Internal MODEL auf "&lt;Hersteller&gt; - &lt;Kameramodell&gt;" oder
  6601. SVS gesetzt und eine passende Teilmenge der beschriebenen set/get-Befehle dem Device zugewiesen. <br>
  6602. Der Gültigkeitsbereich von set/get-Befehlen ist nach dem jeweiligen Befehl angegeben "gilt für CAM, SVS, CAM/SVS".
  6603. <br><br>
  6604. Eine <b>Kamera</b> wird definiert mit: <br><br>
  6605. <ul>
  6606. <b><code>define &lt;Name&gt; SSCAM &lt;Kameraname in SVS&gt; &lt;ServerAddr&gt; [Port] [Protocol]</code></b> <br><br>
  6607. </ul>
  6608. Zunächst muß diese Kamera in der Synology Surveillance Station 7.0 oder höher eingebunden sein und entsprechend
  6609. funktionieren. <br><br>
  6610. Ein <b>SVS-Device</b> zur Steuerung von Funktionen der Surveillance Station wird definiert mit: <br><br>
  6611. <ul>
  6612. <b><code>define &lt;Name&gt; SSCAM SVS &lt;ServerAddr&gt; [Port] [Protocol]</code></b> <br><br>
  6613. </ul>
  6614. In diesem Fall wird statt &lt;Kameraname in SVS&gt; nur <b>SVS</b> angegeben. <br><br>
  6615. Das Modul SSCam basiert auf Funktionen der Synology Surveillance Station API. <br><br>
  6616. Die Parameter beschreiben im Einzelnen:
  6617. <br>
  6618. <br>
  6619. <table>
  6620. <colgroup> <col width=15%> <col width=85%> </colgroup>
  6621. <tr><td><b>Name</b> </td><td>der Name des neuen Gerätes in FHEM</td></tr>
  6622. <tr><td><b>Kameraname</b> </td><td>Kameraname wie er in der Synology Surveillance Station angegeben ist für Kamera-Device, "SVS" für SVS-Device. Leerzeichen im Namen sind nicht erlaubt. </td></tr>
  6623. <tr><td><b>ServerAddr</b> </td><td>die IP-Addresse des Synology Surveillance Station Host. Hinweis: Es sollte kein Servername verwendet werden weil DNS-Aufrufe in FHEM blockierend sind.</td></tr>
  6624. <tr><td><b>Port</b> </td><td>optional - der Port der Synology Disc Station. Wenn nicht angegeben, wird der Default-Port "5000" genutzt </td></tr>
  6625. <tr><td><b>Protocol</b> </td><td>optional - das Protokoll (http oder https) zum Funktionsaufruf. Wenn nicht angegeben, wird der Default "http" genutzt </td></tr>
  6626. </table>
  6627. <br><br>
  6628. <b>Beispiel:</b>
  6629. <pre>
  6630. <code>define CamCP SSCAM Carport 192.168.2.20 [5000] [http] </code>
  6631. <code>define CamCP SSCAM Carport 192.168.2.20 [5001] [https]</code>
  6632. # erstellt ein neues Kamera-Device CamCP
  6633. <code>define DS1 SSCAM SVS 192.168.2.20 [5000] [http] </code>
  6634. <code>define DS1 SSCAM SVS 192.168.2.20 [5001] [https] </code>
  6635. # erstellt ein neues SVS-Device DS1
  6636. </pre>
  6637. Wird eine neue Kamera definiert, wird diesem Device zunächst eine Standardaufnahmedauer von 15 zugewiesen. <br>
  6638. Über das <a href="#SSCamattr">Attribut</a> "rectime" kann die Aufnahmedauer für jede Kamera individuell angepasst werden. Der Wert "0" für "rectime" führt zu einer Endlosaufnahme, die durch "set &lt;name&gt; off" wieder gestoppt werden muß. <br>
  6639. Ein Logeintrag mit einem entsprechenden Hinweis auf diesen Umstand wird geschrieben. <br><br>
  6640. Wird das <a href="#SSCamattr">Attribut</a> "rectime" gelöscht, greift wieder der Default-Wert (15s) für die Aufnahmedauer. <br><br>
  6641. Mit dem <a href="#SSCamset">Befehl</a> <b>"set &lt;name&gt; on [rectime]"</b> wird die Aufnahmedauer temporär festgelegt und überschreibt einmalig sowohl den Defaultwert als auch den Wert des gesetzten Attributs "rectime". <br>
  6642. Auch in diesem Fall führt <b>"set &lt;name&gt; on 0"</b> zu einer Daueraufnahme. <br><br>
  6643. Eine eventuell in der SVS eingestellte Dauer der Voraufzeichnung wird weiterhin berücksichtigt. <br><br>
  6644. Erkennt das Modul die definierte Kamera als PTZ-Device (Reading "DeviceType = PTZ"), wird automatisch ein
  6645. Steuerungspaneel in der Detailansicht erstellt. Dieses Paneel setzt SVS >= 7.1 voraus. Die Eigenschaften und das
  6646. Verhalten des Paneels können mit den <a href="#SSCamattr">Attributen</a> "ptzPanel_.*" beeinflusst werden. <br>
  6647. Siehe dazu auch den <a href="#SSCamset">Befehl</a> <b>"set &lt;name&gt; createPTZcontrol"</b>.
  6648. <br><br><br>
  6649. </ul>
  6650. <a name="SSCam_Credentials"></a>
  6651. <b>Credentials </b><br><br>
  6652. <ul>
  6653. Nach dem Definieren des Gerätes müssen zuerst die Zugangsparameter gespeichert werden. Das geschieht mit dem Befehl:
  6654. <pre>
  6655. set &lt;name&gt; credentials &lt;Username&gt; &lt;Passwort&gt;
  6656. </pre>
  6657. Die Passwortlänge beträgt maximal 20 Zeichen. <br>
  6658. Der Anwender kann in Abhängigkeit der beabsichtigten einzusetzenden Funktionen einen Nutzer im DSM bzw. in der Surveillance
  6659. Station einrichten. <br>
  6660. Ist der DSM-Nutzer der Gruppe Administratoren zugeordnet, hat er auf alle Funktionen Zugriff. Ohne diese Gruppenzugehörigkeit
  6661. können nur Funktionen mit niedrigeren Rechtebedarf ausgeführt werden. Die benötigten Mindestrechte der Funktionen sind in
  6662. der Tabelle weiter unten aufgeführt. <br>
  6663. Alternativ zum DSM-Nutzer kann ein in der SVS angelegter Nutzer verwendet werden. Auch in diesem Fall hat ein Nutzer vom
  6664. Typ Manager das Recht alle Funktionen auszuführen, wobei der Zugriff auf bestimmte Kameras/ im Privilegienprofil beschränkt
  6665. werden kann (siehe Hilfefunktion in SVS). <br>
  6666. Als Best Practice wird vorgeschlagen, jeweils einen User im DSM und einen in der SVS anzulegen: <br><br>
  6667. <ul>
  6668. <li>DSM-User als Mitglied der Admin-Gruppe: uneingeschränkter Test aller Modulfunktionen -> session: DSM </li>
  6669. <li>SVS-User als Manager oder Betrachter: angepasstes Privilegienprofil -> session: SurveillanceStation </li>
  6670. </ul>
  6671. <br>
  6672. Über das <a href="#SSCamattr">Attribut</a> "session" kann ausgewählt werden, ob die Session mit dem DSM oder der SVS
  6673. aufgebaut werden soll. Weitere Informationen zum Usermanagement in der SVS sind verfügbar mit
  6674. "get &lt;name&gt; versionNotes 5".<br>
  6675. Erfolgt der Session-Aufbau mit dem DSM, stehen neben der SVS Web-API auch darüber hinausgehende API-Zugriffe zur Verfügung,
  6676. die unter Umständen zur Verarbeitung benötigt werden. <br><br>
  6677. Nach der Gerätedefinition ist die Grundeinstellung "Login in das DSM", d.h. es können Credentials mit Admin-Berechtigungen
  6678. genutzt werden um zunächst alle Funktionen der Kameras testen zu können. Danach können die Credentials z.B. in Abhängigkeit
  6679. der benötigten Funktionen auf eine SVS-Session mit entsprechend beschränkten Privilegienprofil umgestellt werden. <br><br>
  6680. Die nachfolgende Aufstellung zeigt die <b>Mindestanforderungen</b> der jeweiligen Modulfunktionen an die Nutzerrechte. <br><br>
  6681. <ul>
  6682. <table>
  6683. <colgroup> <col width=20%> <col width=80%> </colgroup>
  6684. <tr><td><li>set ... credentials </td><td> - </li></td></tr>
  6685. <tr><td><li>set ... delPreset </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6686. <tr><td><li>set ... disable </td><td> session: ServeillanceStation - Manager </li></td></tr>
  6687. <tr><td><li>set ... enable </td><td> session: ServeillanceStation - Manager </li></td></tr>
  6688. <tr><td><li>set ... expmode </td><td> session: ServeillanceStation - Manager </li></td></tr>
  6689. <tr><td><li>set ... extevent </td><td> session: DSM - Nutzer Mitglied von Admin-Gruppe </li></td></tr>
  6690. <tr><td><li>set ... goPreset </td><td> session: ServeillanceStation - Betrachter mit Privileg Objektivsteuerung der Kamera </li></td></tr>
  6691. <tr><td><li>set ... homeMode </td><td> session: ServeillanceStation - Betrachter mit Privileg Home-Modus schalten ( gilt für <b>SVS-Device !</b> ) </li></td></tr>
  6692. <tr><td><li>set ... goAbsPTZ </td><td> session: ServeillanceStation - Betrachter mit Privileg Objektivsteuerung der Kamera </li></td></tr>
  6693. <tr><td><li>set ... move </td><td> session: ServeillanceStation - Betrachter mit Privileg Objektivsteuerung der Kamera </li></td></tr>
  6694. <tr><td><li>set ... motdetsc </td><td> session: ServeillanceStation - Manager </li></td></tr>
  6695. <tr><td><li>set ... on </td><td> session: ServeillanceStation - Betrachter mit erweiterten Privileg "manuelle Aufnahme" </li></td></tr>
  6696. <tr><td><li>set ... off </td><td> session: ServeillanceStation - Betrachter mit erweiterten Privileg "manuelle Aufnahme" </li></td></tr>
  6697. <tr><td><li>set ... runView </td><td> session: ServeillanceStation - Betrachter mit Privileg Liveansicht für Kamera </li></td></tr>
  6698. <tr><td><li>set ... runPatrol </td><td> session: ServeillanceStation - Betrachter mit Privileg Objektivsteuerung der Kamera </li></td></tr>
  6699. <tr><td><li>set ... setHome </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6700. <tr><td><li>set ... setPreset </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6701. <tr><td><li>set ... snap </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6702. <tr><td><li>set ... snapGallery </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6703. <tr><td><li>set ... stopView </td><td> - </li></td></tr>
  6704. <tr><td><li>get ... caminfo[all] </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6705. <tr><td><li>get ... eventlist </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6706. <tr><td><li>get ... listLog </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6707. <tr><td><li>get ... listPresets </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6708. <tr><td><li>get ... scanVirgin </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6709. <tr><td><li>get ... svsinfo </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6710. <tr><td><li>get ... snapfileinfo </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6711. <tr><td><li>get ... snapGallery </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6712. <tr><td><li>get ... snapinfo </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6713. <tr><td><li>get ... stmUrlPath </td><td> session: ServeillanceStation - Betrachter </li></td></tr>
  6714. </table>
  6715. </ul>
  6716. <br><br>
  6717. </ul>
  6718. <a name="SSCam_HTTPTimeout"></a>
  6719. <b>HTTP-Timeout setzen</b><br><br>
  6720. <ul>
  6721. Alle Funktionen dieses Moduls verwenden HTTP-Aufrufe gegenüber der SVS Web API. <br>
  6722. Der Standardwert für den HTTP-Timeout beträgt 4 Sekunden. Durch Setzen des
  6723. <a href="#SSCamattr">Attributes</a> "httptimeout" > 0 kann dieser Wert bei Bedarf entsprechend den technischen
  6724. Gegebenheiten angepasst werden. <br>
  6725. </ul>
  6726. <br><br><br>
  6727. <a name="SSCamset"></a>
  6728. <b>Set </b>
  6729. <ul>
  6730. <br>
  6731. Die aufgeführten set-Befehle sind für CAM/SVS-Devices oder nur für CAM-Devices bzw. nur für SVS-Devices gültig. Sie stehen im
  6732. Drop-Down-Menü des jeweiligen Devices zur Auswahl zur Verfügung. <br><br>
  6733. <ul>
  6734. <a name="SSCamcreateStreamDev"></a>
  6735. <li><b> set &lt;name&gt; createStreamDev [generic | mjpeg | switched] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6736. Es wird ein separates Streaming-Device (Typ SSCamSTRM) erstellt. Dieses Device kann z.B. als separates Device
  6737. in einem Dashboard genutzt werden.
  6738. Dem Streaming-Device wird der aktuelle Raum des Kameradevice zugewiesen sofern dort gesetzt.
  6739. <br><br>
  6740. <ul>
  6741. <table>
  6742. <colgroup> <col width=10%> <col width=90%> </colgroup>
  6743. <tr><td>generic </td><td>- das Streaming-Device gibt einen durch das Attribut "genericStrmHtmlTag" bestimmten Content wieder </td></tr>
  6744. <tr><td>mjpeg </td><td>- das Streaming-Device gibt einen permanenten MJPEG Kamerastream wieder (Streamkey Methode) </td></tr>
  6745. <tr><td>switched </td><td>- Wiedergabe unterschiedlicher Streamtypen. Drucktasten zur Steuerung werden angeboten. </td></tr>
  6746. </table>
  6747. </ul>
  6748. <br><br>
  6749. Die Gestaltung kann durch HTML-Tags im <a href="#SSCamattr">Attribut</a> "htmlattr" im Kameradevice oder mit den
  6750. spezifischen Attributen im Streaming-Device beeinflusst werden. <br>
  6751. Soll ein HLS-Stream im Streaming-Device vom Typ "switched" gestartet werden, muss die Kamera in der Synology Surveillance Station
  6752. auf das Videoformat H.264 eingestellt und HLS von der eingesetzten SVS-Version unterstützt sein.
  6753. Diese Auswahltaste wird deshalb im nur im Streaming-Device angeboten wenn das Reading "CamStreamFormat = HLS" beinhaltet. <br>
  6754. HLS (HTTP Live Streaming) kann momentan nur auf Mac Safari oder mobilen iOS/Android-Geräten wiedergegeben werden. <br>
  6755. Im "switched"-Device werden Drucktasten zur Steuerung des zu startenden Medientyps angeboten. <br>
  6756. Ein Streaming-Device vom Typ "generic" benötigt die Angabe von HTML-Tags im Attribut "genericStrmHtmlTag". Diese Tags
  6757. spezifizieren den wiederzugebenden Content. <br><br>
  6758. <ul>
  6759. <b>Beispiel:</b>
  6760. <pre>
  6761. attr &lt;name&gt; genericStrmHtmlTag &lt;video $HTMLATTR controls autoplay&gt;
  6762. &lt;source src='http://192.168.2.10:32000/$NAME.m3u8' type='application/x-mpegURL'&gt;
  6763. &lt;/video&gt;
  6764. </pre>
  6765. Die Variablen $HTMLATTR, $NAME sind Platzhalter und übernehmen ein gesetztes Attribut "htmlattr" bzw. den SSCam-Devicenamen.
  6766. </ul>
  6767. </ul>
  6768. <br><br>
  6769. <ul>
  6770. <li><b> set &lt;name&gt; createPTZcontrol </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für PTZ-CAM)</li> <br>
  6771. Es wird ein separates PTZ-Steuerungspaneel (Type SSCamSTRM) erstellt. Es wird der aktuelle Raum des Kameradevice
  6772. zugewiesen sofern dort gesetzt.
  6773. Mit den "ptzPanel_.*"-<a href="#SSCamattr">Attributen</a> bzw. den spezifischen Attributen des erzeugten
  6774. SSCamSTRM-Devices können die Eigenschaften des PTZ-Paneels beeinflusst werden. <br>
  6775. <br><br>
  6776. </ul>
  6777. <ul>
  6778. <li><b> set &lt;name&gt; createSnapGallery </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6779. Es wird eine Schnappschußgallerie als separates Device (Type SSCamSTRM) erzeugt. Das Device wird im Raum
  6780. "SnapGallery" erstellt.
  6781. Mit den "snapGallery..."-<a href="#SSCamattr">Attributen</a> bzw. den spezifischen Attributen des erzeugten SSCamSTRM-Devices
  6782. können die Eigenschaften der Schnappschußgallerie beeinflusst werden. <br>
  6783. <br><br>
  6784. </ul>
  6785. <ul>
  6786. <li><b> set &lt;name&gt; credentials &lt;username&gt; &lt;password&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM/SVS)</li> <br>
  6787. Setzt Username / Passwort für den Zugriff auf die Synology Surveillance Station.
  6788. Siehe <a href="#SSCam_Credentials">Credentials</a><br>
  6789. <br><br>
  6790. </ul>
  6791. <ul>
  6792. <li><b> set &lt;name&gt; delPreset &lt;PresetName&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für PTZ-CAM)</li> <br>
  6793. Löscht einen Preset "&lt;PresetName&gt;". Im FHEMWEB wird eine Drop-Down Liste der aktuell vorhandenen
  6794. Presets angeboten.
  6795. </ul>
  6796. <br><br>
  6797. <ul>
  6798. <li><b> set &lt;name&gt; [enable|disable] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6799. Aktviviert / deaktiviert eine Kamera. <br>
  6800. Um eine Liste von Kameras oder alle Kameras (mit Regex) zum Beispiel um 21:46 zu <b>deaktivieren</b> / zu <b>aktivieren</b> zwei Beispiele mit at:
  6801. <pre>
  6802. define a13 at 21:46 set CamCP1,CamFL,CamHE1,CamTER disable (enable)
  6803. define a14 at 21:46 set Cam.* disable (enable)
  6804. </pre>
  6805. Etwas komfortabler gelingt das Schalten aller Kameras über einen Dummy. Zunächst wird der Dummy angelegt:
  6806. <pre>
  6807. define allcams dummy
  6808. attr allcams eventMap on:enable off:disable
  6809. attr allcams room Cams
  6810. attr allcams webCmd enable:disable
  6811. </pre>
  6812. Durch Verknüpfung mit zwei angelegten notify, jeweils ein notify für "enable" und "disable", kann man durch Schalten des Dummys auf "enable" bzw. "disable" alle Kameras auf einmal aktivieren bzw. deaktivieren.
  6813. <pre>
  6814. define all_cams_disable notify allcams:.*off set CamCP1,CamFL,CamHE1,CamTER disable
  6815. attr all_cams_disable room Cams
  6816. define all_cams_enable notify allcams:on set CamCP1,CamFL,CamHE1,CamTER enable
  6817. attr all_cams_enable room Cams
  6818. </pre>
  6819. </ul>
  6820. <br>
  6821. <ul>
  6822. <li><b> set &lt;name&gt; expmode [day|night|auto] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6823. Mit diesem Befehl kann der Belichtungsmodus der Kameras gesetzt werden. Dadurch wird z.B. das Verhalten der Kamera-LED's entsprechend gesteuert.
  6824. Die erfolgreiche Umschaltung wird durch das Reading CamExposureMode ("get ... caminfoall") reportet. <br><br>
  6825. <b> Hinweis: </b> <br>
  6826. Die erfolgreiche Ausführung dieser Funktion ist davon abhängig ob die SVS diese Funktionalität der Kamera unterstützt.
  6827. Ist in SVS -&gt; IP-Kamera -&gt; Optimierung -&gt; Belichtungsmodus das Feld für den Tag/Nachtmodus grau hinterlegt, ist nicht von einer lauffähigen Unterstützung dieser
  6828. Funktion auszugehen.
  6829. <br><br>
  6830. </ul>
  6831. <ul>
  6832. <li><b> set &lt;name&gt; extevent [ 1-10 ] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für SVS)</li> <br>
  6833. Dieses Kommando triggert ein externes Ereignis (1-10) in der SVS.
  6834. Die Aktionen, die dieses Ereignis auslöst, sind zuvor in dem Aktionsregeleditor der SVS einzustellen. Es stehen die Ereignisse
  6835. 1-10 zur Verfügung.
  6836. In der Benachrichtigungs-App der SVS können auch Email, SMS oder Mobil (DS-Cam) Nachrichten ausgegeben werden wenn ein externes
  6837. Ereignis ausgelöst wurde.
  6838. Nähere Informationen dazu sind in der Hilfe zum Aktionsregeleditor zu finden.
  6839. Der verwendete User benötigt Admin-Rechte in einer DSM-Session.
  6840. </ul>
  6841. <br><br>
  6842. <ul>
  6843. <li><b> set &lt;name&gt; goAbsPTZ [ X Y | up | down | left | right ] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6844. Mit diesem Kommando wird eine PTZ-Kamera in Richtung einer wählbaren absoluten X/Y-Koordinate bewegt, oder zur maximalen Absolutposition in Richtung up/down/left/right.
  6845. Die Option ist nur für Kameras verfügbar die das Reading "CapPTZAbs=true" (die Fähigkeit für PTZAbs-Aktionen) besitzen. Die Eigenschaften der Kamera kann mit "get &lt;name&gt; caminfoall" abgefragt werden.
  6846. <br><br>
  6847. Beispiel für Ansteuerung absoluter X/Y-Koordinaten: <br>
  6848. <pre>
  6849. set &lt;name&gt; goAbsPTZ 120 450
  6850. </pre>
  6851. Dieses Beispiel bewegt die Kameralinse in die Position X=120 und Y=450. <br>
  6852. Der Wertebereich ist dabei:
  6853. <pre>
  6854. X = 0 - 640 (0 - 319 bewegt nach links, 321 - 640 bewegt nach rechts, 320 bewegt die Linse nicht)
  6855. Y = 0 - 480 (0 - 239 bewegt nach unten, 241 - 480 bewegt nach oben, 240 bewegt die Linse nicht)
  6856. </pre>
  6857. Die Linse kann damit in kleinsten bis sehr großen Schritten in die gewünschte Richtung bewegt werden.
  6858. Dieser Vorgang muß ggf. mehrfach wiederholt werden um die Kameralinse in die gewünschte Position zu bringen. <br><br>
  6859. Soll die Bewegung mit der maximalen Schrittweite erfolgen, kann zur Vereinfachung der Befehl:
  6860. <pre>
  6861. set &lt;name&gt; goAbsPTZ [up|down|left|right]
  6862. </pre>
  6863. verwendet werden. Die Optik wird in diesem Fall mit der größt möglichen Schrittweite zur Absolutposition in der angegebenen Richtung bewegt.
  6864. Auch in diesem Fall muß der Vorgang ggf. mehrfach wiederholt werden um die Kameralinse in die gewünschte Position zu bringen.
  6865. </ul>
  6866. <br><br>
  6867. <ul>
  6868. <li><b> set &lt;name&gt; goPreset &lt;Preset&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6869. Mit diesem Kommando können PTZ-Kameras in eine vordefininierte Position bewegt werden. <br>
  6870. Die Preset-Positionen müssen dazu zunächst in der Synology Surveillance Station angelegt worden sein. Das geschieht in der PTZ-Steuerung im IP-Kamera Setup.
  6871. Die Presets werden über das Kommando "get &lt;name&gt; caminfoall" eingelesen (geschieht bei restart von FHEM automatisch). Der Einlesevorgang kann durch ein Kamerapolling
  6872. regelmäßig wiederholt werden. Ein langes Pollingintervall ist in diesem Fall empfehlenswert, da sich die Presetpositionen nur im Fall der Neuanlage bzw. Änderung verändern werden.
  6873. <br><br>
  6874. Hier ein Beispiel einer PTZ-Steuerung in Abhängigkeit eines IR-Melder Events:
  6875. <pre>
  6876. define CamFL.Preset.Wandschrank notify MelderTER:on.* set CamFL goPreset Wandschrank, ;; define CamFL.Preset.record at +00:00:10 set CamFL on 5 ;;;; define s3 at +*{3}00:00:05 set CamFL snap ;; define CamFL.Preset.back at +00:00:30 set CamFL goPreset Home
  6877. </pre>
  6878. Funktionsweise: <br>
  6879. Der IR-Melder "MelderTER" registriert eine Bewegung. Daraufhin wird die Kamera CamFL in die Preset-Position "Wandschrank" gebracht. Eine Aufnahme mit Dauer von 5 Sekunden startet 10 Sekunden
  6880. später. Da die Voraufnahmezeit der Kamera 10s beträgt (vgl. Reading "CamPreRecTime"), startet die effektive Aufnahme wenn der Kameraschwenk beginnt. <br>
  6881. Mit dem Start der Aufnahme werden drei Schnappschüsse im Abstand von 5 Sekunden angefertigt. <br>
  6882. Nach einer Zeit von 30 Sekunden fährt die Kamera wieder zurück in die "Home"-Position. <br><br>
  6883. Ein Auszug aus dem Log verdeutlicht den Ablauf:
  6884. <pre>
  6885. 2016.02.04 15:02:14 2: CamFL - Camera Flur_Vorderhaus has moved to position "Wandschrank"
  6886. 2016.02.04 15:02:24 2: CamFL - Camera Flur_Vorderhaus Recording with Recordtime 5s started
  6887. 2016.02.04 15:02:29 2: CamFL - Snapshot of Camera Flur_Vorderhaus has been done successfully
  6888. 2016.02.04 15:02:30 2: CamFL - Camera Flur_Vorderhaus Recording stopped
  6889. 2016.02.04 15:02:34 2: CamFL - Snapshot of Camera Flur_Vorderhaus has been done successfully
  6890. 2016.02.04 15:02:39 2: CamFL - Snapshot of Camera Flur_Vorderhaus has been done successfully
  6891. 2016.02.04 15:02:44 2: CamFL - Camera Flur_Vorderhaus has moved to position "Home"
  6892. </pre>
  6893. </ul>
  6894. <br><br>
  6895. <ul>
  6896. <li><b> set &lt;name&gt; homeMode [on|off] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für SVS)</li> <br>
  6897. Schaltet den HomeMode der Surveillance Station ein bzw. aus.
  6898. Informationen zum HomeMode sind in der <a href="https://www.synology.com/de-de/knowledgebase/Surveillance/help/SurveillanceStation/home_mode">Synology Onlinehilfe</a>
  6899. enthalten.
  6900. <br><br>
  6901. </ul>
  6902. <ul>
  6903. <li><b> set &lt;name&gt; motdetsc [camera|SVS|disable] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6904. Der Befehl "motdetsc" (steht für motion detection source) schaltet die Bewegungserkennung in den gewünschten Modus.
  6905. Wird die Bewegungserkennung durch die Kamera / SVS ohne weitere Optionen eingestellt, werden die momentan gültigen Bewegungserkennungsparameter der
  6906. Kamera / SVS beibehalten. Die erfolgreiche Ausführung der Operation lässt sich u.a. anhand des Status von SVS -&gt; IP-Kamera -&gt; Ereigniserkennung -&gt;
  6907. Bewegung nachvollziehen. <br><br>
  6908. Für die Bewegungserkennung durch SVS bzw. durch Kamera können weitere Optionen angegeben werden. Die verfügbaren Optionen bezüglich der Bewegungserkennung
  6909. durch SVS sind "Empfindlichkeit" und "Schwellwert". <br><br>
  6910. <ul>
  6911. <table>
  6912. <colgroup> <col width=50%> <col width=50%> </colgroup>
  6913. <tr><td>set &lt;name&gt; motdetsc SVS [Empfindlichkeit] [Schwellwert] </td><td># Befehlsmuster </td></tr>
  6914. <tr><td>set &lt;name&gt; motdetsc SVS 91 30 </td><td># setzt die Empfindlichkeit auf 91 und den Schwellwert auf 30 </td></tr>
  6915. <tr><td>set &lt;name&gt; motdetsc SVS 0 40 </td><td># behält gesetzten Wert für Empfindlichkeit bei, setzt Schwellwert auf 40 </td></tr>
  6916. <tr><td>set &lt;name&gt; motdetsc SVS 15 </td><td># setzt die Empfindlichkeit auf 15, Schwellwert bleibt unverändert </td></tr>
  6917. </table>
  6918. </ul>
  6919. <br><br>
  6920. Wird die Bewegungserkennung durch die Kamera genutzt, stehen die Optionen "Empfindlichkeit", "Objektgröße" und "Prozentsatz für Auslösung" zur Verfügung. <br><br>
  6921. <ul>
  6922. <table>
  6923. <colgroup> <col width=50%> <col width=50%> </colgroup>
  6924. <tr><td>set &lt;name&gt; motdetsc camera [Empfindlichkeit] [Schwellwert] [Prozentsatz] </td><td># Befehlsmuster </td></tr>
  6925. <tr><td>set &lt;name&gt; motdetsc camera 89 0 20 </td><td># setzt die Empfindlichkeit auf 89, Prozentsatz auf 20 </td></tr>
  6926. <tr><td>set &lt;name&gt; motdetsc camera 0 40 10 </td><td># behält gesetzten Wert für Empfindlichkeit bei, setzt Schwellwert auf 40, Prozentsatz auf 10 </td></tr>
  6927. <tr><td>set &lt;name&gt; motdetsc camera 30 </td><td># setzt die Empfindlichkeit auf 30, andere Werte bleiben unverändert </td></tr>
  6928. </table>
  6929. </ul>
  6930. <br><br>
  6931. Es ist immer die Reihenfolge der Optionswerte zu beachten. Nicht gewünschte Optionen sind mit "0" zu besetzen sofern danach Optionen folgen
  6932. deren Werte verändert werden sollen (siehe Beispiele oben). Der Zahlenwert der Optionen beträgt 1 - 99 (außer Sonderfall "0"). <br><br>
  6933. Die jeweils verfügbaren Optionen unterliegen der Funktion der Kamera und der Unterstützung durch die SVS. Es können jeweils nur die Optionen genutzt werden die in
  6934. SVS -&gt; Kamera bearbeiten -&gt; Ereigniserkennung zur Verfügung stehen. Weitere Infos sind der Online-Hilfe zur SVS zu entnehmen. <br><br>
  6935. Über den Befehl "get &lt;name&gt; caminfoall" wird auch das <a href="#SSCamreadings">Reading</a> "CamMotDetSc" aktualisiert welches die gegenwärtige Einstellung der Bewegungserkennung dokumentiert.
  6936. Es werden nur die Parameter und Parameterwerte angezeigt, welche die SVS aktiv unterstützt. Die Kamera selbst kann weiterführende Einstellmöglichkeiten besitzen. <br><br>
  6937. Beipiel:
  6938. <pre>
  6939. CamMotDetSc SVS, sensitivity: 76, threshold: 55
  6940. </pre>
  6941. <br><br>
  6942. </ul>
  6943. <ul>
  6944. <li><b> set &lt;name&gt; move [ right | up | down | left | dir_X ] [Sekunden] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM bis SVS Version 7.1)</li>
  6945. <b> set &lt;name&gt; move [ right | upright | up | upleft | left | downleft | down | downright ] [Sekunden] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM ab SVS Version 7.2) <br><br>
  6946. Mit diesem Kommando wird eine kontinuierliche Bewegung der PTZ-Kamera gestartet. Neben den vier Grundrichtungen up/down/left/right stehen auch
  6947. Zwischenwinkelmaße "dir_X" zur Verfügung. Die Feinheit dieser Graduierung ist von der Kamera abhängig und kann dem Reading "CapPTZDirections" entnommen werden. <br><br>
  6948. Das Bogenmaß von 360 Grad teilt sich durch den Wert von "CapPTZDirections" und beschreibt die Bewegungsrichtungen beginnend mit "0=rechts" entgegen dem
  6949. Uhrzeigersinn. D.h. bei einer Kamera mit "CapPTZDirections = 8" bedeutet dir_0 = rechts, dir_2 = oben, dir_4 = links, dir_6 = unten bzw. dir_1, dir_3, dir_5 und dir_7
  6950. die entsprechenden Zwischenrichtungen. Die möglichen Bewegungsrichtungen bei Kameras mit "CapPTZDirections = 32" sind dementsprechend kleinteiliger. <br><br>
  6951. Im Gegensatz zum "set &lt;name&gt; goAbsPTZ"-Befehl startet der Befehl "set &lt;name&gt; move" eine kontinuierliche Bewegung bis ein Stop-Kommando empfangen wird.
  6952. Das Stop-Kommando wird nach Ablauf der optional anzugebenden Zeit [Sekunden] ausgelöst. Wird diese Laufzeit nicht angegeben, wird implizit Sekunde = 1 gesetzt. <br><br>
  6953. <b>Beispiele: </b><br>
  6954. <pre>
  6955. set &lt;name&gt; move up 0.5 : bewegt PTZ 0,5 Sek. (zzgl. Prozesszeit) nach oben
  6956. set &lt;name&gt; move dir_1 1.5 : bewegt PTZ 1,5 Sek. (zzgl. Prozesszeit) nach rechts-oben
  6957. set &lt;name&gt; move dir_20 0.7 : bewegt PTZ 1,5 Sek. (zzgl. Prozesszeit) nach links-unten ("CapPTZDirections = 32)"
  6958. </pre>
  6959. </ul>
  6960. <br><br>
  6961. <ul>
  6962. <li><b> set &lt;name&gt; [on [&lt;rectime&gt;] | off] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li><br>
  6963. Der Befehl "set &lt;name&gt; on" startet eine Aufnahme. Die Standardaufnahmedauer beträgt 15 Sekunden. Sie kann mit dem
  6964. Attribut "rectime" individuell festgelegt werden.
  6965. Die im Attribut (bzw. im Standard) hinterlegte Aufnahmedauer kann einmalig mit "set &lt;name&gt; on &lt;rectime&gt;"
  6966. überschrieben werden.
  6967. Die Aufnahme stoppt automatisch nach Ablauf der Zeit "rectime".<br>
  6968. Ein Sonderfall ist der Start einer Daueraufnahme mit "set &lt;name&gt; on 0" bzw. dem Attributwert "rectime = 0".
  6969. In diesem Fall wird eine Daueraufnahme gestartet, die explizit wieder mit dem Befehl "set &lt;name&gt; off" gestoppt
  6970. werden muß.<br>
  6971. Das Aufnahmeverhalten kann weiterhin mit dem Attribut "recextend" beeinflusst werden.<br><br>
  6972. <b>Attribut "recextend = 0" bzw. nicht gesetzt (Standard):</b><br><br>
  6973. <ul>
  6974. <li> wird eine Aufnahme mit z.B. rectime=22 gestartet, wird kein weiterer Startbefehl für eine Aufnahme akzeptiert bis diese gestartete Aufnahme nach 22 Sekunden
  6975. beendet ist. Ein Hinweis wird bei verbose=3 im Logfile protokolliert. </li>
  6976. </ul>
  6977. <br>
  6978. <b>Attribut "recextend = 1" gesetzt:</b><br>
  6979. <ul>
  6980. <li> eine zuvor gestartete Aufnahme wird bei einem erneuten "set <name> on" -Befehl um die Aufnahmezeit "rectime" verlängert. Das bedeutet, dass der Timer für
  6981. den automatischen Stop auf den Wert "rectime" neu gesetzt wird. Dieser Vorgang wiederholt sich mit jedem Start-Befehl. Dadurch verlängert sich eine laufende
  6982. Aufnahme bis kein Start-Inpuls mehr registriert wird. </li>
  6983. <li> eine zuvor gestartete Endlos-Aufnahme wird mit einem erneuten "set <name> on"-Befehl nach der Aufnahmezeit "rectime" gestoppt (Timerneustart). Ist dies
  6984. nicht gewünscht, ist darauf zu achten dass bei der Verwendung einer Endlos-Aufnahme das Attribut "recextend" nicht verwendet wird. </li>
  6985. </ul>
  6986. <br>
  6987. Beispiele für einfachen <b>Start/Stop einer Aufnahme</b>: <br><br>
  6988. <table>
  6989. <colgroup> <col width=20%> <col width=80%> </colgroup>
  6990. <tr><td>set &lt;name&gt; on [rectime] </td><td>startet die Aufnahme der Kamera &lt;name&gt;, automatischer Stop der Aufnahme nach Ablauf der Zeit [rectime] (default 15s oder wie im <a href="#SSCamattr">Attribut</a> "rectime" angegeben)</td></tr>
  6991. <tr><td>set &lt;name&gt; off </td><td>stoppt die Aufnahme der Kamera &lt;name&gt;</td></tr>
  6992. </table>
  6993. </ul>
  6994. <br><br>
  6995. <ul>
  6996. <li><b> set &lt;name&gt; optimizeParams [mirror:&lt;value&gt;] [flip:&lt;value&gt;] [rotate:&lt;value&gt;] [ntp:&lt;value&gt;]</b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  6997. Setzt eine oder mehrere Eigenschaften für die Kamera. Das Video kann gespiegelt (mirror), auf den Kopf gestellt (flip) oder
  6998. gedreht (rotate) werden. Die jeweiligen Eigenschaften müssen von der Kamera unterstützt werden. Mit "ntp" wird der Zeitserver
  6999. eingestellt den die Kamera zur Zeitsynchronisation verwendet. <br><br>
  7000. &lt;value&gt; kann sein für: <br>
  7001. <ul>
  7002. <li> <b>mirror, flip, rotate: </b> true | false </li>
  7003. <li> <b>ntp: </b> der Name oder die IP-Adresse des Zeitservers </li>
  7004. </ul>
  7005. <br><br>
  7006. <b>Beispiele:</b> <br>
  7007. <code> set &lt;name&gt; optimizeParams mirror:true flip:true ntp:time.windows.com </code><br>
  7008. # Das Bild wird gespiegelt, auf den Kopf gestellt und der Zeitserver auf "time.windows.com" eingestellt.<br>
  7009. <code> set &lt;name&gt; optimizeParams ntp:Surveillance%20Station </code><br>
  7010. # Die Surveillance Station wird als Zeitserver eingestellt. (NTP-Dienst muss im DSM aktiviert sein) <br>
  7011. <code> set &lt;name&gt; optimizeParams mirror:true flip:false rotate:true </code><br>
  7012. # Das Bild wird gespiegelt und um 90 Grad gedreht. <br>
  7013. <br><br>
  7014. </ul>
  7015. <ul>
  7016. <li><b> set &lt;name&gt; pirSensor [activate | deactivate] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7017. Aktiviert / deaktiviert den Infrarot-Sensor der Kamera (sofern die Kamera einen PIR-Sensor enthält).
  7018. </ul>
  7019. <br><br>
  7020. <ul>
  7021. <li><b> set &lt;name&gt; runPatrol &lt;Patrolname&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7022. Dieses Kommando startet die vordefinierterte Überwachungstour einer PTZ-Kamera. <br>
  7023. Die Überwachungstouren müssen dazu zunächst in der Synology Surveillance Station angelegt worden sein.
  7024. Das geschieht in der PTZ-Steuerung im IP-Kamera Setup -&gt; PTZ-Steuerung -&gt; Überwachung.
  7025. Die Überwachungstouren (Patrols) werden über das Kommando "get &lt;name&gt; caminfoall" eingelesen, welches beim Restart von FHEM automatisch abgearbeitet wird.
  7026. Der Einlesevorgang kann durch ein Kamerapolling regelmäßig wiederholt werden. Ein langes Pollingintervall ist in diesem Fall empfehlenswert, da sich die
  7027. Überwachungstouren nur im Fall der Neuanlage bzw. Änderung verändern werden.
  7028. Nähere Informationen zur Anlage von Überwachungstouren sind in der Hilfe zur Surveillance Station enthalten.
  7029. </ul>
  7030. <br><br>
  7031. <ul>
  7032. <li><b> set &lt;name&gt; runView [live_fw | live_fw_hls | live_link | live_open [&lt;room&gt;] | lastrec_fw | lastrec_fw_MJPEG | lastrec_fw_MPEG4/H.264 | lastrec_open [&lt;room&gt;] | lastsnap_fw] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7033. <ul>
  7034. <table>
  7035. <colgroup> <col width=25%> <col width=75%> </colgroup>
  7036. <tr><td>live_fw </td><td>- MJPEG-LiveStream. Audiowiedergabe wird mit angeboten wenn verfügbar. </td></tr>
  7037. <tr><td>live_fw_hls </td><td>- HLS-LiveStream (aktuell nur Mac Safari und mobile iOS/Android-Geräte) </td></tr>
  7038. <tr><td>live_link </td><td>- Link zu einem MJPEG-Livestream </td></tr>
  7039. <tr><td>live_open [&lt;room&gt;] </td><td>- öffnet MJPEG-Stream in separatem Browser-Fenster </td></tr>
  7040. <tr><td>lastrec_fw </td><td>- letzte Aufnahme als iFrame Objekt </td></tr>
  7041. <tr><td>lastrec_fw_MJPEG </td><td>- nutzbar wenn Aufnahme im Format MJPEG vorliegt </td></tr>
  7042. <tr><td>lastrec_fw_MPEG4/H.264 </td><td>- nutzbar wenn Aufnahme im Format MPEG4/H.264 vorliegt </td></tr>
  7043. <tr><td>lastrec_open [&lt;room&gt;] </td><td>- letzte Aufnahme wird in separatem Browser-Fenster geöffnet </td></tr>
  7044. <tr><td>lastsnap_fw </td><td>- letzter Schnappschuss wird dargestellt </td></tr>
  7045. </table>
  7046. </ul>
  7047. <br><br>
  7048. Mit <b>"live_fw, live_link, live_open"</b> wird ein MJPEG-Livestream, entweder als eingebettetes Image
  7049. oder als generierter Link, gestartet. <br>
  7050. Der Befehl <b>"live_open"</b> öffnet ein separates Browserfenster mit dem MJPEG-Livestream. Wird dabei optional der Raum mit
  7051. angegeben, wird das Browserfenster nur dann gestartet, wenn dieser Raum aktuell im Browser geöffnet ist. <br>
  7052. Soll mit <b>"live_fw_hls"</b> ein HLS-Stream verwendet werden, muss die Kamera in der Synology Surveillance Station auf
  7053. das Videoformat H.264 (nicht MJPEG) eingestellt und HLS durch die eingesetzte SVS-Version unterstützt sein.
  7054. Diese Möglichkeit wird deshalb nur dann angeboten wenn das Reading "CamStreamFormat" den Wert "HLS" hat.
  7055. <br><br>
  7056. Der Zugriff auf die letzte Aufnahme einer Kamera kann über die Optionen <b>"lastrec_fw.*"</b> bzw. <b>"lastrec_open"</b> erfolgen.
  7057. Bei Verwendung von <b>"lastrec_fw.*"</b> wird die letzte Aufnahme als eingebettetes iFrame-Objekt abgespielt. Es werden entsprechende
  7058. Steuerungselemente zur Wiedergabegeschwindigkeit usw. angeboten wenn verfügbar. <br><br>
  7059. Der Befehl <b>"set &lt;name&gt; runView lastsnap_fw"</b> zeigt den letzten Schnappschuss der Kamera eingebettet an. <br>
  7060. Durch Angabe des optionalen Raumes bei <b>"lastrec_open"</b> erfolgt die gleiche Einschränkung wie bei "live_open". <br>
  7061. Die Gestaltung der Fenster im FHEMWEB kann durch HTML-Tags im <a href="#SSCamattr">Attribut</a> "htmlattr" beeinflusst werden.
  7062. <br><br>
  7063. <b>Beispiel:</b><br>
  7064. <pre>
  7065. attr &lt;name&gt; htmlattr width="500" height="375"
  7066. attr &lt;name&gt; htmlattr width="500" height="375" top="200" left="300"
  7067. </pre>
  7068. Wird der Stream als live_fw gestartet, ändert sich die Größe entsprechend der Angaben von Width und Hight. <br>
  7069. Das Kommando <b>"set &lt;name&gt; runView live_open"</b> startet den Livestreamlink sofort in einem neuen
  7070. Browserfenster.
  7071. Dabei wird für jede aktive FHEMWEB-Session eine Fensteröffnung initiiert. Soll dieses Verhalten geändert werden, kann
  7072. <b>"set &lt;name&gt; runView live_open &lt;room&gt;"</b> verwendet werden um das Öffnen des Browserfensters in einem
  7073. beliebigen, in einer FHEMWEB-Session aktiven Raum "&lt;room&gt;", zu initiieren.<br>
  7074. Das gesetzte <a href="#SSCamattr">Attribut</a> "livestreamprefix" überschreibt im <a href="#SSCamreadings">Reading</a> "LiveStreamUrl"
  7075. die Angaben für Protokoll, Servername und Port. Damit kann z.B. die LiveStreamUrl für den Versand und externen Zugriff
  7076. auf die SVS modifiziert werden. <br><br>
  7077. <b>Beispiel:</b><br>
  7078. <pre>
  7079. attr &lt;name&gt; livestreamprefix https://&lt;Servername&gt;:&lt;Port&gt;
  7080. </pre>
  7081. Der Livestream wird über das Kommando <b>"set &lt;name&gt; stopView"</b> wieder beendet. <br>
  7082. Die "runView" Funktion schaltet ebenfalls Streaming-Devices vom Typ "switched" in den entsprechenden Modus. <br><br>
  7083. Abhängig vom wiedergegebenen Content werden unterschiedliche Steuertasten angeboten: <br><br>
  7084. <ul>
  7085. <table>
  7086. <colgroup> <col width=25%> <col width=75%> </colgroup>
  7087. <tr><td> Start Recording </td><td>- startet eine Endlosaufnahme </td></tr>
  7088. <tr><td> Stop Recording </td><td>- stoppt eine Aufnahme </td></tr>
  7089. <tr><td> Take Snapshot </td><td>- löst einen Schnappschuß aus </td></tr>
  7090. <tr><td> Switch off </td><td>- stoppt eine laufende Wiedergabe </td></tr>
  7091. </table>
  7092. </ul>
  7093. <br>
  7094. <b>Hinweis zu HLS (HTTP Live Streaming):</b> <br>
  7095. Das Video startet mit einer technologisch bedingten Verzögerung. Jeder Stream wird in eine Reihe sehr kleiner Videodateien
  7096. (mit etwa 10 Sekunden Länge) segmentiert und an den Client ausgeliefert.
  7097. Die Kamera muss in der SVS auf das Videoformat H.264 eingestellt sein und nicht jeder Kameratyp ist gleichermassen für
  7098. HLS-Streaming geeignet.
  7099. Momentan kann HLS nur durch den Mac Safari Browser sowie auf mobilen iOS/Android-Geräten wiedergegeben werden.
  7100. </ul>
  7101. <br><br>
  7102. <ul>
  7103. <li><b> set &lt;name&gt; setHome &lt;PresetName&gt; </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für PTZ-CAM)</li> <br>
  7104. Setzt die Home-Position der Kamera auf einen vordefinierten Preset "&lt;PresetName&gt;" oder auf die aktuell angefahrene
  7105. Position.
  7106. </ul>
  7107. <br><br>
  7108. <ul>
  7109. <li><b> set &lt;name&gt; setPreset &lt;PresetNummer&gt; [&lt;PresetName&gt;] [&lt;Speed&gt;] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für PTZ-CAM)</li> <br>
  7110. Setzt einen Preset mit dem Namen "&lt;PresetName&gt;" auf die aktuell angefahrene Position der Kamera. Optional kann die
  7111. Geschwindigkeit angegeben werden (&lt;Speed&gt;). Ist kein PresetName angegeben, wird die PresetNummer als Name verwendet.
  7112. Aus diesem Grund ist &lt;PresetName&gt; optional definiert, sollte jedoch im Normalfall gesetzt werden.
  7113. </ul>
  7114. <br><br>
  7115. <ul>
  7116. <li><b> set &lt;name&gt; snap </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7117. Ein <b>Schnappschuß</b> kann ausgelöst werden mit:
  7118. <pre>
  7119. set &lt;name&gt; snap
  7120. </pre>
  7121. Nachfolgend einige Beispiele für die <b>Auslösung von Schnappschüssen</b>. <br><br>
  7122. Soll eine Reihe von Schnappschüssen ausgelöst werden wenn eine Aufnahme startet, kann das z.B. durch folgendes notify geschehen. <br>
  7123. Sobald der Start der Kamera CamHE1 ausgelöst wird (Attribut event-on-change-reading -> "Record" setzen), werden abhängig davon 3 Snapshots im Abstand von 2 Sekunden getriggert.
  7124. <pre>
  7125. define he1_snap_3 notify CamHE1:Record.*Start define h3 at +*{3}00:00:02 set CamHE1 snap
  7126. </pre>
  7127. Triggern von 2 Schnappschüssen der Kamera "CamHE1" im Abstand von 6 Sekunden nachdem der Bewegungsmelder "MelderHE1" einen Event gesendet hat, <br>
  7128. kann z.B. mit folgendem notify geschehen:
  7129. <pre>
  7130. define he1_snap_2 notify MelderHE1:on.* define h2 at +*{2}00:00:06 set CamHE1 snap
  7131. </pre>
  7132. Es wird die ID und der Filename des letzten Snapshots als Wert der Variable "LastSnapId" bzw. "LastSnapFilename" in den Readings der Kamera ausgegeben. <br><br>
  7133. </ul>
  7134. <br><br>
  7135. <ul>
  7136. <li><b> set &lt;name&gt; snapGallery [1-10] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7137. Der Befehl ist nur vorhanden wenn das Attribut "snapGalleryBoost=1" gesetzt wurde.
  7138. Er erzeugt eine Ausgabe der letzten [x] Schnappschüsse ebenso wie <a href="#SSCamget">"get &lt;name&gt; snapGallery"</a>. Abweichend von "get" wird mit Attribut
  7139. <a href="#SSCamattr">Attribut</a> "snapGalleryBoost=1" kein Popup erzeugt, sondern die Schnappschußgalerie als Browserseite
  7140. dargestellt. Alle weiteren Funktionen und Attribute entsprechen dem "get &lt;name&gt; snapGallery" Kommando. <br>
  7141. Wenn die Ausgabe einer Schnappschußgalerie, z.B. über ein "at oder "notify", getriggert wird, sollte besser das
  7142. <a href="#SSCamget">"get &lt;name&gt; snapGallery"</a> Kommando anstatt "set" verwendet werden.
  7143. </ul>
  7144. <br><br>
  7145. <ul>
  7146. <li><b> set &lt;name&gt; startTracking </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM mit Tracking Fähigkeit)</li> <br>
  7147. Startet Objekt Tracking der Kamera.
  7148. Der Befehl ist nur vorhanden wenn die Surveillance Station die Fähigkeit der Kamera zum Objekt Tracking erkannt hat
  7149. (Reading "CapPTZObjTracking").
  7150. </ul>
  7151. <br><br>
  7152. <ul>
  7153. <li><b> set &lt;name&gt; stopTracking </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM mit Tracking Fähigkeit)</li> <br>
  7154. Stoppt Objekt Tracking der Kamera.
  7155. Der Befehl ist nur vorhanden wenn die Surveillance Station die Fähigkeit der Kamera zum Objekt Tracking erkannt hat
  7156. (Reading "CapPTZObjTracking").
  7157. </ul>
  7158. <br><br>
  7159. </ul>
  7160. <br>
  7161. <a name="SSCamget"></a>
  7162. <b>Get</b>
  7163. <ul>
  7164. <br>
  7165. Mit SSCam können die Eigenschaften der Surveillance Station und der Kameras abgefragt werden. <br>
  7166. Die aufgeführten get-Befehle sind für CAM/SVS-Devices oder nur für CAM-Devices bzw. nur für SVS-Devices gültig. Sie stehen im
  7167. Drop-Down-Menü des jeweiligen Devices zur Auswahl zur Verfügung. <br><br>
  7168. <ul>
  7169. <li><b> get &lt;name&gt; caminfoall </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM/SVS)</li>
  7170. <b> get &lt;name&gt; caminfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM) <br><br>
  7171. Es werden SVS-Parameter und abhängig von der Art der Kamera (z.B. Fix- oder PTZ-Kamera) die verfügbaren Kamera-Eigenschaften
  7172. ermittelt und als Readings zur Verfügung gestellt. <br>
  7173. So wird zum Beispiel das Reading "Availability" auf "disconnected" gesetzt falls die Kamera von der Surveillance Station
  7174. getrennt ist. <br>
  7175. "getcaminfo" ruft eine Teilmenge von "getcaminfoall" ab.
  7176. </ul>
  7177. <br><br>
  7178. <ul>
  7179. <li><b> get &lt;name&gt; eventlist </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7180. Es wird das <a href="#SSCamreadings">Reading</a> "CamEventNum" und "CamLastRec"
  7181. aktualisiert, welches die Gesamtanzahl der registrierten Kameraevents und den Pfad / Namen der letzten Aufnahme enthält.
  7182. Dieser Befehl wird implizit mit "get &lt;name&gt; caminfoall" ausgeführt. <br>
  7183. Mit dem <a href="#SSCamattr">Attribut</a> "videofolderMap" kann der Inhalt des Readings "VideoFolder" überschrieben werden.
  7184. Dies kann von Vortel sein wenn das Surveillance-Verzeichnis der SVS an dem lokalen PC unter anderem Pfadnamen gemountet ist
  7185. und darüber der Zugriff auf die Aufnahmen erfolgen soll (z.B. Verwendung bei Email-Versand). <br><br>
  7186. Ein DOIF-Beispiel für den Email-Versand von Snapshot und Aufnahmelink per non-blocking sendmail:
  7187. <pre>
  7188. define CamHE1.snap.email DOIF ([CamHE1:"LastSnapFilename"])
  7189. ({DebianMailnbl ('Recipient@Domain','Bewegungsalarm CamHE1','Eine Bewegung wurde an der Haustür registriert. Aufnahmelink: \
  7190. \[CamHE1:VideoFolder]\[CamHE1:CamLastRec]','/media/sf_surveillance/@Snapshot/[CamHE1:LastSnapFilename]')})
  7191. </pre>
  7192. </ul>
  7193. <ul>
  7194. <li><b> get &lt;name&gt; homeModeState </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für SVS)</li> <br>
  7195. HomeMode-Status der Surveillance Station wird abgerufen.
  7196. </ul>
  7197. <br><br>
  7198. <ul>
  7199. <li><b> get &lt;name&gt; listLog [severity:&lt;Loglevel&gt;] [limit:&lt;Zeilenzahl&gt;] [match:&lt;Suchstring&gt;] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für SVS)</li> <br>
  7200. Ruft das Surveillance Station Log vom Synology Server ab. Ohne Angabe der optionalen Zusätze wird das gesamte Log abgerufen. <br>
  7201. Es können alle oder eine Auswahl der folgenden Optionen angegeben werden: <br><br>
  7202. <ul>
  7203. <li> &lt;Loglevel&gt; - Information, Warning oder Error. Nur Sätze mit dem Schweregrad werden abgerufen (default: alle) </li>
  7204. <li> &lt;Zeilenzahl&gt; - die angegebene Anzahl der Logzeilen (neueste) wird abgerufen (default: alle) </li>
  7205. <li> &lt;Suchstring&gt; - nur Logeinträge mit dem angegeben String werden abgerufen (Achtung: kein Regex, der Suchstring wird im Call an die SVS mitgegeben) </li>
  7206. </ul>
  7207. <br>
  7208. <b>Beispiele</b> <br>
  7209. <ul>
  7210. <code>get &lt;name&gt; listLog severity:Error limit:5 </code> <br>
  7211. Zeigt die letzten 5 Logeinträge mit dem Schweregrad "Error" <br>
  7212. <code>get &lt;name&gt; listLog severity:Information match:Carport </code> <br>
  7213. Zeigt alle Logeinträge mit dem Schweregrad "Information" die den String "Carport" enthalten <br>
  7214. <code>get &lt;name&gt; listLog severity:Warning </code> <br>
  7215. Zeigt alle Logeinträge mit dem Schweregrad "Warning" <br><br>
  7216. </ul>
  7217. Wurde mit dem <a href="#SSCamattr">Attribut</a> "pollcaminfoall" das Polling der SVS aktiviert, wird das <a href="#SSCamreadings">Reading</a>
  7218. "LastLogEntry" erstellt. <br>
  7219. Im Protokoll-Setup der SVS kann man einstellen was protokolliert werden soll. Für weitere Informationen
  7220. siehe <a href="https://www.synology.com/de-de/knowledgebase/Surveillance/help/SurveillanceStation/log_advanced">Synology Online-Hlfe</a>.
  7221. </ul>
  7222. <br><br>
  7223. <ul>
  7224. <li><b> get &lt;name&gt; listPresets </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für PTZ-CAM)</li> <br>
  7225. Die für die Kamera gespeicherten Presets werden in einem Popup ausgegeben.
  7226. </ul>
  7227. <br><br>
  7228. <ul>
  7229. <li><b> get &lt;name&gt; scanVirgin </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM/SVS)</li> <br>
  7230. Wie mit get caminfoall werden alle Informationen der SVS und Kamera abgerufen. Allerdings wird in jedem Fall eine
  7231. neue Session ID generiert (neues Login), die Kamera-ID neu ermittelt und es werden alle notwendigen API-Parameter neu
  7232. eingelesen.
  7233. </ul>
  7234. <br><br>
  7235. <ul>
  7236. <li><b> get &lt;name&gt; snapGallery [1-10] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7237. Es wird ein Popup mit den letzten [x] Schnapschüssen erzeugt. Ist das <a href="#SSCamattr">Attribut</a> "snapGalleryBoost" gesetzt,
  7238. werden die letzten Schnappschüsse (default 3) über Polling abgefragt und im Speicher gehalten. Das Verfahren hilft die Ausgabe zu beschleunigen,
  7239. kann aber möglicherweise nicht den letzten Schnappschuß anzeigen, falls dieser NICHT über das Modul ausgelöst wurde. <br>
  7240. Diese Funktion kann ebenfalls, z.B. mit "at" oder "notify", getriggert werden. Dabei wird die Schnappschußgalerie auf allen
  7241. verbundenen FHEMWEB-Instanzen als Popup angezeigt. <br><br>
  7242. Zur weiteren Steuerung dieser Funktion stehen die <a href="#SSCamattr">Attribute</a>: <br><br>
  7243. <ul>
  7244. <li>snapGalleryBoost </li>
  7245. <li>snapGalleryColumns </li>
  7246. <li>snapGalleryHtmlAttr </li>
  7247. <li>snapGalleryNumber </li>
  7248. <li>snapGallerySize </li>
  7249. </ul> <br>
  7250. zur Verfügung.
  7251. </ul> <br>
  7252. <ul>
  7253. <b>Hinweis:</b><br>
  7254. Abhängig von der Anzahl und Auflösung (Qualität) der Schnappschuß-Images werden entsprechend ausreichende CPU und/oder
  7255. RAM-Ressourcen benötigt.
  7256. </ul>
  7257. <br><br>
  7258. <ul>
  7259. <li><b> get &lt;name&gt; snapfileinfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7260. Es wird der Filename des letzten Schnapschusses ermittelt. Der Befehl wird implizit mit <b>"get &lt;name&gt; snap"</b>
  7261. ausgeführt.
  7262. </ul>
  7263. <br><br>
  7264. <ul>
  7265. <li><b> get &lt;name&gt; snapinfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7266. Es werden Schnappschussinformationen gelesen. Hilfreich wenn Schnappschüsse nicht durch SSCam, sondern durch die Bewegungserkennung der Kamera
  7267. oder Surveillance Station erzeugt werden.
  7268. </ul>
  7269. <br><br>
  7270. <ul>
  7271. <li><b> get &lt;name&gt; stmUrlPath </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM)</li> <br>
  7272. Mit diesem Kommando wird der aktuelle Streamkey der Kamera abgerufen und das Reading mit dem Key-Wert gefüllt.
  7273. Dieser Streamkey kann verwendet werden um eigene Aufrufe eines Livestreams aufzubauen (siehe Beispiel).
  7274. Wenn das <a href="#SSCamattr">Attribut</a> "showStmInfoFull" gesetzt ist, werden zusaätzliche Stream-Informationen wie "StmKeyUnicst", "StmKeymjpegHttp" ausgegeben.
  7275. Diese Readings enthalten die gültigen Stream-Pfade zu einem Livestream und können z.B. versendet und von einer entsprechenden Anwendung ohne session Id geöffnet werden.
  7276. Wenn das Attribut "livestreamprefix" (Format: "http(s)://&lt;hostname&gt;&lt;port&gt;) gesetzt ist, wird der Servername und Port überschrieben soweit es sinnvoll ist.
  7277. Wird Polling der Kameraeigenschaften genutzt, wird die stmUrlPath-Funktion automatisch mit ausgeführt.
  7278. <br><br>
  7279. Beispiel für den Aufbau eines Http-Calls zu einem Livestream mit StmKey:
  7280. <pre>
  7281. http(s)://&lt;hostname&gt;&lt;port&gt;/webapi/entry.cgi?api=SYNO.SurveillanceStation.VideoStreaming&version=1&method=Stream&format=mjpeg&cameraId=5&StmKey="31fd87279976d89bb98409728cced890"
  7282. </pre>
  7283. cameraId (Internal CAMID), StmKey müssen durch gültige Werte ersetzt werden. <br><br>
  7284. <b>Hinweis:</b> <br>
  7285. Falls der Stream-Aufruf versendet und von extern genutzt wird sowie hostname / port durch gültige Werte ersetzt und die
  7286. Routerports entsprechend geöffnet werden, ist darauf zu achten, dass diese sensiblen Daten nicht durch unauthorisierte Personen
  7287. für den Zugriff genutzt werden können !
  7288. </ul>
  7289. <br><br>
  7290. <ul>
  7291. <li><b> get &lt;name&gt; storedCredentials </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM/SVS)</li> <br>
  7292. Die gespeicherten Anmeldeinformationen (Credentials) werden in einem Popup als Klartext angezeigt.
  7293. </ul>
  7294. <br><br>
  7295. <ul>
  7296. <li><b> get &lt;name&gt; svsinfo </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM/SVS)</li> <br>
  7297. Ermittelt allgemeine Informationen zur installierten SVS-Version und andere Eigenschaften. <br>
  7298. </ul>
  7299. <br><br>
  7300. <ul>
  7301. <li><b> get &lt;name&gt; versionNotes [hints | rel | &lt;key&gt;] </b> &nbsp;&nbsp;&nbsp;&nbsp;(gilt für CAM/SVS)</li> <br>
  7302. Zeigt Release Informationen und/oder Hinweise zum Modul an. Es sind nur Release Informationen mit Bedeutung für den
  7303. Modulnutzer enthalten. <br>
  7304. Sind keine Optionen angegben, werden sowohl Release Informationen als auch Hinweise angezeigt. "rel" zeigt nur Release
  7305. Informationen und "hints" nur Hinweise an. Mit der &lt;key&gt;-Angabe wird der Hinweis mit der angegebenen Nummer
  7306. angezeigt.
  7307. Ist das Attribut "language = DE" im global Device gesetzt, erfolgt die Ausgabe der Hinweise in deutscher Sprache.
  7308. </ul>
  7309. <br><br>
  7310. </ul>
  7311. <br><br>
  7312. <a name="SSCamPolling"></a>
  7313. <b>Polling der Kamera/SVS-Eigenschaften:</b><br><br>
  7314. Die Abfrage der Kameraeigenschaften erfolgt automatisch, wenn das Attribut "pollcaminfoall" (siehe Attribute) mit einem Wert &gt; 10 gesetzt wird. <br>
  7315. Per Default ist das Attribut "pollcaminfoall" nicht gesetzt und das automatische Polling nicht aktiv. <br>
  7316. Der Wert dieses Attributes legt das Intervall der Abfrage in Sekunden fest. Ist das Attribut nicht gesetzt oder &lt; 10 wird kein automatisches Polling <br>
  7317. gestartet bzw. gestoppt wenn vorher der Wert &gt; 10 gesetzt war. <br><br>
  7318. Das Attribut "pollcaminfoall" wird durch einen Watchdog-Timer überwacht. Änderungen des Attributwertes werden alle 90 Sekunden ausgewertet und entsprechend umgesetzt. <br>
  7319. Eine Änderung des Pollingstatus / Pollingintervalls wird im FHEM-Logfile protokolliert. Diese Protokollierung kann durch Setzen des Attributes "pollnologging=1" abgeschaltet werden.<br>
  7320. Dadurch kann ein unnötiges Anwachsen des Logs vermieden werden. Ab verbose=4 wird allerdings trotz gesetzten "pollnologging"-Attribut ein Log des Pollings <br>
  7321. zu Analysezwecken aktiviert. <br><br>
  7322. Wird FHEM neu gestartet, wird bei aktivierten Polling der ersten Datenabruf innerhalb 60s nach dem Start ausgeführt. <br><br>
  7323. Der Status des automatischen Pollings wird durch das Reading "PollState" signalisiert: <br><br>
  7324. <ul>
  7325. <li><b> PollState = Active </b> - automatisches Polling wird mit Intervall entsprechend "pollcaminfoall" ausgeführt </li>
  7326. <li><b> PollState = Inactive </b> - automatisches Polling wird nicht ausgeführt </li>
  7327. </ul>
  7328. <br>
  7329. Die Bedeutung der Readingwerte ist unter <a href="#SSCamreadings">Readings</a> beschrieben. <br><br>
  7330. <b>Hinweise:</b> <br><br>
  7331. Wird Polling eingesetzt, sollte das Intervall nur so kurz wie benötigt eingestellt werden da die ermittelten Werte überwiegend statisch sind. <br>
  7332. Das eingestellte Intervall sollte nicht kleiner sein als die Summe aller HTTP-Verarbeitungszeiten.
  7333. Pro Pollingaufruf und Kamera werden ca. 10 - 20 Http-Calls gegen die Surveillance Station abgesetzt.<br><br>
  7334. Bei einem eingestellten HTTP-Timeout (siehe <a href="#SSCamattr">Attribut</a>) "httptimeout") von 4 Sekunden kann die theoretische Verarbeitungszeit nicht höher als 80 Sekunden betragen. <br>
  7335. In dem Beispiel sollte man das Pollingintervall mit einem Sicherheitszuschlag auf nicht weniger 160 Sekunden setzen. <br>
  7336. Ein praktikabler Richtwert könnte zwischen 600 - 1800 (s) liegen. <br>
  7337. Sind mehrere Kameras in SSCam definiert, sollte "pollcaminfoall" nicht bei allen Kameras auf exakt den gleichen Wert gesetzt werden um Verarbeitungsengpässe <br>
  7338. und dadurch versursachte potentielle Fehlerquellen bei der Abfrage der Synology Surveillance Station zu vermeiden. <br>
  7339. Ein geringfügiger Unterschied zwischen den Pollingintervallen der definierten Kameras von z.B. 1s kann bereits als ausreichend angesehen werden. <br><br>
  7340. <a name="SSCaminternals"></a>
  7341. <b>Internals</b> <br><br>
  7342. <ul>
  7343. Die Bedeutung der verwendeten Internals stellt die nachfolgende Liste dar: <br><br>
  7344. <ul>
  7345. <li><b>CAMID</b> - die ID der Kamera in der SVS, der Wert wird automatisch anhand des SVS-Kameranamens ermittelt. </li>
  7346. <li><b>CAMNAME</b> - der Name der Kamera in der SVS </li>
  7347. <li><b>COMPATIBILITY</b> - Information bis zu welcher SVS-Version das Modul kompatibel bzw. zur Zeit getestet ist (siehe Reading "compstate")</li>
  7348. <li><b>CREDENTIALS</b> - der Wert ist "Set" wenn die Credentials gesetzt wurden </li>
  7349. <li><b>MODEL</b> - Unterscheidung von Kamera-Device (Hersteller - Kameratyp) und Surveillance Station Device (SVS) </li>
  7350. <li><b>NAME</b> - der Kameraname in FHEM </li>
  7351. <li><b>OPMODE</b> - die zuletzt ausgeführte Operation des Moduls </li>
  7352. <li><b>SERVERADDR</b> - IP-Adresse des SVS Hostes </li>
  7353. <li><b>SERVERPORT</b> - der SVS-Port </li>
  7354. <br><br>
  7355. </ul>
  7356. </ul>
  7357. <a name="SSCamattr"></a>
  7358. <b>Attribute</b>
  7359. <br><br>
  7360. <ul>
  7361. <ul>
  7362. <a name="debugactivetoken"></a>
  7363. <li><b>debugactivetoken</b><br>
  7364. wenn gesetzt wird der Status des Active-Tokens gelogged - nur für Debugging, nicht im
  7365. normalen Betrieb benutzen ! </li><br>
  7366. <a name="disable"></a>
  7367. <li><b>disable</b><br>
  7368. deaktiviert das Gerätemodul bzw. die Gerätedefinition </li><br>
  7369. <a name="genericStrmHtmlTag"></a>
  7370. <li><b>genericStrmHtmlTag</b><br>
  7371. Das Attribut enthält HTML-Tags zur Video-Spezifikation in einem Streaming-Device von Typ "generic".
  7372. (siehe "set &lt;name&gt; createStreamDev generic") <br><br>
  7373. <ul>
  7374. <b>Beispiel:</b>
  7375. <pre>
  7376. attr &lt;name&gt; genericStrmHtmlTag &lt;video $HTMLATTR controls autoplay&gt;
  7377. &lt;source src='http://192.168.2.10:32000/$NAME.m3u8' type='application/x-mpegURL'&gt;
  7378. &lt;/video&gt;
  7379. </pre>
  7380. Die Variablen $HTMLATTR, $NAME sind Platzhalter und übernehmen ein gesetztes Attribut "htmlattr" bzw. den SSCam-Devicenamen.
  7381. </ul>
  7382. <br><br>
  7383. </li>
  7384. <a name="httptimeout"></a>
  7385. <li><b>httptimeout</b><br>
  7386. Timeout-Wert für HTTP-Aufrufe zur Synology Surveillance Station, Default: 4 Sekunden (wenn
  7387. httptimeout = "0" oder nicht gesetzt) </li><br>
  7388. <a name="htmlattr"></a>
  7389. <li><b>htmlattr</b><br>
  7390. ergänzende Angaben zur Inline-Bilddarstellung um das Verhalten wie Bildgröße zu beeinflussen. <br><br>
  7391. <ul>
  7392. <b>Beispiel:</b><br>
  7393. attr &lt;name&gt; htmlattr width="500" height="325" top="200" left="300"
  7394. </ul>
  7395. <br>
  7396. </li>
  7397. <a name="livestreamprefix"></a>
  7398. <li><b>livestreamprefix</b><br>
  7399. Überschreibt die Angaben zu Protokoll, Servernamen und Port in StmKey.*-Readings bzw. der Livestreamadresse zur
  7400. Weiterverwendung z.B. als externer Link. <br>
  7401. Die Spezifikation kann auf zwei Arten erfolgen: <br><br>
  7402. <table>
  7403. <colgroup> <col width=25%> <col width=75%> </colgroup>
  7404. <tr><td> <b>DEF</b> </td><td>: es wird Protokoll, Servername und Port aus der Definition
  7405. des SSCam-Devices verwendet </td></tr>
  7406. <tr><td> <b>http(s)://&lt;servername&gt;:&lt;port&gt;</b> </td><td>: eine eigene Adressenangabe wird verwendet </td></tr>
  7407. </table>
  7408. <br>
  7409. Servername kann der Name oder die IP-Adresse der Synology Surveillance Station sein.
  7410. </li><br>
  7411. <a name="loginRetries"></a>
  7412. <li><b>loginRetries</b><br>
  7413. setzt die Anzahl der Login-Wiederholungen im Fehlerfall (default = 3) </li><br>
  7414. <a name="noQuotesForSID"></a>
  7415. <li><b>noQuotesForSID</b><br>
  7416. dieses Attribut kann in bestimmten Fällen die Fehlermeldung "402 - permission denied"
  7417. vermeiden und ein login ermöglichen. </li><br>
  7418. <a name="pollcaminfoall"></a>
  7419. <li><b>pollcaminfoall</b><br>
  7420. Intervall der automatischen Eigenschaftsabfrage (Polling) einer Kamera (kleiner/gleich 10: kein
  7421. Polling, größer 10: Polling mit Intervall) </li><br>
  7422. <a name="pollnologging"></a>
  7423. <li><b>pollnologging</b><br>
  7424. "0" bzw. nicht gesetzt = Logging Gerätepolling aktiv (default), "1" = Logging
  7425. Gerätepolling inaktiv </li><br>
  7426. <a name="ptzPanel_Home"></a>
  7427. <li><b>ptzPanel_Home</b><br>
  7428. Im PTZ-Steuerungspaneel wird dem Home-Icon (im Attribut "ptzPanel_row02") automatisch der Wert des Readings
  7429. "PresetHome" zugewiesen.
  7430. Mit "ptzPanel_Home" kann diese Zuweisung mit einem Preset aus der verfügbaren Preset-Liste geändert werden. </li><br>
  7431. <a name="ptzPanel_iconPath"></a>
  7432. <li><b>ptzPanel_iconPath</b><br>
  7433. Pfad für Icons im PTZ-Steuerungspaneel, default ist "www/images/sscam".
  7434. Der Attribut-Wert wird für alle Icon-Dateien außer *.svg verwendet. </li><br>
  7435. <a name="ptzPanel_iconPrefix"></a>
  7436. <li><b>ptzPanel_iconPrefix</b><br>
  7437. Prefix für Icon-Dateien im PTZ-Steuerungspaneel, default ist "black_btn_".
  7438. Der Attribut-Wert wird für alle Icon-Dateien außer *.svg verwendet. <br>
  7439. Beginnen die verwendeten Icon-Dateien z.B. mit "black_btn_" ("black_btn_CAMDOWN.png"), braucht das Icon in den
  7440. Attributen "ptzPanel_row[00-09]" nur noch mit dem darauf folgenden Teilstring, z.B. "CAMDOWN.png" benannt zu werden.
  7441. </li><br>
  7442. <a name="ptzPanel_row00"></a>
  7443. <li><b>ptzPanel_row[00-09] &lt;command&gt;:&lt;icon&gt;,&lt;command&gt;:&lt;icon&gt;,... </b><br>
  7444. Für PTZ-Kameras werden automatisch die Attribute "ptzPanel_row00" bis "ptzPanel_row04" zur Verwendung im
  7445. PTZ-Steuerungspaneel angelegt. <br>
  7446. Die Attribute enthalten eine Komma-separarierte Liste von Befehl:Icon-Kombinationen (Tasten) je Paneelzeile.
  7447. Eine Paneelzeile kann beliebig viele Tasten enthalten. Die Attribute "ptzPanel_row00" bis "ptzPanel_row04" können nicht
  7448. gelöscht werden da sie in diesem Fall automatisch wieder angelegt werden. Der User kann die Attribute ändern und ergänzen.
  7449. Diese Änderungen bleiben erhalten. <br>
  7450. Bei Bedarf kann die Belegung der Home-Taste in "ptzPanel_row02" geändert werden mit dem Attribut "ptzPanel_Home". <br>
  7451. Die Icons werden im Pfad "ptzPanel_iconPath" gesucht. Dem Icon-Namen wird "ptzPanel_iconPrefix" vorangestellt.
  7452. Eigene Erweiterungen des PTZ-Steuerungspaneels können über die Attribute "ptzPanel_row05" bis "ptzPanel_row09"
  7453. vorgenommen werden. Zur Erstellung eigener Icons gibt es eine Vorlage im SVN. Für weitere Informationen bitte
  7454. "get &lt;name&gt; versionNotes 2" ausführen.
  7455. <br><br>
  7456. <b>Hinweis</b> <br>
  7457. Für eine Leerfeld verwenden sie bitte ":CAMBLANK.png" bzw. ":CAMBLANK.png,:CAMBLANK.png,:CAMBLANK.png,..." für eine
  7458. Leerzeile.
  7459. <br><br>
  7460. <ul>
  7461. <b>Beispiel:</b><br>
  7462. attr &lt;name&gt; ptzPanel_row00 move upleft:CAMUPLEFTFAST.png,:CAMBLANK.png,move up:CAMUPFAST.png,:CAMBLANK.png,move upright:CAMUPRIGHTFAST.png <br>
  7463. # Der Befehl "move upleft" wird der Kamera beim Druck auf Tastenicon "CAMUPLEFTFAST.png" übermittelt. <br>
  7464. </ul>
  7465. <br>
  7466. </li><br>
  7467. <a name="ptzPanel_use"></a>
  7468. <li><b>ptzPanel_use</b><br>
  7469. Die Anzeige des PTZ-Steuerungspaneels in der Detailanzeige bzw. innerhalb eines generierten Streamdevice wird
  7470. ein- bzw. ausgeschaltet (default ein). </li><br>
  7471. <a name="rectime"></a>
  7472. <li><b>rectime</b><br>
  7473. festgelegte Aufnahmezeit wenn eine Aufnahme gestartet wird. Mit rectime = 0 wird eine
  7474. Endlosaufnahme gestartet. Ist "rectime" nicht gesetzt, wird der Defaultwert von 15s
  7475. verwendet.</li><br>
  7476. <a name="recextend"></a>
  7477. <li><b>recextend</b><br>
  7478. "rectime" einer gestarteten Aufnahme wird neu gesetzt. Dadurch verlängert sich die
  7479. Aufnahemzeit einer laufenden Aufnahme </li><br>
  7480. <a name="session"></a>
  7481. <li><b>session</b><br>
  7482. Auswahl der Login-Session. Nicht gesetzt oder "DSM" -> session wird mit DSM aufgebaut
  7483. (Standard). "SurveillanceStation" -> Session-Aufbau erfolgt mit SVS. <br>
  7484. Um eine Session mit der Surveillance Station aufzubauen muss ein Nutzer mit passenden Privilegien Profil in der SVS
  7485. angelegt werden. Für weitere Informationen bitte "get &lt;name&gt; versionNotes 5" ausführen. </li><br>
  7486. <a name="simu_SVSversion"></a>
  7487. <li><b>simu_SVSversion</b><br>
  7488. Simuliert eine andere SVS-Version. (es ist nur eine niedrigere als die installierte SVS
  7489. Version möglich !) </li><br>
  7490. <a name="snapGalleryBoost"></a>
  7491. <li><b>snapGalleryBoost</b><br>
  7492. Wenn gesetzt, werden die letzten Schnappschüsse (default 3) über Polling im Speicher gehalten und mit "set/get snapGallery"
  7493. aufbereitet angezeigt. Dieser Modus bietet sich an wenn viele bzw. Fullsize Images angezeigt werden sollen.
  7494. Ist das Attribut eingeschaltet, können bei "set/get snapGallery" keine Argumente mehr mitgegeben werden.
  7495. (siehe Attribut "snapGalleryNumber") </li><br>
  7496. <a name="snapGalleryColumns"></a>
  7497. <li><b>snapGalleryColumns</b><br>
  7498. Die Anzahl der Snaps die in einer Reihe im Popup erscheinen sollen (default 3). </li><br>
  7499. <a name="snapGalleryHtmlAttr"></a>
  7500. <li><b>snapGalleryHtmlAttr</b><br>
  7501. hiermit kann die Bilddarstellung beeinflusst werden. <br>
  7502. Ist das Attribut nicht gesetzt, wird das Attribut "htmlattr" verwendet. <br>
  7503. Ist auch dieses nicht gesetzt, wird eine Standardvorgabe verwendet (width="500" height="325"). <br><br>
  7504. <ul>
  7505. <b>Beispiel:</b><br>
  7506. attr &lt;name&gt; snapGalleryHtmlAttr width="325" height="225"
  7507. </ul>
  7508. <br>
  7509. </li>
  7510. <a name="snapGalleryNumber"></a>
  7511. <li><b>snapGalleryNumber</b><br>
  7512. Die Anzahl der abzurufenden Schnappschüsse (default 3). </li><br>
  7513. <a name="snapGallerySize"></a>
  7514. <li><b>snapGallerySize</b><br>
  7515. Mit diesem Attribut kann die Qualität der Images eingestellt werden (default "Icon"). <br>
  7516. Im Modus "Full" wird die original vorhandene Auflösung der Images abgerufen. Dies erfordert mehr Ressourcen und kann die
  7517. Anzeige verlangsamen. Mit "snapGalleryBoost=1" kann die Ausgabe beschleunigt werden, da in diesem Fall die Aufnahmen über
  7518. Polling abgerufen und nur noch zur Anzeige gebracht werden. </li><br>
  7519. <a name="showStmInfoFull"></a>
  7520. <li><b>showStmInfoFull</b><br>
  7521. zusaätzliche Streaminformationen wie LiveStreamUrl, StmKeyUnicst, StmKeymjpegHttp werden
  7522. ausgegeben</li><br>
  7523. <a name="showPassInLog"></a>
  7524. <li><b>showPassInLog</b><br>
  7525. Wenn gesetzt, wird das verwendete Passwort im Logfile mit verbose 4 angezeigt.
  7526. (default = 0) </li><br>
  7527. <a name="videofolderMap"></a>
  7528. <li><b>videofolderMap</b><br>
  7529. ersetzt den Inhalt des Readings "VideoFolder", Verwendung z.B. bei gemounteten
  7530. Verzeichnissen </li><br>
  7531. <a name="verbose"></a>
  7532. <li><b>verbose</b> </li><br>
  7533. <ul>
  7534. Es werden verschiedene Verbose-Level unterstützt.
  7535. Dies sind im Einzelnen:
  7536. <table>
  7537. <colgroup> <col width=5%> <col width=95%> </colgroup>
  7538. <tr><td> 0 </td><td>- Start/Stop-Ereignisse werden geloggt </td></tr>
  7539. <tr><td> 1 </td><td>- Fehlermeldungen werden geloggt </td></tr>
  7540. <tr><td> 2 </td><td>- Meldungen über wichtige Ereignisse oder Alarme </td></tr>
  7541. <tr><td> 3 </td><td>- gesendete Kommandos werden geloggt </td></tr>
  7542. <tr><td> 4 </td><td>- gesendete und empfangene Daten werden geloggt </td></tr>
  7543. <tr><td> 5 </td><td>- alle Ausgaben zur Fehleranalyse werden geloggt. <b>ACHTUNG:</b> möglicherweise werden sehr viele Daten in das Logfile geschrieben! </td></tr>
  7544. </table>
  7545. </ul>
  7546. <br>
  7547. <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
  7548. <br><br>
  7549. </ul>
  7550. <a name="SSCamreadings"></a>
  7551. <b>Readings</b>
  7552. <ul>
  7553. <br>
  7554. Über den Pollingmechanismus bzw. durch Abfrage mit "Get" werden Readings bereitgestellt, deren Bedeutung in der nachfolgenden Tabelle dargestellt sind. <br>
  7555. Die übermittelten Readings können in Abhängigkeit des Kameratyps variieren.<br><br>
  7556. <ul>
  7557. <table>
  7558. <colgroup> <col width=5%> <col width=95%> </colgroup>
  7559. <tr><td><li>CamAudioType</li> </td><td>- listet den eingestellten Audiocodec auf wenn verwendet </td></tr>
  7560. <tr><td><li>Availability</li> </td><td>- Verfügbarkeit der Kamera (disabled, enabled, disconnected, other) </td></tr>
  7561. <tr><td><li>CamEventNum</li> </td><td>- liefert die Gesamtanzahl der in SVS registrierten Events der Kamera </td></tr>
  7562. <tr><td><li>CamExposureControl</li> </td><td>- zeigt den aktuell eingestellten Typ der Belichtungssteuerung </td></tr>
  7563. <tr><td><li>CamExposureMode</li> </td><td>- aktueller Belichtungsmodus (Day, Night, Auto, Schedule, Unknown) </td></tr>
  7564. <tr><td><li>CamForceEnableMulticast</li> </td><td>- sagt aus ob die Kamera verpflichet ist Multicast einzuschalten. </td></tr>
  7565. <tr><td><li>CamIP</li> </td><td>- IP-Adresse der Kamera </td></tr>
  7566. <tr><td><li>CamLastRec</li> </td><td>- Pfad / Name der letzten Aufnahme </td></tr>
  7567. <tr><td><li>CamLastRecTime</li> </td><td>- Datum / Startzeit - Stopzeit der letzten Aufnahme </td></tr>
  7568. <tr><td><li>CamLiveFps</li> </td><td>- Frames pro Sekunde des Live-Streams </td></tr>
  7569. <tr><td><li>CamLiveMode</li> </td><td>- Quelle für Live-Ansicht (DS, Camera) </td></tr>
  7570. <tr><td><li>camLiveQuality</li> </td><td>- in SVS eingestellte Live-Stream Qualität </td></tr>
  7571. <tr><td><li>camLiveResolution</li> </td><td>- in SVS eingestellte Live-Stream Auflösung </td></tr>
  7572. <tr><td><li>camLiveStreamNo</li> </td><td>- verwendete Stream-Nummer für Live-Stream </td></tr>
  7573. <tr><td><li>CamModel</li> </td><td>- Kameramodell </td></tr>
  7574. <tr><td><li>CamMotDetSc</li> </td><td>- Status der Bewegungserkennung (disabled, durch Kamera, durch SVS) und deren Parameter </td></tr>
  7575. <tr><td><li>CamNTPServer</li> </td><td>- eingestellter Zeitserver </td></tr>
  7576. <tr><td><li>CamPort</li> </td><td>- IP-Port der Kamera </td></tr>
  7577. <tr><td><li>CamPreRecTime</li> </td><td>- Dauer der der Voraufzeichnung in Sekunden (Einstellung in SVS) </td></tr>
  7578. <tr><td><li>CamPtSpeed</li> </td><td>- eingestellter Wert für Schwenken/Neige-Aktionen (Einstellung in SVS) </td></tr>
  7579. <tr><td><li>CamRecShare</li> </td><td>- gemeinsamer Ordner auf der DS für Aufnahmen </td></tr>
  7580. <tr><td><li>CamRecVolume</li> </td><td>- Volume auf der DS für Aufnahmen </td></tr>
  7581. <tr><td><li>CamStreamFormat</li> </td><td>- aktuelles Format des Videostream </td></tr>
  7582. <tr><td><li>CamVideoType</li> </td><td>- listet den eingestellten Videocodec auf </td></tr>
  7583. <tr><td><li>CamVendor</li> </td><td>- Kamerahersteller Bezeichnung </td></tr>
  7584. <tr><td><li>CamVideoFlip</li> </td><td>- Ist das Video gedreht </td></tr>
  7585. <tr><td><li>CamVideoMirror</li> </td><td>- Ist das Video gespiegelt </td></tr>
  7586. <tr><td><li>CamVideoRotate</li> </td><td>- Ist das Video gedreht </td></tr>
  7587. <tr><td><li>CapAudioOut</li> </td><td>- Fähigkeit der Kamera zur Audioausgabe über Surveillance Station (false/true) </td></tr>
  7588. <tr><td><li>CapChangeSpeed</li> </td><td>- Fähigkeit der Kamera verschiedene Bewegungsgeschwindigkeiten auszuführen </td></tr>
  7589. <tr><td><li>CapPIR</li> </td><td>- besitzt die Kamera einen PIR-Sensor </td></tr>
  7590. <tr><td><li>CapPTZAbs</li> </td><td>- Fähigkeit der Kamera für absolute PTZ-Aktionen </td></tr>
  7591. <tr><td><li>CapPTZAutoFocus</li> </td><td>- Fähigkeit der Kamera für Autofokus Aktionen </td></tr>
  7592. <tr><td><li>CapPTZDirections</li> </td><td>- die verfügbaren PTZ-Richtungen der Kamera </td></tr>
  7593. <tr><td><li>CapPTZFocus</li> </td><td>- Art der Kameraunterstützung für Fokussierung </td></tr>
  7594. <tr><td><li>CapPTZHome</li> </td><td>- Unterstützung der Kamera für Home-Position </td></tr>
  7595. <tr><td><li>CapPTZIris</li> </td><td>- Unterstützung der Kamera für Iris-Aktion </td></tr>
  7596. <tr><td><li>CapPTZObjTracking</li> </td><td>- Unterstützung der Kamera für Objekt-Tracking </td></tr>
  7597. <tr><td><li>CapPTZPan</li> </td><td>- Unterstützung der Kamera für Pan-Aktion </td></tr>
  7598. <tr><td><li>CapPTZPresetNumber</li> </td><td>- die maximale Anzahl unterstützter Presets. 0 steht für keine Preset-Unterstützung </td></tr>
  7599. <tr><td><li>CapPTZTilt</li> </td><td>- Unterstützung der Kamera für Tilt-Aktion </td></tr>
  7600. <tr><td><li>CapPTZZoom</li> </td><td>- Unterstützung der Kamera für Zoom-Aktion </td></tr>
  7601. <tr><td><li>DeviceType</li> </td><td>- Kameratyp (Camera, Video_Server, PTZ, Fisheye) </td></tr>
  7602. <tr><td><li>Error</li> </td><td>- Meldungstext des letzten Fehlers </td></tr>
  7603. <tr><td><li>Errorcode</li> </td><td>- Fehlercode des letzten Fehlers </td></tr>
  7604. <tr><td><li>HomeModeState</li> </td><td>- HomeMode-Status (ab SVS-Version 8.1.0) </td></tr>
  7605. <tr><td><li>LastLogEntry</li> </td><td>- der neueste Eintrag des Surveillance Station Logs (nur SVS-Device und wenn Attribut pollcaminfoall gesetzt) </td></tr>
  7606. <tr><td><li>LastSnapFilename</li> </td><td>- der Filename des letzten Schnapschusses </td></tr>
  7607. <tr><td><li>LastSnapId</li> </td><td>- die ID des letzten Schnapschusses </td></tr>
  7608. <tr><td><li>LastSnapTime</li> </td><td>- Zeitstempel des letzten Schnapschusses </td></tr>
  7609. <tr><td><li>LastUpdateTime</li> </td><td>- Datum / Zeit der letzten Aktualisierung durch "caminfoall" </td></tr>
  7610. <tr><td><li>LiveStreamUrl </li> </td><td>- die LiveStream-Url wenn der Stream gestartet ist. (<a href="#SSCamattr">Attribut</a> "showStmInfoFull" muss gesetzt sein) </td></tr>
  7611. <tr><td><li>Patrols</li> </td><td>- in Surveillance Station voreingestellte Überwachungstouren (bei PTZ-Kameras) </td></tr>
  7612. <tr><td><li>PollState</li> </td><td>- zeigt den Status des automatischen Pollings an </td></tr>
  7613. <tr><td><li>PresetHome</li> </td><td>- Name der Home-Position (bei PTZ-Kameras) </td></tr>
  7614. <tr><td><li>Presets</li> </td><td>- in Surveillance Station voreingestellte Positionen (bei PTZ-Kameras) </td></tr>
  7615. <tr><td><li>Record</li> </td><td>- Aufnahme läuft = Start, keine Aufnahme = Stop </td></tr>
  7616. <tr><td><li>StmKey</li> </td><td>- aktueller StreamKey. Kann zum öffnen eines Livestreams ohne Session Id genutzt werden. </td></tr>
  7617. <tr><td><li>StmKeyUnicst</li> </td><td>- Uni-cast Stream Pfad der Kamera. (<a href="#SSCamattr">Attribut</a> "showStmInfoFull" muss gesetzt sein) </td></tr>
  7618. <tr><td><li>StmKeymjpegHttp</li> </td><td>- Mjpeg Stream Pfad (über http) der Kamera. (<a href="#SSCamattr">Attribut</a> "showStmInfoFull" muss gesetzt sein) </td></tr>
  7619. <tr><td><li>SVScustomPortHttp</li> </td><td>- benutzerdefinierter Port der Surveillance Station (HTTP) im DSM-Anwendungsportal (get mit "svsinfo") </td></tr>
  7620. <tr><td><li>SVScustomPortHttps</li> </td><td>- benutzerdefinierter Port der Surveillance Station (HTTPS) im DSM-Anwendungsportal (get mit "svsinfo") </td></tr>
  7621. <tr><td><li>SVSlicenseNumber</li> </td><td>- die Anzahl der installierten Kameralizenzen (get mit "svsinfo") </td></tr>
  7622. <tr><td><li>SVSuserPriv</li> </td><td>- die effektiven Rechte des verwendeten Users nach dem Login (get mit "svsinfo") </td></tr>
  7623. <tr><td><li>SVSversion</li> </td><td>- die Paketversion der installierten Surveillance Station (get mit "svsinfo") </td></tr>
  7624. <tr><td><li>UsedSpaceMB</li> </td><td>- durch Aufnahmen der Kamera belegter Plattenplatz auf dem Volume </td></tr>
  7625. <tr><td><li>VideoFolder</li> </td><td>- Pfad zu den aufgenommenen Videos </td></tr>
  7626. <tr><td><li>compstate</li> </td><td>- Kompatibilitätsstatus (Vergleich von eingesetzter/simulierter SVS-Version zum Internal COMPATIBILITY) </td></tr>
  7627. </table>
  7628. </ul>
  7629. <br><br>
  7630. </ul>
  7631. </ul>
  7632. <br><br>
  7633. </ul>
  7634. =end html_DE
  7635. =cut