10_EnOcean.pm 864 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518
  1. ##############################################
  2. # $Id: 10_EnOcean.pm 16029 2018-01-28 18:43:46Z klaus.schauer $
  3. package main;
  4. use strict;
  5. use warnings;
  6. my $cryptFunc;
  7. my $xmlFunc;
  8. my $xml;
  9. eval "use Crypt::Rijndael";
  10. if ($@) {
  11. $cryptFunc = 0;
  12. } else {
  13. $cryptFunc = 1;
  14. }
  15. eval "use Crypt::Random qw(makerandom)";
  16. if ($@) {
  17. $cryptFunc = 0;
  18. } else {
  19. $cryptFunc = $cryptFunc == 1 ? 1 : 0;
  20. }
  21. eval "use XML::Simple";
  22. if ($@) {
  23. $xmlFunc = 0;
  24. } else {
  25. $xmlFunc = 1;
  26. $xml = new XML::Simple;
  27. }
  28. eval "use Data::Dumper";
  29. if ($@) {
  30. $xmlFunc = 0;
  31. } else {
  32. $xmlFunc = $xmlFunc == 1 ? 1 : 0;
  33. }
  34. use SetExtensions;
  35. sub EnOcean_Define($$);
  36. sub EnOcean_Initialize($);
  37. sub EnOcean_Parse($$);
  38. sub EnOcean_Get($@);
  39. sub EnOcean_Set($@);
  40. sub EnOcean_hvac_01Cmd($$$);
  41. sub EnOcean_roomCtrlPanel_00Snd($$$$$$$$);
  42. sub EnOcean_CheckSenderID($$$);
  43. sub EnOcean_SndRadio($$$$$$$$);
  44. sub EnOcean_ReadingScaled($$$$);
  45. sub EnOcean_TimerSet($);
  46. sub EnOcean_Undef($$);
  47. my %EnO_rorgname = (
  48. "A5" => "4BS", # 4BS, org 07
  49. "A6" => "ADT", # adressing destination telegram
  50. "A7" => "SMREC", # Smart Ack Relaim
  51. "B0" => "GPTI", # GP teach-in request
  52. "B1" => "GPTR", # GP teach-in response
  53. "B2" => "GPCD", # GP complete data
  54. "B3" => "GPSD", # GP selective data
  55. "C5" => "SYSEX", # remote management >> packet type 7 used
  56. "C6" => "SMLRNREQ", # Smart Ack Learn Request
  57. "C7" => "SMLRNANS", # Smart Ack Learn Answer
  58. "D0" => "SMMBOX", # Smart Ack Mail Box Functions
  59. "D1" => "MSC", # MSC
  60. "D2" => "VLD", # VLD
  61. "D4" => "UTE", # UTE
  62. "D5" => "contact", # 1BS, org 06
  63. "F6" => "switch", # RPS, org 05
  64. "30" => "SEC", # secure telegram
  65. "31" => "ENC", # secure telegram with encapsulation
  66. "32" => "SECD", # decrypted secure telegram
  67. "35" => "STE", # secure Teach-In
  68. "40" => "CDM", # chained data message
  69. );
  70. # switch commands
  71. my @EnO_ptm200btn = ("AI", "A0", "BI", "B0", "CI", "C0", "DI", "D0");
  72. my %EnO_ptm200btn;
  73. # switch.00 commands
  74. my %EnO_switch_00Btn = (
  75. "A0" => 14,
  76. "AI" => 13,
  77. "B0" => 12,
  78. "BI" => 11,
  79. "A0,B0" => 7,
  80. "A0,BI" => 10,
  81. "AI,B0" => 5,
  82. "AI,BI" => 9,
  83. "pressed" => 8,
  84. "pressed34" => 6,
  85. "released" => 15,
  86. "teachInSec" => 253,
  87. "teachOut" => 254,
  88. "teachIn" => 255
  89. );
  90. # gateway commands
  91. my @EnO_gwCmd = ("switching", "dimming", "setpointShift", "setpointBasic", "controlVar", "fanStage", "blindCmd");
  92. my %EnO_gwCmd = (
  93. "switching" => 1,
  94. "dimming" => 2,
  95. "setpointShift" => 3,
  96. "setpointBasic" => 4,
  97. "controlVar" => 5,
  98. "fanStage" => 6,
  99. "blindCmd" => 7,
  100. );
  101. # Some Manufacturers (e.g. Jaeger Direkt) also sell EnOcean products without an entry in the table below.
  102. my %EnO_manuf = (
  103. "000" => "Reserved",
  104. "001" => "Peha",
  105. "002" => "Thermokon",
  106. "003" => "Servodan",
  107. "004" => "EchoFlex Solutions",
  108. "005" => "AWAG Elektrotechnik AG (Omnio)",
  109. "006" => "Hardmeier electronics",
  110. "007" => "Regulvar Inc",
  111. "008" => "Ad Hoc Electronics",
  112. "009" => "Distech Controls",
  113. "00A" => "Kieback + Peter",
  114. "00B" => "EnOcean GmbH",
  115. "00C" => "Probare",
  116. "00D" => "Eltako",
  117. "00E" => "Leviton",
  118. "00F" => "Honeywell",
  119. "010" => "Spartan Peripheral Devices",
  120. "011" => "Siemens",
  121. "012" => "T-Mac",
  122. "013" => "Reliable Controls Corporation",
  123. "014" => "Elsner Elektronik GmbH",
  124. "015" => "Diehl Controls",
  125. "016" => "BSC Computer",
  126. "017" => "S+S Regeltechnik GmbH",
  127. "018" => "Masco Corporation",
  128. "019" => "Intesis Software SL",
  129. "01A" => "Viessmann",
  130. "01B" => "Lutuo Technology",
  131. "01C" => "Schneider Electric",
  132. "01D" => "Sauter",
  133. "01E" => "Boot-Up",
  134. "01F" => "Osram Sylvania",
  135. "020" => "Unotech",
  136. "021" => "Delta Controls Inc",
  137. "022" => "Unitronic AG",
  138. "023" => "NanoSense",
  139. "024" => "The S4 Group",
  140. "025" => "MSR Solutions",
  141. "026" => "GE",
  142. "027" => "Maico",
  143. "028" => "Ruskin Company",
  144. "029" => "Magnum Engery Solutions",
  145. "02A" => "KM Controls",
  146. "02B" => "Ecologix Controls",
  147. "02C" => "Trio 2 Sys",
  148. "02D" => "Afriso-Euro-Index",
  149. "030" => "NEC AccessTechnica Ltd",
  150. "031" => "ITEC Corporation",
  151. "032" => "Simix Co Ltd",
  152. "033" => "Permundo GmbH",
  153. "034" => "Eurotronic Technology GmbH",
  154. "035" => "Art Japan Co Ltd",
  155. "036" => "Tiansu Automation Control System Co Ltd",
  156. "038" => "Gruppo Giordano Idea Spa",
  157. "039" => "alphaEOS AG",
  158. "03A" => "Tag Technologies",
  159. "03C" => "Cloud Buildings Ltd",
  160. "03E" => "GIGA Concept",
  161. "03F" => "Sensortec",
  162. "040" => "Jaeger Direkt",
  163. "041" => "Air System Components Inc",
  164. "043" => "SODA GmbH",
  165. "045" => "Holter",
  166. "046" => "ID-RF",
  167. "049" => "Micropelt GmbH",
  168. "7FF" => "Multi user Manufacturer ID",
  169. );
  170. my %EnO_eepConfig = (
  171. "A5.02.01" => {attr => {subType => "tempSensor.01"}, GPLOT => "EnO_temp4:Temp,"},
  172. "A5.02.02" => {attr => {subType => "tempSensor.02"}, GPLOT => "EnO_temp4:Temp,"},
  173. "A5.02.03" => {attr => {subType => "tempSensor.03"}, GPLOT => "EnO_temp4:Temp,"},
  174. "A5.02.04" => {attr => {subType => "tempSensor.04"}, GPLOT => "EnO_temp4:Temp,"},
  175. "A5.02.05" => {attr => {subType => "tempSensor.05"}, GPLOT => "EnO_temp4:Temp,"},
  176. "A5.02.06" => {attr => {subType => "tempSensor.06"}, GPLOT => "EnO_temp4:Temp,"},
  177. "A5.02.07" => {attr => {subType => "tempSensor.07"}, GPLOT => "EnO_temp4:Temp,"},
  178. "A5.02.08" => {attr => {subType => "tempSensor.08"}, GPLOT => "EnO_temp4:Temp,"},
  179. "A5.02.09" => {attr => {subType => "tempSensor.09"}, GPLOT => "EnO_temp4:Temp,"},
  180. "A5.02.0A" => {attr => {subType => "tempSensor.0A"}, GPLOT => "EnO_temp4:Temp,"},
  181. "A5.02.0B" => {attr => {subType => "tempSensor.0B"}, GPLOT => "EnO_temp4:Temp,"},
  182. "A5.02.10" => {attr => {subType => "tempSensor.10"}, GPLOT => "EnO_temp4:Temp,"},
  183. "A5.02.11" => {attr => {subType => "tempSensor.11"}, GPLOT => "EnO_temp4:Temp,"},
  184. "A5.02.12" => {attr => {subType => "tempSensor.12"}, GPLOT => "EnO_temp4:Temp,"},
  185. "A5.02.13" => {attr => {subType => "tempSensor.13"}, GPLOT => "EnO_temp4:Temp,"},
  186. "A5.02.14" => {attr => {subType => "tempSensor.14"}, GPLOT => "EnO_temp4:Temp,"},
  187. "A5.02.15" => {attr => {subType => "tempSensor.15"}, GPLOT => "EnO_temp4:Temp,"},
  188. "A5.02.16" => {attr => {subType => "tempSensor.16"}, GPLOT => "EnO_temp4:Temp,"},
  189. "A5.02.17" => {attr => {subType => "tempSensor.17"}, GPLOT => "EnO_temp4:Temp,"},
  190. "A5.02.18" => {attr => {subType => "tempSensor.18"}, GPLOT => "EnO_temp4:Temp,"},
  191. "A5.02.19" => {attr => {subType => "tempSensor.19"}, GPLOT => "EnO_temp4:Temp,"},
  192. "A5.02.1A" => {attr => {subType => "tempSensor.1A"}, GPLOT => "EnO_temp4:Temp,"},
  193. "A5.02.1B" => {attr => {subType => "tempSensor.1B"}, GPLOT => "EnO_temp4:Temp,"},
  194. "A5.02.20" => {attr => {subType => "tempSensor.20"}, GPLOT => "EnO_temp4:Temp,"},
  195. "A5.02.30" => {attr => {subType => "tempSensor.30"}, GPLOT => "EnO_temp4:Temp,"},
  196. "A5.04.01" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  197. "A5.04.02" => {attr => {subType => "tempHumiSensor.02"}, GPLOT => "EnO_temp4humi6:Temp/Humi,EnO_voltage4:Voltage,"},
  198. "A5.04.03" => {attr => {subType => "tempHumiSensor.03"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  199. "A5.05.01" => {attr => {subType => "baroSensor.01"}, GPLOT => "EnO_airPressure4:Airpressure,"},
  200. "A5.06.01" => {attr => {subType => "lightSensor.01"}, GPLOT => "EnO_brightness4:Brightness,EnO_voltage4:Voltage,"},
  201. "A5.06.02" => {attr => {subType => "lightSensor.02"}, GPLOT => "EnO_brightness4:Brightness,EnO_voltage4:Voltage,"},
  202. "A5.06.03" => {attr => {subType => "lightSensor.03"}, GPLOT => "EnO_brightness4:Brightness,"},
  203. "A5.06.04" => {attr => {subType => "lightSensor.04"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,"},
  204. "A5.06.05" => {attr => {subType => "lightSensor.05"}, GPLOT => "EnO_brightness4:Brightness,EnO_voltage4:Voltage,"},
  205. "A5.07.01" => {attr => {subType => "occupSensor.01"}, GPLOT => "EnO_motion:Motion,EnO_voltage4current4:Voltage/Current,"},
  206. "A5.07.02" => {attr => {subType => "occupSensor.02"}, GPLOT => "EnO_motion:Motion4brightness4:Motion/Brightness,EnO_voltage4:Voltage,"},
  207. "A5.07.03" => {attr => {subType => "occupSensor.03"}, GPLOT => "EnO_motion:Motion4brightness4:Motion/Brightness,EnO_voltage4:Voltage,"},
  208. "A5.08.01" => {attr => {subType => "lightTempOccupSensor.01"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,EnO_voltage4:Voltage,"},
  209. "A5.08.02" => {attr => {subType => "lightTempOccupSensor.02"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,EnO_voltage4:Voltage,"},
  210. "A5.08.03" => {attr => {subType => "lightTempOccupSensor.03"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,EnO_voltage4:Voltage,"},
  211. "A5.09.01" => {attr => {subType => "COSensor.01"}, GPLOT => "EnO_A5-09-01:CO/Temp,"},
  212. "A5.09.02" => {attr => {subType => "COSensor.02"}, GPLOT => "EnO_A5-09-02:CO/Temp,EnO_voltage4:Voltage,"},
  213. "A5.09.04" => {attr => {subType => "tempHumiCO2Sensor.01"}, GPLOT => "EnO_CO2:CO2,EnO_temp4humi6:Temp/Humi,"},
  214. "A5.09.05" => {attr => {subType => "vocSensor.01"}, GPLOT => "EnO_A5-09-05:Concentration,"},
  215. "A5.09.06" => {attr => {subType => "radonSensor.01"}, GPLOT => "EnO_A5-09-06:Radon,"},
  216. "A5.09.07" => {attr => {subType => "particlesSensor.01"}, GPLOT => "EnO_A5-09-07:Particles,"},
  217. "A5.09.08" => {attr => {subType => "CO2Sensor.01"}, GPLOT => "EnO_CO2:CO2,"},
  218. "A5.09.09" => {attr => {subType => "CO2Sensor.01"}, GPLOT => "EnO_CO2:CO2,"},
  219. "A5.09.0A" => {attr => {subType => "HSensor.01"}, GPLOT => "EnO_A5-09-0A:H/Temp,EnO_voltage4:Voltage,"},
  220. "A5.09.0B" => {attr => {subType => "radiationSensor.01"}, GPLOT => "EnO_radioactivity4/Radioactivity,EnO_voltage4:Voltage,"},
  221. "A5.09.0C" => {attr => {subType => "vocSensor.01"}, GPLOT => "EnO_A5-09-05:Concentration,"},
  222. "A5.10.01" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  223. "A5.10.02" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  224. "A5.10.03" => {attr => {subType => "roomSensorControl.05", comMode => "confirm", subDef => "getNextID"}, GPLOT => "EnO_temp4:Temp,"},
  225. "A5.10.04" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  226. "A5.10.05" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  227. "A5.10.06" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  228. "A5.10.07" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  229. "A5.10.08" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  230. "A5.10.09" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  231. "A5.10.0A" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  232. "A5.10.0B" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  233. "A5.10.0C" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  234. "A5.10.0D" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  235. "A5.10.10" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  236. "A5.10.11" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  237. "A5.10.12" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  238. "A5.10.13" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  239. "A5.10.14" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  240. "A5.10.15" => {attr => {subType => "roomSensorControl.02"}, GPLOT => "EnO_temp4:Temp,"},
  241. "A5.10.16" => {attr => {subType => "roomSensorControl.02"}, GPLOT => "EnO_temp4:Temp,"},
  242. "A5.10.17" => {attr => {subType => "roomSensorControl.02"}, GPLOT => "EnO_temp4:Temp,"},
  243. "A5.10.18" => {attr => {subType => "roomSensorControl.18"}, GPLOT => "EnO_temp4:Temp,"},
  244. "A5.10.19" => {attr => {subType => "roomSensorControl.19"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  245. "A5.10.1A" => {attr => {subType => "roomSensorControl.1A"}, GPLOT => "EnO_temp4:Temp,EnO_voltage4:Voltage,"},
  246. "A5.10.1B" => {attr => {subType => "roomSensorControl.1B"}, GPLOT => "EnO_temp4:Temp,EnO_voltage4:Voltage,"},
  247. "A5.10.1C" => {attr => {subType => "roomSensorControl.1C"}, GPLOT => "EnO_temp4:Temp,"},
  248. "A5.10.1D" => {attr => {subType => "roomSensorControl.1D"}, GPLOT => "EnO_temp4humi6:Temp/Humi"},
  249. "A5.10.1E" => {attr => {subType => "roomSensorControl.1B"}, GPLOT => "EnO_temp4:Temp,"},
  250. "A5.10.1F" => {attr => {subType => "roomSensorControl.1F"}, GPLOT => "EnO_temp4:Temp,"},
  251. "A5.10.20" => {attr => {subType => "roomSensorControl.20"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  252. "A5.10.21" => {attr => {subType => "roomSensorControl.20"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  253. "A5.10.22" => {attr => {subType => "roomSensorControl.22"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  254. "A5.10.23" => {attr => {subType => "roomSensorControl.22"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  255. "A5.11.01" => {attr => {subType => "lightCtrlState.01"}, GPLOT => "EnO_A5-11-01:Dim/Brightness,"},
  256. "A5.11.02" => {attr => {subType => "tempCtrlState.01"}, GPLOT => "EnO_A5-11-02:SetpointTemp/ControlVar,"},
  257. "A5.11.03" => {attr => {subType => "shutterCtrlState.01", subDef => "getNextID", subTypeSet => "gateway", gwCmd => "blindCmd", webCmd => "opens:stop:closes:position"}, GPLOT => "EnO_A5-11-03:Position/AnglePos,"},
  258. "A5.11.04" => {attr => {subType => "lightCtrlState.02", subDef => "getNextID", subTypeSet => "lightCtrl.01", webCmd => "on:off:dim:rgb"}, GPLOT => "EnO_dimFFRGB:DimRGB,"},
  259. "A5.11.05" => {attr => {subType => "switch.05"}},
  260. "A5.12.00" => {attr => {subType => "autoMeterReading.00"}, GPLOT => "EnO_A5-12-00:Value/Counter,"},
  261. "A5.12.01" => {attr => {subType => "autoMeterReading.01"}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  262. "A5.12.02" => {attr => {subType => "autoMeterReading.02"}, GPLOT => "EnO_A5-12-02:Flowrate/Consumption,"},
  263. "A5.12.03" => {attr => {subType => "autoMeterReading.03"}, GPLOT => "EnO_A5-12-03:Flowrate/Consumption,"},
  264. "A5.12.04" => {attr => {subType => "autoMeterReading.04"}, GPLOT => "EnO_A5-12-04:Weight,EnO_A5-12-04_2:Temperature/Battery,"},
  265. "A5.12.05" => {attr => {subType => "autoMeterReading.05"}, GPLOT => "EnO_A5-12-05:Amount,EnO_A5-12-05_2:Temperature/Battery,"},
  266. "A5.12.10" => {attr => {subType => "autoMeterReading.10"}, GPLOT => "EnO_A5-12-10:Current/Change,"},
  267. "A5.13.01" => {attr => {subType => "environmentApp"}, GPLOT => "EnO_A5-13-01:WindSpeed/Raining,EnO_temp4brightness4:Temp/Brightness,"},
  268. "A5.13.02" => {attr => {subType => "environmentApp"}, GPLOT => "EnO_A5-13-01:SunIntensity,"},
  269. "A5.13.03" => {attr => {subType => "environmentApp"}},
  270. "A5.13.04" => {attr => {subType => "environmentApp"}},
  271. "A5.13.05" => {attr => {subType => "environmentApp"}},
  272. "A5.13.06" => {attr => {subType => "environmentApp"}},
  273. "A5.13.07" => {attr => {subType => "windSensor.01"}, GPLOT => "EnO_A5-13-07:WindSpeed,"},
  274. "A5.13.08" => {attr => {subType => "rainSensor.01"}, GPLOT => "EnO_A5-13-08:Raining,"},
  275. "A5.13.10" => {attr => {subType => "environmentApp"}, GPLOT => "EnO_solarRadiation4:SolarRadiation,"},
  276. "A5.14.01" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  277. "A5.14.02" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  278. "A5.14.03" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  279. "A5.14.04" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  280. "A5.14.05" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  281. "A5.14.06" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  282. "A5.14.07" => {attr => {subType => "doorContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  283. "A5.14.08" => {attr => {subType => "doorContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  284. "A5.14.09" => {attr => {subType => "windowContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  285. "A5.14.0A" => {attr => {subType => "windowContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  286. "A5.20.01" => {attr => {subType => "hvac.01", webCmd => "setpointTemp"}, GPLOT => "EnO_A5-20-01:Temp/SetpointTemp/Setpoint,EnO_A5-20-01_2:PID,"},
  287. #"A5.20.02" => {attr => {subType => "hvac.02"}},
  288. #"A5.20.03" => {attr => {subType => "hvac.03"}},
  289. "A5.20.04" => {attr => {subType => "hvac.04", webCmd => "setpointTemp"}, GPLOT => "EnO_A5-20-04:Temp/FeedTemp,EnO_A5-20-04_2:SetpointTemp/Setpoint,EnO_A5-20-04_3:PID,"},
  290. "A5.20.10" => {attr => {subType => "hvac.10", comMode => "biDir", destinationID => "unicast", subDef => "getNextID"}, GPLOT => "EnO_A5-20-10:FanSpeed,"},
  291. "A5.20.11" => {attr => {subType => "hvac.11", comMode => "biDir", destinationID => "unicast", subDef => "getNextID"}},
  292. #"A5.20.12" => {attr => {subType => "hvac.12"}},
  293. "A5.30.01" => {attr => {subType => "digitalInput.01"}, GPLOT => "EnO_A5-30-01:Contact/Battery,"},
  294. "A5.30.02" => {attr => {subType => "digitalInput.02"}, GPLOT => "EnO_A5-30-02:Contact,"},
  295. "A5.30.03" => {attr => {subType => "digitalInput.03"}, GPLOT => "EnO_A5-30-03:Contact,EnO_temp4:Temp,"},
  296. "A5.30.04" => {attr => {subType => "digitalInput.04"}, GPLOT => "EnO_A5-30-04:Contact/Digital,"},
  297. "A5.30.05" => {attr => {subType => "digitalInput.05"}, GPLOT => "EnO_A5-30-05:Contact/Voltage,"},
  298. "A5.37.01" => {attr => {subType => "energyManagement.01", webCmd => "level:max"}, GPLOT => "EnO_A5-37-01:Level,"},
  299. "A5.38.08" => {attr => {subType => "gateway"}},
  300. "A5.38.09" => {attr => {subType => "lightCtrl.01"}, GPLOT => "EnO_dimFFRGB:DimRGB,"},
  301. "A5.3F.00" => {attr => {subType => "radioLinkTest", comMode => "biDir", destinationID => "unicast", subDef => "getNextID"}},
  302. "A5.3F.7F" => {attr => {subType => "manufProfile"}},
  303. "B0.00.00" => {attr => {subType => "genericProfile"}},
  304. "C5.00.00" => {attr => {subType => "remote", manufID => "7FF"}},
  305. "D2.01.00" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  306. "D2.01.01" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  307. "D2.01.02" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  308. "D2.01.03" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,"},
  309. "D2.01.04" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  310. "D2.01.05" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  311. "D2.01.06" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  312. "D2.01.07" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  313. "D2.01.08" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  314. "D2.01.09" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  315. "D2.01.0A" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  316. "D2.01.0B" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  317. "D2.01.0C" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  318. "D2.01.0D" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  319. "D2.01.0E" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  320. "D2.01.0F" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  321. "D2.01.10" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  322. "D2.01.11" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  323. "D2.01.12" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  324. "D2.01.13" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  325. "D2.01.14" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  326. "D2.03.00" => {attr => {subType => "switch.00"}},
  327. "D2.03.10" => {attr => {subType => "windowHandle.10"}, GPLOT => "EnO_windowHandle:WindowHandle,"},
  328. "D2.05.00" => {attr => {subType => "blindsCtrl.00", webCmd => "opens:stop:closes:position"}, GPLOT => "EnO_position4angle4:Position/AnglePos,"},
  329. "D2.05.01" => {attr => {subType => "blindsCtrl.01", webCmd => "opens:stop:closes:position"}},
  330. "D2.05.02" => {attr => {subType => "blindsCtrl.00", webCmd => "opens:stop:closes:position"}, GPLOT => "EnO_position4angle4:Position/AnglePos,"},
  331. "D2.06.01" => {attr => {subType => "multisensor.01"}, GPLOT => "EnO_temp4humi4:Temp/Humi,EnO_brightness4:Brightness,"},
  332. "D2.10.00" => {attr => {subType => "roomCtrlPanel.00", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  333. "D2.10.01" => {attr => {subType => "roomCtrlPanel.00", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  334. "D2.10.02" => {attr => {subType => "roomCtrlPanel.00", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  335. "D2.11.01" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  336. "D2.11.02" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  337. "D2.11.03" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  338. "D2.11.04" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  339. "D2.11.05" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  340. "D2.11.06" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  341. "D2.11.07" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  342. "D2.11.08" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  343. "D2.20.00" => {attr => {subType => "fanCtrl.00", webCmd => "fanSpeed"}, GPLOT => "EnO_fanSpeed4humi4:FanSpeed/Humi,"},
  344. "D2.32.00" => {attr => {subType => "currentClamp.00"}, GPLOT => "EnO_D2-32-xx:Current,"},
  345. "D2.32.01" => {attr => {subType => "currentClamp.01"}, GPLOT => "EnO_D2-32-xx:Current,"},
  346. "D2.32.02" => {attr => {subType => "currentClamp.02"}, GPLOT => "EnO_D2-32-xx:Current,"},
  347. "D2.40.00" => {attr => {subType => "ledCtrlState.00"}, GPLOT => "EnO_dim4:Dim,"},
  348. "D2.40.01" => {attr => {subType => "ledCtrlState.01"}, GPLOT => "EnO_dim4RGB:DimRGB,"},
  349. "D2.50.00" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  350. "D2.50.01" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  351. "D2.50.10" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  352. "D2.50.11" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  353. "D2.A0.01" => {attr => {subType => "valveCtrl.00", defaultChannel => 0, webCmd => "opens:closes"}, GPLOT => "EnO_valveCtrl:Valve,"},
  354. "D2.B0.51" => {attr => {subType => "liquidLeakage.51"}, GPLOT => "EnO_liquidLeakage:LiquidLeakage,"},
  355. "D5.00.01" => {attr => {subType => "contact", manufID => "7FF"}, GPLOT => "EnO_contact:Contact,"},
  356. "F6.01.01" => {attr => {subType => "switch", sensorMode => "pushbutton"}},
  357. "F6.02.01" => {attr => {subType => "switch"}},
  358. "F6.02.02" => {attr => {subType => "switch"}},
  359. "F6.02.03" => {attr => {subType => "switch"}},
  360. #"F6.02.04" => {attr => {subType => "switch.04"}},
  361. "F6.03.01" => {attr => {subType => "switch"}},
  362. "F6.03.02" => {attr => {subType => "switch"}},
  363. "F6.04.01" => {attr => {subType => "keycard"}, GPLOT => "EnO_keycard:Keycard,"},
  364. #"F6.04.02" => {attr => {subType => "keycard.02"}, GPLOT => "EnO_keycard:Keycard,"},
  365. "F6.05.00" => {attr => {subType => "windSpeed.00"}},
  366. "F6.05.01" => {attr => {subType => "liquidLeakage"}, GPLOT => "EnO_liquidLeakage:LiquidLeakage,"},
  367. "F6.05.02" => {attr => {subType => "smokeDetector.02"}},
  368. "F6.10.00" => {attr => {subType => "windowHandle"}, GPLOT => "EnO_windowHandle:WindowHandle,"},
  369. #"F6.10.01" => {attr => {subType => "windowHandle.01"}, GPLOT => "EnO_windowHandle:WindowHandle,"},
  370. "F6.3F.7F" => {attr => {subType => "switch.7F"}},
  371. # special profiles
  372. "G5.07.01" => {attr => {subType => "occupSensor.01", eep => "A5-07-01", manufID => "00D", model => 'tracker'}, GPLOT => "EnO_motion:Motion,EnO_voltage4current4:Voltage/Current,"},
  373. "G5.10.12" => {attr => {subType => "roomSensorControl.01", eep => "A5-10-12", manufID => "00D", scaleMax => 40, scaleMin => 0, scaleDecimals => 1}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  374. "G5.38.08" => {attr => {subType => "gateway", eep => "A5-38-08", gwCmd => "dimming", manufID => "00D", webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,"},
  375. "H5.38.08" => {attr => {subType => "gateway", comMode => "confirm", eep => "A5-38-08", gwCmd => "dimming", manufID => "00D", model => "Eltako_TF", teachMethod => "confirm", webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,"},
  376. "G5.3F.7F" => {attr => {subType => "manufProfile", eep => "A5-3F-7F", manufID => "00D", webCmd => "opens:stop:closes"}},
  377. "H5.3F.7F" => {attr => {subType => "manufProfile", comMode => "confirm", eep => "A5-3F-7F", manufID => "00D", model => "Eltako_TF", sensorMode => 'pushbutton', settingAccuracy => "high", teachMethod => "confirm", webCmd => "opens:stop:closes"}},
  378. "M5.38.08" => {attr => {subType => "gateway", eep => "A5-38-08", gwCmd => "switching", manufID => "00D", webCmd => "on:off"}},
  379. "N5.38.08" => {attr => {subType => "gateway", comMode => "confirm", eep => "A5-38-08", gwCmd => "switching", manufID => "00D", model => "Eltako_TF", teachMethod => "confirm", webCmd => "on:off"}},
  380. "G5.ZZ.ZZ" => {attr => {subType => "PM101", manufID => "005"}, GPLOT => "EnO_motion:Motion,EnO_brightness4:Brightness,"},
  381. "L6.02.01" => {attr => {subType => "smokeDetector.02", eep => "F6-05-02", manufID => "00D"}},
  382. "ZZ.ZZ.ZZ" => {attr => {subType => "raw"}},
  383. );
  384. my %EnO_extendedRemoteFunctionCode = (
  385. 0x210 => "remoteLinkTableInfo", # get
  386. 0x211 => "remoteLinkTable", # get
  387. 0x212 => "remoteLinkTable", # set
  388. 0x213 => "remoteLinkTableGP", # get
  389. 0x214 => "remoteLinkTableGP", # set
  390. 0x220 => "remoteLearnMode", # set
  391. 0x221 => "remoteTeach", # set
  392. 0x224 => "remoteReset", # set
  393. 0x225 => "remoteRLT", # set
  394. 0x226 => "remoteApplyChanges", # set
  395. 0x227 => "remoteProductID", # get
  396. 0x230 => "remoteDevCfg", # get
  397. 0x231 => "remoteDevCfg", # set
  398. 0x232 => "remoteLinkCfg", # get
  399. 0x233 => "remoteLinkCfg", # set
  400. 0x240 => "remoteAck", # parse
  401. 0x250 => "remoteRepeater", # get
  402. 0x251 => "remoteRepeater", # set
  403. 0x252 => "remoteRepeaterFilter" # set
  404. );
  405. my %EnO_models = (
  406. "Eltako_FAE14" => {attr => {manufID => "00D"}},
  407. "Eltako_FHK14" => {attr => {manufID => "00D"}},
  408. "Eltako_FHK61" => {attr => {manufID => "00D"}},
  409. "Eltako_FSA12" => {attr => {manufID => "00D"}},
  410. "Eltako_FSB14" => {attr => {manufID => "00D"}},
  411. "Eltako_FSB61" => {attr => {manufID => "00D"}},
  412. "Eltako_FSB70" => {attr => {manufID => "00D"}},
  413. "Eltako_FSM12" => {attr => {manufID => "00D"}},
  414. "Eltako_FSM61" => {attr => {manufID => "00D"}},
  415. "Eltako_FT55" => {attr => {manufID => "00D"}},
  416. "Eltako_FTS12" => {attr => {manufID => "00D"}},
  417. "Eltako_TF"=> {attr => {manufID => "00D"}},
  418. "Holter_OEM" => {attr => {pidCtrl => "off"}},
  419. "Micropelt_MVA004" => {attr => {remoteCode => "FFFFFFFE", remoteEEP => "A5-20-01", remoteID => "getNextID", remoteManagement => "manager"}, xml => {productID => "0x004900000000", xmlDescrLocation => "/FHEM/lib/EnO_ReCom_Device_Descr.xml"}},
  420. other => {},
  421. tracker => {}
  422. );
  423. my @EnO_defaultChannel = ("all", "input", 0..29);
  424. my %wakeUpCycle = (
  425. 10 => 0,
  426. 60 => 1,
  427. 90 => 2,
  428. 120 => 3,
  429. 150 => 4,
  430. 180 => 5,
  431. 210 => 6,
  432. 240 => 7,
  433. 270 => 8,
  434. 300 => 9,
  435. 330 => 10,
  436. 360 => 11,
  437. 390 => 12,
  438. 420 => 13,
  439. 450 => 14,
  440. 480 => 15,
  441. 510 => 16,
  442. 540 => 17,
  443. 570 => 18,
  444. 600 => 19,
  445. 630 => 20,
  446. 660 => 21,
  447. 690 => 22,
  448. 720 => 23,
  449. 750 => 24,
  450. 780 => 25,
  451. 810 => 26,
  452. 840 => 27,
  453. 870 => 28,
  454. 900 => 29,
  455. 930 => 30,
  456. 960 => 31,
  457. 990 => 32,
  458. 1020 => 33,
  459. 1050 => 34,
  460. 1080 => 35,
  461. 1110 => 36,
  462. 1140 => 37,
  463. 1170 => 38,
  464. 1200 => 39,
  465. 1230 => 40,
  466. 1260 => 41,
  467. 1290 => 42,
  468. 1320 => 43,
  469. 1350 => 44,
  470. 1380 => 45,
  471. 1410 => 46,
  472. 1440 => 47,
  473. 1470 => 48,
  474. 1500 => 49,
  475. 10800 => 50,
  476. 21600 => 51,
  477. 32400 => 52,
  478. 43200 => 53,
  479. 54000 => 54,
  480. 64800 => 55,
  481. 75600 => 56,
  482. 86400 => 57,
  483. 97200 => 58,
  484. 108000 => 59,
  485. 118800 => 60,
  486. 129600 => 61,
  487. 140400 => 62,
  488. 151200 => 63,
  489. );
  490. my %wakeUpCycleInv = (
  491. 0 => 10,
  492. 1 => 60,
  493. 2 => 90,
  494. 3 => 120,
  495. 4 => 150,
  496. 5 => 180,
  497. 6 => 210,
  498. 7 => 240,
  499. 8 => 270,
  500. 9 => 300,
  501. 10 => 330,
  502. 11 => 360,
  503. 12 => 390,
  504. 13 => 420,
  505. 14 => 450,
  506. 15 => 480,
  507. 16 => 510,
  508. 17 => 540,
  509. 18 => 570,
  510. 19 => 600,
  511. 20 => 630,
  512. 21 => 660,
  513. 22 => 690,
  514. 23 => 720,
  515. 24 => 750,
  516. 25 => 780,
  517. 26 => 810,
  518. 27 => 840,
  519. 28 => 870,
  520. 29 => 900,
  521. 30 => 930,
  522. 31 => 960,
  523. 32 => 990,
  524. 33 => 1020,
  525. 34 => 1050,
  526. 35 => 1080,
  527. 36 => 1110,
  528. 37 => 1140,
  529. 38 => 1170,
  530. 39 => 1200,
  531. 40 => 1230,
  532. 41 => 1260,
  533. 42 => 1290,
  534. 43 => 1320,
  535. 44 => 1350,
  536. 45 => 1380,
  537. 46 => 1410,
  538. 47 => 1440,
  539. 48 => 1470,
  540. 49 => 1500,
  541. 50 => 10800,
  542. 51 => 21600,
  543. 52 => 32400,
  544. 53 => 43200,
  545. 54 => 54000,
  546. 55 => 64800,
  547. 56 => 75600,
  548. 57 => 86400,
  549. 58 => 97200,
  550. 59 => 108000,
  551. 60 => 118800,
  552. 61 => 129600,
  553. 62 => 140400,
  554. 63 => 151200,
  555. );
  556. my @EnO_resolution = (1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32);
  557. my @EnO_scaling = (0, 1, 10, 100, 1000, 10000, 100000, 1e6, 1e7, 0.1, 0.01, 0.001, 1e-6, 1e-9);
  558. my %EnO_gpValueEnum = (
  559. 1 => {name => "multipurpose"},
  560. 2 => {name => "buildingMode", enum => {0 => "in_use", 1 => "not_used", 2 => "protection"},
  561. enumInv => {"in_use" => 0, "not_used" => 1, "protection" => 2}},
  562. 3 => {name => "occupanyMode", enum => {0 => "occupied", 1 => "standby", 2 => "not_occupied"},
  563. enumInv => {"occupied" => 0,"standby" => 1,"not_occupied" => 2}},
  564. 4 => {name => "hvacMode", enum => {0 => "auto", 1 => "comfort", 2 => "standby", 3 => "economy", 4 => "building_protection"},
  565. enumInv => {"auto" => 0, "comfort" => 1, "standby" => 2, "economy" => 3, "building_protection" => 4}},
  566. 5 => {name => "changeoverMode", enum => {0 => "auto", 1 => "cooling", 2 => "heating"},
  567. enumInv => {"auto" => 0,"cooling" => 1,"heating" => 2}},
  568. );
  569. my %EnO_gpValueFlag = (
  570. 1 => {name => "auto/man", flag => {0 => "man", 1 => "auto"},
  571. flagInv => {"man" => 0,"auto" => 1}},
  572. 2 => {name => "buttonPressed", flag => {0 => "not_pressed", 1 => "pressed"},
  573. flagInv => {"not_pressed" => 0,"pressed" => 1}},
  574. 3 => {name => "buttonChanged", flag => {0 => "no_change", 1 => "change"},
  575. flagInv => {"no_change" => 0,"change" => 1}},
  576. 4 => {name => "day/night", flag => {0 => "night", 1 => "day"},
  577. flagInv => {"night" => 0,"day" => 1}},
  578. 5 => {name => "down", flag => {0 => "no_change", 1 => "down"},
  579. flagInv => {"no_change" => 0,"down" => 1}},
  580. 6 => {name => "generalAlarm", flag => {0 => "manual", 1 => "alarm"},
  581. flagInv => {"manual" => 0,"alarm" => 1}},
  582. 7 => {name => "heat/cool", flag => {0 => "cool", 1 => "heat"},
  583. flagInv => {"cool" => 0,"heat" => 1}},
  584. 8 => {name => "high/low", flag => {0 => "low", 1 => "high"},
  585. flagInv => {"low" => 0,"high" => 1}},
  586. 9 => {name => "occupancy", flag => {0 => "unoccupied", 1 => "occupied"},
  587. flagInv => {"unoccupied" => 0,"occupied" => 1}},
  588. 10 => {name => "on/off", flag => {0 => "off", 1 => "on"},
  589. flagInv => {"off" => 0,"on" => 1}},
  590. 11 => {name => "open/closed", flag => {0 => "closed", 1 => "open"},
  591. flagInv => {"closed" => 0,"open" => 1}},
  592. 12 => {name => "powerAlarm", flag => {0 => "no_change", 1 => "alarm"},
  593. flagInv => {"no_change" => 0,"alarm" => 1}},
  594. 13 => {name => "start/stop", flag => {0 => "stop", 1 => "start"},
  595. flagInv => {"stop" => 0,"start" => 1}},
  596. 14 => {name => "up", flag => {0 => "no_change", 1 => "up"},
  597. flagInv => {"no_change" => 0,"up" => 1}},
  598. );
  599. my %EnO_gpValueData = (
  600. 1 => {name => "acceleration", unit => "m/s2"},
  601. 2 => {name => "angle", unit => "deg"},
  602. 3 => {name => "angular_velocity", unit => "rad/s"},
  603. 4 => {name => "area", unit => "m²"},
  604. 5 => {name => "concentration", unit => "ppm"},
  605. 6 => {name => "current", unit => "A"},
  606. 7 => {name => "distance", unit => "m"},
  607. 8 => {name => "electric_field_strength", unit => "V/m"},
  608. 9 => {name => "energy", unit => "J"},
  609. 10 => {name => "number", unit => "N/A"},
  610. 11 => {name => "force", unit => "N"},
  611. 12 => {name => "frequency", unit => "Hz"},
  612. 13 => {name => "heat_flux_density", unit => "W/m2"},
  613. 14 => {name => "impulse", unit => "Ns"},
  614. 15 => {name => "luminance_intensity", unit => "lux"},
  615. 16 => {name => "magnetic_field_strength", unit => "A/m"},
  616. 17 => {name => "mass", unit => "kg"},
  617. 18 => {name => "mass_density", unit => "kg/m2"},
  618. 19 => {name => "mass_flow", unit => "kg/s"},
  619. 20 => {name => "power", unit => "W"},
  620. 21 => {name => "pressure", unit => "Pa"},
  621. 22 => {name => "relative_humidity", unit => "%"},
  622. 23 => {name => "resistance", unit => "Ohm"},
  623. 24 => {name => "temperature", unit => "C"},
  624. 25 => {name => "time", unit => "s"},
  625. 26 => {name => "torque", unit => "Nm"},
  626. 27 => {name => "velocity", unit => "m/s"},
  627. 28 => {name => "voltage", unit => "V"},
  628. 29 => {name => "volume", unit => "m3"},
  629. 30 => {name => "volumetric_flow", unit => "m3/s"},
  630. );
  631. # Initialize
  632. sub
  633. EnOcean_Initialize($)
  634. {
  635. my ($hash) = @_;
  636. my %subTypeList;
  637. my @subTypeList;
  638. foreach my $eep (keys %EnO_eepConfig){
  639. push @subTypeList, $EnO_eepConfig{$eep}{attr}{subType};
  640. }
  641. my $subTypeList = join(",", sort grep { !$subTypeList{$_}++ } @subTypeList);
  642. $hash->{AutoCreate} = {"EnO.*" => {ATTR => "creator:autocreate", FILTER => "%NAME"}};
  643. $hash->{noAutocreatedFilelog} = 1;
  644. $hash->{Match} = "^EnOcean:";
  645. $hash->{DefFn} = "EnOcean_Define";
  646. $hash->{DeleteFn} = "EnOcean_Delete";
  647. $hash->{UndefFn} = "EnOcean_Undef";
  648. $hash->{ParseFn} = "EnOcean_Parse";
  649. $hash->{SetFn} = "EnOcean_Set";
  650. #$hash->{StateFn} = "EnOcean_State";
  651. $hash->{GetFn} = "EnOcean_Get";
  652. $hash->{NotifyFn} = "EnOcean_Notify";
  653. $hash->{AttrFn} = "EnOcean_Attr";
  654. $hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 dummy:0,1 " .
  655. "showtime:1,0 " .
  656. "actualTemp angleMax:slider,-180,20,180 alarmAction " .
  657. "angleMin:slider,-180,20,180 " .
  658. "angleTime setCmdTrigger:man,refDev blockUnknownMSC:no,yes blockMotion:no,yes " .
  659. "blockTemp:no,yes blockDisplay:no,yes blockDateTime:no,yes " .
  660. "blockTimeProgram:no,yes blockOccupancy:no,yes blockSetpointTemp:no,yes " .
  661. "blockFanSpeed:no,yes blockKey:no,yes comMode:confirm,biDir,uniDir creator:autocreate,manual " .
  662. "daylightSavingTime:supported,not_supported dataEnc:VAES,AES-CBC " .
  663. "defaultChannel:" . join(",", @EnO_defaultChannel) . " " .
  664. "demandRespAction demandRespRefDev demandRespMax:A0,AI,B0,BI,C0,CI,D0,DI ".
  665. "demandRespMin:A0,AI,B0,BI,C0,CI,D0,DI demandRespRandomTime " .
  666. "demandRespThreshold:slider,0,1,15 demandRespTimeoutLevel:max,last destinationID " .
  667. "devChannel devMode:master,slave devUpdate:off,auto,demand,polling,interrupt " .
  668. "dimMax dimMin dimValueOn disable:0,1 disabledForIntervals " .
  669. "displayContent:default,humidity,off,setpointTemp,tempertureExtern,temperatureIntern,time,no_change " .
  670. "displayOrientation:0,90,180,270 " .
  671. "eep gpDef gwCmd:" . join(",", sort @EnO_gwCmd) . " humitity humidityRefDev " .
  672. "keyRcv keySnd macAlgo:no,3,4 measurementCtrl:disable,enable " .
  673. "manufID:" . join(",", sort keys %EnO_manuf) . " " .
  674. "model:" . join(",", sort keys %EnO_models) . " " .
  675. "observe:on,off observeCmdRepetition:1,2,3,4,5 observeErrorAction observeInterval observeLogic:and,or " .
  676. #observeCmds observeExeptions
  677. "observeRefDev pidActorErrorAction:errorPos,freeze pidActorCallBeforeSetting pidActorErrorPos " .
  678. "pidActorLimitLower pidActorLimitUpper pidCtrl:on,off pidDeltaTreshold pidFactor_D pidFactor_I " .
  679. "pidFactor_P pidIPortionCallBeforeSetting pidSensorTimeout " .
  680. "pollInterval postmasterID productID rampTime rcvRespAction ".
  681. "releasedChannel:A,B,C,D,I,0,auto repeatingAllowed:yes,no remoteCode remoteEEP remoteID remoteManufID " .
  682. "remoteManagement:client,manager,off rlcAlgo:no,2++,3++ rlcRcv rlcSnd rlcTX:true,false " .
  683. "reposition:directly,opens,closes rltRepeat:16,32,64,128,256 rltType:1BS,4BS " .
  684. "scaleDecimals:0,1,2,3,4,5,6,7,8,9 scaleMax scaleMin secMode:rcv,snd,bidir " .
  685. "secLevel:encapsulation,encryption,off sendDevStatus:no,yes sensorMode:switch,pushbutton " .
  686. "serviceOn:no,yes settingAccuracy:high,low setpointRefDev setpointSummerMode:slider,0,5,100 " .
  687. "setpointTempRefDev shutTime shutTimeCloses subDef " .
  688. "subDef0 subDefI subDefA subDefB subDefC subDefD subDefH subDefW " .
  689. "subType:$subTypeList subTypeSet:$subTypeList subTypeReading:$subTypeList " .
  690. "summerMode:off,on switchMode:switch,pushbutton " .
  691. "switchHysteresis switchType:direction,universal,channel,central " .
  692. "teachMethod:1BS,4BS,confirm,GP,RPS,smartAck,STE,UTE temperatureRefDev " .
  693. "temperatureScale:C,F,default,no_change timeNotation:12,24,default,no_change " .
  694. "timeProgram1 timeProgram2 timeProgram3 timeProgram4 trackerWakeUpCycle:10,20,30,40,60,120,180,240,3600,86400 updateState:default,yes,no " .
  695. "uteResponseRequest:yes,no " .
  696. "wakeUpCycle:" . join(",", keys %wakeUpCycle) . " " .
  697. $readingFnAttributes;
  698. for (my $i = 0; $i < @EnO_ptm200btn; $i++) {
  699. $EnO_ptm200btn{$EnO_ptm200btn[$i]} = "$i:30";
  700. }
  701. $EnO_ptm200btn{released} = "0:20";
  702. if ($cryptFunc == 1){
  703. Log3 undef, 2, "EnOcean Cryptographic functions available.";
  704. } else {
  705. Log3 undef, 2, "EnOcean Cryptographic functions are not available.";
  706. }
  707. if ($xmlFunc == 1){
  708. Log3 undef, 2, "EnOcean XML functions available.";
  709. } else {
  710. Log3 undef, 2, "EnOcean XML functions are not available.";
  711. }
  712. return undef;
  713. }
  714. # Define
  715. sub EnOcean_Define($$) {
  716. my ($hash, $def) = @_;
  717. my @a = split("[ \t][ \t]*", $def);
  718. my $name = $hash->{NAME};
  719. my ($autocreateFilelog, $autocreateHash, $autocreateName, $autocreateDeviceRoom, $autocreateWeblinkRoom) =
  720. ('./log/' . $name . '-%Y.log', undef, 'autocreate', 'EnOcean', 'Plots');
  721. my ($cmd, $eep, $ret);
  722. my $filelogName = "FileLog_$name";
  723. $def = "00000000";
  724. if(@a > 2 && @a < 5) {
  725. # find autocreate device
  726. while (($autocreateName, $autocreateHash) = each(%defs)) {
  727. last if ($defs{$autocreateName}{TYPE} eq "autocreate");
  728. }
  729. $autocreateDeviceRoom = AttrVal($autocreateName, "device_room", $autocreateDeviceRoom) if (defined $autocreateName);
  730. $autocreateDeviceRoom = 'EnOcean' if ($autocreateDeviceRoom eq '%TYPE');
  731. $autocreateDeviceRoom = $name if ($autocreateDeviceRoom eq '%NAME');
  732. $autocreateDeviceRoom = AttrVal($name, "room", $autocreateDeviceRoom);
  733. if ($init_done) {
  734. Log3 $name, 2, "EnOcean define " . join(' ', @a);
  735. if (!defined(AttrVal($autocreateName, "disable", undef)) && !exists($defs{$filelogName})) {
  736. # create FileLog
  737. $autocreateFilelog = $attr{$autocreateName}{filelog} if (exists $attr{$autocreateName}{filelog});
  738. $autocreateFilelog =~ s/%NAME/$name/g;
  739. $cmd = "$filelogName FileLog $autocreateFilelog $name";
  740. Log3 $filelogName, 2, "EnOcean define $cmd";
  741. $ret = CommandDefine(undef, $cmd);
  742. if($ret) {
  743. Log3 $filelogName, 2, "EnOcean ERROR: $ret";
  744. } else {
  745. $attr{$filelogName}{room} = $autocreateDeviceRoom;
  746. $attr{$filelogName}{logtype} = 'text';
  747. }
  748. }
  749. }
  750. if ($a[2] eq "getNextID") {
  751. AssignIoPort($hash) if (!exists $hash->{IODev});
  752. if (exists $hash->{OLDDEF}) {
  753. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  754. }
  755. $hash->{DEF} = $def;
  756. $def = EnOcean_CheckSenderID("getNextID", $hash->{IODev}{NAME}, "00000000");
  757. $hash->{DEF} = $def;
  758. $modules{EnOcean}{defptr}{$def} = $hash;
  759. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  760. $attr{$name}{room} = $autocreateDeviceRoom;
  761. $attr{$name}{subType} = "raw" if (!exists $attr{$name}{subType});
  762. } elsif ($a[2] =~ m/^[A-Fa-f0-9]{8}$/i) {
  763. # DestinationID
  764. $def = uc($a[2]);
  765. $hash->{DEF} = $def;
  766. if (defined($a[3]) && $a[3] =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  767. # EEP
  768. my ($rorg, $func, $type) = (uc($1), uc($2), uc($3));
  769. $rorg = "F6" if ($rorg eq "05");
  770. $rorg = "D5" if ($rorg eq "06");
  771. $rorg = "A5" if ($rorg eq "07");
  772. $eep = "$rorg.$func.$type";
  773. if (exists $EnO_eepConfig{$eep}) {
  774. if ($eep eq 'A5.3F.00') {
  775. my ($rltHash, $rltName);
  776. foreach my $dev (keys %defs) {
  777. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  778. next if (!exists($attr{$dev}{subType}));
  779. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  780. $rltHash = $defs{$dev};
  781. $rltName = $rltHash->{NAME};
  782. last;
  783. }
  784. return "Radio Link Test device already defined, use $rltName" if ($rltHash);
  785. }
  786. AssignIoPort($hash) if (!exists $hash->{IODev});
  787. if (exists $hash->{OLDDEF}) {
  788. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  789. }
  790. $modules{EnOcean}{defptr}{$def} = $hash;
  791. if (exists($attr{$name}{eep}) && $attr{$name}{eep} ne "$rorg-$func-$type") {
  792. delete $attr{$name};
  793. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . 'text'
  794. if (exists $attr{$filelogName}{logtype});
  795. # delete SVG devices
  796. my ($weblinkName, $weblinkHash);
  797. while (($weblinkName, $weblinkHash) = each(%defs)) {
  798. if ($weblinkName =~ /^SVG_$name.*/) {
  799. CommandDelete(undef, $weblinkName);
  800. Log3 $hash->{NAME}, 2, "EnOcean $weblinkName deleted";
  801. }
  802. }
  803. }
  804. $attr{$name}{eep} = "$rorg-$func-$type";
  805. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  806. $attr{$name}{room} = $autocreateDeviceRoom;
  807. foreach my $attrCntr (keys %{$EnO_eepConfig{$eep}{attr}}) {
  808. if ($attrCntr eq "subDef") {
  809. if (!exists $attr{$name}{$attrCntr}) {
  810. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_eepConfig{$eep}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  811. }
  812. } else {
  813. $attr{$name}{$attrCntr} = $EnO_eepConfig{$eep}{attr}{$attrCntr};
  814. }
  815. }
  816. EnOcean_CreateSVG(undef, $hash, $a[3]);
  817. } else {
  818. return "EEP $rorg-$func-$type not supported";
  819. }
  820. } elsif (defined($a[3]) && $a[3] =~ m/^EnOcean:.*/) {
  821. # autocreate: parse received device telegram
  822. AssignIoPort($hash) if (!exists $hash->{IODev});
  823. $modules{EnOcean}{defptr}{$def} = $hash;
  824. my @msg = split(':', $a[3]);
  825. my $packetType = hex $msg[1];
  826. if ($packetType == 1) {
  827. my ($data, $rorg, $status);
  828. #EnOcean:PacketType:RORG:MessageData:SourceID:Status:OptionalData
  829. (undef, undef, $rorg, $data, undef, $status, undef) = @msg;
  830. $attr{$name}{subType} = $EnO_rorgname{$rorg};
  831. if ($attr{$name}{subType} eq "switch") {
  832. my $nu = (hex($status) & 0x10) >> 4;
  833. my $t21 = (hex($status) & 0x20) >> 5;
  834. $attr{$name}{manufID} = "7FF";
  835. if ($t21 && $nu) {
  836. $attr{$name}{eep} = "F6-02-01";
  837. readingsSingleUpdate($hash, "teach", "RPS teach-in accepted EEP F6-02-01 Manufacturer: no ID", 1);
  838. $attr{$name}{teachMethod} = 'RPS';
  839. Log3 $name, 2, "EnOcean $name teach-in EEP F6-02-01 Manufacturer: no ID";
  840. } elsif (!$t21 && $nu) {
  841. $attr{$name}{eep} = "F6-03-01";
  842. readingsSingleUpdate($hash, "teach", "RPS teach-in accepted EEP F6-03-01 Manufacturer: no ID", 1);
  843. $attr{$name}{teachMethod} = 'RPS';
  844. Log3 $name, 2, "EnOcean $name teach-in EEP F6-03-01 Manufacturer: no ID";
  845. } elsif ($t21 && !$nu) {
  846. $attr{$name}{subType} = "windowHandle";
  847. $attr{$name}{eep} = "F6-10-00";
  848. readingsSingleUpdate($hash, "teach", "RPS teach-in accepted EEP F6-10-00 Manufacturer: no ID", 1);
  849. $attr{$name}{teachMethod} = 'RPS';
  850. Log3 $name, 2, "EnOcean $name teach-in EEP F6-10-00 Manufacturer: no ID";
  851. }
  852. } elsif ($attr{$name}{subType} eq "contact" && hex($data) & 8) {
  853. $attr{$name}{eep} = "D5-00-01";
  854. $attr{$name}{manufID} = "7FF";
  855. readingsSingleUpdate($hash, "teach", "1BS teach-in accepted EEP D5-00-01 Manufacturer: no ID", 1);
  856. $attr{$name}{teachMethod} = '1BS';
  857. Log3 $name, 2, "EnOcean $name teach-in EEP D5-00-01 Manufacturer: no ID";
  858. } elsif ($attr{$name}{subType} eq "4BS" && hex(substr($data, 6, 2)) & 8) {
  859. $hash->{helper}{teachInWait} = "4BS";
  860. readingsSingleUpdate($hash, "teach", "4BS teach-in is missing", 1);
  861. Log3 $name, 2, "EnOcean $name 4BS teach-in is missing";
  862. } elsif ($attr{$name}{subType} eq "UTE") {
  863. $hash->{helper}{teachInWait} = "UTE";
  864. } elsif ($attr{$name}{subType} eq "VLD") {
  865. $hash->{helper}{teachInWait} = "UTE";
  866. readingsSingleUpdate($hash, "teach", "UTE teach-in is missing", 1);
  867. Log3 $name, 2, "EnOcean $name UTE teach-in is missing";
  868. } elsif ($attr{$name}{subType} eq "MSC") {
  869. readingsSingleUpdate($hash, "teach", "MSC not supported", 1);
  870. Log3 $name, 2, "EnOcean $name MSC not supported";
  871. } elsif ($attr{$name}{subType} =~ m/^SEC|ENC$/) {
  872. $hash->{helper}{teachInWait} = "STE";
  873. readingsSingleUpdate($hash, "teach", "STE teach-in is missing", 1);
  874. Log3 $name, 2, "EnOcean $name STE teach-in is missing";
  875. } elsif ($attr{$name}{subType} =~ m/^GPCD|GPSD$/) {
  876. $hash->{helper}{teachInWait} = "GPTI";
  877. readingsSingleUpdate($hash, "teach", "GP teach-in is missing", 1);
  878. Log3 $name, 2, "EnOcean $name GP teach-in is missing";
  879. }
  880. } elsif ($packetType == 4) {
  881. $hash->{helper}{smartAckLearnWait} = $name;
  882. } elsif ($packetType == 7) {
  883. # remote management
  884. #EnOcean:PacketType:RORG:MessageData:SourceID:DestinationID:FunctionNumber:ManufacturerID:RSSI:Delay
  885. if (hex($msg[6]) < 0x600) {
  886. $attr{$name}{remoteManagement} = 'client';
  887. # unlock device to send acknowledgment telegram
  888. $hash->{RemoteClientUnlock} = 1;
  889. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  890. RemoveInternalTimer(\%functionHash);
  891. InternalTimer(gettimeofday() + 1, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  892. } else {
  893. $attr{$name}{remoteManagement} = 'manager';
  894. }
  895. $attr{$name}{eep} = 'C5-00-00';
  896. $attr{$name}{manufID} = substr($msg[7], 1);
  897. $attr{$name}{remoteEEP} = 'C5-00-00';
  898. $attr{$name}{remoteID} = $msg[4];
  899. $attr{$name}{remoteManufID} = substr($msg[7], 1);
  900. $attr{$name}{subType} = 'remote';
  901. $modules{EnOcean}{defptr}{$msg[4]} = $hash;
  902. }
  903. EnOcean_Parse($hash, $a[3]);
  904. if (exists $attr{$name}{eep}) {
  905. $attr{$name}{eep} =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i;
  906. $eep = uc("$1.$2.$3");
  907. if (exists($attr{$filelogName}{logtype}) && exists($EnO_eepConfig{$eep}{GPLOT})) {
  908. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . 'text';
  909. EnOcean_CreateSVG(undef, $hash, undef);
  910. }
  911. }
  912. } else {
  913. # no device infos
  914. AssignIoPort($hash) if (!exists $hash->{IODev});
  915. # assign defptr
  916. if (exists $hash->{OLDDEF}) {
  917. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  918. }
  919. $modules{EnOcean}{defptr}{$def} = $hash;
  920. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  921. $attr{$name}{room} = $autocreateDeviceRoom;
  922. $attr{$name}{subType} = "raw" if (!exists $attr{$name}{subType});
  923. }
  924. } elsif ($a[2] =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  925. # EEP
  926. my ($rorg, $func, $type) = (uc($1), uc($2), uc($3));
  927. $rorg = "F6" if ($rorg eq "05");
  928. $rorg = "D5" if ($rorg eq "06");
  929. $rorg = "A5" if ($rorg eq "07");
  930. $eep = "$rorg.$func.$type";
  931. if (exists $EnO_eepConfig{$eep}) {
  932. if ($eep eq 'A5.3F.00') {
  933. # radio link test device
  934. my ($rltHash, $rltName);
  935. foreach my $dev (keys %defs) {
  936. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  937. next if (!exists($attr{$dev}{subType}));
  938. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  939. $rltHash = $defs{$dev};
  940. $rltName = $rltHash->{NAME};
  941. last;
  942. }
  943. return "Radio Link Test device already defined, use $rltName" if ($rltHash);
  944. }
  945. AssignIoPort($hash) if (!exists $hash->{IODev});
  946. if (exists($hash->{OLDDEF}) && $hash->{OLDDEF} =~ m/^[A-Fa-f0-9]{8}$/i) {
  947. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  948. if ($hash->{DEF} =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  949. $def = $hash->{OLDDEF};
  950. $hash->{DEF} = $hash->{OLDDEF};
  951. }
  952. } else {
  953. $hash->{DEF} = $def;
  954. if ($eep eq 'A5.3F.00') {
  955. $attr{$name}{subDef} = EnOcean_CheckSenderID("getNextID", $hash->{IODev}{NAME}, "00000000");
  956. } elsif ($eep eq 'C5.00.00') {
  957. # remote management
  958. } else {
  959. $def = EnOcean_CheckSenderID("getNextID", $hash->{IODev}{NAME}, "00000000");
  960. $hash->{DEF} = $def;
  961. }
  962. }
  963. $modules{EnOcean}{defptr}{$def} = $hash;
  964. if (exists($attr{$name}{eep}) && $attr{$name}{eep} ne "$rorg-$func-$type") {
  965. delete $attr{$name};
  966. if (exists $attr{$filelogName}{logtype}) {
  967. if (exists$EnO_eepConfig{$eep}{GPLOT}) {
  968. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . 'text';
  969. } else {
  970. $attr{$filelogName}{logtype} = 'text';
  971. }
  972. }
  973. }
  974. $attr{$name}{eep} = "$rorg-$func-$type";
  975. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  976. $attr{$name}{room} = $autocreateDeviceRoom;
  977. foreach my $attrCntr (keys %{$EnO_eepConfig{$eep}{attr}}) {
  978. if ($attrCntr ne "subDef") {
  979. $attr{$name}{$attrCntr} = $EnO_eepConfig{$eep}{attr}{$attrCntr};
  980. }
  981. }
  982. EnOcean_CreateSVG('del', $hash, $a[2]);
  983. } else {
  984. return "EEP $rorg-$func-$type not supported";
  985. }
  986. } else {
  987. return "wrong syntax: define <name> EnOcean <8-digit-hex-code> [<EEP>]|getNextID|<EEP>";
  988. }
  989. } else {
  990. return "wrong syntax: define <name> EnOcean <8-digit-hex-code> [<EEP>]|getNextID|<EEP>";
  991. }
  992. # device specific actions
  993. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  994. # pid parameter
  995. @{$hash->{helper}{calcPID}} = (undef, $hash, 'defined');
  996. $hash->{helper}{stopped} = 0;
  997. #$hash->{helper}{adjust} = '';
  998. }
  999. # all notifys needed
  1000. #$hash->{NOTIFYDEV} = "global";
  1001. Log3 $name, 5, "EnOcean_define for device $name executed.";
  1002. return undef;
  1003. }
  1004. # Get
  1005. sub EnOcean_Get($@)
  1006. {
  1007. my ($hash, @a) = @_;
  1008. return "no get value specified" if (@a < 2);
  1009. my $name = $hash->{NAME};
  1010. if (IsDisabled($name)) {
  1011. Log3 $name, 4, "EnOcean $name get commands disabled.";
  1012. return;
  1013. }
  1014. my $cmdID;
  1015. my $cmdList = "";
  1016. my $data;
  1017. my $destinationID = AttrVal($name, "destinationID", undef);
  1018. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  1019. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  1020. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  1021. } elsif (!defined $destinationID || $destinationID eq "multicast") {
  1022. $destinationID = "FFFFFFFF";
  1023. } elsif ($destinationID eq "unicast") {
  1024. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  1025. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  1026. } elsif ($destinationID !~ m/^[\dA-Fa-f]{8}$/) {
  1027. return "DestinationID $destinationID wrong, choose <8-digit-hex-code>.";
  1028. }
  1029. $destinationID = uc($destinationID);
  1030. my $eep = uc(AttrVal($name, "eep", "00-00-00"));
  1031. if ($eep =~ m/^([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})$/i) {
  1032. $eep = (((hex($1) << 6) | hex($2)) << 7) | hex($3);
  1033. } else {
  1034. $eep = (((hex("FF") << 6) | hex("3F")) << 7) | hex("7F");
  1035. }
  1036. my $manufID = uc(AttrVal($name, "manufID", ""));
  1037. my $model = AttrVal($name, "model", "");
  1038. my $packetType = 1;
  1039. $packetType = 0x0A if (ReadingsVal($hash->{IODev}{NAME}, "mode", "00") eq "01");
  1040. my $remoteID = AttrVal($name, "remoteID", undef);
  1041. my $remoteManufID = uc(AttrVal($name, "remoteManufID", AttrVal($name, "manufID", "")));
  1042. my $rorg;
  1043. my $status = '00';
  1044. my $st = AttrVal($name, "subType", "");
  1045. my $stSet = AttrVal($name, "subTypeSet", undef);
  1046. if (defined $stSet) {$st = $stSet;}
  1047. my $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  1048. if ($subDef !~ m/^[\dA-F]{8}$/) {return "SenderID $subDef wrong, choose <8-digit-hex-code>.";}
  1049. my $timeNow = TimeNow();
  1050. if (AttrVal($name, "remoteManagement", "off") eq "manager") {
  1051. # Remote Management
  1052. $cmdList = "remoteDevCfg remoteFunctions:noArg remoteID:noArg remoteLinkCfg remoteLinkTableInfo:noArg remoteLinkTable remoteLinkTableGP remotePing:noArg remoteProductID:noArg remoteRepeater:noArg remoteStatus:noArg ";
  1053. }
  1054. # control get actions
  1055. # $updateState = -1: no get commands available e. g. sensors
  1056. # 0: execute get commands
  1057. # 1: execute get commands and and update reading state
  1058. # 2: execute get commands delayed
  1059. my $updateState = 1;
  1060. #Log3 $name, 5, "EnOcean $name EnOcean_Get command: " . join(" ", @a);
  1061. shift @a;
  1062. for (my $i = 0; $i < @a; $i++) {
  1063. my $cmd = $a[$i];
  1064. if ($cmd eq "remoteID") {
  1065. $cmdID = 4;
  1066. $manufID = 0x7FF;
  1067. $packetType = 7;
  1068. $rorg = "C5";
  1069. shift(@a);
  1070. $data = sprintf "0004%04X%06X", $manufID, ($eep << 3);
  1071. $destinationID = "FFFFFFFF";
  1072. $status = '0F';
  1073. $hash->{IODev}{helper}{remoteAnswerWait}{0x604}{hash} = $hash;
  1074. my %functionHash = (hash => $hash, param => 0x604);
  1075. RemoveInternalTimer(\%functionHash);
  1076. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1077. Log3 $name, 3, "EnOcean get $name $cmd";
  1078. } elsif ($cmd eq "remotePing") {
  1079. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1080. $cmdID = 6;
  1081. $manufID = 0x7FF;
  1082. $packetType = 7;
  1083. $rorg = "C5";
  1084. shift(@a);
  1085. $data = sprintf "0006%04X", $manufID;
  1086. $destinationID = $remoteID;
  1087. $status = '0F';
  1088. $hash->{IODev}{helper}{remoteAnswerWait}{0x606}{hash} = $hash;
  1089. my %functionHash = (hash => $hash, param => 0x606);
  1090. RemoveInternalTimer(\%functionHash);
  1091. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1092. Log3 $name, 3, "EnOcean get $name $cmd";
  1093. } elsif ($cmd eq "remoteFunctions") {
  1094. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1095. $cmdID = 7;
  1096. $manufID = 0x7FF;
  1097. $packetType = 7;
  1098. $rorg = "C5";
  1099. shift(@a);
  1100. $data = sprintf "0007%04X", $manufID;
  1101. $destinationID = $remoteID;
  1102. $status = '0F';
  1103. $hash->{IODev}{helper}{remoteAnswerWait}{0x607}{hash} = $hash;
  1104. my %functionHash = (hash => $hash, param => 0x607);
  1105. RemoveInternalTimer(\%functionHash);
  1106. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1107. Log3 $name, 3, "EnOcean get $name $cmd";
  1108. } elsif ($cmd eq "remoteStatus") {
  1109. $cmdID = 8;
  1110. $manufID = 0x7FF;
  1111. $packetType = 7;
  1112. $rorg = "C5";
  1113. shift(@a);
  1114. $data = sprintf "0008%04X", $manufID;
  1115. if (defined $remoteID) {
  1116. $destinationID = $remoteID;
  1117. } else {
  1118. $destinationID = 'F' x 8;
  1119. }
  1120. $status = '0F';
  1121. $hash->{IODev}{helper}{remoteAnswerWait}{0x608}{hash} = $hash;
  1122. my %functionHash = (hash => $hash, param => 0x608);
  1123. RemoveInternalTimer(\%functionHash);
  1124. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1125. Log3 $name, 3, "EnOcean get $name $cmd";
  1126. } elsif ($cmd eq "remoteLinkTableInfo") {
  1127. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1128. $cmdID = 0x210;
  1129. $manufID = 0x7FF;
  1130. $packetType = 7;
  1131. $rorg = "C5";
  1132. shift(@a);
  1133. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1134. $destinationID = $remoteID;
  1135. $status = '0F';
  1136. $hash->{IODev}{helper}{remoteAnswerWait}{0x810}{hash} = $hash;
  1137. my %functionHash = (hash => $hash, param => 0x810);
  1138. RemoveInternalTimer(\%functionHash);
  1139. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1140. Log3 $name, 3, "EnOcean get $name $cmd";
  1141. } elsif ($cmd eq "remoteLinkTable") {
  1142. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1143. $cmdID = 0x211;
  1144. $manufID = 0x7FF;
  1145. $packetType = 7;
  1146. $rorg = "C5";
  1147. my $startRef;
  1148. my $endRef;
  1149. my $direction;
  1150. if (defined($a[1]) && defined($a[2]) && defined($a[3]) && $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/ && $a[3] =~ m/^[\dA-Fa-f]{2}$/) {
  1151. shift(@a);
  1152. $direction = shift(@a);
  1153. $direction = $direction eq 'out' ? '80' : '00';
  1154. $startRef = uc(shift(@a));
  1155. $endRef = uc(shift(@a));
  1156. ($startRef, $endRef) = ($endRef, $startRef) if (hex($startRef) > hex($endRef));
  1157. } else {
  1158. return "Wrong parameter or direction/startRef/endRef not defined.";
  1159. }
  1160. $data = sprintf "%04X%04X%2s%2s%2s", $cmdID, $manufID, $direction, $startRef, $endRef;
  1161. $destinationID = $remoteID;
  1162. $status = '0F';
  1163. $hash->{IODev}{helper}{remoteAnswerWait}{0x811}{hash} = $hash;
  1164. my %functionHash = (hash => $hash, param => 0x811);
  1165. RemoveInternalTimer(\%functionHash);
  1166. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1167. Log3 $name, 3, "EnOcean get $name $cmd";
  1168. } elsif ($cmd eq "remoteLinkTableGP") {
  1169. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1170. $cmdID = 0x213;
  1171. $manufID = 0x7FF;
  1172. $packetType = 7;
  1173. $rorg = "C5";
  1174. my $direction;
  1175. my $index;
  1176. if (defined($a[1]) && defined($a[2]) && $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/) {
  1177. shift(@a);
  1178. $direction = shift(@a);
  1179. $direction = $direction eq 'out' ? '80' : '00';
  1180. $index = uc(shift(@a));
  1181. } else {
  1182. return "Wrong parameter or direction/index not defined.";
  1183. }
  1184. $data = sprintf "%04X%04X%2s%2s", $cmdID, $manufID, $direction, $index;
  1185. $destinationID = $remoteID;
  1186. $status = '0F';
  1187. $hash->{IODev}{helper}{remoteAnswerWait}{0x813}{hash} = $hash;
  1188. my %functionHash = (hash => $hash, param => 0x813);
  1189. RemoveInternalTimer(\%functionHash);
  1190. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1191. Log3 $name, 3, "EnOcean get $name $cmd";
  1192. } elsif ($cmd eq "remoteProductID") {
  1193. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1194. $cmdID = 0x227;
  1195. $manufID = 0x7FF;
  1196. $packetType = 7;
  1197. $rorg = "C5";
  1198. shift(@a);
  1199. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1200. $destinationID = $remoteID;
  1201. $status = '0F';
  1202. $hash->{IODev}{helper}{remoteAnswerWait}{0x827}{hash} = $hash;
  1203. my %functionHash = (hash => $hash, param => 0x827);
  1204. RemoveInternalTimer(\%functionHash);
  1205. InternalTimer(gettimeofday() + 5.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1206. Log3 $name, 3, "EnOcean get $name $cmd";
  1207. } elsif ($cmd eq "remoteDevCfg") {
  1208. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1209. $cmdID = 0x230;
  1210. $manufID = 0x7FF;
  1211. $packetType = 7;
  1212. $rorg = "C5";
  1213. my $startRef;
  1214. my $endRef;
  1215. my $paraLen = '00';
  1216. if (defined($a[1]) && defined($a[2]) && $a[1] =~ m/^[\dA-Fa-f]{4}$/ && $a[2] =~ m/^[\dA-Fa-f]{4}$/) {
  1217. shift(@a);
  1218. $startRef = uc(shift(@a));
  1219. $endRef = uc(shift(@a));
  1220. ($startRef, $endRef) = ($endRef, $startRef) if (hex($startRef) > hex($endRef));
  1221. if (defined($a[0]) && $a[0] =~ m/^[\dA-Fa-f]{2}$/) {
  1222. $paraLen = uc(shift(@a));
  1223. }
  1224. } else {
  1225. return "Wrong parameter or startRef/endRef not defined.";
  1226. }
  1227. $data = sprintf "%04X%04X%4s%4s%2s", $cmdID, $manufID, $startRef, $endRef, $paraLen;
  1228. $destinationID = $remoteID;
  1229. $status = '0F';
  1230. $hash->{IODev}{helper}{remoteAnswerWait}{0x830}{hash} = $hash;
  1231. my %functionHash = (hash => $hash, param => 0x830);
  1232. RemoveInternalTimer(\%functionHash);
  1233. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1234. Log3 $name, 3, "EnOcean get $name $cmd";
  1235. } elsif ($cmd eq "remoteLinkCfg") {
  1236. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1237. $cmdID = 0x232;
  1238. $manufID = 0x7FF;
  1239. $packetType = 7;
  1240. $rorg = "C5";
  1241. my $direction;
  1242. my $idx;
  1243. my $startRef;
  1244. my $endRef;
  1245. my $paraLen = '00';
  1246. if (defined($a[1]) && defined($a[2]) && defined($a[3]) && defined($a[4])
  1247. && $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/ && $a[3] =~ m/^[\dA-Fa-f]{4}$/ && $a[4] =~ m/^[\dA-Fa-f]{4}$/) {
  1248. shift(@a);
  1249. $direction = shift(@a);
  1250. $direction = $direction eq 'out' ? '80' : '00';
  1251. $idx = uc(shift(@a));
  1252. $startRef = uc(shift(@a));
  1253. $endRef = uc(shift(@a));
  1254. ($startRef, $endRef) = ($endRef, $startRef) if (hex($startRef) > hex($endRef));
  1255. if (defined($a[0]) && $a[0] =~ m/^[\dA-Fa-f]{2}$/) {
  1256. $paraLen = uc(shift(@a));
  1257. }
  1258. } else {
  1259. return "Wrong parameter or startRef/endRef not defined.";
  1260. }
  1261. $data = sprintf "%04X%04X%2s%2s%4s%4s%2s", $cmdID, $manufID, $direction, $idx, $startRef, $endRef, $paraLen;
  1262. $destinationID = $remoteID;
  1263. $status = '0F';
  1264. $hash->{IODev}{helper}{remoteAnswerWait}{0x832}{hash} = $hash;
  1265. my %functionHash = (hash => $hash, param => 0x832);
  1266. RemoveInternalTimer(\%functionHash);
  1267. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1268. Log3 $name, 3, "EnOcean get $name $cmd";
  1269. } elsif ($cmd eq "remoteRepeater") {
  1270. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1271. $cmdID = 0x250;
  1272. $manufID = 0x7FF;
  1273. $packetType = 7;
  1274. $rorg = "C5";
  1275. shift(@a);
  1276. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1277. $destinationID = $remoteID;
  1278. $status = '0F';
  1279. $hash->{IODev}{helper}{remoteAnswerWait}{0x850}{hash} = $hash;
  1280. my %functionHash = (hash => $hash, param => 0x850);
  1281. RemoveInternalTimer(\%functionHash);
  1282. InternalTimer(gettimeofday() + 5.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1283. Log3 $name, 3, "EnOcean get $name $cmd";
  1284. } elsif ($st eq "switch.05") {
  1285. # Dual Channel Switch Actuator
  1286. # (A5-11-05)
  1287. $rorg = "A5";
  1288. shift(@a);
  1289. $updateState = 0;
  1290. if ($cmd eq "state") {
  1291. # query state
  1292. Log3 $name, 3, "EnOcean get $name $cmd";
  1293. $data = "00000008";
  1294. } else {
  1295. $cmdList .= "state:noArg";
  1296. return "Unknown argument $cmd, choose one of $cmdList";
  1297. }
  1298. } elsif ($st eq "lightCtrl.01") {
  1299. # Central Command, Extended Lighting-Control
  1300. # (A5-38-09)
  1301. $rorg = "A5";
  1302. shift(@a);
  1303. $updateState = 0;
  1304. if ($cmd eq "state") {
  1305. # query state
  1306. Log3 $name, 3, "EnOcean get $name $cmd";
  1307. $data = "00000008";
  1308. } else {
  1309. $cmdList .= "state:noArg";
  1310. return "Unknown argument $cmd, choose one of $cmdList";
  1311. }
  1312. } elsif ($st eq "actuator.01") {
  1313. # Electronic switches and dimmers with Energy Measurement and Local Control
  1314. # (D2-01-00 - D2-01-12)
  1315. $rorg = "D2";
  1316. shift(@a);
  1317. my $channel;
  1318. if ($cmd !~ m/^roomCtrlMode$/) {
  1319. $channel = shift(@a);
  1320. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  1321. if (!defined $channel || $channel eq "all") {
  1322. $channel = 30;
  1323. } elsif ($channel eq "input" || $channel + 0 == 31) {
  1324. $channel = 31;
  1325. } elsif ($channel + 0 >= 30) {
  1326. $channel = 30;
  1327. } elsif ($channel + 0 >= 0 && $channel + 0 <= 29) {
  1328. } else {
  1329. return "$cmd <channel> wrong, choose 0...29|all|input.";
  1330. }
  1331. }
  1332. if ($cmd eq "state") {
  1333. $cmdID = 3;
  1334. Log3 $name, 3, "EnOcean get $name $cmd $channel";
  1335. $data = sprintf "%02X%02X", $cmdID, $channel;
  1336. } elsif ($cmd eq "measurement") {
  1337. $cmdID = 6;
  1338. my $query = shift(@a);
  1339. if (!defined $query) {
  1340. return "$cmd <channel> <query> wrong, choose 0...30|all|input energy|power.";
  1341. } elsif ($query eq "energy") {
  1342. $query = 0;
  1343. } elsif ($query eq "power") {
  1344. $query = 1;
  1345. } else {
  1346. return "$cmd <channel> <query> wrong, choose 0...30|all|input energy|power.";
  1347. }
  1348. Log3 $name, 3, "EnOcean get $name $cmd $channel $query";
  1349. $data = sprintf "%02X%02X", $cmdID, $query << 5 | $channel;
  1350. } elsif ($cmd eq "roomCtrlMode") {
  1351. Log3 $name, 3, "EnOcean get $name $cmd";
  1352. $data = '09';
  1353. } elsif ($cmd eq "settings") {
  1354. $cmdID = 10;
  1355. Log3 $name, 3, "EnOcean get $name $cmd $channel";
  1356. $data = sprintf "%02X%02X", $cmdID, $channel;
  1357. } elsif ($cmd eq "special") {
  1358. $rorg = "D1";
  1359. my $query = shift(@a);
  1360. if ($manufID eq "033") {
  1361. if (!defined $query) {
  1362. return "$cmd <channel> <query> wrong, choose health|load|voltage|serialNumber.";
  1363. } elsif ($query eq "health") {
  1364. $query = 7;
  1365. } elsif ($query eq "load") {
  1366. $query = 8;
  1367. } elsif ($query eq "voltage") {
  1368. $query = 9;
  1369. } elsif ($query eq "serialNumber") {
  1370. $query = 0x81;
  1371. } else {
  1372. return "$cmd <channel> <query> wrong, choose health|load|voltage|serialNumber.";
  1373. }
  1374. $data = sprintf "0331%02X", $query;
  1375. Log3 $name, 3, "EnOcean get $name $cmd $channel $query";
  1376. readingsSingleUpdate($hash, "getParam", $query, 0);
  1377. } elsif ($manufID eq "046") {
  1378. if (!defined $query) {
  1379. return "$cmd <channel> <query> wrong, choose reset|firmwareVersion|taughtInDevNum|taughtInDevID.";
  1380. } elsif ($query eq "reset") {
  1381. $query = 1;
  1382. $data = sprintf "0046%02X", $query;
  1383. } elsif ($query eq "firmwareVersion") {
  1384. $query = 2;
  1385. $data = sprintf "0046%02X", $query;
  1386. } elsif ($query eq "taughtInDevNum") {
  1387. $query = 4;
  1388. $data = sprintf "0046%02X", $query;
  1389. } elsif ($query eq "taughtInDevID") {
  1390. $query = 6;
  1391. my $taughtInDevNum = shift(@a);
  1392. if (defined $taughtInDevNum && $taughtInDevNum =~ m/^\d+$/ && $taughtInDevNum >= 0 && $taughtInDevNum <= 23) {
  1393. $data = sprintf "0046%02X%02X", $query, $taughtInDevNum;
  1394. } else {
  1395. return "Usage: taughtInDevID is not numeric or out of range";
  1396. }
  1397. } else {
  1398. return "$cmd <channel> <query> wrong, choose reset|firmwareVersion|taughtInDevNum|taughtInDevID.";
  1399. }
  1400. Log3 $name, 3, "EnOcean get $name $cmd $channel $query";
  1401. readingsSingleUpdate($hash, "getParam", $query, 0);
  1402. }
  1403. } else {
  1404. if ($manufID =~ m/^033|046$/) {
  1405. return "Unknown argument $cmd, choose one of " . $cmdList . "state measurement roomCtrlMode:noArg special settings";
  1406. } else {
  1407. return "Unknown argument $cmd, choose one of " . $cmdList . "state measurement roomCtrlMode:noArg settings";
  1408. }
  1409. }
  1410. } elsif ($st =~ m/^blindsCtrl\.0[01]$/) {
  1411. # Blinds Control for Position and Angle
  1412. # (D2-05-xx)
  1413. $rorg = "D2";
  1414. shift(@a);
  1415. $updateState = 0;
  1416. if ($cmd eq "position") {
  1417. # query position and angle
  1418. $cmdID = 3;
  1419. my $channel = shift(@a);
  1420. if (!defined $channel) {
  1421. $channel = AttrVal($name, "defaultChannel", 'all');
  1422. $channel = $channel eq "all" ? 15 : $channel - 1;
  1423. } elsif ($channel =~ m/^all$/) {
  1424. $channel = 15;
  1425. } elsif ($channel =~ m/^[1234]$/) {
  1426. $channel -= 1;
  1427. } else {
  1428. return "$cmd parameter wrong, choose one of 1|2|3|4|all";
  1429. }
  1430. Log3 $name, 3, "EnOcean get $name $cmd";
  1431. $data = sprintf "%02X", $channel << 4 | $cmdID;
  1432. } else {
  1433. $cmdList .= "position";
  1434. return "Unknown argument $cmd, choose one of $cmdList";
  1435. }
  1436. } elsif ($st eq "multisensor.01") {
  1437. #####
  1438. # Multisensor Windows Handle
  1439. # (D2-06-01)
  1440. $rorg = "D2";
  1441. shift(@a);
  1442. $updateState = 2;
  1443. my $waitingCmds = ReadingsVal($name, "waitingCmds", undef);
  1444. if (defined $waitingCmds) {
  1445. # check presence state
  1446. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? $waitingCmds & 0xDF | 32 : $waitingCmds & 0xDF;
  1447. } else {
  1448. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? 32 : 0;
  1449. }
  1450. if ($cmd eq "config") {
  1451. # query config
  1452. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 0x80, 0);
  1453. Log3 $name, 3, "EnOcean get $name $cmd";
  1454. } elsif ($cmd eq "log") {
  1455. # query log
  1456. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 0x40, 0);
  1457. Log3 $name, 3, "EnOcean get $name $cmd";
  1458. } else {
  1459. $cmdList .= "config:noArg log:noArg";
  1460. return "Unknown argument $cmd, choose one of $cmdList";
  1461. }
  1462. } elsif ($st eq "roomCtrlPanel.00") {
  1463. # Room Control Panel
  1464. # (D2-10-00 - D2-10-02)
  1465. $rorg = "D2";
  1466. shift(@a);
  1467. $updateState = 2;
  1468. if ($cmd eq "data") {
  1469. # data request
  1470. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 1, 0);
  1471. Log3 $name, 3, "EnOcean get $name $cmd";
  1472. } elsif ($cmd eq "config") {
  1473. # configuration request
  1474. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 32, 0);
  1475. Log3 $name, 3, "EnOcean get $name $cmd";
  1476. } elsif ($cmd eq "roomCtrl") {
  1477. # room control setup request
  1478. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 128, 0);
  1479. Log3 $name, 3, "EnOcean get $name $cmd";
  1480. } elsif ($cmd eq "timeProgram") {
  1481. # time program request
  1482. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 256, 0);
  1483. Log3 $name, 3, "EnOcean get $name $cmd";
  1484. } else {
  1485. $cmdList .= "data:noArg config:noArg roomCtrl:noArg timeProgram:noArg";
  1486. return "Unknown argument $cmd, choose one of $cmdList";
  1487. }
  1488. } elsif ($st eq "fanCtrl.00") {
  1489. # Fan Control
  1490. # (D2-20-00 - D2-20-02)
  1491. $rorg = "D2";
  1492. shift(@a);
  1493. $updateState = 0;
  1494. if ($cmd eq "state") {
  1495. # query position and angle
  1496. $data = "F6FFFFFF";
  1497. Log3 $name, 3, "EnOcean get $name $cmd DATA: $data";
  1498. } else {
  1499. $cmdList .= "state:noArg";
  1500. return "Unknown argument $cmd, choose one of $cmdList";
  1501. }
  1502. } elsif ($st eq "heatRecovery.00") {
  1503. # heat recovery ventilation
  1504. # (D2-50-00)
  1505. $rorg = "D2";
  1506. shift(@a);
  1507. $updateState = 0;
  1508. if ($cmd eq "basicState") {
  1509. # query switch state
  1510. $data = "00";
  1511. Log3 $name, 3, "EnOcean get $name $cmd";
  1512. } elsif ($cmd eq "extendedState") {
  1513. # query switch state
  1514. $data = "01";
  1515. Log3 $name, 3, "EnOcean get $name $cmd";
  1516. } else {
  1517. $cmdList .= "basicState:noArg extendedState:noArg";
  1518. return "Unknown argument $cmd, choose one of $cmdList";
  1519. }
  1520. } elsif ($st eq "valveCtrl.00" && AttrVal($name, "devMode", "master") eq "master") {
  1521. # Valve Control
  1522. # (D2-A0-01)
  1523. $rorg = "D2";
  1524. shift(@a);
  1525. $updateState = 0;
  1526. if ($cmd eq "state") {
  1527. # query switch state
  1528. $data = "00";
  1529. readingsSingleUpdate($hash, "state", $cmd, 1);
  1530. Log3 $name, 3, "EnOcean get $name $cmd";
  1531. } else {
  1532. $cmdList .= "state:noArg";
  1533. return "Unknown argument $cmd, choose one of $cmdList";
  1534. }
  1535. } elsif ($st eq "remote") {
  1536. return "Unknown argument $cmd, choose one of $cmdList";
  1537. } else {
  1538. # subtype does not support get commands
  1539. if (AttrVal($name, "remoteManagement", "off") eq "manager") {
  1540. return "Unknown argument $cmd, choose one of $cmdList";
  1541. } else {
  1542. return;
  1543. }
  1544. }
  1545. if($updateState != 2) {
  1546. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, $status, $destinationID);
  1547. }
  1548. }
  1549. }
  1550. # Set
  1551. sub EnOcean_Set($@)
  1552. {
  1553. my ($hash, @a) = @_;
  1554. return "no set value specified" if (@a < 2);
  1555. my $name = $hash->{NAME};
  1556. if (IsDisabled($name)) {
  1557. Log3 $name, 4, "EnOcean $name set commands disabled.";
  1558. return;
  1559. }
  1560. my $cmdID;
  1561. my $cmdList = "";
  1562. my @cmdObserve = @a;
  1563. my ($ctrl, $data, $err, $logLevel, $response);
  1564. my $destinationID = AttrVal($name, "destinationID", undef);
  1565. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  1566. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  1567. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  1568. } elsif (!defined $destinationID || $destinationID eq "multicast") {
  1569. $destinationID = "FFFFFFFF";
  1570. } elsif ($destinationID eq "unicast") {
  1571. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  1572. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  1573. } elsif ($destinationID !~ m/^[\dA-Fa-f]{8}$/) {
  1574. return "DestinationID $destinationID wrong, choose <8-digit-hex-code>.";
  1575. }
  1576. $destinationID = uc($destinationID);
  1577. my $IODev = $hash->{IODev}{NAME};
  1578. my $IOHash = $defs{$IODev};
  1579. my $manufID = uc(AttrVal($name, "manufID", ""));
  1580. my $model = AttrVal($name, "model", "");
  1581. my $packetType = 1;
  1582. $packetType = 0x0A if (ReadingsVal($IODev, "mode", "00") eq "01");
  1583. my $remoteID = AttrVal($name, "remoteID", undef);
  1584. my $remoteManufID = uc(AttrVal($name, "remoteManufID", AttrVal($name, "manufID", "")));
  1585. my $rorg;
  1586. my $sendCmd = 1;
  1587. my $status = "00";
  1588. my $st = AttrVal($name, "subType", "");
  1589. my $stSet = AttrVal($name, "subTypeSet", undef);
  1590. if (defined $stSet) {$st = $stSet;}
  1591. my $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  1592. if ($subDef !~ m/^[\dA-F]{8}$/) {return "SenderID $subDef wrong, choose <8-digit-hex-code>.";}
  1593. my $switchMode = AttrVal($name, "switchMode", "switch");
  1594. my $timeNow = TimeNow();
  1595. my $remoteManagement = AttrVal($name, "remoteManagement", "off");
  1596. if ($remoteManagement eq "manager") {
  1597. # Remote Management Manager
  1598. $cmdList = "remoteAction:noArg remoteApplyChanges:devCfg,linkTable,no_change remoteDevCfg remoteLinkCfg remoteLock:noArg remoteLearnMode remoteLinkTable remoteLinkTableGP remoteRepeater remoteRepeaterFilter remoteReset:devCfg,linkTableIn,linkTableOut,no_change remoteRLT remoteSetCode:noArg remoteTeach remoteUnlock:noArg ";
  1599. } elsif ($remoteManagement eq "client" || $st eq "remote") {
  1600. # Remote Management Client
  1601. $cmdList .= "remoteLock:noArg remoteUnlock ";
  1602. }
  1603. # control set actions
  1604. # $updateState = -1: no set commands available e. g. sensors
  1605. # 0: execute set commands
  1606. # 1: execute set commands and and update reading state
  1607. # 2: execute set commands delayed
  1608. # 3: internal command
  1609. my $updateState = AttrVal($name, "comMode", "uniDir") eq "uniDir" ? 1 : 0;
  1610. my $updateStateAttr = AttrVal($name, "updateState", "default");
  1611. shift @a;
  1612. for (my $i = 0; $i < @a; $i++) {
  1613. my $cmd = $a[$i];
  1614. my ($cmd1, $cmd2);
  1615. if ($cmd eq "remoteUnlock") {
  1616. if ($remoteManagement eq "manager") {
  1617. # manager
  1618. $cmdID = 1;
  1619. my $remoteCode = AttrVal($name, "remoteCode", undef);
  1620. return "Security Code not defined, set attr $name remoteCode <00000001 ... FFFFFFFE>!" if (!defined($remoteCode));
  1621. $manufID = 0x7FF;
  1622. $packetType = 7;
  1623. $rorg = "C5";
  1624. $data = sprintf "%04X%04X%s", $cmdID, $manufID, uc($remoteCode);
  1625. if (defined $remoteID) {
  1626. $destinationID = $remoteID;
  1627. } else {
  1628. $destinationID = 'F' x 8;
  1629. }
  1630. $updateState = 0;
  1631. } else {
  1632. # client
  1633. my $remoteUnlockPeriod = 1800;
  1634. if (defined $a[1]) {
  1635. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 1800) {
  1636. $remoteUnlockPeriod = $a[1];
  1637. shift(@a);
  1638. } else {
  1639. return "Usage: $a[1] is not numeric or out of range";
  1640. }
  1641. }
  1642. $hash->{RemoteClientUnlock} = 1;
  1643. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  1644. RemoveInternalTimer(\%functionHash);
  1645. InternalTimer(gettimeofday() + $remoteUnlockPeriod, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  1646. $updateState = 3;
  1647. }
  1648. Log3 $name, 3, "EnOcean set $name $cmd";
  1649. } elsif ($cmd eq "remoteLock") {
  1650. if ($remoteManagement eq "manager") {
  1651. # manager
  1652. $cmdID = 2;
  1653. my $remoteCode = AttrVal($name, "remoteCode", undef);
  1654. return "Security Code not defined, set attr $name remoteCode <00000001 ... FFFFFFFE>!" if (!defined($remoteCode));
  1655. $manufID = 0x7FF;
  1656. $packetType = 7;
  1657. $rorg = "C5";
  1658. $data = sprintf "%04X%04X%s", $cmdID, $manufID, uc($remoteCode);
  1659. if (defined $remoteID) {
  1660. $destinationID = $remoteID;
  1661. } else {
  1662. $destinationID = 'F' x 8;
  1663. }
  1664. $updateState = 0;
  1665. } else {
  1666. # client
  1667. delete $hash->{RemoteClientUnlock};
  1668. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  1669. RemoveInternalTimer(\%functionHash);
  1670. $updateState = 3;
  1671. }
  1672. Log3 $name, 3, "EnOcean set $name $cmd";
  1673. } elsif ($cmd eq "remoteSetCode") {
  1674. $cmdID = 3;
  1675. my $remoteCode = AttrVal($name, "remoteCode", undef);
  1676. return "Security Code not defined, set attr $name remoteCode <00000001 ... FFFFFFFE>!" if (!defined($remoteCode));
  1677. $manufID = 0x7FF;
  1678. $packetType = 7;
  1679. $rorg = "C5";
  1680. $data = sprintf "%04X%04X%s", $cmdID, $manufID, uc($remoteCode);
  1681. if (defined $remoteID) {
  1682. $destinationID = $remoteID;
  1683. } else {
  1684. $destinationID = 'F' x 8;
  1685. }
  1686. Log3 $name, 3, "EnOcean set $name $cmd";
  1687. $updateState = 0;
  1688. } elsif ($cmd eq "remoteAction") {
  1689. $cmdID = 5;
  1690. $manufID = 0x7FF;
  1691. $packetType = 7;
  1692. $rorg = "C5";
  1693. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1694. if (defined $remoteID) {
  1695. $destinationID = $remoteID;
  1696. } else {
  1697. $destinationID = 'F' x 8;
  1698. }
  1699. Log3 $name, 3, "EnOcean set $name $cmd";
  1700. $updateState = 0;
  1701. } elsif ($cmd eq "remoteLinkTable") {
  1702. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1703. if (defined $a[1] && defined $a[2] && defined $a[3] && defined $a[4] && defined $a[5] &&
  1704. $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/ && $a[3] =~ m/^[\dA-Fa-f]{8}$/ && $a[4] =~ m/^[\dA-Fa-f]{2}-[\dA-Fa-f]{2}-[\dA-Fa-f]{2}$/ && $a[5] =~ m/^[\dA-Fa-f]{2}$/) {
  1705. $cmdID = 0x212;
  1706. $manufID = 0x7FF;
  1707. $packetType = 7;
  1708. $rorg = "C5";
  1709. $a[4] =~ m/^(..)-(..)-(..)$/;
  1710. $data = sprintf "%04X%04X%s%s%s%s%s%s%s", $cmdID, $manufID, $a[1] eq 'out' ? '80' : '00', uc($a[2]), uc($a[3]), uc($1), uc($2), uc($3), uc($a[5]);
  1711. splice(@a,0,5);
  1712. Log3 $name, 3, "EnOcean set $name $cmd";
  1713. $updateState = 0;
  1714. } else {
  1715. return "Usage: $cmd arguments needed or wrong.";
  1716. }
  1717. } elsif ($cmd eq "remoteLinkTableGP") {
  1718. # gpDef example: ch2:O:1:24:1:7:-40:1:40:1
  1719. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1720. if (defined $a[1] && defined $a[2] && defined $a[3] && $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/) {
  1721. $cmdID = 0x214;
  1722. $manufID = 0x7FF;
  1723. $packetType = 7;
  1724. $rorg = "C5";
  1725. my $direction = $a[1] eq 'out' ? '80' : '00';
  1726. my $gpDef;
  1727. my ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  1728. split(':', $a[3]);
  1729. if ($channelDir eq "O" && $a[1] eq 'out' || $channelDir eq "I" && $a[1] eq 'in') {
  1730. # add channel-, signal- and valuetype
  1731. $gpDef .= substr(unpack('B8', pack('C', $channelType)), 6) .
  1732. unpack('B8', pack('C', $signalType)) .
  1733. substr(unpack('B8', pack('C', $valueType)), 6);
  1734. if ($channelType == 1 || $channelType == 3) {
  1735. # data, enumeration: add resolution
  1736. $gpDef .= substr(unpack('B8', pack('C', $resolution)), 4);
  1737. }
  1738. if ($channelType == 1) {
  1739. # data: add engineering and scaling
  1740. $gpDef .= unpack('B8', pack('c', $engMin)) .
  1741. substr(unpack('B8', pack('C', $scalingMin)), 4) .
  1742. unpack('B8', pack('c', $engMax)) .
  1743. substr(unpack('B8', pack('C', $scalingMax)), 4);
  1744. }
  1745. } else {
  1746. return "Usage: Link Table GP Entry Direction wrong.";
  1747. }
  1748. if (length($gpDef) % 8) {
  1749. # fill with trailing zeroes to x bytes
  1750. $gpDef .= 0 x (8 - length($gpDef) % 8);
  1751. }
  1752. $data = sprintf "%04X%04X%s%s%s", $cmdID, $manufID, $a[1] eq 'out' ? '80' : '00', uc($a[2]), EnOcean_convBitToHex($gpDef);
  1753. splice(@a,0,3);
  1754. Log3 $name, 3, "EnOcean set $name $cmd";
  1755. $updateState = 0;
  1756. } else {
  1757. return "Usage: $cmd arguments needed or wrong.";
  1758. }
  1759. } elsif ($cmd eq "remoteLearnMode") {
  1760. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1761. if (defined $a[1]) {
  1762. $cmdID = 0x220;
  1763. $manufID = 0x7FF;
  1764. $packetType = 7;
  1765. $rorg = "C5";
  1766. $destinationID = $remoteID;
  1767. my $learnMode;
  1768. my $cmdVal = 0;
  1769. if ($a[1] eq 'in') {
  1770. $learnMode = '00';
  1771. shift(@a);
  1772. } elsif ($a[1] eq 'out') {
  1773. $learnMode = '40';
  1774. shift(@a);
  1775. } elsif ($a[1] eq 'off') {
  1776. $learnMode = '80';
  1777. shift(@a);
  1778. } else {
  1779. return "Usage: $cmd $a[1] argument unknown.";
  1780. }
  1781. if (defined $a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  1782. $cmdVal = $a[1];
  1783. shift(@a);
  1784. } else {
  1785. return "Usage: $cmd <learnMode> argument needed or wrong.";
  1786. }
  1787. $data = sprintf "%04X%04X%s%s", $cmdID, $manufID, $learnMode, $cmdVal;
  1788. Log3 $name, 3, "EnOcean set $name $cmd";
  1789. $updateState = 0;
  1790. }
  1791. } elsif ($cmd eq "remoteTeach") {
  1792. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1793. if (defined $a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  1794. $cmdID = 0x221;
  1795. $manufID = 0x7FF;
  1796. $packetType = 7;
  1797. $rorg = "C5";
  1798. $destinationID = $remoteID;
  1799. $data = sprintf "%04X%04X%s", $cmdID, $manufID, $a[1];
  1800. shift(@a);
  1801. Log3 $name, 3, "EnOcean set $name $cmd";
  1802. $updateState = 0;
  1803. if (!exists($hash->{IODev}{Teach})) {
  1804. # enable teach-in receiving for 3 sec
  1805. $hash->{IODev}{Teach} = 1;
  1806. my %functionHash = (hash => $IOHash, param => 'Teach');
  1807. RemoveInternalTimer(\%functionHash);
  1808. InternalTimer(gettimeofday() + 3, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  1809. }
  1810. } else {
  1811. return "Usage: $cmd argument needed or wrong.";
  1812. }
  1813. } elsif ($cmd eq "remoteReset") {
  1814. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1815. if (defined $a[1] && $a[1] =~ m/^devCfg|linkTableIn|linkTableOut|no_change$/) {
  1816. $cmdID = 0x224;
  1817. $manufID = 0x7FF;
  1818. $packetType = 7;
  1819. $rorg = "C5";
  1820. $destinationID = $remoteID;
  1821. my %changeCmd = ('devCfg' => '80', 'linkTableIn' => '40', 'linkTableOut' => '20', 'no_change' => '00');
  1822. $data = sprintf "%04X%04X%s", $cmdID, $manufID, $changeCmd{$a[1]};
  1823. shift(@a);
  1824. Log3 $name, 3, "EnOcean set $name $cmd";
  1825. $updateState = 0;
  1826. } else {
  1827. return "Usage: $cmd argument needed or wrong.";
  1828. }
  1829. } elsif ($cmd eq "remoteRLT") {
  1830. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1831. if (defined $a[1] && defined $a[2] && $a[1] =~ m/^off|on$/ && $a[2] =~ m/^[0-7][1-9A-Fa-f]$/) {
  1832. $cmdID = 0x225;
  1833. $manufID = 0x7FF;
  1834. $packetType = 7;
  1835. $rorg = "C5";
  1836. $destinationID = $remoteID;
  1837. my $rltMode = hex $a[2];
  1838. $rltMode |= 0x80 if ($a[1] eq 'on');
  1839. $data = sprintf "%04X%04X%02X", $cmdID, $manufID, $rltMode;
  1840. splice(@a,0,2);
  1841. Log3 $name, 3, "EnOcean set $name $cmd";
  1842. $updateState = 0;
  1843. }
  1844. } elsif ($cmd eq "remoteApplyChanges") {
  1845. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1846. if (defined $a[1] && $a[1] =~ m/^devCfg|linkTable|no_change$/) {
  1847. $cmdID = 0x226;
  1848. $manufID = 0x7FF;
  1849. $packetType = 7;
  1850. $rorg = "C5";
  1851. $destinationID = $remoteID;
  1852. my %changeCmd = ('devCfg' => '40', 'linkTable' => '80', 'no_change' => '00');
  1853. $data = sprintf "%04X%04X%s", $cmdID, $manufID, $changeCmd{$a[1]};
  1854. shift(@a);
  1855. Log3 $name, 3, "EnOcean set $name $cmd";
  1856. $updateState = 0;
  1857. } else {
  1858. return "Usage: $cmd argument needed or wrong.";
  1859. }
  1860. } elsif ($cmd eq "remoteDevCfg") {
  1861. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1862. if (defined $a[1] && defined $a[2] && $a[1] =~ m/^[\dA-Fa-f]{4}$/ && $a[2] =~ m/^[\dA-Fa-f]{2}[\dA-Fa-f]*$/ && length($a[2]) % 2 == 0) {
  1863. $cmdID = 0x231;
  1864. $manufID = 0x7FF;
  1865. $packetType = 7;
  1866. $rorg = "C5";
  1867. $destinationID = $remoteID;
  1868. $data = sprintf "%04X%04X%s%02X%s", $cmdID, $manufID, uc($a[1]), length($a[2]) / 2, uc($a[2]);
  1869. splice(@a,0,2);
  1870. Log3 $name, 3, "EnOcean set $name $cmd";
  1871. $updateState = 0;
  1872. } else {
  1873. return "Usage: $cmd arguments needed or wrong.";
  1874. }
  1875. } elsif ($cmd eq "remoteLinkCfg") {
  1876. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1877. if (defined $a[1] && defined $a[2] && defined $a[3] && defined $a[4] &&
  1878. $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/ && $a[3] =~ m/^[\dA-Fa-f]{4}$/ &&
  1879. $a[4] =~ m/^[\dA-Fa-f]{2}[\dA-Fa-f]*$/ && length($a[4]) % 2 == 0) {
  1880. $cmdID = 0x233;
  1881. $manufID = 0x7FF;
  1882. $packetType = 7;
  1883. $rorg = "C5";
  1884. my $direction = $a[1] eq 'out' ? '80' : '00';
  1885. $destinationID = $remoteID;
  1886. $data = sprintf "%04X%04X%s%s%s%02X%s", $cmdID, $manufID, $direction, uc($a[2]), uc($a[3]), length($a[4]) / 2, uc($a[4]);
  1887. splice(@a,0,4);
  1888. Log3 $name, 3, "EnOcean set $name $cmd";
  1889. $updateState = 0;
  1890. } else {
  1891. return "Usage: $cmd arguments needed or wrong.";
  1892. }
  1893. } elsif ($cmd eq "remoteRepeater") {
  1894. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1895. if (defined $a[1] && defined $a[2] && defined $a[3] &&
  1896. $a[1] =~ m/^on|off|filter$/ && $a[2] =~ m/^[1-2]$/ && $a[3] =~ m/^AND|OR$/) {
  1897. $cmdID = 0x251;
  1898. $manufID = 0x7FF;
  1899. $packetType = 7;
  1900. $rorg = "C5";
  1901. my %repFunc = ('on' => 0x40, 'off' => 0, 'filter' => 0x80);
  1902. my $cmdVal = $repFunc{$a[1]} | ($a[2] == 2 ? 0x20 : 0x10) | ($a[3] eq 'OR' ? 8 : 0);
  1903. $destinationID = $remoteID;
  1904. $data = sprintf "%04X%04X%02X", $cmdID, $manufID, $cmdVal;
  1905. splice(@a,0,3);
  1906. Log3 $name, 3, "EnOcean set $name $cmd";
  1907. $updateState = 0;
  1908. } else {
  1909. return "Usage: $cmd arguments needed or wrong.";
  1910. }
  1911. } elsif ($cmd eq "remoteRepeaterFilter") {
  1912. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1913. if (defined $a[1] && defined $a[2] &&
  1914. $a[1] =~ m/^apply|block|delete|deleteAll$/ && $a[2] =~ m/^destinationID|sourceID|rorg|rssi$/) {
  1915. my %repFilterCtrl = ('deleteAll' => 0x30, 'delete' => 0x20, 'apply' => 0x10, 'block' => 0);
  1916. my $cmdVal = $repFilterCtrl{$a[1]};
  1917. my $cmdAttr;
  1918. if (defined $a[3]) {
  1919. if ($a[2] =~ m/^destinationID$/ && $a[3] =~ m/^[\dA-Fa-f]{8}$/) {
  1920. $cmdVal |= 3;
  1921. $cmdAttr = $a[3];
  1922. } elsif ($a[2] =~ m/^sourceID$/ && $a[3] =~ m/^[\dA-Fa-f]{8}$/) {
  1923. $cmdVal |= 0;
  1924. $cmdAttr = $a[3];
  1925. } elsif ($a[2] =~ m/^rorg$/ && $a[3] =~ m/^[\dA-Fa-f]{2}$/) {
  1926. $cmdVal |= 1;
  1927. $cmdAttr = '0' x 6 . $a[3];
  1928. } elsif ($a[2] =~ m/^rssi$/ && $a[3] =~ m/^-?\d+$/ && abs($a[3]) >= 0 && abs($a[3]) <= 255) {
  1929. $cmdVal |= 2;
  1930. $cmdAttr = sprintf "000000%02X", abs($a[3]);
  1931. } else {
  1932. return "Usage: $cmd $a[2] argument wrong.";
  1933. }
  1934. } else {
  1935. return "Usage: $cmd $a[2] argument needed.";
  1936. }
  1937. $cmdID = 0x252;
  1938. $manufID = 0x7FF;
  1939. $packetType = 7;
  1940. $rorg = "C5";
  1941. $destinationID = $remoteID;
  1942. $data = sprintf "%04X%04X%02X%s", $cmdID, $manufID, $cmdVal, $cmdAttr;
  1943. splice(@a,0,3);
  1944. Log3 $name, 3, "EnOcean set $name $cmd";
  1945. $updateState = 0;
  1946. } else {
  1947. return "Usage: $cmd arguments needed or wrong.";
  1948. }
  1949. } elsif ($st eq "switch") {
  1950. # Rocker Switch, simulate a PTM200 switch module
  1951. # separate first and second action
  1952. ($cmd1, $cmd2) = split(",", $cmd, 2);
  1953. # check values
  1954. if (!defined($EnO_ptm200btn{$cmd1}) || ($cmd2 && !defined($EnO_ptm200btn{$cmd2}))) {
  1955. $cmdList .= join(":noArg ", sort keys %EnO_ptm200btn) . ':noArg';
  1956. return SetExtensions($hash, $cmdList, $name, @a);
  1957. }
  1958. my $channelA = ReadingsVal($name, "channelA", undef);
  1959. my $channelB = ReadingsVal($name, "channelB", undef);
  1960. my $channelC = ReadingsVal($name, "channelC", undef);
  1961. my $channelD = ReadingsVal($name, "channelD", undef);
  1962. my $lastChannel = ReadingsVal($name, ".lastChannel", "A");
  1963. my $releasedChannel = AttrVal($name, "releasedChannel", "auto");
  1964. my $subDefA = AttrVal($name, "subDefA", $subDef);
  1965. my $subDefB = AttrVal($name, "subDefB", $subDef);
  1966. my $subDefC = AttrVal($name, "subDefC", $subDef);
  1967. my $subDefD = AttrVal($name, "subDefD", $subDef);
  1968. my $subDefI = AttrVal($name, "subDefI", $subDef);
  1969. my $subDef0 = AttrVal($name, "subDef0", $subDef);
  1970. my $switchType = AttrVal($name, "switchType", "direction");
  1971. # first action
  1972. if ($cmd1 eq "released") {
  1973. if ($switchType eq "central") {
  1974. if ($releasedChannel eq "auto") {
  1975. if ($lastChannel =~ m/0|I/) {
  1976. $releasedChannel = $lastChannel;
  1977. } else {
  1978. $releasedChannel = 0;
  1979. }
  1980. } elsif ($releasedChannel !~ m/0|I/) {
  1981. $releasedChannel = 0;
  1982. }
  1983. } elsif ($switchType eq "channel") {
  1984. if ($releasedChannel eq "auto") {
  1985. if ($lastChannel =~ m/A|B|C|D/) {
  1986. $releasedChannel = $lastChannel;
  1987. } else {
  1988. $releasedChannel = "A";
  1989. }
  1990. } elsif ($releasedChannel !~ m/A|B|C|D/) {
  1991. $releasedChannel = "A";
  1992. }
  1993. }
  1994. $subDef = AttrVal($name, "subDef" . $releasedChannel, $subDef);
  1995. } elsif ($switchType eq "central") {
  1996. if ($cmd1 =~ m/.0/) {
  1997. $subDef = $subDef0;
  1998. $lastChannel = 0;
  1999. } elsif ($cmd1 =~ m/.I/) {
  2000. $subDef = $subDefI;
  2001. $lastChannel = "I";
  2002. }
  2003. } elsif ($switchType eq "channel") {
  2004. $lastChannel = substr($cmd1, 0, 1);
  2005. $subDef = AttrVal($name, "subDef" . $lastChannel, $subDefA);
  2006. } else {
  2007. $lastChannel = substr($cmd1, 0, 1);
  2008. }
  2009. if ($switchType eq "universal") {
  2010. if ($cmd1 =~ m/A./ && (!defined($channelA) || $cmd1 ne $channelA)) {
  2011. $cmd1 = "A0";
  2012. } elsif ($cmd1 =~ m/B./ && (!defined($channelB) || $cmd1 ne $channelB)) {
  2013. $cmd1 = "B0";
  2014. } elsif ($cmd1 =~ m/C./ && (!defined($channelC) || $cmd1 ne $channelC)) {
  2015. $cmd1 = "C0";
  2016. } elsif ($cmd1 =~ m/D./ && (!defined($channelD) || $cmd1 ne $channelD)) {
  2017. $cmd1 = "D0";
  2018. } elsif ($cmd1 eq "released") {
  2019. } else {
  2020. $sendCmd = undef;
  2021. }
  2022. }
  2023. # second action
  2024. if ($cmd2 && $switchType eq "universal") {
  2025. if ($cmd2 =~ m/A./ && (!defined($channelA) || $cmd2 ne $channelA)) {
  2026. $cmd2 = "A0";
  2027. } elsif ($cmd2 =~ m/B./ && (!defined($channelB) || $cmd2 ne $channelB)) {
  2028. $cmd2 = "B0";
  2029. } elsif ($cmd2 =~ m/C./ && (!defined($channelC) || $cmd2 ne $channelC)) {
  2030. $cmd2 = "C0";
  2031. } elsif ($cmd2 =~ m/D./ && (!defined($channelD) || $cmd2 ne $channelD)) {
  2032. $cmd2 = "D0";
  2033. } else {
  2034. $cmd2 = undef;
  2035. }
  2036. if ($cmd2 && undef($sendCmd)) {
  2037. # only second action has changed, send as first action
  2038. $cmd1 = $cmd2;
  2039. $cmd2 = undef;
  2040. $sendCmd = 1;
  2041. }
  2042. }
  2043. # convert and send first and second command
  2044. my $switchCmd;
  2045. ($switchCmd, $status) = split(':', $EnO_ptm200btn{$cmd1}, 2);
  2046. # reset T21 status flag if 4 rocker
  2047. $status = '10' if ($switchCmd > 3);
  2048. $switchCmd <<= 5;
  2049. if ($cmd1 ne "released") {
  2050. # set the pressed flag
  2051. $switchCmd |= 0x10 ;
  2052. }
  2053. if($cmd2) {
  2054. # execute second action
  2055. if ($switchType =~ m/^central|channel$/) {
  2056. # second action not supported
  2057. $cmd = $cmd1;
  2058. } else {
  2059. my ($d2, undef) = split(':', $EnO_ptm200btn{$cmd2}, 2);
  2060. # reset T21 status flag if 4 rocker
  2061. $status = '10' if ($d2 > 3);
  2062. $switchCmd |= ($d2 << 1) | 0x01;
  2063. }
  2064. }
  2065. if (defined $sendCmd) {
  2066. $data = sprintf "%02X", $switchCmd;
  2067. $rorg = "F6";
  2068. #####
  2069. SetExtensionsCancel($hash);
  2070. Log3 $name, 3, "EnOcean set $name $cmd";
  2071. if ($updateState) {
  2072. readingsSingleUpdate($hash, "channel" . $1, $cmd1, 1) if ($cmd1 =~ m/^([A-D])./);
  2073. readingsSingleUpdate($hash, "channel" . $1, $cmd2, 1) if ($cmd2 && $cmd2 =~ m/^([A-D])./);
  2074. }
  2075. readingsSingleUpdate($hash, ".lastChannel", $lastChannel, 0);
  2076. }
  2077. } elsif ($st eq "switch.00") {
  2078. my $switchCmd = join(",", sort split(",", $cmd, 2));
  2079. ($cmd1, $cmd2) = split(",", $switchCmd, 2);
  2080. $cmd = $switchCmd;
  2081. if ((!defined($switchCmd)) || (!defined($EnO_switch_00Btn{$switchCmd}))) {
  2082. # check values
  2083. $cmdList .= join(":noArg ", keys %EnO_switch_00Btn);
  2084. return SetExtensions($hash, $cmdList, $name, @a);
  2085. } elsif ($switchCmd eq "teachIn") {
  2086. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, AttrVal($name, "comMode", "uniDir"),
  2087. AttrVal($name, "uteResponseRequest", "no"), "in", 0, "D2-03-00");
  2088. $updateState = 0;
  2089. } elsif ($switchCmd eq "teachInSec") {
  2090. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2091. ($err, $response, $logLevel) = EnOcean_sec_createTeachIn(undef, $hash, "uniDir", "VAES", "D2-03-00", 3,
  2092. "2++", "false", "encryption", $subDef, $destinationID);
  2093. if ($err) {
  2094. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  2095. return $err;
  2096. } else {
  2097. EnOcean_CommandSave(undef, undef);
  2098. Log3 $name, $logLevel, "EnOcean $name $response";
  2099. readingsSingleUpdate($hash, "teach", "STE teach-in sent", 1);
  2100. return(undef);
  2101. }
  2102. } elsif ($switchCmd eq "teachOut") {
  2103. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, AttrVal($name, "comMode", "uniDir"),
  2104. AttrVal($name, "uteResponseRequest", "no"), "out", 0, "D2-03-00");
  2105. $updateState = 0;
  2106. } else {
  2107. $data = sprintf "%02X", $EnO_switch_00Btn{$switchCmd};
  2108. $rorg = "D2";
  2109. #####
  2110. SetExtensionsCancel($hash);
  2111. }
  2112. Log3 $name, 3, "EnOcean set $name $switchCmd";
  2113. } elsif ($st eq "roomSensorControl.01") {
  2114. # Room Sensor and Control Unit (EEP A5-04-01, A5-10-10 ... A5-10-14)
  2115. # [Thermokon SR04 * rH, Thanus SR *, untested]
  2116. # $db[3] is the setpoint where 0x00 = min ... 0xFF = max
  2117. # $db[2] is the humidity where 0x00 = 0%rH ... 0xFA = 100%rH
  2118. # $db[1] is the temperature where 0x00 = 0°C ... 0xFA = +40°C
  2119. # $db[0] bit D0 is the occupy button, pushbutton or slide switch
  2120. $rorg = "A5";
  2121. # primarily temperature from the reference device then the attribute actualTemp is read
  2122. my $temperatureRefDev = AttrVal($name, "temperatureRefDev", undef);
  2123. my $actualTemp = AttrVal($name, "actualTemp", 20);
  2124. $actualTemp = ReadingsVal($temperatureRefDev, "temperature", 20) if (defined $temperatureRefDev);
  2125. $actualTemp = 20 if ($actualTemp !~ m/^[+-]?\d+(\.\d+)?$/);
  2126. $actualTemp = 0 if ($actualTemp < 0);
  2127. $actualTemp = 40 if ($actualTemp > 40);
  2128. $actualTemp = sprintf "%0.1f", $actualTemp;
  2129. # primarily humidity from the reference device then the attribute humidity is read
  2130. my $humidityRefDev = AttrVal($name, "humidityRefDev", undef);
  2131. my $humidity = AttrVal($name, "humidity", 0);
  2132. $humidity = ReadingsVal($humidityRefDev, "humidity", 0) if (defined $humidityRefDev);
  2133. $humidity = 0 if ($humidity !~ m/^\d+(\.\d+)?$/);
  2134. $humidity = 0 if ($humidity < 0);
  2135. $humidity = 100 if ($humidity > 100);
  2136. $humidity = sprintf "%d", $humidity;
  2137. my $setCmd = 8;
  2138. my $setpoint = ReadingsVal($name, "setpoint", 125);
  2139. my $setpointScaled = ReadingsVal($name, "setpointScaled", undef);
  2140. my $switch = ReadingsVal($name, "switch", "off");
  2141. $setCmd |= 1 if ($switch eq "on");
  2142. if ($cmd eq "teach") {
  2143. if ($manufID eq "00D") {
  2144. # teach-in EEP A5-10-12, Manufacturer "Eltako"
  2145. $data = "40900D80";
  2146. $attr{$name}{eep} = "A5-10-12";
  2147. } else {
  2148. # teach-in EEP A5-10-10, Manufacturer "Multi user Manufacturer ID"
  2149. $data = "4087FF80";
  2150. $attr{$name}{eep} = "A5-10-10";
  2151. }
  2152. CommandDeleteReading(undef, "$name .*");
  2153. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2154. $updateState = 0;
  2155. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2156. } elsif ($cmd eq "setpoint") {
  2157. #
  2158. if (defined $a[1]) {
  2159. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 255)) {
  2160. $setpoint = $a[1];
  2161. shift(@a);
  2162. if (defined $setpointScaled) {
  2163. $setpointScaled = EnOcean_ReadingScaled($hash, $setpoint, 0, 255);
  2164. }
  2165. } else {
  2166. return "Usage: $a[1] is not numeric or out of range";
  2167. }
  2168. }
  2169. readingsBeginUpdate($hash);
  2170. readingsBulkUpdate($hash, "temperature", $actualTemp);
  2171. readingsBulkUpdate($hash, "humidity", $humidity);
  2172. readingsBulkUpdate($hash, "setpointScaled", $setpointScaled) if (defined $setpointScaled);
  2173. readingsBulkUpdate($hash, "setpoint", $setpoint);
  2174. readingsBulkUpdate($hash, "switch", $switch);
  2175. readingsBulkUpdate($hash, "state", "T: $actualTemp H: $humidity SP: $setpoint SW: $switch");
  2176. readingsEndUpdate($hash, 1);
  2177. $actualTemp = $actualTemp / 40 * 250;
  2178. $humidity = $humidity / 100 * 250;
  2179. $updateState = 0;
  2180. $data = sprintf "%02X%02X%02X%02X", $setpoint, $humidity, $actualTemp, $setCmd;
  2181. } elsif ($cmd eq "setpointScaled") {
  2182. #
  2183. if (defined $a[1]) {
  2184. my $scaleMin = AttrVal($name, "scaleMin", undef);
  2185. my $scaleMax = AttrVal($name, "scaleMax", undef);
  2186. my ($rangeMin, $rangeMax);
  2187. if (defined $scaleMax && defined $scaleMin &&
  2188. $scaleMax =~ m/^[+-]?\d+(\.\d+)?$/ && $scaleMin =~ m/^[+-]?\d+(\.\d+)?$/) {
  2189. if ($scaleMin > $scaleMax) {
  2190. ($rangeMin, $rangeMax)= ($scaleMax, $scaleMin);
  2191. } else {
  2192. ($rangeMin, $rangeMax)= ($scaleMin, $scaleMax);
  2193. }
  2194. } else {
  2195. return "Usage: Attributes scaleMin and/or scaleMax not defined or not numeric.";
  2196. }
  2197. if ($a[1] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[1] >= $rangeMin && $a[1] <= $rangeMax) {
  2198. $setpointScaled = $a[1];
  2199. shift(@a);
  2200. $setpoint = sprintf "%d", 255 * $scaleMin/($scaleMin-$scaleMax) - 255/($scaleMin-$scaleMax) * $setpointScaled;
  2201. } else {
  2202. return "Usage: $a[1] is not numeric or out of range";
  2203. }
  2204. }
  2205. readingsBeginUpdate($hash);
  2206. readingsBulkUpdate($hash, "temperature", $actualTemp);
  2207. readingsBulkUpdate($hash, "humidity", $humidity);
  2208. readingsBulkUpdate($hash, "setpointScaled", $setpointScaled) if (defined $setpointScaled);
  2209. readingsBulkUpdate($hash, "setpoint", $setpoint);
  2210. readingsBulkUpdate($hash, "switch", $switch);
  2211. readingsBulkUpdate($hash, "state", "T: $actualTemp H: $humidity SP: $setpoint SW: $switch");
  2212. readingsEndUpdate($hash, 1);
  2213. $actualTemp = $actualTemp / 40 * 250;
  2214. $humidity = $humidity / 100 * 250;
  2215. $updateState = 0;
  2216. $data = sprintf "%02X%02X%02X%02X", $setpoint, $humidity, $actualTemp, $setCmd;
  2217. } elsif ($cmd eq "switch") {
  2218. #
  2219. if (defined $a[1]) {
  2220. if ($a[1] eq "on") {
  2221. $switch = $a[1];
  2222. $setCmd |= 1;
  2223. shift(@a);
  2224. } elsif ($a[1] eq "off"){
  2225. $switch = $a[1];
  2226. shift(@a);
  2227. } else {
  2228. return "Usage: $a[1] is unknown";
  2229. }
  2230. }
  2231. readingsBeginUpdate($hash);
  2232. readingsBulkUpdate($hash, "temperature", $actualTemp);
  2233. readingsBulkUpdate($hash, "humidity", $humidity);
  2234. readingsBulkUpdate($hash, "setpointScaled", $setpointScaled) if (defined $setpointScaled);
  2235. readingsBulkUpdate($hash, "setpoint", $setpoint);
  2236. readingsBulkUpdate($hash, "switch", $switch);
  2237. readingsBulkUpdate($hash, "state", "T: $actualTemp H: $humidity SP: $setpoint SW: $switch");
  2238. readingsEndUpdate($hash, 1);
  2239. $actualTemp = $actualTemp / 40 * 250;
  2240. $humidity = $humidity / 100 * 250;
  2241. $updateState = 0;
  2242. $data = sprintf "%02X%02X%02X%02X", $setpoint, $humidity, $actualTemp, $setCmd;
  2243. } else {
  2244. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . " setpoint:slider,0,1,255 setpointScaled switch:on,off teach:noArg"
  2245. }
  2246. Log3 $name, 3, "EnOcean set $name $cmd";
  2247. } elsif ($st eq "roomSensorControl.05") {
  2248. # Room Sensor and Control Unit (EEP A5-10-01 ... A5-10-0D)
  2249. # [Eltako FTR55D, FTR55H, Thermokon SR04 *, Thanos SR *, untested]
  2250. # $db[3] is the fan speed or night reduction for Eltako
  2251. # $db[2] is the setpoint where 0x00 = min ... 0xFF = max or
  2252. # reference temperature for Eltako where 0x00 = 0°C ... 0xFF = 40°C
  2253. # $db[1] is the temperature where 0x00 = +40°C ... 0xFF = 0°C
  2254. # $db[1]_bit_1 is blocking the aditional Room Sensor and Control Unit for Eltako FVS
  2255. # $db[0]_bit_0 is the slide switch
  2256. $rorg = "A5";
  2257. # primarily temperature from the reference device then the attribute actualTemp is read
  2258. my $temperatureRefDev = AttrVal($name, "temperatureRefDev", undef);
  2259. my $actualTemp = AttrVal($name, "actualTemp", 20);
  2260. $actualTemp = ReadingsVal($temperatureRefDev, "temperature", 20) if (defined $temperatureRefDev);
  2261. $actualTemp = 20 if ($actualTemp !~ m/^[+-]?\d+(\.\d+)?$/);
  2262. $actualTemp = 0 if ($actualTemp < 0);
  2263. $actualTemp = 40 if ($actualTemp > 40);
  2264. $actualTemp = sprintf "%0.1f", $actualTemp;
  2265. my $setCmd = 8;
  2266. if ($manufID eq "00D") {
  2267. # EEP A5-10-06 plus DB3 [Eltako FVS]
  2268. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  2269. my $nightReduction = ReadingsVal($name, "nightReduction", 0);
  2270. my $block = ReadingsVal($name, "block", "unlock");
  2271. if ($cmd eq "teach") {
  2272. # teach-in EEP A5-10-06 plus "FVS", Manufacturer "Eltako"
  2273. $data = "40300D85";
  2274. $attr{$name}{eep} = "A5-10-06";
  2275. CommandDeleteReading(undef, "$name .*");
  2276. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2277. $updateState = 0;
  2278. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2279. } elsif ($cmd eq "desired-temp" || $cmd eq "setpointTemp") {
  2280. #
  2281. if (defined $a[1]) {
  2282. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 40)) {
  2283. $setpointTemp = sprintf "%0.1f", $a[1];
  2284. shift(@a);
  2285. } else {
  2286. return "Usage: $a[1] is not numeric or out of range";
  2287. }
  2288. }
  2289. if (defined $a[1]) {
  2290. if (($a[1] =~ m/^(lock|unlock)$/) ) {
  2291. $block = $a[1];
  2292. shift(@a);
  2293. } else {
  2294. return "Usage: $a[1] is unknown";
  2295. }
  2296. }
  2297. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2298. readingsSingleUpdate($hash, "setpointTemp", $setpointTemp, 1);
  2299. readingsSingleUpdate($hash, "nightReduction", $nightReduction, 1);
  2300. readingsSingleUpdate($hash, "block", $block, 1);
  2301. readingsSingleUpdate($hash, "state", "T: $actualTemp SPT: $setpointTemp NR: $nightReduction", 1);
  2302. if ($nightReduction == 5) {
  2303. $nightReduction = 31;
  2304. } elsif ($nightReduction == 4) {
  2305. $nightReduction = 25;
  2306. } elsif ($nightReduction == 3) {
  2307. $nightReduction = 19;
  2308. } elsif ($nightReduction == 2) {
  2309. $nightReduction = 12;
  2310. } elsif ($nightReduction == 1) {
  2311. $nightReduction = 6;
  2312. } else {
  2313. $nightReduction = 0;
  2314. }
  2315. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2316. $setpointTemp = $setpointTemp * 255 / 40;
  2317. # control of the aditional Room Sensor and Control Unit
  2318. if ($block eq "lock") {
  2319. # temperature setting is locked
  2320. $setCmd = 0x0D;
  2321. } else {
  2322. # setpointTemp may be subject to change at +/-3 K
  2323. $setCmd = 0x0F;
  2324. }
  2325. $updateState = 0;
  2326. $data = sprintf "%02X%02X%02X%02X", $nightReduction, $setpointTemp, $actualTemp, $setCmd;
  2327. } elsif ($cmd eq "nightReduction") {
  2328. #
  2329. if (defined $a[1]) {
  2330. if ($a[1] =~ m/^[0-5]$/) {
  2331. $nightReduction = $a[1];
  2332. shift(@a);
  2333. } else {
  2334. return "Usage: $a[1] is not numeric or out of range";
  2335. }
  2336. }
  2337. if (defined $a[1]) {
  2338. if (($a[1] =~ m/^(lock|unlock)$/) ) {
  2339. $block = $a[1];
  2340. shift(@a);
  2341. } else {
  2342. return "Usage: $a[1] is unknown";
  2343. }
  2344. }
  2345. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2346. readingsSingleUpdate($hash, "setpointTemp", $setpointTemp, 1);
  2347. readingsSingleUpdate($hash, "nightReduction", $nightReduction, 1);
  2348. readingsSingleUpdate($hash, "block", $block, 1);
  2349. readingsSingleUpdate($hash, "state", "T: $actualTemp SPT: $setpointTemp NR: $nightReduction", 1);
  2350. if ($nightReduction == 5) {
  2351. $nightReduction = 31;
  2352. } elsif ($nightReduction == 4) {
  2353. $nightReduction = 25;
  2354. } elsif ($nightReduction == 3) {
  2355. $nightReduction = 19;
  2356. } elsif ($nightReduction == 2) {
  2357. $nightReduction = 12;
  2358. } elsif ($nightReduction == 1) {
  2359. $nightReduction = 6;
  2360. } else {
  2361. $nightReduction = 0;
  2362. }
  2363. $actualTemp = (40 - $actualTemp) / 40 * 254;
  2364. $setpointTemp = $setpointTemp * 254 / 40;
  2365. # control of the aditional Room Sensor and Control Unit
  2366. if ($block eq "lock") {
  2367. # temperature setting is locked
  2368. $setCmd = 0x0D;
  2369. } else {
  2370. # setpointTemp may be subject to change at +/-3 K
  2371. $setCmd = 0x0F;
  2372. }
  2373. $updateState = 0;
  2374. $data = sprintf "%02X%02X%02X%02X", $nightReduction, $setpointTemp, $actualTemp, $setCmd;
  2375. } else {
  2376. return "Unknown argument " . $cmd . ", choose one of setpointTemp:slider,0,1,40 desired-temp nightReduction:0,1,2,3,4,5 teach:noArg"
  2377. }
  2378. } else {
  2379. # EEP A5-10-02 or EEP A5-10-03
  2380. my $setpoint = ReadingsVal($name, "setpoint", 128);
  2381. my $setpointScaled = ReadingsVal($name, "setpointScaled", undef);
  2382. my $fanStage = ReadingsVal($name, "fanStage", "auto");
  2383. my $switch = ReadingsVal($name, "switch", "off");
  2384. $setCmd |= 1 if ($switch eq "on");
  2385. if ($cmd eq "teach") {
  2386. if ($manufID eq "019") {
  2387. # teach-in EEP A5-10-03, Manufacturer "Multi user Manufacturer ID"
  2388. $data = "401FFF80";
  2389. $attr{$name}{eep} = "A5-10-03";
  2390. } else {
  2391. # teach-in EEP A5-10-02, Manufacturer "Multi user Manufacturer ID"
  2392. $data = "4017FF80";
  2393. $attr{$name}{eep} = "A5-10-02";
  2394. }
  2395. CommandDeleteReading(undef, "$name .*");
  2396. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2397. $updateState = 0;
  2398. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2399. } elsif ($cmd eq "fanStage") {
  2400. #
  2401. if (defined $a[1] && ($a[1] =~ m/^[0-3]$/ || $a[1] eq "auto")) {
  2402. $fanStage = $a[1];
  2403. shift(@a);
  2404. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2405. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1) if (defined $setpointScaled);
  2406. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2407. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2408. readingsSingleUpdate($hash, "switch", $switch, 1);
  2409. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2410. if ($fanStage eq "auto"){
  2411. $fanStage = 255;
  2412. } elsif ($fanStage == 0) {
  2413. $fanStage = 209;
  2414. } elsif ($fanStage == 1) {
  2415. $fanStage = 189;
  2416. } elsif ($fanStage == 2) {
  2417. $fanStage = 164;
  2418. } else {
  2419. $fanStage = 144;
  2420. }
  2421. } else {
  2422. return "Usage: $a[1] is not numeric, out of range or unknown";
  2423. }
  2424. $actualTemp = (40 - $actualTemp) / 40 * 254;
  2425. $updateState = 0;
  2426. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2427. } elsif ($cmd eq "setpoint") {
  2428. #
  2429. if (defined $a[1]) {
  2430. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 255)) {
  2431. $setpoint = $a[1];
  2432. shift(@a);
  2433. if (defined $setpointScaled) {
  2434. $setpointScaled = EnOcean_ReadingScaled($hash, $setpoint, 0, 255);
  2435. }
  2436. } else {
  2437. return "Usage: $a[1] is not numeric or out of range";
  2438. }
  2439. }
  2440. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2441. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1) if (defined $setpointScaled);
  2442. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2443. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2444. readingsSingleUpdate($hash, "switch", $switch, 1);
  2445. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2446. if ($fanStage eq "auto"){
  2447. $fanStage = 255;
  2448. } elsif ($fanStage == 0) {
  2449. $fanStage = 209;
  2450. } elsif ($fanStage == 1) {
  2451. $fanStage = 189;
  2452. } elsif ($fanStage == 2) {
  2453. $fanStage = 164;
  2454. } else {
  2455. $fanStage = 144;
  2456. }
  2457. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2458. $updateState = 0;
  2459. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2460. } elsif ($cmd eq "setpointScaled") {
  2461. #
  2462. if (defined $a[1]) {
  2463. my $scaleMin = AttrVal($name, "scaleMin", undef);
  2464. my $scaleMax = AttrVal($name, "scaleMax", undef);
  2465. my ($rangeMin, $rangeMax);
  2466. if (defined $scaleMax && defined $scaleMin &&
  2467. $scaleMax =~ m/^[+-]?\d+(\.\d+)?$/ && $scaleMin =~ m/^[+-]?\d+(\.\d+)?$/) {
  2468. if ($scaleMin > $scaleMax) {
  2469. ($rangeMin, $rangeMax)= ($scaleMax, $scaleMin);
  2470. } else {
  2471. ($rangeMin, $rangeMax)= ($scaleMin, $scaleMax);
  2472. }
  2473. } else {
  2474. return "Usage: Attributes scaleMin and/or scaleMax not defined or not numeric.";
  2475. }
  2476. if ($a[1] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[1] >= $rangeMin && $a[1] <= $rangeMax) {
  2477. $setpointScaled = $a[1];
  2478. shift(@a);
  2479. $setpoint = sprintf "%d", 255 * $scaleMin/($scaleMin-$scaleMax) - 255/($scaleMin-$scaleMax) * $setpointScaled;
  2480. } else {
  2481. return "Usage: $a[1] is not numeric or out of range";
  2482. }
  2483. }
  2484. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2485. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1);
  2486. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2487. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2488. readingsSingleUpdate($hash, "switch", $switch, 1);
  2489. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2490. if ($fanStage eq "auto"){
  2491. $fanStage = 255;
  2492. } elsif ($fanStage == 0) {
  2493. $fanStage = 209;
  2494. } elsif ($fanStage == 1) {
  2495. $fanStage = 189;
  2496. } elsif ($fanStage == 2) {
  2497. $fanStage = 164;
  2498. } else {
  2499. $fanStage = 144;
  2500. }
  2501. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2502. $updateState = 0;
  2503. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2504. } elsif ($cmd eq "switch") {
  2505. #
  2506. if (defined $a[1]) {
  2507. if ($a[1] eq "on") {
  2508. $switch = $a[1];
  2509. $setCmd |= 1;
  2510. shift(@a);
  2511. } elsif ($a[1] eq "off"){
  2512. $switch = $a[1];
  2513. shift(@a);
  2514. } else {
  2515. return "Usage: $a[1] is unknown";
  2516. }
  2517. }
  2518. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2519. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1) if (defined $setpointScaled);
  2520. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2521. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2522. readingsSingleUpdate($hash, "switch", $switch, 1);
  2523. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2524. if ($fanStage eq "auto"){
  2525. $fanStage = 255;
  2526. } elsif ($fanStage == 0) {
  2527. $fanStage = 209;
  2528. } elsif ($fanStage == 1) {
  2529. $fanStage = 189;
  2530. } elsif ($fanStage == 2) {
  2531. $fanStage = 164;
  2532. } else {
  2533. $fanStage = 144;
  2534. }
  2535. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2536. $updateState = 0;
  2537. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2538. } else {
  2539. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . "setpoint:slider,0,1,255 fanStage:auto,0,1,2,3 setpointScaled switch:on,off teach:noArg"
  2540. }
  2541. }
  2542. Log3 $name, 3, "EnOcean set $name $cmd";
  2543. } elsif ($st eq "hvac.01" || $st eq "MD15") {
  2544. # Battery Powered Actuator (EEP A5-20-01)
  2545. # [Kieback&Peter MD15-FTL-xx]
  2546. $rorg = "A5";
  2547. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  2548. my $temperature = ReadingsVal($name, "temperature", 20);
  2549. if ($cmd eq "setpoint") {
  2550. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  2551. readingsBeginUpdate($hash);
  2552. readingsBulkUpdate($hash, "setpointSet", $a[1]);
  2553. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2554. readingsEndUpdate($hash, 0);
  2555. # stop PID regulator
  2556. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2557. CommandDeleteReading(undef, "$name setpointTempSet");
  2558. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  2559. shift(@a);
  2560. } else {
  2561. return "Usage: $cmd value wrong.";
  2562. }
  2563. $updateState = 2;
  2564. } elsif ($cmd =~ m/^desired-temp|setpointTemp$/) {
  2565. if (defined $a[1] && $a[1] =~ m/^\d+(\.\d)?$/ && $a[1] >= 10 && $a[1] <= 30) {
  2566. $cmd = "setpointTemp";
  2567. $setpointTemp = $a[1];
  2568. readingsBeginUpdate($hash);
  2569. readingsBulkUpdate($hash, "setpointTempSet", sprintf("%0.1f", $setpointTemp));
  2570. readingsBulkUpdate($hash, "waitingCmds", "setpointTemp");
  2571. readingsEndUpdate($hash, 0);
  2572. # PID regulator active
  2573. my $activatePID = AttrVal($name, 'pidCtrl', 'off') eq 'on' ? 'start' : 'stop';
  2574. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  2575. CommandDeleteReading(undef, "$name setpointSet");
  2576. Log3 $name, 3, "EnOcean set $name $cmd $setpointTemp";
  2577. shift(@a);
  2578. } else {
  2579. return "Usage: $cmd value wrong.";
  2580. }
  2581. $updateState = 2;
  2582. } elsif ($cmd =~ m/^liftSet|runInit|valveOpens|valveCloses$/) {
  2583. # unattended?
  2584. readingsBeginUpdate($hash);
  2585. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2586. readingsEndUpdate($hash, 0);
  2587. # stop PID regulator
  2588. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2589. CommandDeleteReading(undef, "$name setpointSet");
  2590. CommandDeleteReading(undef, "$name setpointTempSet");
  2591. Log3 $name, 3, "EnOcean set $name $cmd";
  2592. $updateState = 2;
  2593. } else {
  2594. $cmdList .= "setpointTemp:slider,0,1,40 " if (AttrVal($name, "pidCtrl", 'on') eq 'on' || AttrVal($name, "manufID", '7FF') ne '049');
  2595. $cmdList .= "setpoint:slider,0,5,100 desired-temp liftSet:noArg runInit:noArg valveOpens:noArg valveCloses:noArg";
  2596. return "Unknown command " . $cmd . ", choose one of " . $cmdList;
  2597. }
  2598. } elsif ($st eq "hvac.04") {
  2599. # heating radiator valve actuating drive (EEP A5-20-04)
  2600. $rorg = "A5";
  2601. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  2602. my $temperature = ReadingsVal($name, "temperature", 20);
  2603. if ($cmd eq "setpoint") {
  2604. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  2605. readingsBeginUpdate($hash);
  2606. readingsBulkUpdate($hash, "setpointSet", $a[1]);
  2607. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2608. readingsEndUpdate($hash, 0);
  2609. # stop PID regulator
  2610. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2611. CommandDeleteReading(undef, "$name setpointTempSet");
  2612. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  2613. shift(@a);
  2614. } else {
  2615. return "Usage: $cmd value wrong.";
  2616. }
  2617. $updateState = 2;
  2618. } elsif ($cmd =~ m/^desired-temp|setpointTemp$/) {
  2619. if (defined $a[1] && $a[1] =~ m/^\d+(\.\d)?$/ && $a[1] >= 10 && $a[1] <= 30) {
  2620. $cmd = "setpointTemp";
  2621. $setpointTemp = $a[1];
  2622. readingsBeginUpdate($hash);
  2623. readingsBulkUpdate($hash, "setpointTempSet", sprintf("%0.1f", $setpointTemp));
  2624. readingsBulkUpdate($hash, "waitingCmds", "setpointTemp");
  2625. readingsEndUpdate($hash, 0);
  2626. # PID regulator active
  2627. #####
  2628. my $activatePID = AttrVal($name, 'pidCtrl', 'on') eq 'on' ? 'start' : 'stop';
  2629. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  2630. CommandDeleteReading(undef, "$name setpointSet");
  2631. Log3 $name, 3, "EnOcean set $name $cmd $setpointTemp";
  2632. shift(@a);
  2633. } else {
  2634. return "Usage: $cmd value wrong.";
  2635. }
  2636. $updateState = 2;
  2637. } elsif ($cmd =~ m/^runInit|valveOpens|valveCloses$/) {
  2638. readingsBeginUpdate($hash);
  2639. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2640. readingsEndUpdate($hash, 0);
  2641. # stop PID regulator
  2642. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2643. CommandDeleteReading(undef, "$name setpointSet");
  2644. CommandDeleteReading(undef, "$name setpointTempSet");
  2645. Log3 $name, 3, "EnOcean set $name $cmd";
  2646. $updateState = 2;
  2647. } else {
  2648. $cmdList .= "setpointTemp:slider,10,1,30 " if (AttrVal($name, "pidCtrl", 'on') eq 'on' || AttrVal($name, "model", '') eq 'Holter_OEM');
  2649. $cmdList .= "setpoint:slider,0,5,100 " if (AttrVal($name, "pidCtrl", 'on') eq 'off' && AttrVal($name, "model", '') ne 'Holter_OEM');
  2650. $cmdList .= "runInit:noArg valveCloses:noArg valveOpens:noArg";
  2651. return "Unknown command " . $cmd . ", choose one of " . $cmdList;
  2652. }
  2653. } elsif ($st eq "hvac.10") {
  2654. # Generic HVAC Interface (EEP A5-20-10)
  2655. $rorg = "A5";
  2656. my %ctrlFunc = (
  2657. "off" => 1,
  2658. "on" => 2,
  2659. "occupancy" => 3,
  2660. "ctrl" => 4,
  2661. "fanSpeed" => 5,
  2662. "vanePosition" => 6,
  2663. "mode" => 7,
  2664. "teach" => 255,
  2665. );
  2666. my %mode = (
  2667. "auto" => 0,
  2668. "heat" => 1,
  2669. "morning_warmup" => 2,
  2670. "cool" => 3,
  2671. "night_purge" => 4,
  2672. "precool" => 5,
  2673. "off" => 6,
  2674. "test" => 7,
  2675. "emergency_heat" => 8,
  2676. "fan_only" => 9,
  2677. "free_cool" => 10,
  2678. "ice" => 11,
  2679. "max_heat" => 12,
  2680. "eco" => 13,
  2681. "dehumidification" => 14,
  2682. "calibration" => 15,
  2683. "emergency_cool" => 16,
  2684. "emergency_stream" => 17,
  2685. "max_cool" => 18,
  2686. "hvc_load" => 19,
  2687. "no_load" => 20,
  2688. "auto_heat" => 31,
  2689. "auto_cool" => 32,
  2690. );
  2691. my %vanePosition = (
  2692. "auto" => 0,
  2693. "horizontal" => 1,
  2694. "position_2" => 2,
  2695. "position_3" => 3,
  2696. "position_4" => 4,
  2697. "vertical" => 5,
  2698. "swing" => 6,
  2699. "vertical_swing" => 11,
  2700. "horizontal_swing" => 12,
  2701. "hor_vert_swing" => 13,
  2702. "stop_swing" => 14,
  2703. );
  2704. my $ctrlFuncID;
  2705. if (defined $ctrlFunc{$cmd}) {
  2706. $ctrlFuncID = $ctrlFunc{$cmd};
  2707. } else {
  2708. $cmdList .= "ctrl mode:" . join(",", sort keys %mode) . " fanSpeed:auto,1,2,3,4,5,6,7,8,9,10,11,12,13,14 " .
  2709. "occupancy:occupied,off,standby,unoccupied on:noArg off:noArg teach:noArg vanePosition:" .
  2710. join(",", sort keys %vanePosition);
  2711. return SetExtensions ($hash, $cmdList, $name, @a);
  2712. }
  2713. $ctrl = ReadingsVal($name, "ctrl", "auto");
  2714. my $fanSpeed = ReadingsVal($name, "fanSpeed", "auto");
  2715. my $mode = ReadingsVal($name, "mode", "off");
  2716. my $occupancy = ReadingsVal($name, "occupancy", "off");
  2717. my $powerSwitch = ReadingsVal($name, "powerSwitch", "off");
  2718. my $vanePosition = ReadingsVal($name, "vanePosition", "auto");
  2719. my ($ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd) = (0, 0, 0, 8);
  2720. if($ctrlFuncID == 255) {
  2721. # teach-in EEP A5-20-10, Manufacturer "Multi user Manufacturer ID"
  2722. $ctrlParam1 = 0x80;
  2723. $ctrlParam2 = 0x87;
  2724. $ctrlParam3 = 0xFF;
  2725. $setCmd = 0x80;
  2726. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  2727. EnOcean_4BSRespWait(undef, $hash, $subDef);
  2728. readingsSingleUpdate($hash, "teach", "4BS teach-in sent, response requested", 1);
  2729. $updateState = 0;
  2730. } elsif ($ctrlFuncID == 1) {
  2731. # off
  2732. $powerSwitch = "off";
  2733. $updateState = 0;
  2734. readingsBeginUpdate($hash);
  2735. readingsBulkUpdate($hash, "powerSwitch", "off");
  2736. readingsBulkUpdate($hash, "state", "off");
  2737. readingsEndUpdate($hash, 0);
  2738. #####
  2739. SetExtensionsCancel($hash);
  2740. } elsif ($ctrlFuncID == 2) {
  2741. # on
  2742. $powerSwitch = "on";
  2743. $updateState = 0;
  2744. readingsBeginUpdate($hash);
  2745. readingsBulkUpdate($hash, "powerSwitch", "on");
  2746. readingsBulkUpdate($hash, "state", "off");
  2747. readingsEndUpdate($hash, 0);
  2748. #####
  2749. SetExtensionsCancel($hash);
  2750. } elsif ($ctrlFuncID == 3) {
  2751. # occupancy
  2752. if (defined $a[1] && $a[1] =~ m/^occupied|standby|unoccupied|off$/) {
  2753. $occupancy = $a[1];
  2754. readingsSingleUpdate($hash, "occupancy", $a[1], 0);
  2755. shift(@a);
  2756. } else {
  2757. return "Usage: $cmd value wrong.";
  2758. }
  2759. $updateState = 0;
  2760. } elsif ($ctrlFuncID == 4) {
  2761. # ctrl
  2762. if (defined $a[1] && ($a[1] =~ m/^auto$/ || $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100)) {
  2763. $ctrl = $a[1];
  2764. readingsSingleUpdate($hash, "ctrl", $a[1], 0);
  2765. shift(@a);
  2766. } else {
  2767. return "Usage: $cmd value wrong.";
  2768. }
  2769. $updateState = 0;
  2770. } elsif ($ctrlFuncID == 5) {
  2771. # fanSpeed
  2772. if (defined $a[1] && ($a[1] =~ m/^auto$/ || $a[1] =~ m/^\d+$/ && $a[1] > 0 && $a[1] < 15)) {
  2773. $fanSpeed = $a[1];
  2774. readingsSingleUpdate($hash, "fanSpeed", $a[1], 0);
  2775. shift(@a);
  2776. } else {
  2777. return "Usage: $cmd value wrong.";
  2778. }
  2779. $updateState = 0;
  2780. } elsif ($ctrlFuncID == 6) {
  2781. # vanePosition
  2782. my $vanePositionValues = join("|", keys %vanePosition);
  2783. if (defined $a[1] && $a[1] =~ m/^$vanePositionValues$/) {
  2784. $vanePosition = $a[1];
  2785. readingsSingleUpdate($hash, "vanePosition", $a[1], 0);
  2786. shift(@a);
  2787. } else {
  2788. return "Usage: $cmd value wrong.";
  2789. }
  2790. $updateState = 0;
  2791. } elsif ($ctrlFuncID == 7) {
  2792. # mode
  2793. my $modeValues = join("|", keys %mode);
  2794. if (defined $a[1] && $a[1] =~ m/^$modeValues$/) {
  2795. $mode = $a[1];
  2796. readingsSingleUpdate($hash, "mode", $a[1], 0);
  2797. shift(@a);
  2798. } else {
  2799. return "Usage: $cmd value wrong.";
  2800. }
  2801. $updateState = 0;
  2802. }
  2803. if ($cmd ne "teach") {
  2804. $ctrlParam1 = $mode{$mode};
  2805. $vanePosition = $vanePosition{$vanePosition};
  2806. $fanSpeed = 0 if ($fanSpeed eq "auto");
  2807. $ctrlParam2 = $vanePosition << 4 || $fanSpeed;
  2808. $ctrl = 255 if ($ctrl eq "auto");
  2809. $ctrlParam3 = $ctrl;
  2810. if ($occupancy eq "occupied") {
  2811. $occupancy = 0;
  2812. } elsif ($occupancy eq "standby") {
  2813. $occupancy = 1;
  2814. } elsif ($occupancy eq "unoccupied") {
  2815. $occupancy = 2;
  2816. } else {
  2817. $occupancy = 3;
  2818. }
  2819. $powerSwitch = $powerSwitch eq "on" ? 1 : 0;
  2820. $setCmd |= $occupancy << 1 | $powerSwitch;
  2821. }
  2822. $data = sprintf "%02X%02X%02X%02X", $ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd;
  2823. Log3 $name, 3, "EnOcean set $name $cmd";
  2824. } elsif ($st eq "hvac.11") {
  2825. # Generic HVAC Interface - Error Control (EEP A5-20-11)
  2826. $rorg = "A5";
  2827. my %ctrlFunc = (
  2828. "externalDisable" => 1,
  2829. "remoteCtrl" => 2,
  2830. "window" => 3,
  2831. "teach" => 255,
  2832. );
  2833. my $ctrlFuncID;
  2834. if (defined $ctrlFunc{$cmd}) {
  2835. $ctrlFuncID = $ctrlFunc{$cmd};
  2836. } else {
  2837. $cmdList .= "externalDisable:disabled,enabled remoteCtrl:disabled,enabled teach:noArg window:closed,opened";
  2838. return "Unknown argument " . $cmd . ", choose one of " . $cmdList;
  2839. }
  2840. my $extern = ReadingsVal($name, "externalDisable", "enable");
  2841. my $remote = ReadingsVal($name, "remoteCtrl", "enable");
  2842. my $window = ReadingsVal($name, "window", "closed");
  2843. my ($ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd) = (0, 0, 0, 8);
  2844. if($ctrlFuncID == 255) {
  2845. # teach-in EEP A5-20-11, Manufacturer "Multi user Manufacturer ID"
  2846. $ctrlParam1 = 0x80;
  2847. $ctrlParam2 = 0x8F;
  2848. $ctrlParam3 = 0xFF;
  2849. $setCmd = 0x80;
  2850. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  2851. EnOcean_4BSRespWait(undef, $hash, $subDef);
  2852. readingsSingleUpdate($hash, "teach", "4BS teach-in sent, response requested", 1);
  2853. $updateState = 0;
  2854. } elsif ($ctrlFuncID == 1) {
  2855. # external disablement
  2856. if (defined $a[1] && $a[1] =~ m/^disabled|enabled$/) {
  2857. $extern = $a[1];
  2858. readingsSingleUpdate($hash, "externalDisable", $a[1], 0);
  2859. shift(@a);
  2860. } else {
  2861. return "Usage: $cmd value wrong.";
  2862. }
  2863. $updateState = 0;
  2864. } elsif ($ctrlFuncID == 2) {
  2865. # disable remote controller
  2866. if (defined $a[1] && $a[1] =~ m/^disabled|enabled$/) {
  2867. $remote = $a[1];
  2868. readingsSingleUpdate($hash, "remoteCtrl", $a[1], 0);
  2869. shift(@a);
  2870. } else {
  2871. return "Usage: $cmd value wrong.";
  2872. }
  2873. $updateState = 0;
  2874. } elsif ($ctrlFuncID == 3) {
  2875. # window contact
  2876. if (defined $a[1] && $a[1] =~ m/^closed|opened$/) {
  2877. $window = $a[1];
  2878. readingsSingleUpdate($hash, "window", $a[1], 0);
  2879. shift(@a);
  2880. } else {
  2881. return "Usage: $cmd value wrong.";
  2882. }
  2883. $updateState = 0;
  2884. }
  2885. if ($cmd ne "teach") {
  2886. $ctrlParam3 = $extern eq "disabled" ? 1 : 0;
  2887. $setCmd |= ($remote eq "disabled" ? 1 : 0) << 2 | ($window eq "closed" ? 1 : 0) << 1;
  2888. }
  2889. $data = sprintf "%02X%02X%02X%02X", $ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd;
  2890. Log3 $name, 3, "EnOcean set $name $cmd";
  2891. } elsif ($st eq "gateway") {
  2892. # Gateway (EEP A5-38-08)
  2893. # select Command from attribute gwCmd or command line
  2894. my $gwCmd = AttrVal($name, "gwCmd", undef);
  2895. if ($gwCmd && $EnO_gwCmd{$gwCmd}) {
  2896. # command from attribute gwCmd
  2897. if ($EnO_gwCmd{$cmd}) {
  2898. # shift $cmd
  2899. $cmd = $a[1];
  2900. shift(@a);
  2901. }
  2902. } elsif ($EnO_gwCmd{$cmd}) {
  2903. # command from command line
  2904. $gwCmd = $cmd;
  2905. $cmd = $a[1];
  2906. shift(@a);
  2907. } else {
  2908. return "Unknown Gateway command " . $cmd . ", choose one of " . $cmdList . join(" ", sort keys %EnO_gwCmd);
  2909. }
  2910. my $gwCmdID;
  2911. $rorg = "A5";
  2912. my $setCmd = 0;
  2913. my $time = 0;
  2914. if ($gwCmd eq "switching") {
  2915. # Switching
  2916. $gwCmdID = 1;
  2917. if($cmd eq "teach") {
  2918. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  2919. #$data = sprintf "%02X000000", $gwCmdID;
  2920. if ($model =~ m/TF$/) {
  2921. $data = "E0400D80";
  2922. } else {
  2923. $data = "E047FF80";
  2924. }
  2925. $attr{$name}{eep} = "A5-38-08";
  2926. CommandDeleteReading(undef, "$name .*");
  2927. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2928. $updateState = 0;
  2929. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2930. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  2931. } elsif ($cmd eq "on") {
  2932. $setCmd = 9;
  2933. readingsSingleUpdate($hash, "block", "unlock", 1);
  2934. if ($a[1]) {
  2935. return "Usage: $cmd [lock|unlock]" if (($a[1] ne "lock") && ($a[1] ne "unlock"));
  2936. if ($a[1] eq "lock") {
  2937. $setCmd = $setCmd | 4;
  2938. readingsSingleUpdate($hash, "block", "lock", 1);
  2939. }
  2940. shift(@a);
  2941. }
  2942. #$updateState = 0;
  2943. #####
  2944. SetExtensionsCancel($hash);
  2945. $data = sprintf "%02X%04X%02X", $gwCmdID, $time, $setCmd;
  2946. } elsif ($cmd eq "off") {
  2947. if ($model =~ m/FSA12$/) {
  2948. $setCmd = 0x0E;
  2949. } else {
  2950. $setCmd = 8;
  2951. }
  2952. readingsSingleUpdate($hash, "block", "unlock", 1);
  2953. if ($a[1]) {
  2954. return "Usage: $cmd [lock|unlock]" if (($a[1] ne "lock") && ($a[1] ne "unlock"));
  2955. if ($a[1] eq "lock") {
  2956. $setCmd = $setCmd | 4;
  2957. readingsSingleUpdate($hash, "block", "lock", 1);
  2958. }
  2959. shift(@a);
  2960. }
  2961. #$updateState = 0;
  2962. #####
  2963. SetExtensionsCancel($hash);
  2964. $data = sprintf "%02X%04X%02X", $gwCmdID, $time, $setCmd;
  2965. } elsif ($cmd eq "local") {
  2966. if ($a[1]) {
  2967. return "Usage: $cmd [learn]" if ($a[1] ne "learn");
  2968. if ($a[1] eq "learn") {
  2969. $cmd = 'off';
  2970. $setCmd = $setCmd | 0x28;
  2971. readingsSingleUpdate($hash, "block", "unlock", 1);
  2972. }
  2973. shift(@a);
  2974. }
  2975. #$updateState = 0;
  2976. $data = sprintf "%02X%04X%02X", $gwCmdID, $time, $setCmd;
  2977. } else {
  2978. my $cmdList = "local:learn on:noArg off:noArg teach:noArg";
  2979. return SetExtensions ($hash, $cmdList, $name, @a);
  2980. }
  2981. } elsif ($gwCmd eq "dimming") {
  2982. # Dimming
  2983. $gwCmdID = 2;
  2984. my $dimMax = AttrVal($name, "dimMax", 255);
  2985. my $dimMin = AttrVal($name, "dimMin", "off");
  2986. if ($dimMax =~ m/^\d+$/ && $dimMin =~ m/^\d+$/ && $dimMin > $dimMax) {
  2987. ($dimMax, $dimMin) = ($dimMin , $dimMax);
  2988. }
  2989. my $dimVal = ReadingsVal($name, "dim", undef);
  2990. my $rampTime = AttrVal($name, "rampTime", 1);
  2991. my $sendDimCmd = 0;
  2992. $setCmd = 9;
  2993. if ($cmd =~ m/^\d+$/) {
  2994. # interpretive numeric value as dimming
  2995. unshift(@a, 'dim');
  2996. $cmd = 'dim';
  2997. }
  2998. if ($cmd eq "teach") {
  2999. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3000. #$data = "E047FF80";
  3001. # teach-in Eltako
  3002. if ($model =~ m/TF$/) {
  3003. $data = "E0400D80";
  3004. } else {
  3005. $data = "02000000";
  3006. }
  3007. $attr{$name}{eep} = "A5-38-08";
  3008. CommandDeleteReading(undef, "$name .*");
  3009. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3010. $updateState = 0;
  3011. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3012. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3013. } elsif ($cmd eq "dim") {
  3014. return "Usage: $cmd dim/% [rampTime/s lock|unlock]"
  3015. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3016. # for eltako relative (0-100) (but not compliant to EEP because DB0.2 is 0)
  3017. # >> if manufID needed: set DB2.0
  3018. $dimVal = $a[1];
  3019. if ($dimVal > 0) {
  3020. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3021. }
  3022. shift(@a);
  3023. if (defined($a[1])) {
  3024. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] !~ m/^\d+$/);
  3025. $rampTime = $a[1];
  3026. shift(@a);
  3027. }
  3028. $sendDimCmd = 1;
  3029. } elsif ($cmd eq "dimup") {
  3030. return "Usage: $cmd dim/% [rampTime/s lock|unlock]"
  3031. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3032. $dimVal += $a[1];
  3033. if ($dimVal > 0) {
  3034. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3035. }
  3036. shift(@a);
  3037. if (defined($a[1])) {
  3038. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] !~ m/^\d+$/);
  3039. $rampTime = $a[1];
  3040. shift(@a);
  3041. }
  3042. $sendDimCmd = 1;
  3043. } elsif ($cmd eq "dimdown") {
  3044. return "Usage: $cmd dim/% [rampTime/s lock|unlock]"
  3045. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3046. $dimVal -= $a[1];
  3047. if ($dimVal > 0) {
  3048. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3049. }
  3050. shift(@a);
  3051. if (defined($a[1])) {
  3052. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] !~ m/^\d+$/);
  3053. $rampTime = $a[1];
  3054. shift(@a);
  3055. }
  3056. $sendDimCmd = 1;
  3057. } elsif ($cmd eq "on") {
  3058. $rampTime = 1;
  3059. my $dimValueOn = AttrVal($name, "dimValueOn", 100);
  3060. if ($dimValueOn eq "stored") {
  3061. $dimVal = ReadingsVal($name, "dimValueStored", 100);
  3062. if ($dimVal < 1) {
  3063. $dimVal = 100;
  3064. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3065. }
  3066. } elsif ($dimValueOn eq "last") {
  3067. $dimVal = ReadingsVal ($name, "dimValueLast", 100);
  3068. if ($dimVal < 1) { $dimVal = 100; }
  3069. } else {
  3070. if ($dimValueOn !~ m/^\d+$/) {
  3071. $dimVal = 100;
  3072. } elsif ($dimValueOn > 100) {
  3073. $dimVal = 100;
  3074. } elsif ($dimValueOn < 1) {
  3075. $dimVal = 1;
  3076. } else {
  3077. $dimVal = $dimValueOn;
  3078. }
  3079. }
  3080. $sendDimCmd = 1;
  3081. } elsif ($cmd eq "off") {
  3082. $dimVal = 0;
  3083. $rampTime = 1;
  3084. $setCmd = 8;
  3085. $sendDimCmd = 1;
  3086. } elsif ($cmd eq "local") {
  3087. if ($a[1]) {
  3088. return "Usage: $cmd [learn]" if ($a[1] ne "learn");
  3089. if ($a[1] eq "learn") {
  3090. $cmd = 'off';
  3091. $dimVal = 0;
  3092. $rampTime = 1;
  3093. $setCmd = 0x2C;
  3094. readingsSingleUpdate($hash, "block", "lock", 1);
  3095. }
  3096. shift(@a);
  3097. }
  3098. #$updateState = 0;
  3099. #####
  3100. SetExtensionsCancel($hash);
  3101. $data = sprintf "%02X%02X%02X%02X", $gwCmdID, $dimVal, $rampTime, $setCmd;
  3102. } else {
  3103. my $cmdList = "dim:slider,0,1,100 local:learn on:noArg off:noArg teach:noArg";
  3104. return SetExtensions ($hash, $cmdList, $name, @a);
  3105. }
  3106. if ($sendDimCmd) {
  3107. readingsSingleUpdate($hash, "block", "unlock", 1);
  3108. if (defined $a[1]) {
  3109. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] ne "lock" && $a[1] ne "unlock");
  3110. # Eltako devices: lock dimming value
  3111. if ($manufID eq "00D" && $a[1] eq "lock" ) {
  3112. $setCmd = $setCmd | 4;
  3113. readingsSingleUpdate($hash, "block", "lock", 1);
  3114. }
  3115. shift(@a);
  3116. } else {
  3117. # Dimming value relative
  3118. if ($manufID ne "00D") {$setCmd = $setCmd | 4;}
  3119. }
  3120. if ($cmd eq "off" && $dimMin =~ m/^\d+$/ && $dimMin == 0) {
  3121. # switch off
  3122. } elsif ($cmd eq "off" && $dimMin =~ m/^\d+$/) {
  3123. $dimVal = $dimMin;
  3124. $setCmd = 9;
  3125. } elsif ($dimMax eq "off" || $dimVal == 0 && $dimMin eq "off" || $dimVal < 0) {
  3126. # switch off
  3127. $dimVal = 0;
  3128. $setCmd = 8;
  3129. } elsif ($dimMin eq "off") {
  3130. } elsif ($dimVal < $dimMin) {
  3131. $dimVal = $dimMin;
  3132. }
  3133. $dimVal = $dimMax if ($dimVal > $dimMax);
  3134. $dimVal = 100 if ($dimVal > 100);
  3135. $rampTime = 0 if ($rampTime < 0);
  3136. $rampTime = 255 if ($rampTime > 255);
  3137. #$updateState = 0;
  3138. readingsSingleUpdate ($hash, "dim", $dimVal, 1);
  3139. $data = sprintf "%02X%02X%02X%02X", $gwCmdID, $dimVal, $rampTime, $setCmd;
  3140. }
  3141. } elsif ($gwCmd eq "setpointShift") {
  3142. $gwCmdID = 3;
  3143. if ($cmd eq "teach") {
  3144. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3145. $data = "E047FF80";
  3146. $attr{$name}{eep} = "A5-38-08";
  3147. CommandDeleteReading(undef, "$name .*");
  3148. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3149. $updateState = 0;
  3150. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3151. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3152. } elsif ($cmd eq "shift") {
  3153. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= -12.7) && ($a[1] <= 12.8)) {
  3154. #$updateState = 0;
  3155. $data = sprintf "%02X00%02X08", $gwCmdID, ($a[1] + 12.7) * 10;
  3156. shift(@a);
  3157. } else {
  3158. return "Usage: $a[1] is not numeric or out of range";
  3159. }
  3160. } else {
  3161. return "Unknown argument $cmd, choose one of teach:noArg shift";
  3162. }
  3163. } elsif ($gwCmd eq "setpointBasic") {
  3164. $gwCmdID = 4;
  3165. if($cmd eq "teach") {
  3166. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3167. $data = "E047FF80";
  3168. $attr{$name}{eep} = "A5-38-08";
  3169. CommandDeleteReading(undef, "$name .*");
  3170. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3171. $updateState = 0;
  3172. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3173. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3174. } elsif ($cmd eq "basic") {
  3175. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 51.2)) {
  3176. #$updateState = 0;
  3177. $data = sprintf "%02X00%02X08", $gwCmdID, $a[1] * 5;
  3178. shift(@a);
  3179. } else {
  3180. return "Usage: $cmd parameter is not numeric or out of range.";
  3181. }
  3182. } else {
  3183. return "Unknown argument $cmd, choose one of teach:noArg basic";
  3184. }
  3185. } elsif ($gwCmd eq "controlVar") {
  3186. $gwCmdID = 5;
  3187. my $controlVar = ReadingsVal($name, "controlVar", 0);
  3188. if($cmd eq "teach") {
  3189. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3190. $data = "E047FF80";
  3191. $attr{$name}{eep} = "A5-38-08";
  3192. CommandDeleteReading(undef, "$name .*");
  3193. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3194. $updateState = 0;
  3195. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3196. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3197. } elsif ($cmd eq "presence") {
  3198. if ($a[1] eq "standby") {
  3199. $setCmd = 0x0A;
  3200. } elsif ($a[1] eq "absent") {
  3201. $setCmd = 9;
  3202. } elsif ($a[1] eq "present") {
  3203. $setCmd = 8;
  3204. } else {
  3205. return "Usage: $cmd parameter unknown.";
  3206. }
  3207. shift(@a);
  3208. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3209. } elsif ($cmd eq "energyHoldOff") {
  3210. if ($a[1] eq "normal") {
  3211. $setCmd = 8;
  3212. } elsif ($a[1] eq "holdoff") {
  3213. $setCmd = 0x0C;
  3214. } else {
  3215. return "Usage: $cmd parameter unknown.";
  3216. }
  3217. shift(@a);
  3218. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3219. } elsif ($cmd eq "controllerMode") {
  3220. if ($a[1] eq "auto") {
  3221. $setCmd = 8;
  3222. } elsif ($a[1] eq "heating") {
  3223. $setCmd = 0x28;
  3224. } elsif ($a[1] eq "cooling") {
  3225. $setCmd = 0x48;
  3226. } elsif ($a[1] eq "off" || $a[1] eq "BI") {
  3227. $setCmd = 0x68;
  3228. } else {
  3229. return "Usage: $cmd parameter unknown.";
  3230. }
  3231. shift(@a);
  3232. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3233. } elsif ($cmd eq "controllerState") {
  3234. if ($a[1] eq "auto") {
  3235. $setCmd = 8;
  3236. } elsif ($a[1] eq "override") {
  3237. $setCmd = 0x18;
  3238. if (defined $a[2] && ($a[2] =~ m/^[+-]?\d+$/) && ($a[2] >= 0) && ($a[2] <= 100) ) {
  3239. $controlVar = $a[2] * 255;
  3240. shift(@a);
  3241. } else {
  3242. return "Usage: Control Variable Override is not numeric or out of range.";
  3243. }
  3244. } else {
  3245. return "Usage: $cmd parameter unknown.";
  3246. }
  3247. shift(@a);
  3248. #$updateState = 0;
  3249. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3250. } else {
  3251. return "Unknown argument, choose one of teach:noArg presence:absent,present,standby energyHoldOff:holdoff,normal controllerMode:cooling,heating,off controllerState:auto,override";
  3252. }
  3253. } elsif ($gwCmd eq "fanStage") {
  3254. $gwCmdID = 6;
  3255. if($cmd eq "teach") {
  3256. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3257. $data = "E047FF80";
  3258. $attr{$name}{eep} = "A5-38-08";
  3259. CommandDeleteReading(undef, "$name .*");
  3260. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3261. $updateState = 0;
  3262. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3263. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3264. } elsif ($cmd eq "stage") {
  3265. if ($a[1] eq "auto") {
  3266. #$updateState = 0;
  3267. $data = sprintf "%02X00%02X08", $gwCmdID, 255;
  3268. } elsif ($a[1] && $a[1] =~ m/^[0-3]$/) {
  3269. #$updateState = 0;
  3270. $data = sprintf "%02X00%02X08", $gwCmdID, $a[1];
  3271. } else {
  3272. return "Usage: $cmd parameter is not numeric or out of range"
  3273. }
  3274. shift(@a);
  3275. } else {
  3276. return "Unknown argument, choose one of teach:noArg stage:auto,0,1,2,3";
  3277. }
  3278. } elsif ($gwCmd eq "blindCmd") {
  3279. $gwCmdID = 7;
  3280. my %blindFunc = (
  3281. "status" => 0,
  3282. "stop" => 1,
  3283. "opens" => 2,
  3284. "closes" => 3,
  3285. "position" => 4,
  3286. "up" => 5,
  3287. "down" => 6,
  3288. "runtimeSet" => 7,
  3289. "angleSet" => 8,
  3290. "positionMinMax" => 9,
  3291. "angleMinMax" => 10,
  3292. "positionLogic" => 11,
  3293. "teach" => 255,
  3294. );
  3295. my @blindFunc = (
  3296. "position:slider,0,1,100",
  3297. "opens:noArg",
  3298. "closes:noArg",
  3299. "up",
  3300. "down",
  3301. "stop:noArg",
  3302. "status:noArg",
  3303. "runtimeSet",
  3304. "angleSet",
  3305. "positionMinMax",
  3306. "angleMinMax",
  3307. "positionLogic:normal,inverse",
  3308. "teach:noArg",
  3309. );
  3310. my $blindFuncID;
  3311. if (defined $blindFunc {$cmd}) {
  3312. $blindFuncID = $blindFunc {$cmd};
  3313. } elsif ($cmd =~ m/^\d+$/) {
  3314. # interpretive numeric value as position
  3315. unshift(@a, 'position');
  3316. $cmd = 'position';
  3317. $blindFuncID = 4;
  3318. } else {
  3319. return "Unknown Gateway Blind Central Function " . $cmd . ", choose one of ". join(" ", @blindFunc);
  3320. }
  3321. my $blindParam1 = 0;
  3322. my $blindParam2 = 0;
  3323. $setCmd = $blindFuncID << 4 | 8;
  3324. if($blindFuncID == 255) {
  3325. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3326. $gwCmdID = 0xE0;
  3327. $blindParam1 = 0x47;
  3328. $blindParam2 = 0xFF;
  3329. $setCmd = 0x80;
  3330. $attr{$name}{eep} = "A5-38-08";
  3331. CommandDeleteReading(undef, "$name .*");
  3332. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3333. $updateState = 0;
  3334. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3335. } elsif ($blindFuncID == 0) {
  3336. # status
  3337. $updateState = 0;
  3338. } elsif ($blindFuncID == 1) {
  3339. # stop
  3340. $updateState = 0;
  3341. } elsif ($blindFuncID == 2) {
  3342. # opens
  3343. $updateState = 0;
  3344. } elsif ($blindFuncID == 3) {
  3345. # closes
  3346. $updateState = 0;
  3347. } elsif ($blindFuncID == 4) {
  3348. # position
  3349. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  3350. $blindParam1 = $a[1];
  3351. shift(@a);
  3352. if (defined $a[1]) {
  3353. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= -180 && $a[1] <= 180) {
  3354. # set angle
  3355. $blindParam2 = abs($a[1]) / 2;
  3356. if ($a[1] < 0) {$blindParam2 |= 0x80;}
  3357. shift(@a);
  3358. } else {
  3359. return "Usage: $cmd variable is not numeric or out of range.";
  3360. }
  3361. } else {
  3362. # set angle defaults
  3363. my $positionLogic = ReadingsVal($name, 'positionLogic', 'normal');
  3364. my $angleMin = ReadingsVal($name, 'angleMin', -180);
  3365. my $angleMax = ReadingsVal($name, 'angleMax', 180);
  3366. if ($blindParam1 == 0) {
  3367. $blindParam2 = $positionLogic eq 'normal' ? $angleMax : $angleMin;
  3368. } elsif ($blindParam1 == 100) {
  3369. $blindParam2 = $positionLogic eq 'normal' ? $angleMin : $angleMax;
  3370. } else {
  3371. $blindParam2 = $angleMin + ($angleMax - $angleMin) / 2;
  3372. }
  3373. if ($blindParam2 < 0) {
  3374. $blindParam2 = abs($blindParam2) / 2;
  3375. $blindParam2 |= 0x80;
  3376. } else {
  3377. $blindParam2 = $blindParam2 / 2;
  3378. }
  3379. }
  3380. } else {
  3381. return "Usage: $cmd variable is not numeric or out of range.";
  3382. }
  3383. # angle und position value available
  3384. $setCmd |= 2;
  3385. $updateState = 0;
  3386. } elsif ($blindFuncID == 5 || $blindFuncID == 6) {
  3387. # up / down
  3388. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3389. $blindParam1 = $a[1];
  3390. if (defined $a[2] && $a[2] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[2] >= 0 && $a[2] <= 25.5) {
  3391. $blindParam2 = $a[2] * 10;
  3392. shift(@a);
  3393. } else {
  3394. return "Usage: $cmd variable is not numeric or out of range.";
  3395. }
  3396. shift(@a);
  3397. } else {
  3398. return "Usage: $cmd variable is not numeric or out of range.";
  3399. }
  3400. $updateState = 0;
  3401. } elsif ($blindFuncID == 7) {
  3402. # runtimeSet
  3403. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3404. $blindParam1 = $a[1];
  3405. if (defined $a[2] && $a[2] =~ m/^[+-]?\d+$/ && $a[2] >= 0 && $a[2] <= 255) {
  3406. $blindParam2 = $a[2];
  3407. shift(@a);
  3408. } else {
  3409. return "Usage: $cmd variable is not numeric or out of range.";
  3410. }
  3411. shift(@a);
  3412. } else {
  3413. return "Usage: $cmd variable is not numeric or out of range.";
  3414. }
  3415. readingsSingleUpdate($hash, "runTimeUp", $blindParam1, 1);
  3416. readingsSingleUpdate($hash, "runTimeDown", $blindParam2, 1);
  3417. $updateState = 0;
  3418. } elsif ($blindFuncID == 8) {
  3419. # angleSet
  3420. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[1] >= 0 && $a[1] <= 25.5) {
  3421. $blindParam1 = $a[1] * 10;
  3422. ##
  3423. readingsSingleUpdate($hash, "angleTime", (sprintf "%0.1f", $a[1]), 1);
  3424. shift(@a);
  3425. } else {
  3426. return "Usage: $cmd variable is not numeric or out of range.";
  3427. }
  3428. $updateState = 0;
  3429. } elsif ($blindFuncID == 9) {
  3430. # positionMinMax
  3431. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  3432. $blindParam1 = $a[1];
  3433. if (defined $a[2] && $a[2] =~ m/^[+-]?\d+$/ && $a[2] >= 0 && $a[2] <= 100) {
  3434. $blindParam2 = $a[2];
  3435. shift(@a);
  3436. } else {
  3437. return "Usage: $cmd variable is not numeric or out of range.";
  3438. }
  3439. # angle und position value available
  3440. $setCmd |= 2;
  3441. shift(@a);
  3442. } else {
  3443. return "Usage: $cmd variable is not numeric or out of range.";
  3444. }
  3445. if ($blindParam1 > $blindParam2) {($blindParam1, $blindParam2) = ($blindParam2, $blindParam1);}
  3446. readingsSingleUpdate($hash, "positionMin", $blindParam1, 1);
  3447. readingsSingleUpdate($hash, "positionMax", $blindParam2, 1);
  3448. $updateState = 0;
  3449. } elsif ($blindFuncID == 10) {
  3450. # angleMinMax
  3451. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= -180 && $a[1] <= 180) {
  3452. if (!defined $a[2] || $a[2] !~ m/^[+-]?\d+$/ || $a[2] < -180 || $a[2] > 180) {
  3453. return "Usage: $cmd variable is not numeric or out of range.";
  3454. }
  3455. if ($a[1] > $a[2]) {($a[1], $a[2]) = ($a[2], $a[1]);}
  3456. $blindParam1 = abs($a[1]) / 2;
  3457. if ($a[1] < 0) {$blindParam1 |= 0x80;}
  3458. $blindParam2 = abs($a[2]) / 2;
  3459. if ($a[2] < 0) {$blindParam2 |= 0x80;}
  3460. # angle und position value available
  3461. $setCmd |= 2;
  3462. } else {
  3463. return "Usage: $cmd variable is not numeric or out of range.";
  3464. }
  3465. readingsSingleUpdate($hash, "angleMin", $a[1], 1);
  3466. readingsSingleUpdate($hash, "angleMax", $a[2], 1);
  3467. splice (@a, 0, 2);
  3468. shift(@a);
  3469. $updateState = 0;
  3470. } elsif ($blindFuncID == 11) {
  3471. # positionLogic
  3472. if ($a[1] eq "normal") {
  3473. $blindParam1 = 0;
  3474. } elsif ($a[1] eq "inverse") {
  3475. $blindParam1 = 1;
  3476. } else {
  3477. return "Usage: $cmd variable is unknown.";
  3478. }
  3479. readingsSingleUpdate($hash, "positionLogic", $a[1], 1);
  3480. shift(@a);
  3481. $updateState = 0;
  3482. } else {
  3483. }
  3484. $setCmd |= 4 if (AttrVal($name, "sendDevStatus", "no") eq "yes");
  3485. $setCmd |= 1 if (AttrVal($name, "serviceOn", "no") eq "yes");
  3486. $data = sprintf "%02X%02X%02X%02X", $gwCmdID, $blindParam1, $blindParam2, $setCmd;
  3487. } else {
  3488. return "Unknown Gateway command " . $cmd . ", choose one of ". $cmdList . join(" ", sort keys %EnO_gwCmd);
  3489. }
  3490. Log3 $name, 3, "EnOcean set $name $cmd";
  3491. } elsif ($st eq "energyManagement.01") {
  3492. # Energy Management, Demand Response (A5-37-01)
  3493. $rorg = "A5";
  3494. $updateState = 0;
  3495. my $drLevel = 15;
  3496. my $powerUsage = 100;
  3497. my $powerUsageLevel = 1;
  3498. my $powerUsageScale = 0;
  3499. my $randomStart = 0;
  3500. my $randomEnd = 0;
  3501. my $randomTime = rand(AttrVal($name, "demandRespRandomTime", 1));
  3502. my $setpoint = 255;
  3503. my $timeout = 0;
  3504. my $threshold = AttrVal($name, "demandRespThreshold", 8);
  3505. if($cmd eq "teach") {
  3506. # teach-in EEP A5-37-01, Manufacturer "Multi user Manufacturer ID"
  3507. $data = "DC0FFF80";
  3508. $attr{$name}{eep} = "A5-37-01";
  3509. CommandDeleteReading(undef, "$name .*");
  3510. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3511. $updateState = 0;
  3512. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3513. Log3 $name, 3, "EnOcean set $name $cmd";
  3514. } elsif ($cmd eq "level") {
  3515. return "Usage: $cmd 0...15 [max|rel [yes|no [yes|no [timeout/min]]]]"
  3516. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 15 );
  3517. $drLevel = $a[1];
  3518. $powerUsage = $a[1] / 15 * 100;
  3519. $powerUsageLevel = $drLevel >= $threshold ? 1 : 0;
  3520. $setpoint = $a[1] * 17;
  3521. shift(@a);
  3522. } elsif ($cmd eq "max") {
  3523. } elsif ($cmd eq "min") {
  3524. $drLevel = 0;
  3525. $powerUsage = 0;
  3526. $powerUsageLevel = 0;
  3527. $setpoint = 0;
  3528. } elsif ($cmd eq "power") {
  3529. return "Usage: $cmd 0...100 [max|rel [yes|no [yes|no [timeout/min]]]]"
  3530. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3531. $drLevel = $a[1] / 100 * 15;
  3532. $powerUsage = $a[1];
  3533. $powerUsageLevel = $drLevel >= $threshold ? 1 : 0;
  3534. $setpoint = $a[1] * 2.55;
  3535. shift(@a);
  3536. } elsif ($cmd eq "setpoint") {
  3537. return "Usage: $cmd 0...255 [max|rel [yes|no [yes|no [timeout/min]]]]"
  3538. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 255 );
  3539. $drLevel = $a[1] / 255 * 15 ;
  3540. $powerUsage = $a[1] / 255 * 100;
  3541. $powerUsageLevel = $drLevel >= $threshold ? 1 : 0;
  3542. $setpoint = $a[1];
  3543. shift(@a);
  3544. } else {
  3545. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . "level:slider,0,1,15 max:noArg min:noArg power:slider,0,5,100 setpoint:slider,0,5,255 teach:noArg"
  3546. }
  3547. if ($cmd ne "teach") {
  3548. if (@a > 1) {
  3549. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]" if($a[1] !~ m/^max|rel$/);
  3550. $powerUsageScale = $a[1] eq "rel" ? 0x80 : 0;
  3551. shift(@a);
  3552. }
  3553. if (@a > 1) {
  3554. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]" if($a[1] !~ m/^yes|no$/);
  3555. $randomStart = $a[1] eq "yes" ? 4 : 0;
  3556. shift(@a);
  3557. }
  3558. if (@a > 1) {
  3559. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]" if($a[1] !~ m/^yes|no$/);
  3560. $randomEnd = $a[1] eq "yes" ? 2 : 0;
  3561. shift(@a);
  3562. }
  3563. if (@a > 1) {
  3564. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]"
  3565. if($a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 3825);
  3566. $timeout = int($a[1] / 15);
  3567. shift(@a);
  3568. }
  3569. $data = sprintf "%02X%02X%02X%02X", $setpoint, $powerUsageScale | $powerUsage, $timeout,
  3570. $drLevel << 4 | $randomStart | $randomEnd | $powerUsageLevel | 8;
  3571. my @db = ($drLevel << 4 | $randomStart | $randomEnd | $powerUsageLevel | 8,
  3572. $timeout, $powerUsageScale | $powerUsage, $setpoint);
  3573. EnOcean_energyManagement_01Parse($hash, @db);
  3574. }
  3575. Log3 $name, 3, "EnOcean set $name $cmd";
  3576. } elsif ($st eq "lightCtrl.01") {
  3577. # Central Command, Extended Lighting-Control (EEP A5-38-09)
  3578. $rorg = "A5";
  3579. my %ctrlFunc = (
  3580. "off" => 1,
  3581. "on" => 2,
  3582. "dimup" => 3,
  3583. "dimdown" => 4,
  3584. "stop" => 5,
  3585. "dim" => 6,
  3586. "rgb" => 7,
  3587. "scene" => 8,
  3588. "dimMinMax" => 9,
  3589. "lampOpHours" => 10,
  3590. "block" => 11,
  3591. "meteringValue" => 12,
  3592. "teach" => 255,
  3593. );
  3594. my $ctrlFuncID;
  3595. if (exists $ctrlFunc{$cmd}) {
  3596. $ctrlFuncID = $ctrlFunc{$cmd};
  3597. } elsif ($cmd =~ m/^\d+$/) {
  3598. # interpretive numeric value as dimming
  3599. unshift(@a, 'dim');
  3600. $cmd = 'dim';
  3601. $ctrlFuncID = 6;
  3602. } else {
  3603. $cmdList .= "dim:slider,0,5,255 dimup:noArg dimdown:noArg on:noArg off:noArg stop:noArg rgb:colorpicker,RGB scene dimMinMax lampOpHours block meteringValue teach:noArg";
  3604. return SetExtensions ($hash, $cmdList, $name, @a);
  3605. }
  3606. my ($ctrlParam1, $ctrlParam2, $ctrlParam3) = (0, 0, 0);
  3607. my $setCmd = $ctrlFuncID << 4 | 8;
  3608. if($ctrlFuncID == 255) {
  3609. # teach-in EEP A5-38-09, Manufacturer "Multi user Manufacturer ID"
  3610. $ctrlParam1 = 0xE1;
  3611. $ctrlParam2 = 0xC7;
  3612. $ctrlParam3 = 0xFF;
  3613. $setCmd = 0x80;
  3614. $attr{$name}{eep} = "A5-38-09";
  3615. CommandDeleteReading(undef, "$name .*");
  3616. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3617. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3618. $updateState = 0;
  3619. } elsif ($ctrlFuncID == 1) {
  3620. # off
  3621. CommandDeleteReading(undef, "$name scene");
  3622. #####
  3623. SetExtensionsCancel($hash);
  3624. $updateState = 0;
  3625. } elsif ($ctrlFuncID == 2) {
  3626. # on
  3627. CommandDeleteReading(undef, "$name scene");
  3628. #####
  3629. SetExtensionsCancel($hash);
  3630. $updateState = 0;
  3631. } elsif ($ctrlFuncID == 3 || $ctrlFuncID == 4) {
  3632. # dimup / dimdown
  3633. my $rampTime = $a[1];
  3634. if (defined $a[1]) {
  3635. if ($a[1] =~ m/^\d+?$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3636. shift(@a);
  3637. } else {
  3638. return "Usage: $cmd ramping time value is not numeric or out of range.";
  3639. }
  3640. } else {
  3641. $rampTime = AttrVal($name, "rampTime", 1);
  3642. }
  3643. $ctrlParam3 = $rampTime & 0xFF;
  3644. $ctrlParam2 = ($rampTime & 0xFF00) >> 8;
  3645. readingsSingleUpdate($hash, "rampTime", $rampTime, 1);
  3646. CommandDeleteReading(undef, "$name scene");
  3647. #####
  3648. SetExtensionsCancel($hash);
  3649. $updateState = 0;
  3650. } elsif ($ctrlFuncID == 5) {
  3651. # stop
  3652. CommandDeleteReading(undef, "$name scene");
  3653. #####
  3654. SetExtensionsCancel($hash);
  3655. $updateState = 0;
  3656. } elsif ($ctrlFuncID == 6) {
  3657. # dim
  3658. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3659. $ctrlParam1 = $a[1];
  3660. shift(@a);
  3661. } else {
  3662. return "Usage: $cmd dimming value is not numeric or out of range.";
  3663. }
  3664. my $rampTime = $a[1];
  3665. if (defined $a[1]) {
  3666. if ($a[1] =~ m/^\d+?$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3667. shift(@a);
  3668. } else {
  3669. return "Usage: $cmd ramping time value is not numeric or out of range.";
  3670. }
  3671. } else {
  3672. $rampTime = AttrVal($name, "rampTime", 1);
  3673. }
  3674. $ctrlParam3 = $rampTime & 0xFF;
  3675. $ctrlParam2 = ($rampTime & 0xFF00) >> 8;
  3676. CommandDeleteReading(undef, "$name scene");
  3677. readingsSingleUpdate($hash, "rampTime", $rampTime, 1);
  3678. #####
  3679. SetExtensionsCancel($hash);
  3680. $updateState = 0;
  3681. } elsif ($ctrlFuncID == 7) {
  3682. # RGB
  3683. if (@a > 1) {
  3684. if ($a[1] =~ m/^[\dA-Fa-f]{6}$/) {
  3685. # red
  3686. $ctrlParam1 = hex substr($a[1], 0, 2);
  3687. # green
  3688. $ctrlParam2 = hex substr($a[1], 2, 2);
  3689. # blue
  3690. $ctrlParam3 = hex substr($a[1], 4, 2);
  3691. readingsBeginUpdate($hash);
  3692. readingsBulkUpdate($hash, "red", $ctrlParam1);
  3693. readingsBulkUpdate($hash, "green", $ctrlParam2);
  3694. readingsBulkUpdate($hash, "blue", $ctrlParam3);
  3695. readingsBulkUpdate($hash, "rgb", uc($a[1]));
  3696. readingsEndUpdate($hash, 0);
  3697. shift(@a);
  3698. } else {
  3699. return "Usage: $cmd value is not hexadecimal or out of range.";
  3700. }
  3701. } else {
  3702. return "Usage: $cmd values are missing";
  3703. }
  3704. $updateState = 0;
  3705. } elsif ($ctrlFuncID == 8) {
  3706. # scene
  3707. if (@a > 2) {
  3708. if ($a[2] =~ m/^\d+?$/ && $a[2] >= 0 && $a[2] <= 15) {
  3709. $ctrlParam3 = $a[2];
  3710. } else {
  3711. return "Usage: $cmd number is not numeric or out of range.";
  3712. }
  3713. if ($a[1] eq "drive") {
  3714. readingsSingleUpdate($hash, "scene", $ctrlParam3, 1);
  3715. splice(@a, 0, 2);
  3716. } elsif ($a[1] eq "store") {
  3717. $ctrlParam3 |= 0x80;
  3718. splice(@a, 0, 2);
  3719. } else {
  3720. return "Usage: $cmd parameter is wrong.";
  3721. }
  3722. } else {
  3723. return "Usage: $cmd values are missing";
  3724. }
  3725. $updateState = 0;
  3726. } elsif ($ctrlFuncID == 9) {
  3727. # dimMinMax
  3728. if (@a > 2) {
  3729. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3730. # dimming limit min
  3731. $ctrlParam1 = $a[1];
  3732. shift(@a);
  3733. } else {
  3734. return "Usage: $cmd value is not numeric or out of range.";
  3735. }
  3736. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3737. # dimming limit max
  3738. $ctrlParam2 = $a[1];
  3739. shift(@a);
  3740. } else {
  3741. return "Usage: $cmd value is not numeric or out of range.";
  3742. }
  3743. readingsBeginUpdate($hash);
  3744. readingsBulkUpdate($hash, "dimMin", $ctrlParam1);
  3745. readingsBulkUpdate($hash, "dimMax", $ctrlParam2);
  3746. readingsEndUpdate($hash, 1);
  3747. } else {
  3748. return "Usage: $cmd values are missing";
  3749. }
  3750. $updateState = 0;
  3751. } elsif ($ctrlFuncID == 10) {
  3752. # set operating hours of the lamp
  3753. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3754. $ctrlParam2 = $a[1] & 0xFF;
  3755. $ctrlParam1 = ($a[1] & 0xFF00) >> 8;
  3756. shift(@a);
  3757. } else {
  3758. return "Usage: $cmd variable is not numeric or out of range.";
  3759. }
  3760. $updateState = 0;
  3761. } elsif ($ctrlFuncID == 11) {
  3762. # block
  3763. if (!defined $a[1]) {
  3764. return "Usage: $cmd values are missing";
  3765. } elsif ($a[1] eq "unlock") {
  3766. $ctrlParam3 = 0;
  3767. } elsif ($a[1] eq "on") {
  3768. $ctrlParam3 = 1;
  3769. } elsif ($a[1] eq "off") {
  3770. $ctrlParam3 = 2;
  3771. } elsif ($a[1] eq "local") {
  3772. $ctrlParam3 = 3;
  3773. } else {
  3774. return "Usage: $cmd variable is unknown.";
  3775. }
  3776. readingsSingleUpdate($hash, "block", $a[1], 1);
  3777. shift(@a);
  3778. $updateState = 0;
  3779. } elsif ($ctrlFuncID == 12) {
  3780. # meteringValues
  3781. if (@a > 2) {
  3782. my %unitEnum = (
  3783. "mW" => 0,
  3784. "W" => 1,
  3785. "kW" => 2,
  3786. "MW" => 3,
  3787. "Wh" => 4,
  3788. "kWh" => 5,
  3789. "MWh" => 6,
  3790. "GWh" => 7,
  3791. "mA" => 8,
  3792. "A" => 9,
  3793. "mV" => 10,
  3794. "V" => 11,
  3795. );
  3796. if (exists $unitEnum{$a[2]}) {
  3797. $ctrlParam3 = $unitEnum{$a[2]};
  3798. } else {
  3799. return "Unknown metering value choose one of " . join(" ", sort keys %unitEnum);
  3800. }
  3801. if ($ctrlParam3 == 9 || $ctrlParam3 == 11) {
  3802. if ($a[1] =~ m/^\d+(\.\d+)?$/ && $a[1] >= 0 && $a[1] <= 6553.5) {
  3803. $ctrlParam2 = int($a[1] * 10) & 0xFF;
  3804. $ctrlParam1 = (int($a[1] * 10) & 0xFF00) >> 8;
  3805. } else {
  3806. return "Usage: $cmd value is not numeric or out of range.";
  3807. }
  3808. } else {
  3809. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3810. $ctrlParam2 = $a[1] & 0xFF;
  3811. $ctrlParam1 = ($a[1] & 0xFF00) >> 8;
  3812. } else {
  3813. return "Usage: $cmd value is not numeric or out of range.";
  3814. }
  3815. }
  3816. splice(@a, 0, 2);
  3817. } else {
  3818. return "Usage: $cmd values are missing";
  3819. }
  3820. $updateState = 0;
  3821. }
  3822. $setCmd |= 4 if (AttrVal($name, "sendDevStatus", "yes") eq "no");
  3823. $setCmd |= 1 if (AttrVal($name, "serviceOn", "no") eq "yes");
  3824. $data = sprintf "%02X%02X%02X%02X", $ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd;
  3825. Log3 $name, 3, "EnOcean set $name $cmd";
  3826. } elsif ($st eq "radioLinkTest") {
  3827. # Radio Link Test (A5-3F-00)
  3828. $rorg = "A5";
  3829. $updateState = 3;
  3830. if($cmd =~ m/^standby|stop$/) {
  3831. @{$hash->{helper}{rlt}{param}} = ($cmd, $hash, undef, $subDef, 'master', 0);
  3832. EnOcean_RLT($hash->{helper}{rlt}{param});
  3833. } else {
  3834. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . "standby:noArg stop:noArg"
  3835. }
  3836. Log3 $name, 3, "EnOcean set $name $cmd";
  3837. } elsif ($st eq "manufProfile") {
  3838. if ($manufID eq "00D") {
  3839. # Eltako Shutter
  3840. my $angleMax = AttrVal($name, "angleMax", 90);
  3841. my $angleMin = AttrVal($name, "angleMin", -90);
  3842. my $anglePos = ReadingsVal($name, "anglePos", undef);
  3843. my $anglePosStart;
  3844. my $angleTime = AttrVal($name, "angleTime", 0);
  3845. my $position = ReadingsVal($name, "position", undef);
  3846. my $positionStart;
  3847. my $setCmd = 8;
  3848. my $settingAccuracy = 1;
  3849. if (AttrVal($name, 'settingAccuracy', 'low') eq 'high') {
  3850. $setCmd = 0x0A;
  3851. $settingAccuracy = 10;
  3852. }
  3853. if ($cmd eq "?" || $cmd eq "stop") {
  3854. } else {
  3855. # check actual shutter position
  3856. my $actualState = ReadingsVal($name, "state", undef);
  3857. if (defined $actualState) {
  3858. if ($actualState eq "open") {
  3859. $position = 0;
  3860. $anglePos = 0;
  3861. } elsif ($actualState eq "closed") {
  3862. $position = 100;
  3863. $anglePos = $angleMax;
  3864. }
  3865. }
  3866. $anglePosStart = $anglePos;
  3867. $positionStart = $position;
  3868. readingsSingleUpdate($hash, ".anglePosStart", $anglePosStart, 0);
  3869. readingsSingleUpdate($hash, ".positionStart", $positionStart, 0);
  3870. }
  3871. $rorg = "A5";
  3872. my $shutTime = AttrVal($name, "shutTime", 255);
  3873. my $shutTimeCloses = AttrVal($name, "shutTimeCloses", $shutTime);
  3874. $shutTimeCloses = $shutTime if ($shutTimeCloses < $shutTime);
  3875. my $shutCmd = 0;
  3876. $angleMax = 90 if ($angleMax !~ m/^[+-]?\d+$/);
  3877. $angleMax = 180 if ($angleMax > 180);
  3878. $angleMax = -180 if ($angleMax < -180);
  3879. $angleMin = -90 if ($angleMin !~ m/^[+-]?\d+$/);
  3880. $angleMin = 180 if ($angleMin > 180);
  3881. $angleMin = -180 if ($angleMin < -180);
  3882. ($angleMax, $angleMin) = ($angleMin, $angleMax) if ($angleMin > $angleMax);
  3883. $angleMax ++ if ($angleMin == $angleMax);
  3884. $angleTime = 6 if ($angleTime !~ m/^[+-]?\d+$/);
  3885. $angleTime = 6 if ($angleTime > 6);
  3886. $angleTime = 0 if ($angleTime < 0);
  3887. $shutTime = 255 if ($shutTime !~ m/^[+-]?\d+$/);
  3888. $shutTime = 255 if ($shutTime > 255);
  3889. $shutTime = 1 if ($shutTime < 1);
  3890. if ($cmd =~ m/^\d+$/) {
  3891. # interpretive numeric value as position
  3892. unshift(@a, 'position');
  3893. $cmd = 'position';
  3894. }
  3895. if ($cmd eq "teach") {
  3896. # teach-in EEP A5-3F-7F, Manufacturer "Eltako"
  3897. $data = "FFF80D80";
  3898. $attr{$name}{eep} = "A5-3F-7F";
  3899. CommandDeleteReading(undef, "$name .*");
  3900. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3901. $updateState = 0;
  3902. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3903. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3904. } elsif ($cmd eq "stop") {
  3905. # stop
  3906. # delete readings, as they are undefined
  3907. CommandDeleteReading(undef, "$name anglePos");
  3908. CommandDeleteReading(undef, "$name position");
  3909. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  3910. readingsSingleUpdate($hash, "state", "stop", 1);
  3911. $shutCmd = 0;
  3912. } elsif ($cmd eq "opens") {
  3913. # opens >> B0
  3914. $anglePos = 0;
  3915. $position = 0;
  3916. readingsSingleUpdate($hash, "anglePos", $anglePos, 1);
  3917. readingsSingleUpdate($hash, "position", $position, 1);
  3918. readingsSingleUpdate($hash, "endPosition", "open", 1);
  3919. $cmd = "open";
  3920. $shutTime = $shutTimeCloses;
  3921. $shutCmd = 1;
  3922. #$updateState = 0;
  3923. } elsif ($cmd eq "closes") {
  3924. # closes >> BI
  3925. $anglePos = $angleMax;
  3926. $position = 100;
  3927. readingsSingleUpdate($hash, "anglePos", $anglePos, 1);
  3928. readingsSingleUpdate($hash, "position", $position, 1);
  3929. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  3930. $cmd = "closed";
  3931. $shutTime = $shutTimeCloses;
  3932. $shutCmd = 2;
  3933. #$updateState = 0;
  3934. } elsif ($cmd eq "up") {
  3935. # up
  3936. if (defined $a[1]) {
  3937. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3938. $position = $positionStart - $a[1] / $shutTime * 100;
  3939. if ($angleTime) {
  3940. $anglePos = $anglePosStart - ($angleMax - $angleMin) * $a[1] / $angleTime;
  3941. if ($anglePos < $angleMin) {
  3942. $anglePos = $angleMin;
  3943. }
  3944. } else {
  3945. $anglePos = $angleMin;
  3946. }
  3947. if ($position <= 0) {
  3948. $anglePos = 0;
  3949. $position = 0;
  3950. readingsSingleUpdate($hash, "endPosition", "open", 1);
  3951. $cmd = "open";
  3952. } else {
  3953. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  3954. $cmd = "not_reached";
  3955. }
  3956. $shutTime = $a[1];
  3957. shift(@a);
  3958. } else {
  3959. return "Usage: $a[1] is not numeric or out of range";
  3960. }
  3961. } else {
  3962. $anglePos = 0;
  3963. $position = 0;
  3964. readingsSingleUpdate($hash, "endPosition", "open", 1);
  3965. $cmd = "open";
  3966. }
  3967. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  3968. readingsSingleUpdate($hash, "position", sprintf("%d", $position), 1);
  3969. $shutCmd = 1;
  3970. } elsif ($cmd eq "down") {
  3971. # down
  3972. if (defined $a[1]) {
  3973. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3974. $position = $positionStart + $a[1] / $shutTime * 100;
  3975. if ($angleTime) {
  3976. $anglePos = $anglePosStart + ($angleMax - $angleMin) * $a[1] / $angleTime;
  3977. if ($anglePos > $angleMax) {
  3978. $anglePos = $angleMax;
  3979. }
  3980. } else {
  3981. $anglePos = $angleMax;
  3982. }
  3983. if($position >= 100) {
  3984. $anglePos = $angleMax;
  3985. $position = 100;
  3986. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  3987. $cmd = "closed";
  3988. } else {
  3989. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  3990. $cmd = "not_reached";
  3991. }
  3992. $shutTime = $a[1];
  3993. shift(@a);
  3994. } else {
  3995. return "Usage: $a[1] is not numeric or out of range";
  3996. }
  3997. } else {
  3998. $anglePos = $angleMax;
  3999. $position = 100;
  4000. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  4001. $cmd = "closed";
  4002. }
  4003. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  4004. readingsSingleUpdate($hash, "position", sprintf("%d", $position), 1);
  4005. $shutCmd = 2;
  4006. } elsif ($cmd eq "position") {
  4007. if (!defined $positionStart) {
  4008. return "Position unknown, please first opens the blinds completely."
  4009. } elsif ($angleTime > 0 && !defined $anglePosStart){
  4010. return "Slats angle position unknown, please first opens the blinds completely."
  4011. } else {
  4012. my $shutTimeSet = $shutTime;
  4013. if (defined $a[2]) {
  4014. if ($a[2] =~ m/^[+-]?\d+$/ && $a[2] >= $angleMin && $a[2] <= $angleMax) {
  4015. $anglePos = $a[2];
  4016. } else {
  4017. return "Usage: $a[1] $a[2] is not numeric or out of range";
  4018. }
  4019. splice(@a,2,1);
  4020. } else {
  4021. $anglePos = $angleMax;
  4022. }
  4023. if ($positionStart <= $angleTime * $angleMax / ($angleMax - $angleMin) / $shutTimeSet * 100) {
  4024. $anglePosStart = $angleMax;
  4025. }
  4026. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  4027. if ($positionStart < $a[1]) {
  4028. # down
  4029. $angleTime = $angleTime * ($angleMax - $anglePos) / ($angleMax - $angleMin);
  4030. $shutTime = $shutTime * ($a[1] - $positionStart) / 100 + $angleTime;
  4031. # round up
  4032. $angleTime = int($angleTime) + 1 if ($settingAccuracy == 1 && $angleTime > int($angleTime));
  4033. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4034. $position = $a[1] + $angleTime / $shutTimeSet * 100;
  4035. if ($position >= 100) {
  4036. $position = 100;
  4037. }
  4038. $shutCmd = 2;
  4039. if ($angleTime) {
  4040. my @timerCmd = ($name, "up", $angleTime);
  4041. my %par = (hash => $hash, timerCmd => \@timerCmd);
  4042. InternalTimer(gettimeofday() + $shutTime + 1, "EnOcean_TimerSet", \%par, 0);
  4043. }
  4044. } elsif ($positionStart > $a[1]) {
  4045. # up
  4046. $angleTime = $angleTime * ($anglePos - $angleMin) /($angleMax - $angleMin);
  4047. $shutTime = $shutTime * ($positionStart - $a[1]) / 100 + $angleTime;
  4048. # round up
  4049. $angleTime = int($angleTime) + 1 if ($settingAccuracy == 1 && $angleTime > int($angleTime));
  4050. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4051. $position = $a[1] - $angleTime / $shutTimeSet * 100;
  4052. if ($position <= 0) {
  4053. $position = 0;
  4054. $anglePos = 0;
  4055. }
  4056. $shutCmd = 1;
  4057. if ($angleTime && $a[1] > 0) {
  4058. my @timerCmd = ($name, "down", $angleTime);
  4059. my %par = (hash => $hash, timerCmd => \@timerCmd);
  4060. InternalTimer(gettimeofday() + $shutTime + 1, "EnOcean_TimerSet", \%par, 0);
  4061. }
  4062. } else {
  4063. if ($anglePosStart > $anglePos) {
  4064. # up >> reduce slats angle
  4065. $shutTime = $angleTime * ($anglePosStart - $anglePos)/($angleMax - $angleMin);
  4066. # round up
  4067. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4068. $shutCmd = 1;
  4069. } elsif ($anglePosStart < $anglePos) {
  4070. # down >> enlarge slats angle
  4071. $shutTime = $angleTime * ($anglePos - $anglePosStart) /($angleMax - $angleMin);
  4072. # round up
  4073. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4074. $shutCmd = 2;
  4075. } else {
  4076. # position and slats angle ok
  4077. $data = '00000008';
  4078. $shutCmd = 0;
  4079. $updateState = 3;
  4080. }
  4081. }
  4082. if ($position == 0) {
  4083. readingsSingleUpdate($hash, "endPosition", "open", 1);
  4084. $cmd = "open";
  4085. } elsif ($position == 100) {
  4086. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  4087. $cmd = "closed";
  4088. } else {
  4089. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  4090. $cmd = "not_reached";
  4091. }
  4092. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  4093. readingsSingleUpdate($hash, "position", sprintf("%d", $position), 1);
  4094. shift(@a);
  4095. } else {
  4096. return "Usage: $a[1] is not numeric or out of range";
  4097. }
  4098. }
  4099. } elsif ($cmd eq "anglePos") {
  4100. if (!defined $positionStart) {
  4101. return "Position unknown, please first opens the blinds completely."
  4102. } elsif ($angleTime > 0 && !defined $anglePosStart){
  4103. return "Slats angle position unknown, please first opens the blinds completely."
  4104. } else {
  4105. if (defined $a[1]) {
  4106. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= $angleMin && $a[1] <= $angleMax) {
  4107. $anglePos = $a[1];
  4108. shift(@a);
  4109. if ($anglePosStart > $anglePos) {
  4110. # up >> reduce slats angle
  4111. $shutTime = $angleTime * ($anglePosStart - $anglePos)/($angleMax - $angleMin);
  4112. # round up
  4113. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4114. $shutCmd = 1;
  4115. } elsif ($anglePosStart < $anglePos) {
  4116. # down >> enlarge slats angle
  4117. $shutTime = $angleTime * ($anglePos - $anglePosStart) /($angleMax - $angleMin);
  4118. # round up
  4119. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4120. $shutCmd = 2;
  4121. } else {
  4122. # slats angle ok
  4123. $data = '00000008';
  4124. $shutCmd = 0;
  4125. $updateState = 3;
  4126. }
  4127. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  4128. } else {
  4129. return "Usage: $a[1] is not numeric or out of range";
  4130. }
  4131. } else {
  4132. return "Usage: $cmd values are missing";
  4133. }
  4134. }
  4135. } elsif ($cmd eq "local") {
  4136. if ($a[1]) {
  4137. return "Usage: $cmd [learn]" if ($a[1] ne "learn");
  4138. if ($a[1] eq "learn") {
  4139. $setCmd = $setCmd | 0x20;
  4140. }
  4141. shift(@a);
  4142. }
  4143. $updateState = 0;
  4144. $data = sprintf "%04X%02X%02X", int($shutTime * $settingAccuracy), $shutCmd, $setCmd;
  4145. } else {
  4146. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . "position:slider,0,5,100 anglePos:slider,-180,5,180 closes:noArg down local:learn opens:noArg stop:noArg teach:noArg up"
  4147. }
  4148. if ($shutCmd || $cmd eq "stop") {
  4149. #$updateState = 0;
  4150. $data = sprintf "%04X%02X%02X", int($shutTime * $settingAccuracy), $shutCmd, $setCmd;
  4151. }
  4152. Log3 $name, 3, "EnOcean set $name $cmd";
  4153. }
  4154. } elsif ($st eq "actuator.01") {
  4155. # Electronic switches and dimmers with Energy Measurement and Local Control
  4156. # (D2-01-00 - D2-01-12)
  4157. $rorg = "D2";
  4158. #$updateState = 0;
  4159. my $cmdID;
  4160. my $channel;
  4161. my $dimValTimer = 0;
  4162. my $outputVal;
  4163. if ($cmd =~ m/^\d+$/) {
  4164. # interpretive numeric value as dimming
  4165. unshift(@a, 'dim');
  4166. $cmd = 'dim';
  4167. }
  4168. if ($cmd eq "on") {
  4169. shift(@a);
  4170. $cmdID = 1;
  4171. my $dimValueOn = AttrVal($name, "dimValueOn", 100);
  4172. if ($dimValueOn eq "stored") {
  4173. $outputVal = ReadingsVal($name, "dimValueStored", 100);
  4174. if ($outputVal < 1) {
  4175. $outputVal = 100;
  4176. readingsSingleUpdate ($hash, "dimValueStored", $outputVal, 1);
  4177. }
  4178. } elsif ($dimValueOn eq "last") {
  4179. $outputVal = ReadingsVal ($name, "dimValueLast", 100);
  4180. if ($outputVal < 1) { $outputVal = 100; }
  4181. } else {
  4182. if ($dimValueOn !~ m/^[+-]?\d+$/) {
  4183. $outputVal = 100;
  4184. } elsif ($dimValueOn > 100) {
  4185. $outputVal = 100;
  4186. } elsif ($dimValueOn < 1) {
  4187. $outputVal = 1;
  4188. } else {
  4189. $outputVal = $dimValueOn;
  4190. }
  4191. }
  4192. $channel = shift(@a);
  4193. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4194. if (!defined $channel || $channel eq "all") {
  4195. CommandDeleteReading(undef, "$name channel.*");
  4196. CommandDeleteReading(undef, "$name dim.*");
  4197. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4198. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4199. $channel = 30;
  4200. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4201. readingsSingleUpdate($hash, "channelInput", "on", 1);
  4202. readingsSingleUpdate($hash, "dimInput", $outputVal, 1);
  4203. $channel = 31;
  4204. } elsif ($channel + 0 >= 30) {
  4205. CommandDeleteReading(undef, "$name channel.*");
  4206. CommandDeleteReading(undef, "$name dim.*");
  4207. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4208. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4209. $channel = 30;
  4210. } elsif ($channel + 0 >= 0 && $channel + 0 <= 29) {
  4211. readingsSingleUpdate($hash, "channel" . $channel, "on", 1);
  4212. readingsSingleUpdate($hash, "dim" . $channel, $outputVal, 1);
  4213. } else {
  4214. return "$cmd $channel wrong, choose 0...29|all|input.";
  4215. }
  4216. #readingsSingleUpdate($hash, "state", "on", 1);
  4217. $data = sprintf "%02X%02X%02X", $cmdID, $dimValTimer << 5 | $channel, $outputVal;
  4218. } elsif ($cmd eq "off") {
  4219. shift(@a);
  4220. $cmdID = 1;
  4221. $outputVal = 0;
  4222. $channel = shift(@a);
  4223. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4224. if (!defined $channel || $channel eq "all") {
  4225. CommandDeleteReading(undef, "$name channel.*");
  4226. CommandDeleteReading(undef, "$name dim.*");
  4227. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4228. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4229. $channel = 30;
  4230. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4231. readingsSingleUpdate($hash, "channelInput", "off", 1);
  4232. readingsSingleUpdate($hash, "dimInput", $outputVal, 1);
  4233. $channel = 31;
  4234. } elsif ($channel + 0 >= 30) {
  4235. CommandDeleteReading(undef, "$name channel.*");
  4236. CommandDeleteReading(undef, "$name dim.*");
  4237. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4238. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4239. $channel = 30;
  4240. } elsif ($channel >= 0 && $channel <= 29) {
  4241. readingsSingleUpdate($hash, "channel" . $channel, "off", 1);
  4242. readingsSingleUpdate($hash, "dim" . $channel, $outputVal, 1);
  4243. } else {
  4244. return "$cmd $channel wrong, choose 0...39|all|input.";
  4245. }
  4246. #readingsSingleUpdate($hash, "state", "off", 1);
  4247. $data = sprintf "%02X%02X%02X", $cmdID, $dimValTimer << 5 | $channel, $outputVal;
  4248. } elsif ($cmd eq "dim") {
  4249. shift(@a);
  4250. $cmdID = 1;
  4251. $outputVal = shift(@a);
  4252. if (!defined $outputVal || $outputVal !~ m/^[+-]?\d+$/ || $outputVal < 0 || $outputVal > 100) {
  4253. return "Usage: $cmd variable is not numeric or out of range.";
  4254. }
  4255. $channel = shift(@a);
  4256. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4257. if (!defined $channel) {
  4258. CommandDeleteReading(undef, "$name channel.*");
  4259. CommandDeleteReading(undef, "$name dim.*");
  4260. if ($outputVal == 0) {
  4261. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4262. } else {
  4263. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4264. }
  4265. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4266. $channel = 30;
  4267. } else {
  4268. if ($channel eq "all") {
  4269. CommandDeleteReading(undef, "$name channel.*");
  4270. CommandDeleteReading(undef, "$name dim.*");
  4271. if ($outputVal == 0) {
  4272. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4273. } else {
  4274. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4275. }
  4276. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4277. $channel = 30;
  4278. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4279. if ($outputVal == 0) {
  4280. readingsSingleUpdate($hash, "channelInput", "off", 1);
  4281. } else {
  4282. readingsSingleUpdate($hash, "channelInput", "on", 1);
  4283. }
  4284. readingsSingleUpdate($hash, "dimInput", $outputVal, 1);
  4285. $channel = 31;
  4286. } elsif ($channel + 0 >= 30) {
  4287. CommandDeleteReading(undef, "$name channel.*");
  4288. CommandDeleteReading(undef, "$name dim.*");
  4289. if ($outputVal == 0) {
  4290. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4291. } else {
  4292. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4293. }
  4294. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4295. $channel = 30;
  4296. } elsif ($channel >= 0 && $channel <= 29) {
  4297. if ($outputVal == 0) {
  4298. readingsSingleUpdate($hash, "channel" . $channel, "off", 1);
  4299. } else {
  4300. readingsSingleUpdate($hash, "channel" . $channel, "on", 1);
  4301. }
  4302. readingsSingleUpdate($hash, "dim" . $channel, $outputVal, 1);
  4303. } else {
  4304. return "Usage: $cmd $channel wrong, choose 0...39|all|input.";
  4305. }
  4306. $dimValTimer = shift(@a);
  4307. if (defined $dimValTimer) {
  4308. if ($dimValTimer eq "switch") {
  4309. $dimValTimer = 0;
  4310. } elsif ($dimValTimer eq "stop") {
  4311. $dimValTimer = 4;
  4312. } elsif ($dimValTimer =~ m/^[1-3]$/) {
  4313. } else {
  4314. return "Usage: $cmd <channel> $dimValTimer wrong, choose 1..3|switch|stop.";
  4315. }
  4316. } else {
  4317. $dimValTimer = 0;
  4318. }
  4319. }
  4320. if ($outputVal == 0) {
  4321. $cmd = "off";
  4322. #readingsSingleUpdate($hash, "state", "off", 1);
  4323. } else {
  4324. $cmd = "on";
  4325. #readingsSingleUpdate($hash, "state", "on", 1);
  4326. }
  4327. $data = sprintf "%02X%02X%02X", $cmdID, $dimValTimer << 5 | $channel, $outputVal;
  4328. } elsif ($cmd eq "local") {
  4329. shift(@a);
  4330. $updateState = 0;
  4331. $cmdID = 2;
  4332. # same configuration for all channels
  4333. $channel = 30;
  4334. my $dayNight = ReadingsVal($name, "dayNight", "day");
  4335. my $dayNightCmd = ($dayNight eq "night")? 1:0;
  4336. my $defaultState = ReadingsVal($name, "defaultState", "off");
  4337. my $defaultStateCmd;
  4338. if ($defaultState eq "off") {
  4339. $defaultStateCmd = 0;
  4340. } elsif ($defaultState eq "on") {
  4341. $defaultStateCmd = 1;
  4342. } elsif ($defaultState eq "last") {
  4343. $defaultStateCmd = 2;
  4344. } else {
  4345. $defaultStateCmd = 0;
  4346. }
  4347. my $localControl = ReadingsVal($name, "localControl", "disabled");
  4348. my $localControlCmd = ($localControl eq "enabled")? 1:0;
  4349. my $overCurrentShutdown = ReadingsVal($name, "overCurrentShutdown", "off");
  4350. my $overCurrentShutdownCmd = ($overCurrentShutdown eq "restart")? 1:0;
  4351. my $overCurrentShutdownReset = "not_active";
  4352. my $overCurrentShutdownResetCmd = 0;
  4353. my $rampTime1 = ReadingsVal($name, "rampTime1", 0);
  4354. my $rampTime1Cmd = $rampTime1 * 2;
  4355. if ($rampTime1Cmd <= 0) {
  4356. $rampTime1Cmd = 0;
  4357. } elsif ($rampTime1Cmd >= 15) {
  4358. $rampTime1Cmd = 15;
  4359. }
  4360. my $rampTime2 = ReadingsVal($name, "rampTime2", 0);
  4361. my $rampTime2Cmd = $rampTime2 * 2;
  4362. if ($rampTime2Cmd <= 0) {
  4363. $rampTime2Cmd = 0;
  4364. } elsif ($rampTime2Cmd >= 15) {
  4365. $rampTime2Cmd = 15;
  4366. }
  4367. my $rampTime3 = ReadingsVal($name, "rampTime3", 0);
  4368. my $rampTime3Cmd = $rampTime3 * 2;
  4369. if ($rampTime3Cmd <= 0) {
  4370. $rampTime3Cmd = 0;
  4371. } elsif ($rampTime3Cmd >= 15) {
  4372. $rampTime3Cmd = 15;
  4373. }
  4374. my $teachInDev = ReadingsVal($name, "teachInDev", "disabled");
  4375. my $teachInDevCmd = ($teachInDev eq "enabled")? 1:0;
  4376. my $localCmd = shift(@a);
  4377. my $localCmdVal = shift(@a);
  4378. if ($localCmd eq "dayNight") {
  4379. if ($localCmdVal eq "day") {
  4380. $dayNight = "day";
  4381. $dayNightCmd = 0;
  4382. } elsif ($localCmdVal eq "night") {
  4383. $dayNight = "night";
  4384. $dayNightCmd = 1;
  4385. } else {
  4386. return "Usage: $cmd $localCmd <value> wrong, choose day night.";
  4387. }
  4388. } elsif ($localCmd eq "defaultState"){
  4389. if ($localCmdVal eq "off") {
  4390. $defaultState = "off";
  4391. $defaultStateCmd = 0;
  4392. } elsif ($localCmdVal eq "on") {
  4393. $defaultState = "on";
  4394. $defaultStateCmd = 1;
  4395. } elsif ($localCmdVal eq "last") {
  4396. $defaultState = "last";
  4397. $defaultStateCmd = 2;
  4398. } else {
  4399. return "Usage: $cmd $localCmd <value> wrong, choose on off last.";
  4400. }
  4401. } elsif ($localCmd eq "localControl"){
  4402. if ($localCmdVal eq "disabled") {
  4403. $localControl = "disabled";
  4404. $localControlCmd = 0;
  4405. } elsif ($localCmdVal eq "enabled") {
  4406. $localControl = "enabled";
  4407. $localControlCmd = 1;
  4408. } else {
  4409. return "Usage: $cmd $localCmd <value> wrong, choose disabled enabled.";
  4410. }
  4411. } elsif ($localCmd eq "overCurrentShutdown"){
  4412. if ($localCmdVal eq "off") {
  4413. $overCurrentShutdown = "off";
  4414. $overCurrentShutdownCmd = 0;
  4415. } elsif ($localCmdVal eq "restart") {
  4416. $overCurrentShutdown = "restart";
  4417. $overCurrentShutdownCmd = 1;
  4418. } else {
  4419. return "Usage: $cmd $localCmd <value> wrong, choose off restart.";
  4420. }
  4421. } elsif ($localCmd eq "overCurrentShutdownReset"){
  4422. if ($localCmdVal eq "not_active") {
  4423. $overCurrentShutdownReset = "not_active";
  4424. $overCurrentShutdownResetCmd = 0;
  4425. } elsif ($localCmdVal eq "trigger") {
  4426. $overCurrentShutdownReset = "trigger";
  4427. $overCurrentShutdownResetCmd = 1;
  4428. } else {
  4429. return "Usage: $cmd $localCmd <value> wrong, choose not_active trigger.";
  4430. }
  4431. } elsif ($localCmd eq "rampTime1"){
  4432. if ($localCmdVal >= 0 || $localCmdVal <= 7.5) {
  4433. $rampTime1 = $localCmdVal;
  4434. $rampTime1Cmd = $localCmdVal * 2;
  4435. } else {
  4436. return "Usage: $cmd $localCmd <value> wrong, choose 0, 0.5, ..., 7, 7.5";
  4437. }
  4438. } elsif ($localCmd eq "rampTime2"){
  4439. if ($localCmdVal >= 0 || $localCmdVal <= 7.5) {
  4440. $rampTime2 = $localCmdVal;
  4441. $rampTime2Cmd = $localCmdVal * 2;
  4442. } else {
  4443. return "Usage: $cmd $localCmd <value> wrong, choose 0, 0.5, ..., 7, 7.5";
  4444. }
  4445. } elsif ($localCmd eq "rampTime3"){
  4446. if ($localCmdVal >= 0 || $localCmdVal <= 7.5) {
  4447. $rampTime3 = $localCmdVal;
  4448. $rampTime3Cmd = $localCmdVal * 2;
  4449. } else {
  4450. return "Usage: $cmd $localCmd <value> wrong, choose 0, 0.5, ..., 7, 7.5";
  4451. }
  4452. } elsif ($localCmd eq "teachInDev"){
  4453. if ($localCmdVal eq "disabled") {
  4454. $teachInDev = "disabled";
  4455. $teachInDevCmd = 0;
  4456. } elsif ($localCmdVal eq "enabled") {
  4457. $teachInDev = "enabled";
  4458. $teachInDevCmd = 1;
  4459. } else {
  4460. return "Usage: $cmd $localCmd <value> wrong, choose disabled enabled.";
  4461. }
  4462. } else {
  4463. return "Usage: $cmd <localCmd> wrong, choose dayNight|defaultState|localControl|" .
  4464. "overCurrentShutdown|overCurrentShutdownReset|rampTime1|rampTime2|rampTime3|teachInDev.";
  4465. }
  4466. readingsSingleUpdate($hash, "dayNight", $dayNight, 1);
  4467. readingsSingleUpdate($hash, "defaultState", $defaultState, 1);
  4468. readingsSingleUpdate($hash, "localControl", $localControl, 1);
  4469. readingsSingleUpdate($hash, "overCurrentShutdown", $overCurrentShutdown, 1);
  4470. readingsSingleUpdate($hash, "overCurrentShutdownReset", $overCurrentShutdownReset, 1);
  4471. readingsSingleUpdate($hash, "rampTime1", $rampTime1, 1);
  4472. readingsSingleUpdate($hash, "rampTime2", $rampTime2, 1);
  4473. readingsSingleUpdate($hash, "rampTime3", $rampTime3, 1);
  4474. readingsSingleUpdate($hash, "teachInDev", $teachInDev, 1);
  4475. $data = sprintf "%02X%02X%02X%02X", $teachInDevCmd << 7 | $cmdID,
  4476. $overCurrentShutdownCmd << 7 | $overCurrentShutdownResetCmd << 6 | $localControlCmd << 5 | $channel,
  4477. int($rampTime2Cmd) << 4 | int($rampTime3Cmd),
  4478. $dayNightCmd << 7 | $defaultStateCmd << 4 | int($rampTime1Cmd);
  4479. } elsif ($cmd eq "measurement") {
  4480. shift(@a);
  4481. $updateState = 0;
  4482. $cmdID = 5;
  4483. # same configuration for all channels
  4484. $channel = 30;
  4485. my $measurementMode = ReadingsVal($name, "measurementMode", "energy");
  4486. my $measurementModeCmd = ($measurementMode eq "power")? 0:1;
  4487. my $measurementReport = ReadingsVal($name, "measurementReport", "query");
  4488. my $measurementReportCmd = ($measurementReport eq "auto")? 0:1;
  4489. my $measurementReset = "not_active";
  4490. my $measurementResetCmd = 0;
  4491. my $measurementDelta = int(ReadingsVal($name, "measurementDelta", 0));
  4492. if ($measurementDelta <= 0) {
  4493. $measurementDelta = 0;
  4494. } elsif ($measurementDelta >= 4095) {
  4495. $measurementDelta = 4095;
  4496. }
  4497. my $unit = ReadingsVal($name, "measurementUnit", "Ws");
  4498. my $unitCmd;
  4499. if ($unit eq "Ws") {
  4500. $unitCmd = 0;
  4501. } elsif ($unit eq "Wh") {
  4502. $unitCmd = 1;
  4503. } elsif ($unit eq "KWh") {
  4504. $unitCmd = 2;
  4505. } elsif ($unit eq "W") {
  4506. $unitCmd = 3;
  4507. } elsif ($unit eq "KW") {
  4508. $unitCmd = 4;
  4509. } else {
  4510. $unitCmd = 0;
  4511. }
  4512. my $responseTimeMax = ReadingsVal($name, "responseTimeMax", 10);
  4513. my $responseTimeMaxCmd = $responseTimeMax / 10;
  4514. if ($responseTimeMaxCmd <= 1) {
  4515. $responseTimeMaxCmd = 1;
  4516. } elsif ($responseTimeMaxCmd >= 255) {
  4517. $responseTimeMaxCmd = 255;
  4518. }
  4519. my $responseTimeMin = ReadingsVal($name, "responseTimeMin", 1);
  4520. if ($responseTimeMin <= 1) {
  4521. $responseTimeMin = 1;
  4522. } elsif ($responseTimeMin >= 255) {
  4523. $responseTimeMin = 255;
  4524. }
  4525. my $measurementCmd = shift(@a);
  4526. my $measurementCmdVal = shift(@a);
  4527. if (!defined $measurementCmdVal) {
  4528. return "Usage: $cmd $measurementCmd <value> needed.";
  4529. }
  4530. if (!defined $measurementCmd) {
  4531. return "Usage: $cmd <measurementCmd> wrong, choose mode|report|" .
  4532. "reset|delta|unit|responseTimeMax|responseTimeMin.";
  4533. } elsif ($measurementCmd eq "mode") {
  4534. if ($measurementCmdVal eq "energy") {
  4535. $measurementMode = "energy";
  4536. $measurementModeCmd = 0;
  4537. } elsif ($measurementCmdVal eq "power") {
  4538. $measurementMode = "power";
  4539. $measurementModeCmd = 1;
  4540. } else {
  4541. return "Usage: $cmd $measurementCmd <value> wrong, choose energy power.";
  4542. }
  4543. } elsif ($measurementCmd eq "report"){
  4544. if ($measurementCmdVal eq "query") {
  4545. $measurementReport = "query";
  4546. $measurementReportCmd = 0;
  4547. } elsif ($measurementCmdVal eq "auto") {
  4548. $measurementReport = "auto";
  4549. $measurementReportCmd = 1;
  4550. } else {
  4551. return "Usage: $cmd $measurementCmd <value> wrong, choose query auto.";
  4552. }
  4553. } elsif ($measurementCmd eq "reset"){
  4554. if ($measurementCmdVal eq "not_active") {
  4555. $measurementReset = "not_active";
  4556. $measurementResetCmd = 0;
  4557. } elsif ($measurementCmdVal eq "trigger") {
  4558. $measurementReset = "trigger";
  4559. $measurementResetCmd = 1;
  4560. } else {
  4561. return "Usage: $cmd $measurementCmd <value> wrong, choose not_active trigger.";
  4562. }
  4563. } elsif ($measurementCmd eq "unit"){
  4564. if ($measurementCmdVal eq "Ws") {
  4565. $unit = "Ws";
  4566. $unitCmd = 0;
  4567. } elsif ($measurementCmdVal eq "Wh") {
  4568. $unit = "Wh";
  4569. $unitCmd = 1;
  4570. } elsif ($measurementCmdVal eq "KWh") {
  4571. $unit = "KWh";
  4572. $unitCmd = 2;
  4573. } elsif ($measurementCmdVal eq "W") {
  4574. $unit = "W";
  4575. $unitCmd = 3;
  4576. } elsif ($measurementCmdVal eq "KW") {
  4577. $unit = "KW";
  4578. $unitCmd = 4;
  4579. } else {
  4580. return "Usage: $cmd $measurementCmd <value> wrong, choose Ws Wh KWh W KW.";
  4581. }
  4582. } elsif ($measurementCmd eq "delta"){
  4583. if ($measurementCmdVal >= 0 || $measurementCmdVal <= 4095) {
  4584. $measurementDelta = int($measurementCmdVal);
  4585. } else {
  4586. return "Usage: $cmd $measurementCmd <value> wrong, choose 0 ... 4095";
  4587. }
  4588. } elsif ($measurementCmd eq "responseTimeMax"){
  4589. if ($measurementCmdVal >= 10 || $measurementCmdVal <= 2550) {
  4590. $responseTimeMax = int($measurementCmdVal);
  4591. $responseTimeMaxCmd = int($measurementCmdVal) / 10;
  4592. } else {
  4593. return "Usage: $cmd $measurementCmd <value> wrong, choose 10 ... 2550";
  4594. }
  4595. } elsif ($measurementCmd eq "responseTimeMin"){
  4596. if ($measurementCmdVal >= 1 || $measurementCmdVal <= 255) {
  4597. $responseTimeMin = int($measurementCmdVal);
  4598. } else {
  4599. return "Usage: $cmd $measurementCmd <value> wrong, choose 1 ... 255";
  4600. }
  4601. } else {
  4602. return "Usage: $cmd <measurementCmd> wrong, choose mode|report|" .
  4603. "reset|delta|unit|responseTimeMax|responseTimeMin.";
  4604. }
  4605. readingsSingleUpdate($hash, "measurementMode", $measurementMode, 1);
  4606. readingsSingleUpdate($hash, "measurementReport", $measurementReport, 1);
  4607. readingsSingleUpdate($hash, "measurementReset", $measurementReset, 1);
  4608. readingsSingleUpdate($hash, "measurementDelta", $measurementDelta, 1);
  4609. readingsSingleUpdate($hash, "measurementUnit", $unit, 1);
  4610. readingsSingleUpdate($hash, "responseTimeMax", $responseTimeMax, 1);
  4611. readingsSingleUpdate($hash, "responseTimeMin", $responseTimeMin, 1);
  4612. $data = sprintf "%02X%02X%02X%02X%02X%02X", $cmdID,
  4613. $measurementReportCmd << 7 | $measurementResetCmd << 6 | $measurementModeCmd << 5 | $channel,
  4614. ($measurementDelta | 0x0F) << 4 | $unitCmd, ($measurementDelta | 0xFF00) >> 8,
  4615. $responseTimeMax, $responseTimeMin;
  4616. } elsif ($cmd eq "roomCtrlMode") {
  4617. shift(@a);
  4618. $updateState = 0;
  4619. $cmdID = 8;
  4620. my $roomCtrlModeCmd = shift(@a);
  4621. return "$cmd <channel> <roomCtrlMode> is missing, choose off|comfort|comfort-1|comfort-2|economy|buildingProtection." if (!defined $roomCtrlModeCmd);
  4622. if ($roomCtrlModeCmd eq "off") {
  4623. $roomCtrlModeCmd = 0;
  4624. } elsif ($roomCtrlModeCmd eq "comfort") {
  4625. $roomCtrlModeCmd = 1;
  4626. } elsif ($roomCtrlModeCmd eq "economy") {
  4627. $roomCtrlModeCmd = 2;
  4628. } elsif ($roomCtrlModeCmd eq "buildingProtection") {
  4629. $roomCtrlModeCmd = 3;
  4630. } elsif ($roomCtrlModeCmd eq "comfort-1") {
  4631. $roomCtrlModeCmd = 4;
  4632. } elsif ($roomCtrlModeCmd eq "comfort-2") {
  4633. $roomCtrlModeCmd = 5;
  4634. } else {
  4635. return "$cmd <channel> <roomCtrlMode> wrong, choose off|comfort|comfort-1|comfort-2|economy|buildingProtection.";
  4636. }
  4637. $data = sprintf "%02X%02X", $cmdID, $roomCtrlModeCmd;
  4638. } elsif ($cmd eq "autoOffTime") {
  4639. shift(@a);
  4640. $updateState = 0;
  4641. $cmdID = 0x0B;
  4642. $outputVal = int(shift(@a) * 10);
  4643. if (!defined $outputVal || $outputVal !~ m/^[+-]?\d+$/ || $outputVal < 0 || $outputVal > 65534) {
  4644. return "Usage: $cmd variable is not numeric or out of range.";
  4645. }
  4646. $channel = shift(@a);
  4647. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4648. if (!defined $channel || $channel eq "all") {
  4649. CommandDeleteReading(undef, "$name autoOffTime.*");
  4650. $channel = 30;
  4651. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4652. $channel = 31;
  4653. } elsif ($channel + 0 >= 30) {
  4654. CommandDeleteReading(undef, "$name autoOffTime.*");
  4655. $channel = 30;
  4656. } elsif ($channel >= 0 && $channel <= 29) {
  4657. } else {
  4658. return "$cmd $channel wrong, choose 0...31|all|input.";
  4659. }
  4660. my $extSwitchMode = ReadingsVal($name, "extSwitchMode", 'unavailable');
  4661. my %extSwitchMode = (
  4662. "unavailable" => 0,
  4663. "switch" => 1,
  4664. "pushbutton" => 2,
  4665. "auto" => 3
  4666. );
  4667. if (exists $extSwitchMode{$extSwitchMode}) {
  4668. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4669. } else {
  4670. $extSwitchMode = 0;
  4671. }
  4672. my $extSwitchType = ReadingsVal($name, "extSwitchType", 'toggle') eq 'direction' ? 1 : 0;
  4673. $data = sprintf "%02X%02X%04XFFFF%02X", $cmdID, $channel, $outputVal, $extSwitchMode << 6 | $extSwitchType << 5;
  4674. } elsif ($cmd eq "delayOffTime") {
  4675. shift(@a);
  4676. $updateState = 0;
  4677. $cmdID = 0x0B;
  4678. $outputVal = int(shift(@a) * 10);
  4679. if (!defined $outputVal || $outputVal !~ m/^[+-]?\d+$/ || $outputVal < 0 || $outputVal > 65534) {
  4680. return "Usage: $cmd variable is not numeric or out of range.";
  4681. }
  4682. $channel = shift(@a);
  4683. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4684. if (!defined $channel || $channel eq "all") {
  4685. CommandDeleteReading(undef, "$name delayOffTime.*");
  4686. $channel = 30;
  4687. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4688. $channel = 31;
  4689. } elsif ($channel + 0 >= 30) {
  4690. CommandDeleteReading(undef, "$name delayOffTime.*");
  4691. $channel = 30;
  4692. } elsif ($channel >= 0 && $channel <= 29) {
  4693. } else {
  4694. return "$cmd $channel wrong, choose 0...31|all|input.";
  4695. }
  4696. my $extSwitchMode = ReadingsVal($name, "extSwitchMode", 'unavailable');
  4697. my %extSwitchMode = (
  4698. "unavailable" => 0,
  4699. "switch" => 1,
  4700. "pushbutton" => 2,
  4701. "auto" => 3
  4702. );
  4703. if (exists $extSwitchMode{$extSwitchMode}) {
  4704. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4705. } else {
  4706. $extSwitchMode = 0;
  4707. }
  4708. my $extSwitchType = ReadingsVal($name, "extSwitchType", 'toggle') eq 'direction' ? 1 : 0;
  4709. $data = sprintf "%02X%02XFFFF%04X%02X", $cmdID, $channel, $outputVal, $extSwitchMode << 6 | $extSwitchType << 5;
  4710. } elsif ($cmd eq "extSwitchMode") {
  4711. shift(@a);
  4712. $updateState = 0;
  4713. $cmdID = 0x0B;
  4714. my $extSwitchMode = shift(@a);
  4715. return "Usage: $cmd variable is missing, choose unavailable|switch|pushbutton|auto." if (!defined $extSwitchMode);
  4716. my %extSwitchMode = (
  4717. "unavailable" => 0,
  4718. "switch" => 1,
  4719. "pushbutton" => 2,
  4720. "auto" => 3
  4721. );
  4722. if (exists $extSwitchMode{$extSwitchMode}) {
  4723. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4724. } else {
  4725. return "Usage: $cmd variable wrong, choose unavailable|switch|pushbutton|auto.";
  4726. }
  4727. $channel = shift(@a);
  4728. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4729. if (!defined $channel || $channel eq "all") {
  4730. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4731. $channel = 30;
  4732. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4733. $channel = 31;
  4734. } elsif ($channel + 0 >= 30) {
  4735. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4736. $channel = 30;
  4737. } elsif ($channel >= 0 && $channel <= 29) {
  4738. } else {
  4739. return "$cmd $channel wrong, choose 0...31|all|input.";
  4740. }
  4741. my $extSwitchType = ReadingsVal($name, "extSwitchType", 'toggle') eq 'direction' ? 1 : 0;
  4742. $data = sprintf "%02X%02XFFFFFFFF%02X", $cmdID, $channel, $extSwitchMode << 6 | $extSwitchType << 5;
  4743. } elsif ($cmd eq "extSwitchType") {
  4744. shift(@a);
  4745. $updateState = 0;
  4746. $cmdID = 0x0B;
  4747. my $extSwitchType = shift(@a);
  4748. return "Usage: $cmd variable is missing, choose toggle|direction." if (!defined $extSwitchType);
  4749. my %extSwitchType = (
  4750. "toggle" => 0,
  4751. "direction" => 1,
  4752. );
  4753. if (exists $extSwitchType{$extSwitchType}) {
  4754. $extSwitchType = $extSwitchType{$extSwitchType};
  4755. } else {
  4756. return "Usage: $cmd variable wrong, choose toggle|direction.";
  4757. }
  4758. $channel = shift(@a);
  4759. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4760. if (!defined $channel || $channel eq "all") {
  4761. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4762. $channel = 30;
  4763. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4764. $channel = 31;
  4765. } elsif ($channel + 0 >= 30) {
  4766. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4767. $channel = 30;
  4768. } elsif ($channel >= 0 && $channel <= 29) {
  4769. } else {
  4770. return "$cmd $channel wrong, choose 0...31|all|input.";
  4771. }
  4772. my $extSwitchMode = ReadingsVal($name, "extSwitchMode", 'unavailable');
  4773. my %extSwitchMode = (
  4774. "unavailable" => 0,
  4775. "switch" => 1,
  4776. "pushbutton" => 2,
  4777. "auto" => 3
  4778. );
  4779. if (exists $extSwitchMode{$extSwitchMode}) {
  4780. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4781. } else {
  4782. $extSwitchMode = 0;
  4783. }
  4784. $data = sprintf "%02X%02XFFFFFFFF%02X", $cmdID, $channel, $extSwitchMode << 6 | $extSwitchType << 5;
  4785. } elsif ($cmd eq "special") {
  4786. $rorg = "D1";
  4787. shift(@a);
  4788. $updateState = 0;
  4789. my $repeaterActive = 0;
  4790. my $repeaterLevel = 0;
  4791. my $specialCmd = shift(@a);
  4792. if ($manufID eq "046") {
  4793. if (!defined $specialCmd) {
  4794. return "$cmd <command> wrong, choose repeaterLevel.";
  4795. } elsif ($specialCmd eq "repeaterLevel") {
  4796. $cmdID = 8;
  4797. my $repeaterLevel = shift(@a);
  4798. if (defined $repeaterLevel && $repeaterLevel =~ m/^off|1|2$/) {
  4799. if ($repeaterLevel eq "off") {
  4800. $repeaterLevel = 0;
  4801. } else {
  4802. $repeaterActive = 1;
  4803. }
  4804. } else {
  4805. return "Usage: repeaterLevel is wrong";
  4806. }
  4807. } else {
  4808. return "$cmd $specialCmd <arg> wrong, choose repeaterLevel off|1|2.";
  4809. }
  4810. }
  4811. $data = sprintf "0046%02X%02X%02X", $cmdID, $repeaterActive, $repeaterLevel;
  4812. } else {
  4813. if ($manufID =~ m/^046$/) {
  4814. $cmdList .= "dim:slider,0,1,100 on off autoOffTime delayOffTime extSwitchMode extSwitchType local measurement roomCtrlMode:off,buildingProtection,economy,comfort-2,comfort-1,comfort special";
  4815. } else {
  4816. $cmdList .= "dim:slider,0,1,100 on off autoOffTime delayOffTime extSwitchMode extSwitchType local measurement roomCtrlMode:off,buildingProtection,economy,comfort-2,comfort-1,comfort";
  4817. }
  4818. return SetExtensions ($hash, $cmdList, $name, @a);
  4819. }
  4820. Log3 $name, 3, "EnOcean set $name $cmd";
  4821. } elsif ($st =~ m/^blindsCtrl\.0[01]$/) {
  4822. # Blinds Control for Position and Angle
  4823. # (D2-05-xx)
  4824. $rorg = "D2";
  4825. $updateState = 0;
  4826. my $cmdID;
  4827. my $channel = AttrVal($name, "defaultChannel", 'all');
  4828. my $position = 127;
  4829. my $angle = 127;
  4830. my $repo = AttrVal($name, "reposition", "directly");
  4831. if ($repo eq "directly") {
  4832. $repo = 0;
  4833. } elsif ($repo eq "opens") {
  4834. $repo = 1;
  4835. } elsif ($repo eq "closes") {
  4836. $repo = 2;
  4837. } else {
  4838. $repo = 0;
  4839. }
  4840. my $lock = 0;
  4841. if ($cmd =~ m/^\d+$/) {
  4842. # interpretive numeric value as position
  4843. unshift(@a, 'position');
  4844. $cmd = 'position';
  4845. }
  4846. if ($cmd eq "position") {
  4847. $cmdID = 1;
  4848. shift(@a);
  4849. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4850. return "Attention: Device locked";
  4851. }
  4852. if (defined $a[0]) {
  4853. # position value
  4854. if (($a[0] =~ m/^\d+$/) && ($a[0] >= 0) && ($a[0] <= 100)) {
  4855. $position = shift(@a);
  4856. if (defined $a[0]) {
  4857. # angle value
  4858. if (($a[0] =~ m/^\d+$/) && ($a[0] >= 0) && ($a[0] <= 100)) {
  4859. $angle = shift(@a);
  4860. if (defined $a[0]) {
  4861. # channel
  4862. $channel = shift(@a);
  4863. if ($channel =~ m/^all$/) {
  4864. $channel = 15;
  4865. } elsif ($channel =~ m/^[1234]$/) {
  4866. $channel -= 1;
  4867. } else {
  4868. return "Usage: $position $angle $channel argument unknown, choose one of 1|2|3|4|all";
  4869. }
  4870. } else {
  4871. $channel = 15;
  4872. }
  4873. if (defined $a[0]) {
  4874. # reposition value
  4875. $repo = shift(@a);
  4876. if ($repo eq "directly") {
  4877. $repo = 0;
  4878. } elsif ($repo eq "opens") {
  4879. $repo = 1;
  4880. } elsif ($repo eq "closes") {
  4881. $repo = 2;
  4882. } else {
  4883. return "Usage: $position $angle $channel $repo argument unknown, choose one of directly opens closes";
  4884. }
  4885. }
  4886. readingsSingleUpdate($hash, "anglePos", $angle, 1);
  4887. } else {
  4888. return "Usage: $position $a[0] is not numeric or out of range";
  4889. }
  4890. } else {
  4891. $channel = 15;
  4892. }
  4893. readingsSingleUpdate($hash, "state", "in_motion", 1);
  4894. } else {
  4895. return "Usage: $a[0] is not numeric or out of range";
  4896. }
  4897. } else {
  4898. return "Usage: set <name> position <position> [<angle> [<repo>]]";
  4899. }
  4900. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4901. } elsif ($cmd eq "anglePos") {
  4902. $cmdID = 1;
  4903. shift(@a);
  4904. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4905. return "Attention: Device locked";
  4906. }
  4907. if (defined $a[0]) {
  4908. if (($a[0] =~ m/^\d+$/) && ($a[0] >= 0) && ($a[0] <= 100)) {
  4909. $angle = shift(@a);
  4910. if (defined $a[0]) {
  4911. # channel
  4912. $channel = shift(@a);
  4913. if ($channel =~ m/^all$/) {
  4914. $channel = 15;
  4915. } elsif ($channel =~ m/^[1234]$/) {
  4916. $channel -= 1;
  4917. } else {
  4918. return "Usage: $angle $channel argument unknown, choose one of 1|2|3|4|all";
  4919. }
  4920. } else {
  4921. $channel = 15;
  4922. }
  4923. readingsSingleUpdate($hash, "state", "in_motion", 1);
  4924. } else {
  4925. return "Usage: $a[0] is not numeric or out of range";
  4926. }
  4927. } else {
  4928. return "Usage: set <name> anglePos <angle>";
  4929. }
  4930. $repo = 0;
  4931. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4932. } elsif ($cmd eq "stop") {
  4933. $cmdID = 2;
  4934. shift(@a);
  4935. if (defined $a[0]) {
  4936. # channel
  4937. $channel = shift(@a);
  4938. if ($channel =~ m/^all$/) {
  4939. $channel = 15;
  4940. } elsif ($channel =~ m/^[1234]$/) {
  4941. $channel -= 1;
  4942. } else {
  4943. return "Usage: stop $channel argument unknown, choose one of 1|2|3|4|all";
  4944. }
  4945. } else {
  4946. $channel = 15;
  4947. }
  4948. readingsSingleUpdate($hash, "state", "stopped", 1);
  4949. $data = sprintf "%02X", $channel << 4 | $cmdID;
  4950. } elsif ($cmd eq "opens") {
  4951. $cmdID = 1;
  4952. shift(@a);
  4953. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4954. return "Attention: Device locked";
  4955. }
  4956. if (defined $a[0]) {
  4957. # channel
  4958. $channel = shift(@a);
  4959. if ($channel =~ m/^all$/) {
  4960. $channel = 15;
  4961. } elsif ($channel =~ m/^[1234]$/) {
  4962. $channel -= 1;
  4963. } else {
  4964. return "Usage: opens $channel argument unknown, choose one of 1|2|3|4|all";
  4965. }
  4966. } else {
  4967. $channel = 15;
  4968. }
  4969. $position = 0;
  4970. $repo = 0;
  4971. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4972. } elsif ($cmd eq "closes") {
  4973. $cmdID = 1;
  4974. shift(@a);
  4975. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4976. return "Attention: Device locked";
  4977. }
  4978. if (defined $a[0]) {
  4979. # channel
  4980. $channel = shift(@a);
  4981. if ($channel =~ m/^all$/) {
  4982. $channel = 15;
  4983. } elsif ($channel =~ m/^[1234]$/) {
  4984. $channel -= 1;
  4985. } else {
  4986. return "Usage: closes $channel argument unknown, choose one of 1|2|3|4|all";
  4987. }
  4988. } else {
  4989. $channel = 15;
  4990. }
  4991. $position = 100;
  4992. $repo = 0;
  4993. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4994. } elsif ($cmd eq "unlock") {
  4995. $cmdID = 1;
  4996. shift(@a);
  4997. if (defined $a[0]) {
  4998. # channel
  4999. $channel = shift(@a);
  5000. if ($channel =~ m/^all$/) {
  5001. $channel = 15;
  5002. } elsif ($channel =~ m/^[1234]$/) {
  5003. $channel -= 1;
  5004. } else {
  5005. return "Usage: unlock $channel argument unknown, choose one of 1|2|3|4|all";
  5006. }
  5007. } else {
  5008. $channel = 15;
  5009. }
  5010. $repo = 0;
  5011. $lock = 7;
  5012. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  5013. } elsif ($cmd eq "lock") {
  5014. $cmdID = 1;
  5015. shift(@a);
  5016. if (defined $a[0]) {
  5017. # channel
  5018. $channel = shift(@a);
  5019. if ($channel =~ m/^all$/) {
  5020. $channel = 15;
  5021. } elsif ($channel =~ m/^[1234]$/) {
  5022. $channel -= 1;
  5023. } else {
  5024. return "Usage: lock $channel argument unknown, choose one of 1|2|3|4|all";
  5025. }
  5026. } else {
  5027. $channel = 15;
  5028. }
  5029. $repo = 0;
  5030. $lock = 1;
  5031. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  5032. } elsif ($cmd eq "alarm") {
  5033. $cmdID = 1;
  5034. shift(@a);
  5035. if (defined $a[0]) {
  5036. # channel
  5037. $channel = shift(@a);
  5038. if ($channel =~ m/^all$/) {
  5039. $channel = 15;
  5040. } elsif ($channel =~ m/^[1234]$/) {
  5041. $channel -= 1;
  5042. } else {
  5043. return "Usage: alarm $channel argument unknown, choose one of 1|2|3|4|all";
  5044. }
  5045. } else {
  5046. $channel = 15;
  5047. }
  5048. $repo = 0;
  5049. $lock = 2;
  5050. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  5051. } else {
  5052. $cmdList .= "position:slider,0,1,100 anglePos:slider,0,1,100 stop opens closes lock unlock alarm";
  5053. return "Unknown argument $cmd, choose one of $cmdList";
  5054. }
  5055. Log3 $name, 3, "EnOcean set $name $cmd";
  5056. } elsif ($st eq "multisensor.01") {
  5057. #####
  5058. # Multisensor Windows Handle
  5059. # (D2-06-01)
  5060. $rorg = "D2";
  5061. $updateState = 2;
  5062. my $waitingCmds = ReadingsVal($name, "waitingCmds", undef);
  5063. if (defined $waitingCmds) {
  5064. # check presence state
  5065. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? $waitingCmds & 0xDF | 32 : $waitingCmds & 0xDF;
  5066. } else {
  5067. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? 32 : 0;
  5068. }
  5069. if ($cmd eq "presence") {
  5070. # set presence
  5071. if (defined $a[1]) {
  5072. if ($a[1] =~ m/^absent$/) {
  5073. readingsSingleUpdate($hash, "presence", $a[1], 1);
  5074. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5075. shift(@a);
  5076. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xDF | 32, 0);
  5077. } elsif ($a[1] =~ m/^present$/) {
  5078. readingsSingleUpdate($hash, "presence", $a[1], 1);
  5079. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5080. shift(@a);
  5081. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xDF, 0);
  5082. } else {
  5083. return "Usage: $a[1] is not numeric or out of range";
  5084. }
  5085. }
  5086. } elsif ($cmd eq "handleClosedClick") {
  5087. # set battery closed click
  5088. if (defined $a[1]) {
  5089. if ($a[1] =~ m/^disable$/) {
  5090. readingsSingleUpdate($hash, "handleClosedClick", $a[1] . 'd', 1);
  5091. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5092. shift(@a);
  5093. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xE7 | 8, 0);
  5094. } elsif ($a[1] =~ m/^enable$/) {
  5095. readingsSingleUpdate($hash, "handleClosedClick", $a[1] . 'd', 1);
  5096. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5097. shift(@a);
  5098. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xE7 | 16, 0);
  5099. } else {
  5100. return "Usage: $a[1] is not numeric or out of range";
  5101. }
  5102. }
  5103. } elsif ($cmd eq "batteryLowClick") {
  5104. # set battery click low
  5105. if (defined $a[1]) {
  5106. if ($a[1] =~ m/^disable$/) {
  5107. readingsSingleUpdate($hash, "batteryLowClick", $a[1] . 'd', 1);
  5108. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5109. shift(@a);
  5110. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xF9 | 2, 0);
  5111. } elsif ($a[1] =~ m/^enable$/) {
  5112. readingsSingleUpdate($hash, "batteryLowClick", $a[1] . 'd', 1);
  5113. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5114. shift(@a);
  5115. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xF9 | 4, 0);
  5116. } else {
  5117. return "Usage: $a[1] is not numeric or out of range";
  5118. }
  5119. }
  5120. } elsif ($cmd eq "updateInterval") {
  5121. # set update interval
  5122. if (defined $a[1]) {
  5123. if ($a[1] =~ m/^\d+$/ && $a[1] >= 5 && $a[1] <= 65535) {
  5124. readingsSingleUpdate($hash, "updateInterval", $a[1], 1);
  5125. readingsSingleUpdate($hash, "updateIntervalSet", $a[1], 0);
  5126. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5127. shift(@a);
  5128. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 1, 0);
  5129. } else {
  5130. return "Usage: $a[1] is not numeric or out of range";
  5131. }
  5132. }
  5133. } elsif ($cmd eq "blinkInterval") {
  5134. # set blick interval
  5135. if (defined $a[1]) {
  5136. if ($a[1] =~ m/^\d+$/ && $a[1] >= 3 && $a[1] <= 255) {
  5137. readingsSingleUpdate($hash, "blinkInterval", $a[1], 1);
  5138. readingsSingleUpdate($hash, "blinkIntervalSet", $a[1], 0);
  5139. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5140. shift(@a);
  5141. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 1, 0);
  5142. } else {
  5143. return "Usage: $a[1] is not numeric or out of range";
  5144. }
  5145. }
  5146. } elsif ($cmd eq "teachSlave") {
  5147. # teach slave
  5148. $updateState = 0;
  5149. $destinationID = "FFFFFFFF";
  5150. if (defined $a[1]) {
  5151. if ($a[1] =~ m/^contact$/) {
  5152. $rorg = "D5";
  5153. $data = '00';
  5154. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefW", "biDir");
  5155. readingsSingleUpdate($hash, "teachSlave", '1BS teach-in sent', 1);
  5156. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5157. shift(@a);
  5158. } elsif ($a[1] =~ m/^windowHandleOpen$/) {
  5159. $rorg = "F6";
  5160. $data = 'E0';
  5161. $status = '20';
  5162. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefH", "biDir");
  5163. readingsSingleUpdate($hash, "teachSlave", 'RPS teach-in sent', 1);
  5164. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5165. shift(@a);
  5166. } elsif ($a[1] =~ m/^windowHandleClosed$/) {
  5167. $rorg = "F6";
  5168. $data = 'F0';
  5169. $status = '20';
  5170. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefH", "biDir");
  5171. readingsSingleUpdate($hash, "teachSlave", 'RPS teach-in sent', 1);
  5172. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5173. shift(@a);
  5174. } elsif ($a[1] =~ m/^windowHandleTilted$/) {
  5175. $rorg = "F6";
  5176. $data = 'D0';
  5177. $status = '20';
  5178. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefH", "biDir");
  5179. readingsSingleUpdate($hash, "teachSlave", 'RPS teach-in sent', 1);
  5180. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5181. shift(@a);
  5182. } else {
  5183. return "Usage: $a[1] is wrong";
  5184. }
  5185. }
  5186. } else {
  5187. $cmdList .= "presence:absent,present handleClosedClick:enable,disable batteryLowClick:enable,disable " .
  5188. "updateInterval blinkInterval teachSlave:contact,windowHandleClosed,windowHandleOpen,windowHandleTilted";
  5189. return "Unknown argument $cmd, choose one of $cmdList";
  5190. }
  5191. } elsif ($st eq "roomCtrlPanel.00") {
  5192. # Room Control Panel
  5193. # (D2-10-00 - D2-10-02)
  5194. $rorg = "D2";
  5195. $updateState = 2;
  5196. if ($cmd eq "desired-temp"|| $cmd eq "setpointTemp") {
  5197. if (defined $a[1]) {
  5198. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 40)) {
  5199. $a[1] = sprintf "%0.1f", $a[1];
  5200. readingsSingleUpdate($hash, "setpointTemp", $a[1], 1);
  5201. readingsSingleUpdate($hash, "setpointTempSet", $a[1], 0);
  5202. Log3 $name, 3, "EnOcean set $name setpointTemp $a[1]";
  5203. shift(@a);
  5204. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5205. } else {
  5206. return "Usage: $a[1] is not numeric or out of range";
  5207. }
  5208. }
  5209. } elsif ($cmd eq "economyTemp" || $cmd eq "preComfortTemp" || $cmd eq "buildingProtectionTemp" || $cmd eq "comfortTemp") {
  5210. if (defined $a[1]) {
  5211. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 40)) {
  5212. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5213. $cmd =~ s/(\b)([a-z])/$1\u$2/g;
  5214. $a[1] = sprintf "%0.1f", $a[1];
  5215. readingsSingleUpdate($hash, "setpoint" . $cmd, $a[1], 1);
  5216. readingsSingleUpdate($hash, "setpoint" . $cmd . "Set", $a[1], 0);
  5217. shift(@a);
  5218. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 8, 0);
  5219. } else {
  5220. return "Usage: $a[1] is not numeric or out of range";
  5221. }
  5222. }
  5223. } elsif ($cmd eq "fanSpeed") {
  5224. if (defined $a[1]) {
  5225. if ($a[1] >= 0 && $a[1] <= 100) {
  5226. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5227. readingsSingleUpdate($hash, "fanSpeedSet", $a[1], 0);
  5228. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5229. shift(@a);
  5230. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5231. } else {
  5232. return "Usage: $a[1] is wrong.";
  5233. }
  5234. }
  5235. } elsif ($cmd eq "fanSpeedMode") {
  5236. if (defined $a[1]) {
  5237. if ($a[1] =~ m/^(central|local)$/) {
  5238. readingsSingleUpdate($hash, "fanSpeedMode", $a[1], 1);
  5239. readingsSingleUpdate($hash, "fanSpeedModeSet", $a[1], 0);
  5240. Log3 $name, 3, "EnOcean set $name fanSpeedMode $a[1]";
  5241. shift(@a);
  5242. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5243. } else {
  5244. return "Usage: $a[1] is wrong.";
  5245. }
  5246. }
  5247. } elsif ($cmd eq "cooling") {
  5248. if (defined $a[1]) {
  5249. if ($a[1] =~ m/^(on|off|auto|no_change)$/) {
  5250. readingsSingleUpdate($hash, "cooling", $a[1], 1);
  5251. readingsSingleUpdate($hash, "coolingSet", $a[1], 0);
  5252. Log3 $name, 3, "EnOcean set $name cooling $a[1]";
  5253. shift(@a);
  5254. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5255. } else {
  5256. return "Usage: $a[1] is wrong.";
  5257. }
  5258. }
  5259. } elsif ($cmd eq "heating") {
  5260. if (defined $a[1]) {
  5261. if ($a[1] =~ m/^(on|off|auto|no_change)$/) {
  5262. readingsSingleUpdate($hash, "heating", $a[1], 1);
  5263. readingsSingleUpdate($hash, "heatingSet", $a[1], 0);
  5264. Log3 $name, 3, "EnOcean set $name heating $a[1]";
  5265. shift(@a);
  5266. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5267. } else {
  5268. return "Usage: $a[1] is wrong.";
  5269. }
  5270. }
  5271. } elsif ($cmd eq "roomCtrlMode") {
  5272. if (defined $a[1]) {
  5273. if ($a[1] =~ m/^(comfort|preComfort|economy|buildingProtection)$/) {
  5274. readingsSingleUpdate($hash, "roomCtrlMode", $a[1], 1);
  5275. readingsSingleUpdate($hash, "roomCtrlModeSet", $a[1], 0);
  5276. Log3 $name, 3, "EnOcean set $name roomCtrlMode $a[1]";
  5277. shift(@a);
  5278. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5279. } else {
  5280. return "Usage: $a[1] is wrong.";
  5281. }
  5282. }
  5283. } elsif ($cmd eq "config") {
  5284. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 64, 0);
  5285. Log3 $name, 3, "EnOcean set $name $cmd";
  5286. } elsif ($cmd eq "timeProgram") {
  5287. # delete remote and send new time program
  5288. delete $hash->{helper}{4}{telegramWait};
  5289. for (my $messagePartCntr = 1; $messagePartCntr <= 4; $messagePartCntr ++) {
  5290. if (defined AttrVal($name, "timeProgram" . $messagePartCntr, undef)) {
  5291. $hash->{helper}{4}{telegramWait}{$messagePartCntr} = 1;
  5292. Log3 $name, 3, "EnOcean $name EnOcean_Set timeProgram" . $messagePartCntr . " set";
  5293. }
  5294. }
  5295. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 528, 0);
  5296. Log3 $name, 3, "EnOcean set $name $cmd";
  5297. } elsif ($cmd eq "deleteTimeProgram") {
  5298. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 512, 0);
  5299. Log3 $name, 3, "EnOcean set $name $cmd";
  5300. } elsif ($cmd eq "time") {
  5301. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 4, 0);
  5302. Log3 $name, 3, "EnOcean set $name $cmd";
  5303. } elsif ($cmd eq "window") {
  5304. if (defined $a[1]) {
  5305. if ($a[1] =~ m/^closed|open$/) {
  5306. readingsSingleUpdate($hash, "window", $a[1], 1);
  5307. readingsSingleUpdate($hash, "windowSet", $a[1], 0);
  5308. Log3 $name, 3, "EnOcean set $name window $a[1]";
  5309. shift(@a);
  5310. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5311. } else {
  5312. return "Usage: $a[1] is wrong.";
  5313. }
  5314. }
  5315. } elsif ($cmd eq "clearCmds") {
  5316. CommandDeleteReading(undef, "$name waitingCmds");
  5317. Log3 $name, 3, "EnOcean set $name $cmd";
  5318. } else {
  5319. $cmdList .= "cooling:auto,off,on,no_change desired-temp setpointTemp:slider,0,1,40 " .
  5320. "comfortTemp deleteTimeProgram:noArg " .
  5321. "economyTemp preComfortTemp buildingProtectionTemp config:noArg " .
  5322. "clearCmds:noArg fanSpeed:slider,0,1,100 heating:auto,off,on,no_change " .
  5323. "fanSpeedMode:central,local time:noArg " .
  5324. "roomCtrlMode:comfort,economy,preComfort,buildingProtection timeProgram:noArg window:closed,open";
  5325. return "Unknown argument $cmd, choose one of $cmdList";
  5326. }
  5327. } elsif ($st eq "roomCtrlPanel.01") {
  5328. # Room Control Panel
  5329. # (D2-11-01 - D2-11-08)
  5330. $rorg = "D2";
  5331. $updateState = 0;
  5332. my $cooling = ReadingsVal($name, "colling", 'off');
  5333. my $fanSpeed = ReadingsVal($name, "fanSpeed", 'auto');
  5334. my $heating = ReadingsVal($name, "heating", 'off');
  5335. my $humidity = ReadingsVal($name, "humidity", 0);
  5336. my $occupancy = ReadingsVal($name, "occupancy", 'unoccupied');
  5337. my $setpointBase = ReadingsVal($name, "setpointBase", 20);
  5338. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  5339. my $setpointShift = ReadingsVal($name, "setpointShift", 0);
  5340. my $setpointShiftMax = ReadingsVal($name, "setpointShiftMax", 10);
  5341. my $setpointType = ReadingsVal($name, "setpointType", 'setpointShift');
  5342. my $temperature = ReadingsVal($name, "temperature", 20);
  5343. my $waitingCmds = ReadingsVal($name, "waitingCmds", 0);
  5344. my $window = ReadingsVal($name, "window", 'closed');
  5345. if ($cmd eq "desired-temp"|| $cmd eq "setpointTemp") {
  5346. if (defined $a[1]) {
  5347. if ($a[1] =~ m/^\d+$/ && $a[1] >= 5 && $a[1] <= 40) {
  5348. readingsBeginUpdate($hash);
  5349. if ($a[1] < 15) {
  5350. $setpointBase = 15;
  5351. $setpointShift = $a[1] - $setpointBase;
  5352. $setpointShiftMax = $setpointBase - $a[1] if ($setpointShiftMax < -$setpointShift);
  5353. readingsBulkUpdate($hash, "setpointShiftMax", $setpointShiftMax);
  5354. } elsif ($a[1] > 30) {
  5355. $setpointBase = 30;
  5356. $setpointShift = $a[1] - $setpointBase;
  5357. $setpointShiftMax = $a[1] - $setpointBase if ($setpointShiftMax < $setpointShift);
  5358. readingsBulkUpdate($hash, "setpointShiftMax", $setpointShiftMax);
  5359. } else {
  5360. $setpointBase = $a[1];
  5361. $setpointShift = 0;
  5362. }
  5363. readingsBulkUpdate($hash, "setpointShift", $setpointShift);
  5364. readingsBulkUpdate($hash, "setpointBase", $setpointBase);
  5365. $setpointTemp = $a[1];
  5366. readingsBulkUpdate($hash, "setpointTemp", $a[1]);
  5367. readingsBulkUpdate($hash, "state", "T: $temperature H: $humidity SPT: $setpointTemp F: $fanSpeed");
  5368. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 1);
  5369. readingsEndUpdate($hash, 1);
  5370. CommandDeleteReading(undef, "$name smartAckMailbox");
  5371. Log3 $name, 3, "EnOcean set $name setpointTemp $a[1]";
  5372. shift(@a);
  5373. } else {
  5374. return "Usage: $a[1] is not numeric or out of range";
  5375. }
  5376. } else {
  5377. return "Usage: set <name> setpointTemp 5...40";
  5378. }
  5379. } elsif ($cmd eq "setpointShiftMax") {
  5380. if (defined $a[1]) {
  5381. if ($a[1] =~ m/^\d+$/ && $a[1] >= 1 && $a[1] <= 10) {
  5382. readingsBeginUpdate($hash);
  5383. if ($setpointTemp < 15 - $a[1]) {
  5384. $setpointShiftMax = 15 - $setpointTemp;
  5385. } elsif ($setpointTemp > 30 + $a[1]) {
  5386. $setpointShiftMax = $setpointTemp - 30;
  5387. } else {
  5388. $setpointShiftMax = $a[1];
  5389. }
  5390. readingsBulkUpdate($hash, "setpointShiftMax", $setpointShiftMax);
  5391. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 2);
  5392. readingsEndUpdate($hash, 1);
  5393. CommandDeleteReading(undef, "$name smartAckMailbox");
  5394. Log3 $name, 3, "EnOcean set $name setpointShiftMax $a[1]";
  5395. shift(@a);
  5396. } else {
  5397. return "Usage: $a[1] is not numeric or out of range";
  5398. }
  5399. } else {
  5400. return "Usage: set <name> setpointShiftMax 1...10";
  5401. }
  5402. } elsif ($cmd eq "setpointType") {
  5403. if (defined $a[1]) {
  5404. if ($a[1] =~ m/^setpointTemp|setpointShift$/) {
  5405. readingsBeginUpdate($hash);
  5406. $setpointType = $a[1];
  5407. readingsBulkUpdate($hash, "setpointType", $setpointType);
  5408. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x80);
  5409. readingsEndUpdate($hash, 1);
  5410. CommandDeleteReading(undef, "$name smartAckMailbox");
  5411. Log3 $name, 3, "EnOcean set $name setpointType $a[1]";
  5412. shift(@a);
  5413. } else {
  5414. return "Usage: $a[1] is wrong.";
  5415. }
  5416. } else {
  5417. return "Usage: set <name> setpointType setpointTemp|setpointShift";
  5418. }
  5419. } elsif ($cmd eq 'fanSpeed') {
  5420. if (defined $a[1]) {
  5421. if ($a[1] =~ m/^auto|off|1|2|3$/) {
  5422. $fanSpeed = $a[1];
  5423. readingsBeginUpdate($hash);
  5424. readingsBulkUpdate($hash, "fanSpeed", $a[1]);
  5425. readingsBulkUpdate($hash, "state", "T: $temperature H: $humidity SPT: $setpointTemp F: $fanSpeed");
  5426. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 4);
  5427. readingsEndUpdate($hash, 1);
  5428. CommandDeleteReading(undef, "$name smartAckMailbox");
  5429. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5430. shift(@a);
  5431. } else {
  5432. return "Usage: $a[1] is wrong.";
  5433. }
  5434. } else {
  5435. return "Usage: set <name> fanspeed 1...3|auto|off";
  5436. }
  5437. } elsif ($cmd eq "cooling") {
  5438. if (defined $a[1]) {
  5439. if ($a[1] =~ m/^on|off$/) {
  5440. $cooling = $a[1];
  5441. readingsBeginUpdate($hash);
  5442. readingsBulkUpdate($hash, "cooling", $a[1]);
  5443. if ($a[1] eq 'on') {
  5444. $heating = 'off';
  5445. readingsBulkUpdate($hash, "heating", 'off');
  5446. }
  5447. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x20);
  5448. readingsEndUpdate($hash, 1);
  5449. CommandDeleteReading(undef, "$name smartAckMailbox");
  5450. Log3 $name, 3, "EnOcean set $name cooling $a[1]";
  5451. shift(@a);
  5452. } else {
  5453. return "Usage: $a[1] is wrong.";
  5454. }
  5455. } else {
  5456. return "Usage: set <name> cooling on|off";
  5457. }
  5458. } elsif ($cmd eq "heating") {
  5459. if (defined $a[1]) {
  5460. if ($a[1] =~ m/^on|off$/) {
  5461. $heating = $a[1];
  5462. readingsBeginUpdate($hash);
  5463. readingsBulkUpdate($hash, "heating", $a[1]);
  5464. if ($a[1] eq 'on') {
  5465. $cooling = 'off';
  5466. readingsBulkUpdate($hash, "cooling", 'off');
  5467. }
  5468. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x40);
  5469. readingsEndUpdate($hash, 1);
  5470. CommandDeleteReading(undef, "$name smartAckMailbox");
  5471. Log3 $name, 3, "EnOcean set $name heating $a[1]";
  5472. shift(@a);
  5473. } else {
  5474. return "Usage: $a[1] is wrong.";
  5475. }
  5476. } else {
  5477. return "Usage: set <name> heating on|off";
  5478. }
  5479. } elsif ($cmd eq "occupancy") {
  5480. if (defined $a[1]) {
  5481. if ($a[1] =~ m/^occupied|unoccupied$/) {
  5482. $occupancy = $a[1];
  5483. readingsBeginUpdate($hash);
  5484. readingsBulkUpdate($hash, "occupancy", $a[1]);
  5485. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 8);
  5486. readingsEndUpdate($hash, 1);
  5487. CommandDeleteReading(undef, "$name smartAckMailbox");
  5488. Log3 $name, 3, "EnOcean set $name occupancy $a[1]";
  5489. shift(@a);
  5490. } else {
  5491. return "Usage: $a[1] is wrong.";
  5492. }
  5493. } else {
  5494. return "Usage: set <name> occupancy occupied|unoccupied";
  5495. }
  5496. } elsif ($cmd eq "window") {
  5497. if (defined $a[1]) {
  5498. if ($a[1] =~ m/^closed|open$/) {
  5499. $window = $a[1];
  5500. readingsBeginUpdate($hash);
  5501. readingsBulkUpdate($hash, "window", $a[1]);
  5502. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x10);
  5503. readingsEndUpdate($hash, 1);
  5504. CommandDeleteReading(undef, "$name smartAckMailbox");
  5505. Log3 $name, 3, "EnOcean set $name window $a[1]";
  5506. shift(@a);
  5507. } else {
  5508. return "Usage: $a[1] is wrong.";
  5509. }
  5510. } else {
  5511. return "Usage: set <name> window open|closed";
  5512. }
  5513. } else {
  5514. $cmdList .= "setpointTemp:slider,5,1,40 cooling:off,on desired-temp " .
  5515. "fanSpeed:auto,off,1,2,3 heating:off,on occupancy:occupied,unoccupied " .
  5516. "setpointShiftMax:slider,1,1,10 setpointType:setpointShift,setpointTemp window:closed,open";
  5517. return "Unknown argument $cmd, choose one of $cmdList";
  5518. }
  5519. $setpointType = $setpointType eq 'setpointTemp' ? 0x80 : 0;
  5520. $heating = $heating eq 'on' ? 0x40 : 0;
  5521. $cooling = $cooling eq 'on' ? 0x20 : 0;
  5522. $window = $window eq 'open' ? 0x10 : 0;
  5523. $setpointShift = int(($setpointShift + $setpointShiftMax) * 255 / ($setpointShiftMax * 2));
  5524. #$setpointShift = unpack('C', pack('c', $setpointShift));
  5525. my %fanSpeed = ('auto' => 0, 'off' =>1, 1 => 2, 2 => 3, 3 => 4);
  5526. $occupancy = $occupancy eq 'occupied' ? 1 : 0;
  5527. $data = sprintf "%02X%02X%02X%02X", $setpointType |$heating | $cooling | $window | 1,
  5528. $setpointShift, $setpointBase,
  5529. $setpointShiftMax << 4 | $fanSpeed{$fanSpeed} << 1 | $occupancy;
  5530. } elsif ($st eq "fanCtrl.00") {
  5531. # Fan Control
  5532. # (D2-20-00 - D2-20-02)
  5533. $rorg = "D2";
  5534. #$updateState = 0;
  5535. my ($fanSpeed, $humiThreshold, $roomSize, $roomSizeRef, $humidityCtrl, $tempLevel, $opMode) =
  5536. (255, 255, 15, 3, 3, 3, 15);
  5537. my $messageType = 0;
  5538. my @roomSizeTbl = (25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350);
  5539. if ($cmd eq "fanSpeed") {
  5540. $updateState = 0;
  5541. if (defined $a[1]) {
  5542. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  5543. $fanSpeed = $a[1];
  5544. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5545. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5546. shift(@a);
  5547. } elsif ($a[1] eq "auto") {
  5548. $fanSpeed = 253;
  5549. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5550. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5551. shift(@a);
  5552. } elsif ($a[1] eq "default") {
  5553. $fanSpeed = 254;
  5554. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5555. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5556. shift(@a);
  5557. } else {
  5558. return "Usage: $a[1] is wrong.";
  5559. }
  5560. } else {
  5561. return "Usage: set <name> fanspeed 0...100|auto|default";
  5562. }
  5563. shift(@a);
  5564. } elsif ($cmd eq "on") {
  5565. $opMode = 1;
  5566. Log3 $name, 3, "EnOcean set $name $a[0]";
  5567. shift(@a);
  5568. } elsif ($cmd eq "off") {
  5569. $opMode = 0;
  5570. Log3 $name, 3, "EnOcean set $name $a[0]";
  5571. shift(@a);
  5572. } elsif ($cmd eq "desired-temp" || $cmd eq "setpointTemp") {
  5573. $updateState = 0;
  5574. my $temperatureRefDev = AttrVal($name, "temperatureRefDev", undef);
  5575. return "attribute missing: attr $name temperatureRefDev <refDev> must be defined" if (!defined $temperatureRefDev);
  5576. my $temperature = ReadingsVal($temperatureRefDev, "temperature", 20);
  5577. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  5578. my $switchHysteresis = AttrVal($name, "switchHysteresis", 1);
  5579. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 40) {
  5580. $setpointTemp = $a[1];
  5581. shift(@a);
  5582. }
  5583. if ($setpointTemp > $temperature + $switchHysteresis / 2) {
  5584. $tempLevel = 2;
  5585. } elsif ($setpointTemp < $temperature - $switchHysteresis / 2) {
  5586. $tempLevel = 0;
  5587. } else {
  5588. $tempLevel = 1;
  5589. }
  5590. readingsBeginUpdate($hash);
  5591. readingsBulkUpdate($hash, "setpointTemp", sprintf("%.1f", $setpointTemp));
  5592. readingsBulkUpdate($hash, "temperature", sprintf("%.1f", $temperature));
  5593. readingsEndUpdate($hash, 1);
  5594. Log3 $name, 3, "EnOcean set $name $cmd $setpointTemp";
  5595. shift(@a);
  5596. } elsif ($cmd eq "humidityThreshold") {
  5597. $updateState = 0;
  5598. if (defined $a[1]) {
  5599. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  5600. $humidityCtrl = 1;
  5601. $humiThreshold = $a[1];
  5602. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5603. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5604. shift(@a);
  5605. } elsif ($a[1] eq "auto") {
  5606. $humidityCtrl = 1;
  5607. $humiThreshold = 253;
  5608. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5609. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5610. shift(@a);
  5611. } elsif ($a[1] eq "default") {
  5612. $humidityCtrl = 2;
  5613. $humiThreshold = 254;
  5614. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5615. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5616. shift(@a);
  5617. } elsif ($a[1] eq "disabled") {
  5618. $humidityCtrl = 0;
  5619. $humiThreshold = 255;
  5620. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5621. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5622. shift(@a);
  5623. } else {
  5624. return "Usage: $a[1] is wrong.";
  5625. }
  5626. } else {
  5627. return "Usage: set <name> humidityThreshold 0...100|auto|default|disabled";
  5628. }
  5629. shift(@a);
  5630. } elsif ($cmd eq "roomSize") {
  5631. $updateState = 0;
  5632. if (defined $a[1]) {
  5633. if ($a[1] =~ m/^\d+$/) {
  5634. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5635. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5636. $roomSize = 14;
  5637. for (my $i = 0; $i < @roomSizeTbl; $i++) {
  5638. if ($a[1] <= $roomSizeTbl[$i]) {
  5639. $roomSize = $i;
  5640. last;
  5641. }
  5642. }
  5643. $roomSizeRef = 0;
  5644. shift(@a);
  5645. } elsif ($a[1] eq "not_used") {
  5646. $roomSizeRef = 1;
  5647. $roomSize = 15;
  5648. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5649. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5650. shift(@a);
  5651. } elsif ($a[1] eq "default") {
  5652. $roomSizeRef = 2;
  5653. $roomSize = 15;
  5654. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5655. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5656. shift(@a);
  5657. } elsif ($a[1] eq "max") {
  5658. $roomSizeRef = 0;
  5659. $roomSize = 14;
  5660. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5661. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5662. shift(@a);
  5663. } else {
  5664. return "Usage: $a[1] is wrong.";
  5665. }
  5666. } else {
  5667. return "Usage: set <name> roomSize 0...350|max|not_used|default";
  5668. }
  5669. shift(@a);
  5670. } else {
  5671. $cmdList .= "off:noArg on:noArg desired-temp fanSpeed setpointTemp:slider,0,1,40 " .
  5672. "humidityThreshold roomSize";
  5673. return "Unknown argument $cmd, choose one of $cmdList";
  5674. }
  5675. $data = sprintf "%02X%02X%02X%02X", ($opMode << 4) | ($tempLevel << 1),
  5676. ($humidityCtrl << 6) | ($roomSizeRef << 4) | $roomSize,
  5677. $humiThreshold, $fanSpeed;
  5678. } elsif ($st eq "heatRecovery.00") {
  5679. # heat recovery ventilation
  5680. # (D2-50-00)
  5681. $rorg = "D2";
  5682. $updateState = 0;
  5683. my $airQuatityThreshold = ReadingsVal($name, "airQuatityThreshold", 'default');
  5684. $airQuatityThreshold = $airQuatityThreshold eq 'default' ? 127 : $airQuatityThreshold;
  5685. my $CO2Threshold = ReadingsVal($name, "CO2Threshold", 'default');
  5686. $CO2Threshold = $CO2Threshold eq 'default' ? 127 : $CO2Threshold;
  5687. my $heatExchangerBypass = 0;
  5688. my $humidityThreshold = ReadingsVal($name, "humidityThreshold", 'default');
  5689. $humidityThreshold = $humidityThreshold eq 'default' ? 127 : $humidityThreshold;
  5690. my $startTimerMode = 0;
  5691. my $tempThreshold = ReadingsVal($name, "roomTempSet", 'default');
  5692. $tempThreshold = $tempThreshold eq 'default' ? 0 : $tempThreshold;
  5693. my $ventilation = 15;
  5694. if ($cmd eq "ventilation") {
  5695. $ventilation = $a[1];
  5696. return "Usage: $cmd variable is missing, choose off|1...4|auto|demand|supplyAir|exhaustAir." if (!defined $ventilation);
  5697. shift(@a);
  5698. my %ventilation = (
  5699. "off" => 0,
  5700. 1 => 1,
  5701. 2 => 2,
  5702. 3 => 3,
  5703. 4 => 4,
  5704. "auto" => 11,
  5705. "demand" => 12,
  5706. "supplyAir" => 13,
  5707. "exhaustAir" => 14
  5708. );
  5709. if (exists $ventilation{$ventilation}) {
  5710. $ventilation = $ventilation{$ventilation};
  5711. } else {
  5712. return "Usage: $cmd variable wrong, choose off|1...4|auto|demand|supplyAir|exhaustAir.";
  5713. }
  5714. } elsif ($cmd eq "heatExchangerBypass") {
  5715. $heatExchangerBypass = $a[1];
  5716. return "Usage: $cmd variable is missing, choose opens|closes." if (!defined $heatExchangerBypass);
  5717. shift(@a);
  5718. my %heatExchangerBypass = (
  5719. "closes" => 1,
  5720. "opens" => 2
  5721. );
  5722. if (exists $heatExchangerBypass{$heatExchangerBypass}) {
  5723. $heatExchangerBypass = $heatExchangerBypass{$heatExchangerBypass};
  5724. } else {
  5725. return "Usage: $cmd variable wrong, choose opens|closes.";
  5726. }
  5727. } elsif ($cmd eq "startTimerMode") {
  5728. $startTimerMode = 1;
  5729. } elsif ($cmd eq "CO2Threshold") {
  5730. $CO2Threshold = $a[1];
  5731. if (defined $CO2Threshold) {
  5732. if ($CO2Threshold eq 'default') {
  5733. $CO2Threshold = 127;
  5734. readingsSingleUpdate($hash, "CO2Threshold", 'default', 1);
  5735. } elsif ($CO2Threshold =~ m/^\d+$/ && $CO2Threshold >= 0 && $CO2Threshold <= 100) {
  5736. readingsSingleUpdate($hash, "CO2Threshold", $CO2Threshold, 1);
  5737. } else {
  5738. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5739. }
  5740. } else {
  5741. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5742. }
  5743. shift(@a);
  5744. } elsif ($cmd eq "humidityThreshold") {
  5745. $humidityThreshold = $a[1];
  5746. if (defined $humidityThreshold) {
  5747. if ($humidityThreshold eq 'default') {
  5748. $humidityThreshold = 127;
  5749. readingsSingleUpdate($hash, "humidityThreshold", 'default', 1);
  5750. } elsif ($humidityThreshold =~ m/^\d+$/ && $humidityThreshold >= 0 && $humidityThreshold <= 100) {
  5751. readingsSingleUpdate($hash, "humidityThreshold", $humidityThreshold, 1);
  5752. } else {
  5753. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5754. }
  5755. } else {
  5756. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5757. }
  5758. shift(@a);
  5759. } elsif ($cmd eq "airQuatityThreshold") {
  5760. $airQuatityThreshold = $a[1];
  5761. if (defined $airQuatityThreshold) {
  5762. if ($airQuatityThreshold eq 'default') {
  5763. $airQuatityThreshold = 127;
  5764. readingsSingleUpdate($hash, "airQuatityThreshold", 'default', 1);
  5765. } elsif ($airQuatityThreshold =~ m/^\d+$/ && $airQuatityThreshold >= 0 && $airQuatityThreshold <= 100) {
  5766. readingsSingleUpdate($hash, "airQuatityThreshold", $airQuatityThreshold, 1);
  5767. } else {
  5768. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5769. }
  5770. } else {
  5771. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5772. }
  5773. shift(@a);
  5774. } elsif ($cmd eq "roomTemp") {
  5775. $tempThreshold = $a[1];
  5776. if (defined $tempThreshold) {
  5777. if ($tempThreshold eq 'default') {
  5778. $tempThreshold = 0;
  5779. readingsSingleUpdate($hash, "roomTempSet", 'default', 1);
  5780. } elsif ($tempThreshold =~ m/^[+-]?\d+$/ && $tempThreshold >= - 63 && $tempThreshold <= 63) {
  5781. readingsSingleUpdate($hash, "roomTempSet", $tempThreshold, 1);
  5782. $tempThreshold += 64;
  5783. #$tempThreshold = abs($tempThreshold) | 0x40 if ($tempThreshold < 0);
  5784. } else {
  5785. return "Usage: $cmd variable is wrong, choose default|-63 ... 63." ;
  5786. }
  5787. } else {
  5788. return "Usage: $cmd variable is wrong, choose default|-63 ... 63." ;
  5789. }
  5790. shift(@a);
  5791. } else {
  5792. $cmdList .= "ventilation:off,1,2,3,4,auto,demand,supplyAir,exhaustAir roomTemp heatExchangerBypass:closes,opens " .
  5793. "startTimerMode:noArg CO2Threshold humidityThreshold airQuatityThreshold";
  5794. return "Unknown argument $cmd, choose one of $cmdList";
  5795. }
  5796. $data = sprintf "%02X%02X%02X%02X%02X%02X", 32 | $ventilation, $heatExchangerBypass << 4, $startTimerMode << 7 | $CO2Threshold,
  5797. $humidityThreshold, $airQuatityThreshold, $tempThreshold;
  5798. Log3 $name, 3, "EnOcean set $name $cmd";
  5799. } elsif ($st eq "valveCtrl.00") {
  5800. # Valve Control
  5801. # (D2-A0-01)
  5802. if (AttrVal($name, "devMode", "master") eq "slave") {
  5803. # devNode slave
  5804. if ($cmd eq "closed") {
  5805. $rorg = "D2";
  5806. $data = "01";
  5807. } elsif ($cmd eq "open") {
  5808. $rorg = "D2";
  5809. $data = "02";
  5810. } elsif ($cmd eq "teachIn") {
  5811. $updateState = 0;
  5812. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, "biDir",
  5813. AttrVal($name, "uteResponseRequest", "yes"), "in", 0, "D2-A0-01");
  5814. } elsif ($cmd eq "teachOut") {
  5815. $updateState = 0;
  5816. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, "biDir",
  5817. AttrVal($name, "uteResponseRequest", "yes"), "out", 0, "D2-A0-01");
  5818. } else {
  5819. return "Unknown argument $cmd, choose one of " . $cmdList . "open:noArg closed:noArg teachIn:noArg teachOut:noArg";
  5820. }
  5821. } else {
  5822. # devMode master
  5823. if ($cmd eq "closes") {
  5824. $rorg = "D2";
  5825. $data = "01";
  5826. } elsif ($cmd eq "opens") {
  5827. $rorg = "D2";
  5828. $data = "02";
  5829. } else {
  5830. return "Unknown argument $cmd, choose one of " . $cmdList . "opens:noArg closes:noArg";
  5831. }
  5832. }
  5833. Log3 $name, 3, "EnOcean set $name $cmd";
  5834. } elsif ($st eq "contact") {
  5835. # 1BS Telegram
  5836. # Single Input Contact (EEP D5-00-01)
  5837. $rorg = "D5";
  5838. my $setCmd;
  5839. if ($cmd eq "teach") {
  5840. $attr{$name}{eep} = "D5-00-01";
  5841. CommandDeleteReading(undef, "$name .*");
  5842. readingsSingleUpdate($hash, "teach", "1BS teach-in sent", 1);
  5843. $setCmd = 0;
  5844. $updateState = 0;
  5845. } elsif ($cmd eq "closed") {
  5846. $setCmd = 9;
  5847. } elsif ($cmd eq "open") {
  5848. $setCmd = 8;
  5849. } else {
  5850. return "Unknown argument $cmd, choose one of " . $cmdList . "open:noArg closed:noArg teach:noArg";
  5851. }
  5852. $data = sprintf "%02X", $setCmd;
  5853. Log3 $name, 3, "EnOcean set $name $cmd";
  5854. } elsif ($st eq "genericProfile") {
  5855. # Generic Profile
  5856. my $channel = 0;
  5857. my $devMode = AttrVal($name, "devMode", "master");
  5858. my $header = 1;
  5859. my ($setChannel, $setChannelName) = split(/-|:/, $cmd, 2);
  5860. my ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax);
  5861. my ($readingFormat, $readingName, $readingType, $readingUnit, $readingValue);
  5862. my $gpDef = AttrVal($name, "gpDef", undef);
  5863. return "Usage: Channel definition is missing" if (!defined $gpDef);
  5864. my @gpDef = split("[ \t][ \t]*", $gpDef);
  5865. if ($cmd eq "channelName") {
  5866. # rename channel name
  5867. ($setChannel, $setChannelName) = split(/-|:/, $a[1], 2);
  5868. if (defined $gpDef[$setChannel]) {
  5869. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  5870. split(':', $gpDef[$setChannel]);
  5871. # remove spaces und tabs
  5872. #$channelName =~ tr/ \t//d;
  5873. if ($setChannelName eq "?") {
  5874. $channelName = "none";
  5875. if ($channelType == 1 && defined $EnO_gpValueData{$signalType}{name}) {
  5876. $channelName = $EnO_gpValueData{$signalType}{name};
  5877. } elsif ($channelType == 2 && defined $EnO_gpValueFlag{$signalType}{name}) {
  5878. $channelName = $EnO_gpValueFlag{$signalType}{name};
  5879. } elsif ($channelType == 3 && defined $EnO_gpValueEnum{$signalType}{name}) {
  5880. $channelName = $EnO_gpValueEnum{$signalType}{name};
  5881. }
  5882. } else {
  5883. $channelName = $setChannelName;
  5884. }
  5885. $resolution = '' if (!defined $resolution);
  5886. $engMin = '' if (!defined $engMin);
  5887. $scalingMin = '' if (!defined $scalingMin);
  5888. $engMax = '' if (!defined $engMax);
  5889. $scalingMax = '' if (!defined $scalingMax);
  5890. $gpDef[$setChannel] = $channelName . ':' . $channelDir . ':' . $channelType . ':' . $signalType . ':' . $valueType .
  5891. ':' . $resolution . ':' . $engMin . ':' . $scalingMin . ':' . $engMax . ':' . $scalingMax;
  5892. $attr{$name}{gpDef} = join(' ', @gpDef);
  5893. shift @a;
  5894. $updateState = 3;
  5895. $channelType = 255;
  5896. EnOcean_CommandSave(undef, undef);
  5897. } else {
  5898. return "Wrong parameter, channel $setChannel not defined.";
  5899. }
  5900. } elsif ($cmd eq "teachIn" && $devMode eq "slave") {
  5901. # teach-in generic profile
  5902. $rorg = "B0";
  5903. my ($gpDefO, $gpDefI, $formatPattern, $teachInInfo);
  5904. my $channelDirSeq = "--";
  5905. my $comMode = 0;
  5906. $attr{$name}{comMode} = "uniDir";
  5907. $attr{$name}{eep} = "B0-00-00";
  5908. # multicast teach-in
  5909. $destinationID = "FFFFFFFF";
  5910. my $productID = AttrVal($name, "productID", undef);
  5911. if (defined $productID) {
  5912. $productID = '0000000010' . EnOcean_convHexToBit($productID);
  5913. } else {
  5914. $productID = '';
  5915. }
  5916. while ($gpDef[$channel]) {
  5917. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  5918. split(':', $gpDef[$channel]);
  5919. if ($channelDir eq "O") {
  5920. #Log3 $name, 3, "EnOcean set $name channel: $channel channelDir: $channelDir seq: $channelDirSeq";
  5921. #Log3 $name, 3, "EnOcean set $name channel: $channel channelType: $channelType signalType: $signalType valueType: $valueType";
  5922. return "Usage: attr $name gpDef: O/I sequence error" if $channelDirSeq =~ m/.I$/;
  5923. $channelDirSeq = "O-";
  5924. # add channel-, signal- and valuetype
  5925. $gpDefO .= substr(unpack('B8', pack('C', $channelType)), 6) .
  5926. unpack('B8', pack('C', $signalType)) .
  5927. substr(unpack('B8', pack('C', $valueType)), 6);
  5928. if ($channelType == 1 || $channelType == 3) {
  5929. # data, enumeration: add resolution
  5930. $gpDefO .= substr(unpack('B8', pack('C', $resolution)), 4);
  5931. }
  5932. if ($channelType == 1) {
  5933. # data: add engineering and scaling
  5934. $gpDefO .= unpack('B8', pack('c', $engMin)) .
  5935. substr(unpack('B8', pack('C', $scalingMin)), 4) .
  5936. unpack('B8', pack('c', $engMax)) .
  5937. substr(unpack('B8', pack('C', $scalingMax)), 4);
  5938. }
  5939. } elsif ($channelDir eq "I") {
  5940. #Log3 $name, 3, "EnOcean set $name channel: $channel channelDir: $channelDir seq: $channelDirSeq";
  5941. return "Usage: attr $name gpDef: O/I sequence error" if $channelDirSeq !~ m/^O./;
  5942. $channelDirSeq = "OI";
  5943. $gpDefI .= substr(unpack('B8', pack('C', $channelType)), 6) .
  5944. unpack('B8', pack('C', $signalType)) .
  5945. substr(unpack('B8', pack('C', $valueType)), 6);
  5946. if ($channelType == 1 || $channelType == 3) {
  5947. # data, enumeration: add resolution
  5948. $gpDefI .= substr(unpack('B8', pack('C', $resolution)), 4);
  5949. }
  5950. if ($channelType == 1) {
  5951. # data: add engineering and scaling
  5952. $gpDefI .= unpack('B8', pack('c', $engMin)) .
  5953. substr(unpack('B8', pack('C', $scalingMin)), 4) .
  5954. unpack('B8', pack('c', $engMax)) .
  5955. substr(unpack('B8', pack('C', $scalingMax)), 4);
  5956. }
  5957. }
  5958. $channel ++;
  5959. }
  5960. if ($channelDirSeq eq "OI") {
  5961. # await teach-in response
  5962. $comMode = 1;
  5963. $attr{$name}{comMode} = "biDir";
  5964. # set flag for response request
  5965. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{teachInReq} = "in";
  5966. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{hash} = $hash;
  5967. if (!exists($hash->{IODev}{Teach})) {
  5968. # enable teach-in receiving for 3 sec
  5969. $hash->{IODev}{Teach} = 1;
  5970. my %timeoutHash = (hash => $IOHash, function => "gpRespTimeout", helper => "gpRespWait");
  5971. RemoveInternalTimer(\%timeoutHash);
  5972. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  5973. }
  5974. }
  5975. $header = (0x7FF << 1 | $comMode) << 4;
  5976. if ($channelDirSeq =~ m/.I$/) {
  5977. # create teach-in information
  5978. if (length($gpDefI) % 8) {
  5979. # fill with trailing zeroes to x bytes
  5980. $gpDefI .= 0 x (8 - length($gpDefI) % 8);
  5981. }
  5982. $teachInInfo = '0000000001' . unpack('B8', pack('C', length($gpDefI) / 4));
  5983. }
  5984. #Log3 $name, 3, "EnOcean set $name header: $header O: $gpDefO Info: $teachInInfo I: $gpDefI";
  5985. # DophinView GP profile error if Product ID sent
  5986. $data = $productID . $gpDefO . $teachInInfo . $gpDefI;
  5987. #$data = $gpDefO . $teachInInfo . $gpDefI;
  5988. if (length($data) % 8) {
  5989. # fill with trailing zeroes to x bytes
  5990. $data .= 0 x (8 - length($data) % 8);
  5991. }
  5992. $channelType = 0;
  5993. EnOcean_CommandSave(undef, undef);
  5994. $data = sprintf '%04X%s', $header, EnOcean_convBitToHex($data);
  5995. my $teachInState = $comMode == 1 ? "teach-in sent, response requested" : "teach-in sent";
  5996. readingsSingleUpdate($hash, "teach", "GP $teachInState", 1);
  5997. } elsif ($cmd eq "teachOut" && $devMode eq "slave") {
  5998. # teach out generic profile
  5999. $rorg = "B0";
  6000. $channelType = 0;
  6001. my $comMode = 0;
  6002. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  6003. $comMode = 1;
  6004. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{teachInReq} = "out";
  6005. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{hash} = $hash;
  6006. if (!exists($hash->{IODev}{Teach})) {
  6007. # enable teach-in receiving for 3 sec
  6008. $hash->{IODev}{Teach} = 1;
  6009. my %timeoutHash = (hash => $IOHash, function => "gpRespTimeout", helper => "gpRespWait");
  6010. RemoveInternalTimer(\%timeoutHash);
  6011. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  6012. }
  6013. }
  6014. $data = sprintf '%04X', (0x7FF << 1 | $comMode) << 4 | 4;
  6015. my $teachInState = $comMode == 1 ? "teach-in deletion sent, response requested" : "teach-in deletion sent";
  6016. readingsSingleUpdate($hash, "teach", "GP $teachInState", 1);
  6017. } elsif ($setChannel =~ m/^\d+$/ && defined $gpDef[$setChannel]) {
  6018. # send selective data (GPSD)
  6019. $rorg = "B3";
  6020. # select channel
  6021. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  6022. split(':', $gpDef[$setChannel]);
  6023. if ($channelName eq $setChannelName && $channelDir eq "O") {
  6024. $channel = $setChannel;
  6025. } else {
  6026. return "Channel name wrong or no output channel";
  6027. }
  6028. } else {
  6029. # command error
  6030. my $channelCntr = 0;
  6031. my @cmdList;
  6032. while (defined $gpDef[$channelCntr]) {
  6033. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  6034. split(':', $gpDef[$channelCntr]);
  6035. if ($channelDir ne "O") {
  6036. $channelCntr ++;
  6037. next;
  6038. }
  6039. if ($channelType == 1) {
  6040. # data
  6041. push @cmdList, sprintf('%02d', $channelCntr) . "-" . $channelName;
  6042. } elsif ($channelType == 2) {
  6043. # flag
  6044. push @cmdList, sprintf('%02d', $channelCntr) . "-" . $channelName . ':' .
  6045. $EnO_gpValueFlag{$signalType}{flag}{0} . "," .
  6046. $EnO_gpValueFlag{$signalType}{flag}{1};
  6047. } elsif ($channelType == 3) {
  6048. # enumeration
  6049. my $cmdListEnum = "";
  6050. my $enum = 0;
  6051. while (defined $EnO_gpValueEnum{$signalType}{enum}{$enum}) {
  6052. $cmdListEnum .= $EnO_gpValueEnum{$signalType}{enum}{$enum} . ",";
  6053. $enum ++;
  6054. }
  6055. push @cmdList, sprintf('%02d', $channelCntr) . "-" . $channelName . ':' . substr($cmdListEnum, 0, -1);
  6056. }
  6057. $channelCntr ++;
  6058. }
  6059. if (defined $cmdList[0] && $devMode eq "slave") {
  6060. return "Unknown argument $cmd, choose one of " . $cmdList . 'channelName teachIn:noArg teachOut:noArg ' . join(" ", @cmdList);
  6061. } elsif (defined $cmdList[0] && $devMode eq "master") {
  6062. return "Unknown argument $cmd, choose one of " . $cmdList . 'channelName ' . join(" ", @cmdList);
  6063. } else {
  6064. return "Unknown argument $cmd, choose one of " . $cmdList . 'channelName';
  6065. }
  6066. }
  6067. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel";
  6068. if ($channelType == 1) {
  6069. # data
  6070. if ($engMin * $EnO_scaling[$scalingMin] > $engMax * $EnO_scaling[$scalingMax]) {
  6071. return "Usage: numerical value is missing" if (!defined $a[1]);
  6072. if ($a[1] =~ m/^[-+]?\d*\.?\d+([eE][-+]?\d+)?$/ &&
  6073. $a[1] >= $engMax * $EnO_scaling[$scalingMax] &&
  6074. $a[1] <= $engMin * $EnO_scaling[$scalingMin]) {
  6075. $data = int(2**$EnO_resolution[$resolution] * ($a[1] - $engMin * $EnO_scaling[$scalingMin]) /
  6076. ($engMax * $EnO_scaling[$scalingMax] - $engMin * $EnO_scaling[$scalingMin]));
  6077. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6078. if ($data >= 2**$EnO_resolution[$resolution]) {
  6079. $data = 2**$EnO_resolution[$resolution] - 1;
  6080. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6081. }
  6082. shift @a;
  6083. } else {
  6084. return "Usage: $a[1] is not numeric or out of range";
  6085. }
  6086. } else {
  6087. return "Usage: numerical value is missing" if (!defined $a[1]);
  6088. if ($a[1] =~ m/^[-+]?\d*\.?\d+([eE][-+]?\d+)?$/ &&
  6089. $a[1] >= $engMin * $EnO_scaling[$scalingMin] &&
  6090. $a[1] <= $engMax * $EnO_scaling[$scalingMax]) {
  6091. $data = int(2**$EnO_resolution[$resolution] * ($a[1] - $engMin * $EnO_scaling[$scalingMin]) /
  6092. ($engMax * $EnO_scaling[$scalingMax] - $engMin * $EnO_scaling[$scalingMin]));
  6093. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6094. if ($data >= 2**$EnO_resolution[$resolution]) {
  6095. $data = 2**$EnO_resolution[$resolution] - 1;
  6096. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6097. }
  6098. shift @a;
  6099. } else {
  6100. return "Usage: $a[1] is not numeric or out of range";
  6101. }
  6102. }
  6103. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType) =
  6104. EnOcean_gpConvDataToValue (undef, $hash, $channel, $data, $gpDef[$channel]);
  6105. readingsBeginUpdate($hash);
  6106. readingsBulkUpdate($hash, $readingName, sprintf("$readingFormat", $readingValue));
  6107. readingsBulkUpdate($hash, $readingName . "Unit", $readingUnit);
  6108. readingsBulkUpdate($hash, $readingName . "ValueType", $valueType);
  6109. readingsBulkUpdate($hash, $readingName . "ChannelType", $readingType);
  6110. readingsEndUpdate($hash, 1);
  6111. $data = EnOcean_gpConvSelDataToSndData($header, $channel, $EnO_resolution[$resolution], $data);
  6112. } elsif ($channelType == 2) {
  6113. # flag
  6114. if (defined $EnO_gpValueFlag{$signalType}{flagInv}{$a[1]}) {
  6115. $data = $EnO_gpValueFlag{$signalType}{flagInv}{$a[1]};
  6116. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel data: " . $EnO_gpValueFlag{$signalType}{flagInv}{$a[1]};
  6117. shift @a;
  6118. } else {
  6119. return "Usage: $a[1] is unknown";
  6120. }
  6121. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel data: $data";
  6122. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType)=
  6123. EnOcean_gpConvDataToValue (undef, $hash, $channel, $data, $gpDef[$channel]);
  6124. readingsBeginUpdate($hash);
  6125. readingsBulkUpdate($hash, $readingName, sprintf("$readingFormat", $readingValue));
  6126. readingsBulkUpdate($hash, $readingName . "Unit", $readingUnit);
  6127. readingsBulkUpdate($hash, $readingName . "ValueType", $valueType);
  6128. readingsBulkUpdate($hash, $readingName . "ChannelType", $readingType);
  6129. readingsEndUpdate($hash, 1);
  6130. $data = sprintf '%04X', (($header << 6 | $channel) << 1 | $data) << 5;
  6131. } elsif ($channelType == 3) {
  6132. # enumeration
  6133. if (defined $EnO_gpValueEnum{$signalType}{enumInv}{$a[1]}) {
  6134. $data = $EnO_gpValueEnum{$signalType}{enumInv}{$a[1]};
  6135. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel data: $data";
  6136. shift @a;
  6137. } else {
  6138. return "Usage: $a[1] is unknown";
  6139. }
  6140. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType)=
  6141. EnOcean_gpConvDataToValue (undef, $hash, $channel, $data, $gpDef[$channel]);
  6142. readingsBeginUpdate($hash);
  6143. readingsBulkUpdate($hash, $readingName, sprintf("$readingFormat", $readingValue));
  6144. readingsBulkUpdate($hash, $readingName . "Unit", $readingUnit);
  6145. readingsBulkUpdate($hash, $readingName . "ValueType", $valueType);
  6146. readingsBulkUpdate($hash, $readingName . "ChannelType", $readingType);
  6147. readingsEndUpdate($hash, 1);
  6148. $data = EnOcean_gpConvSelDataToSndData($header, $channel, $EnO_resolution[$resolution], $data);
  6149. }
  6150. Log3 $name, 3, "EnOcean set $name $cmd";
  6151. } elsif ($st eq "raw") {
  6152. # sent raw data
  6153. if ($cmd eq "4BS"){
  6154. # 4BS Telegram
  6155. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{8}$/) {
  6156. $data = uc($a[1]);
  6157. $rorg = "A5";
  6158. } else {
  6159. return "Wrong parameter, choose 4BS <data 4 Byte hex> [status 1 Byte hex]";
  6160. }
  6161. } elsif ($cmd eq "1BS") {
  6162. # 1BS Telegram
  6163. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  6164. $data = uc($a[1]);
  6165. $rorg = "D5";
  6166. } else {
  6167. return "Wrong parameter, choose 1BS <data 1 Byte hex> [status 1 Byte hex]";
  6168. }
  6169. } elsif ($cmd eq "RPS") {
  6170. # RPS Telegram
  6171. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  6172. $data = uc($a[1]);
  6173. $rorg = "F6";
  6174. } else {
  6175. return "Wrong parameter, choose RPS <data 1 Byte hex> [status 1 Byte hex]";
  6176. }
  6177. } elsif ($cmd eq "MSC") {
  6178. # MSC Telegram
  6179. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6180. $data = uc($a[1]);
  6181. $rorg = "D1";
  6182. } else {
  6183. return "Wrong parameter, choose MSC <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6184. }
  6185. } elsif ($cmd eq "UTE") {
  6186. # UTE Telegram
  6187. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{14}$/) {
  6188. $data = uc($a[1]);
  6189. $rorg = "D4";
  6190. } else {
  6191. return "Wrong parameter, choose UTE <data 7 Byte hex> [status 1 Byte hex]";
  6192. }
  6193. } elsif ($cmd eq "VLD") {
  6194. # VLD Telegram
  6195. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6196. $data = uc($a[1]);
  6197. $rorg = "D2";
  6198. } else {
  6199. return "Wrong parameter, choose VLD <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6200. }
  6201. } elsif ($cmd eq "GPTI") {
  6202. # GP teach-in request telegram
  6203. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6204. $data = uc($a[1]);
  6205. $rorg = "B0";
  6206. } else {
  6207. return "Wrong parameter, choose GPTI <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6208. }
  6209. } elsif ($cmd eq "GPTR") {
  6210. # GP teach-in response telegram
  6211. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6212. $data = uc($a[1]);
  6213. $rorg = "B1";
  6214. } else {
  6215. return "Wrong parameter, choose GPTR <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6216. }
  6217. } elsif ($cmd eq "GPCD") {
  6218. # GP complete date telegram
  6219. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6220. $data = uc($a[1]);
  6221. $rorg = "B2";
  6222. } else {
  6223. return "Wrong parameter, choose GPCD <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6224. }
  6225. } elsif ($cmd eq "GPSD") {
  6226. # GP selective data telegram
  6227. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6228. $data = uc($a[1]);
  6229. $rorg = "B3";
  6230. } else {
  6231. return "Wrong parameter, choose GPSD <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6232. }
  6233. } elsif ($cmd eq "SEC") {
  6234. # secure telegram
  6235. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6236. $data = uc($a[1]);
  6237. $rorg = "30";
  6238. } else {
  6239. return "Wrong parameter, choose SEC <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6240. }
  6241. } elsif ($cmd eq "ENC") {
  6242. # secure telegram with encapsulation
  6243. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6244. $data = uc($a[1]);
  6245. $rorg = "31";
  6246. } else {
  6247. return "Wrong parameter, choose ENC <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6248. }
  6249. } elsif ($cmd eq "STE") {
  6250. # secure Teach-In
  6251. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6252. $data = uc($a[1]);
  6253. $rorg = "35";
  6254. } else {
  6255. return "Wrong parameter, choose STE <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6256. }
  6257. } else {
  6258. return "Unknown argument $cmd, choose one of 1BS 4BS ENC GPCD GPSD GPTI GPTR MSC RPS SEC STE UTE VLD";
  6259. }
  6260. if ($a[2]) {
  6261. if ($a[2] !~ m/^[\dA-Fa-f]{2}$/) {
  6262. return "Wrong status parameter, choose $cmd $a[1] [status 1 Byte hex]";
  6263. }
  6264. $status = uc($a[2]);
  6265. splice(@a,2,1);
  6266. }
  6267. $updateState = 0;
  6268. readingsSingleUpdate($hash, "RORG", $cmd, 1);
  6269. readingsSingleUpdate($hash, "dataSent", $data, 1);
  6270. readingsSingleUpdate($hash, "statusSent", $status, 1);
  6271. Log3 $name, 3, "EnOcean set $name $cmd $data $status";
  6272. shift(@a);
  6273. } elsif ($st eq "remote") {
  6274. return "Unknown argument $cmd, choose one of $cmdList";
  6275. } else {
  6276. # subtype does not support set commands
  6277. $updateState = -1;
  6278. if (AttrVal($name, "remoteManagement", "off") eq "manager") {
  6279. return "Unknown argument $cmd, choose one of $cmdList";
  6280. } else {
  6281. return;
  6282. }
  6283. }
  6284. # set reading state if confirmation telegram is not expected
  6285. if($updateState == 1 && $updateStateAttr =~ m/^default|yes$/) {
  6286. readingsSingleUpdate($hash, "state", $cmd, 1);
  6287. } elsif ($updateState == 0 && $updateStateAttr eq "yes") {
  6288. readingsSingleUpdate($hash, "state", $cmd, 1);
  6289. #} elsif ($updateState == 3) {
  6290. #internal command
  6291. #} else {
  6292. # readingsSingleUpdate($hash, ".info", "await_confirm", 0);
  6293. }
  6294. # send commands
  6295. if($updateState >= -1 && $updateState <= 1) {
  6296. EnOcean_SndCdm(undef, $hash, $packetType, $rorg, $data, $subDef, $status, $destinationID);
  6297. EnOcean_observeInit(1, $hash, @cmdObserve);
  6298. if ($switchMode eq "pushbutton" && $cmd1 ne "released") {
  6299. my @timerCmd = ($name, "released");
  6300. my %par = (hash => $hash, timerCmd => \@timerCmd);
  6301. InternalTimer(gettimeofday() + 0.1, "EnOcean_TimerSet", \%par, 0);
  6302. }
  6303. }
  6304. #Log3 $name, 3, "EnOcean set $name remainder of CmdArg: " . join(' ' ,@a) if (@a > 0);
  6305. }
  6306. return undef;
  6307. }
  6308. # parse and display the incoming telegrams
  6309. sub EnOcean_Parse($$)
  6310. {
  6311. my ($iohash, $msg) = @_;
  6312. my $IODev = $iohash->{NAME};
  6313. my ($hash, $name, $filelogName, $rorgname);
  6314. my ($ctrl, $err, $logLevel, $response);
  6315. Log3 $IODev, 4, "EnOcean received via $IODev: $msg";
  6316. my @msg = split(':', $msg);
  6317. my ($rorg, $data, $senderID, $status, $odata, $subDef, $destinationID, $funcNumber, $manufID, $RSSI, $delay, $subTelNum);
  6318. my $packetType = hex($msg[1]);
  6319. my @event;
  6320. if ($packetType == 1) {
  6321. # packet type RADIO
  6322. #EnOcean:PacketType:RORG:MessageData:SourceID:Status:OptionalData
  6323. (undef, undef, $rorg, $data, $senderID, $status, $odata) = @msg;
  6324. $odata =~ m/^(..)(........)(..)(..)$/;
  6325. ($subTelNum, $destinationID, $RSSI) = (hex($1), $2, hex($3));
  6326. if (exists $modules{EnOcean}{defptr}{$senderID}) {
  6327. $hash = $modules{EnOcean}{defptr}{$senderID};
  6328. } elsif ($destinationID ne 'FFFFFFFF') {
  6329. $hash = $modules{EnOcean}{defptr}{$destinationID};
  6330. }
  6331. $rorgname = $EnO_rorgname{$rorg};
  6332. if (!$rorgname) {
  6333. if($hash) {
  6334. Log3 $hash->{NAME}, 2, "EnOcean $hash->{NAME} RORG $rorg unknown.";
  6335. } else {
  6336. Log3 undef, 2, "EnOcean RORG $rorg received from $senderID unknown.";
  6337. }
  6338. return "";
  6339. }
  6340. if ($rorg eq "40") {
  6341. # chained data message (CDM)
  6342. $data =~ m/^(..)(.*)$/;
  6343. # SEQ evaluation?
  6344. my ($seq, $idx) = (hex($1) & 0xC0, hex($1) & 0x3F);
  6345. $data = $2;
  6346. if ($idx == 0) {
  6347. # first message part
  6348. delete $iohash->{helper}{cdm};
  6349. $data =~ m/^(....)(..)(.*)$/;
  6350. $iohash->{helper}{cdm}{len} = hex($1);
  6351. $iohash->{helper}{cdm}{rorg} = $2;
  6352. $iohash->{helper}{cdm}{data}{$idx} = $3;
  6353. $iohash->{helper}{cdm}{lenCounter} = length($3) / 2;
  6354. my %functionHash = (hash => $iohash, function => "cdm");
  6355. RemoveInternalTimer(\%functionHash);
  6356. InternalTimer(gettimeofday() + 1, "EnOcean_helperClear", \%functionHash, 0);
  6357. #Log3 $IODev, 3, "EnOcean $IODev CDM timer started";
  6358. } else {
  6359. $iohash->{helper}{cdm}{data}{$idx} = $data;
  6360. $iohash->{helper}{cdm}{lenCounter} += length($data) / 2;
  6361. }
  6362. if ($iohash->{helper}{cdm}{lenCounter} >= $iohash->{helper}{cdm}{len}) {
  6363. # data message complete
  6364. # reconstruct RORG, DATA
  6365. my ($idx, $dataPart, @data);
  6366. while (($idx, $dataPart) = each(%{$iohash->{helper}{cdm}{data}})) {
  6367. $data[$idx] = $iohash->{helper}{cdm}{data}{$idx};
  6368. }
  6369. $data = join('', @data);
  6370. $msg[3] = $data;
  6371. $rorg = $iohash->{helper}{cdm}{rorg};
  6372. $msg[2] = $rorg;
  6373. $msg = join(':', @msg);
  6374. $rorgname = $EnO_rorgname{$rorg};
  6375. if (!$rorgname) {
  6376. Log3 undef, 2, "EnOcean RORG $rorg received from $senderID unknown.";
  6377. return "";
  6378. }
  6379. delete $iohash->{helper}{cdm};
  6380. my %functionHash = (hash => $iohash, function => "cdm");
  6381. RemoveInternalTimer(\%functionHash);
  6382. #Log3 $IODev, 3, "EnOcean $IODev CDM concatenated DATA $data";
  6383. } else {
  6384. # wait for next data message part
  6385. return $IODev;
  6386. }
  6387. }
  6388. if($hash) {
  6389. $name = $hash->{NAME};
  6390. if ($rorg eq 'A5' && !(hex(substr($data, 6, 2)) & 8) &&
  6391. hex(substr($data, 0, 2)) >> 2 == 0x3F &&
  6392. (hex(substr($data, 0, 4)) >> 3 & 0x7F) == 0) {
  6393. # find Radio Link Test device
  6394. my $rltHash;
  6395. foreach my $dev (keys %defs) {
  6396. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  6397. next if (!exists($attr{$dev}{subType}));
  6398. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  6399. $rltHash = $defs{$dev};
  6400. last;
  6401. }
  6402. if (defined $rltHash) {
  6403. if ($rltHash != $hash) {
  6404. if (ReadingsVal($rltHash->{NAME}, 'state', '') =~ m/^standby$/) {
  6405. # device is temporarily subType radioLinkTest
  6406. @{$rltHash->{helper}{rlt}{oldDev}} = ($hash, $name, $hash->{DEF});
  6407. CommandModify(undef, "$name 00000000");
  6408. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  6409. $hash = $rltHash;
  6410. $name = $hash->{NAME};
  6411. CommandModify(undef, "$name $senderID");
  6412. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6413. } else {
  6414. # Radio Link Test Devices not ready at the moment
  6415. return '';
  6416. }
  6417. }
  6418. Log3 $name, 4, "EnOcean received RLT Query messsage DATA: $data from DeviceID: $senderID";
  6419. } else {
  6420. Log3 $name, 4, "EnOcean received RLT Query messsage DATA: $data from DeviceID: $senderID";
  6421. }
  6422. } else {
  6423. Log3 $name, 4, "EnOcean $name received PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6424. }
  6425. $manufID = uc(AttrVal($name, "manufID", ""));
  6426. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6427. $filelogName = "FileLog_$name";
  6428. #if ($IODev ne $hash->{IODev}{NAME}) {
  6429. # transceiver wrong
  6430. # Log3 $name, 4, "EnOcean $name locked telegram via $IODev PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6431. # return "";
  6432. #}
  6433. } else {
  6434. # SenderID unknown, created new device
  6435. Log3 undef, 5, "EnOcean received PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6436. my $learningMode = AttrVal($IODev, "learningMode", "demand");
  6437. my $ret = "UNDEFINED EnO_$senderID EnOcean $senderID $msg";
  6438. if ($rorgname =~ m/^GPCD|GPSD|SMLRNANS|SMREC|SMMBOX$/) {
  6439. Log3 undef, 4, "EnOcean Received $rorgname telegram to the unknown device with SenderID $senderID.";
  6440. return '';
  6441. } elsif ($rorg eq 'A5' &&
  6442. hex(substr($data, 0, 2)) >> 2 == 0x3F &&
  6443. (hex(substr($data, 0, 4)) >> 3 & 0x7F) == 0 &&
  6444. !(hex(substr($data, 6, 2)) & 8)) {
  6445. # find Radio Link Test device
  6446. my $rltHash;
  6447. foreach my $dev (keys %defs) {
  6448. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  6449. next if (!exists($attr{$dev}{subType}));
  6450. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  6451. $rltHash = $defs{$dev};
  6452. last;
  6453. }
  6454. if ($rltHash) {
  6455. return '' if (ReadingsVal($rltHash->{NAME}, 'state', '') !~ m/^standby$/);
  6456. $hash = $rltHash;
  6457. $name = $hash->{NAME};
  6458. CommandModify(undef, "$name $senderID");
  6459. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6460. $filelogName = "FileLog_$name";
  6461. Log3 $name, 4, "EnOcean RLT Query messsage DATA: $data from SenderID: $senderID received";
  6462. $manufID = uc(AttrVal($name, "manufID", ""));
  6463. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6464. } else {
  6465. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and RLT Query message, please define it.";
  6466. return $ret;
  6467. }
  6468. } elsif (exists $iohash->{helper}{teachConfirmWaitHash}) {
  6469. # teach-in response with confirm telegram, assign remote device
  6470. $hash = $iohash->{helper}{teachConfirmWaitHash};
  6471. $name = $hash->{NAME};
  6472. # substitute subDef with DEF
  6473. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  6474. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6475. $attr{$name}{subDef} = $hash->{DEF};
  6476. $subDef = $attr{$name}{subDef};
  6477. $hash->{DEF} = $senderID;
  6478. $attr{$name}{comMode} = "confirm";
  6479. $manufID = uc(AttrVal($name, "manufID", ""));
  6480. $filelogName = "FileLog_$name";
  6481. # clear teach-in request
  6482. delete $iohash->{helper}{teachConfirmWaitHash};
  6483. # store changes
  6484. EnOcean_CommandSave(undef, undef);
  6485. push @event, "3:teach:4BS teach-in accepted";
  6486. Log3 $name, 2, "EnOcean $name remote device with SenderID $senderID assigned";
  6487. } elsif ($learningMode eq "demand" && $iohash->{Teach}) {
  6488. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6489. return $ret;
  6490. } elsif ($learningMode eq "nearfield" && $iohash->{Teach} && $RSSI <= 60) {
  6491. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6492. return $ret;
  6493. } elsif ($learningMode eq "always") {
  6494. if ($rorgname =~ m/^UTE|GPTI|GPTR$/) {
  6495. if ($iohash->{Teach}) {
  6496. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6497. return $ret;
  6498. } else {
  6499. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, activate learning mode.";
  6500. return "";
  6501. }
  6502. } elsif ($rorgname =~ m/^SMLRNREQ$/) {
  6503. if ($iohash->{SmartAckLearn}) {
  6504. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6505. return $ret;
  6506. } else {
  6507. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, activate learning mode.";
  6508. return "";
  6509. }
  6510. } else {
  6511. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6512. return $ret;
  6513. }
  6514. } else {
  6515. Log3 undef, 4, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, activate learning mode.";
  6516. return "";
  6517. }
  6518. }
  6519. } elsif ($packetType == 2) {
  6520. # packet type RESPONSE
  6521. #EnOcean:PacketType:ResposeCode:MessageData:OptionalData
  6522. (undef, undef, $funcNumber, $data, $odata) = @msg;
  6523. $data = defined($data) ? $data : '';
  6524. $odata = defined($odata) ? $odata : '';
  6525. my %codes = (
  6526. "00" => "OK",
  6527. "01" => "ERROR",
  6528. "02" => "NOT_SUPPORTED",
  6529. "03" => "WRONG_PARAM",
  6530. "04" => "OPERATION_DENIED",
  6531. "82" => "FLASH_HW_ERROR",
  6532. "90" => "BASEID_OUT_OF_RANGE",
  6533. "91" => "BASEID_MAX_REACHED",
  6534. );
  6535. my $rcTxt = $codes{$funcNumber} if($codes{$funcNumber});
  6536. if($hash) {
  6537. $name = $hash->{NAME};
  6538. $funcNumber = hex($funcNumber);
  6539. Log3 $name, $funcNumber == 0 ? 5 : 2, "EnOcean $name RESPONSE: $rcTxt DATA: $data ODATA: $odata";
  6540. return $name;
  6541. } else {
  6542. Log3 undef, $funcNumber == 0 ? 5 : 2, "EnOcean RESPONSE: $rcTxt DATA: $data ODATA: $odata";
  6543. return "";
  6544. }
  6545. } elsif ($packetType == 4) {
  6546. # packet type EVENT
  6547. #EnOcean:PacketType:EventCode:MessageData
  6548. (undef, undef, $funcNumber, $data) = @msg;
  6549. Log3 undef, 5, "EnOcean EventCode: $funcNumber DATA: $data";
  6550. $funcNumber = hex($funcNumber);
  6551. if ($funcNumber == 2) {
  6552. # smart Ack confirm learn
  6553. my ($priority, $rorg, $func, $type, $postmasterID, $hopCount);
  6554. my $responseTime = 150;
  6555. my $sendData = '';
  6556. my $sendHash = defined($hash) ? $hash : $iohash;
  6557. my $sendName = $sendHash->{NAME};
  6558. $data =~ m/^(..)(....)(..)(..)(..)(..)(........)(........)(..)$/;
  6559. ($priority, $manufID, $rorg, $func, $type, $RSSI, $postmasterID, $senderID, $hopCount) = (hex($1), $2, $3, $4, $5, hex($6), $7, $8, $9);
  6560. #Log3 undef, 2, "EnOcean IOHASH: $iohash PRIORITY: $priority SmartAckLearn: " . (exists($iohash->{SmartAckLearn}) ? 1 : 0) .
  6561. # " SmartAckLearnWait: " . (exists($iohash->{helper}{smartAckLearnWait}) ? $iohash->{helper}{smartAckLearnWait} : '');
  6562. if ($iohash->{SmartAckLearn} ||
  6563. exists($iohash->{helper}{smartAckLearnWait}) && $iohash->{helper}{smartAckLearnWait} eq $sendName) {
  6564. my $subType = "$rorg.$func.$type";
  6565. if (exists $EnO_eepConfig{$subType}) {
  6566. # EEP supported
  6567. if (exists $modules{EnOcean}{defptr}{$senderID}) {
  6568. $hash = $modules{EnOcean}{defptr}{$senderID};
  6569. }
  6570. $rorgname = $EnO_rorgname{$rorg};
  6571. if($hash) {
  6572. delete $iohash->{helper}{smartAckLearnWait};
  6573. $name = $hash->{NAME};
  6574. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6575. if (($priority & 15) == 15) {
  6576. # device exists, learn OUT
  6577. # send response, to delete mailbox
  6578. $rorg = substr(AttrVal($name, "eep", ' '), 0, 2);
  6579. $sendData = sprintf "00%04X20", $responseTime;
  6580. EnOcean_SndRadio(undef, $hash, 2, $rorg, $sendData, $subDef, '00', $hash->{DEF});
  6581. Log3 $name, 2, "EnOcean $name Smart Ack teach-out send";
  6582. Log3 $name, 2, "EnOcean $name device $name deleted";
  6583. CommandDelete(undef, $name);
  6584. EnOcean_CommandSave(undef, undef);
  6585. return '';
  6586. } else {
  6587. # config device
  6588. Log3 $name, 5, "EnOcean $name received PacketType: $packetType EventCode: $funcNumber DATA: $data";
  6589. $attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType};
  6590. $attr{$name}{eep} = "$rorg-$func-$type";
  6591. $manufID = sprintf "%03X", hex($manufID) & 0x7FF;
  6592. $attr{$name}{manufID} = $manufID;
  6593. $manufID = $EnO_manuf{$manufID} if(exists $EnO_manuf{$manufID});
  6594. $attr{$name}{postmasterID} = $postmasterID;
  6595. $hash->{SmartAckRSSI} = $RSSI;
  6596. $attr{$name}{teachMethod} = 'smartAck';
  6597. foreach my $attrCntr (keys %{$EnO_eepConfig{$subType}{attr}}) {
  6598. if ($attrCntr ne "subDef") {
  6599. $attr{$name}{$attrCntr} = $EnO_eepConfig{$subType}{attr}{$attrCntr};
  6600. }
  6601. }
  6602. #if (defined AttrVal($name, 'subDef', undef)) {
  6603. # $subDef = $attr{$name}{subDef};
  6604. #} else {
  6605. #$subDef = $postmasterID;
  6606. #$attr{$name}{subDef} = $postmasterID;
  6607. #}
  6608. $subDef = '0' x 8;
  6609. $attr{$name}{subDef} = '0' x 8;
  6610. # sent response to create mailbox
  6611. $sendData = sprintf "00%04X00", $responseTime;
  6612. EnOcean_SndRadio(undef, $hash, 2, $rorg, $sendData, $subDef, '00', $hash->{DEF});
  6613. readingsSingleUpdate($hash, "teach", "Smart Ack teach-in accepted EEP $rorg-$func-$type Manufacturer: $manufID", 1);
  6614. Log3 $name, 2, "EnOcean $name Smart Ack teach-in accepted EEP $rorg-$func-$type Manufacturer: $manufID";
  6615. EnOcean_CommandSave(undef, undef);
  6616. return $name;
  6617. }
  6618. } else {
  6619. # device unknown
  6620. if (($priority & 5) == 5) {
  6621. # Smart Ack priority ok (place for mailbox, good RSSI, Local)
  6622. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and Smart Ack learn In message, please define it.";
  6623. return "UNDEFINED EnO_$senderID EnOcean $senderID $msg";
  6624. } elsif (($priority & 5) == 1) {
  6625. # Smart Ack no place for mailbox
  6626. $sendData = sprintf "00%04X12", $responseTime;
  6627. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6628. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID Discard learn in, postmaster has no place for further mailbox";
  6629. return '';
  6630. } else {
  6631. # Smart Ack priority to low
  6632. $sendData = sprintf "00%04X13", $responseTime;
  6633. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6634. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID Discard learn in, priority to low";
  6635. return '';
  6636. }
  6637. }
  6638. } else {
  6639. # EEP not supported
  6640. # sent response
  6641. $sendData = sprintf "00%04X11", $responseTime;
  6642. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6643. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID with EEP $rorg-$func-$type not supported";
  6644. return '';
  6645. }
  6646. } else {
  6647. # smart ack learn not activated
  6648. $sendData = sprintf "00%04XFF", $responseTime;
  6649. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6650. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID received, activate learning";
  6651. return '';
  6652. }
  6653. }
  6654. } elsif ($packetType == 6) {
  6655. # packet type SMART ACK
  6656. #EnOcean:PacketType:SmartAckCode:MessageData
  6657. (undef, undef, $funcNumber, $data) = @msg;
  6658. if($hash) {
  6659. $name = $hash->{NAME};
  6660. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6661. Log3 $name, 2, "EnOcean $name received PacketType: $packetType Function Number: $funcNumber DATA: $data";
  6662. } else {
  6663. Log3 undef, 2, "EnOcean received PacketType: $packetType Function Number: $funcNumber DATA: $data";
  6664. return "";
  6665. }
  6666. $funcNumber = hex($funcNumber);
  6667. } elsif ($packetType == 7) {
  6668. # packet type REMOTE_MAN_COMMAND
  6669. #EnOcean:PacketType:RORG:MessageData:SourceID:DestinationID:FunctionNumber:ManufacturerID:RSSI:Delay
  6670. (undef, undef, $rorg, $data, $senderID, $destinationID, $funcNumber, $manufID, $RSSI, $delay) = @msg;
  6671. if (exists $modules{EnOcean}{defptr}{$senderID}) {
  6672. $hash = $modules{EnOcean}{defptr}{$senderID};
  6673. $name = $hash->{NAME};
  6674. if (!exists $attr{$name}{remoteID}) {
  6675. $attr{$name}{remoteID} = $senderID;
  6676. Log3 $name, 2, "EnOcean $name remoteID $senderID assigned";
  6677. if (exists($iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash}) &&
  6678. $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash} == $hash) {
  6679. delete $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash};
  6680. }
  6681. }
  6682. } elsif (exists($iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash})) {
  6683. # the remoteID is assigned to the requesting device
  6684. $hash = $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash};
  6685. $name = $hash->{NAME};
  6686. $subDef = '0' x 8;
  6687. $attr{$name}{remoteID} = $senderID;
  6688. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6689. delete $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash};
  6690. Log3 $name, 2, "EnOcean $name remoteID $senderID assigned";
  6691. #EnOcean_CommandSave(undef, undef);
  6692. } elsif ($destinationID ne 'FFFFFFFF') {
  6693. $hash = $modules{EnOcean}{defptr}{$destinationID};
  6694. }
  6695. #$funcNumber = substr($funcNumber, 1);
  6696. if($hash) {
  6697. $name = $hash->{NAME};
  6698. $manufID = substr($manufID, 1);
  6699. $rorgname = $EnO_rorgname{$rorg};
  6700. $subDef = '0' x 8;
  6701. Log3 $name, 4, "EnOcean $name received PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID
  6702. DestinationID $destinationID Function Number: " . substr($funcNumber, 1) . " ManufacturerID: $manufID";
  6703. $delay = hex($delay);
  6704. $funcNumber = hex($funcNumber);
  6705. $RSSI = hex($RSSI);
  6706. } else {
  6707. if (hex($funcNumber) == 4) {
  6708. #Log3 undef, 1, "EnOcean received remote management query ID from unknown SenderID $senderID, please define device.";
  6709. #return "UNDEFINED EnO_$senderID EnOcean $senderID $msg";
  6710. return '';
  6711. } else {
  6712. return '';
  6713. }
  6714. }
  6715. }
  6716. my $eep = AttrVal($name, "eep", undef);
  6717. my $smartAckLearn = $hash->{IODev}{SmartAckLearn};
  6718. my $teach = $hash->{IODev}{Teach};
  6719. my ($deleteDevice, $oldDevice);
  6720. if (AttrVal($name, "secLevel", "off") =~ m/^encapsulation|encryption$/ &&
  6721. AttrVal($name, "secMode", "") =~ m/^rcv|biDir$/) {
  6722. if ($rorg eq "30" || $rorg eq "31") {
  6723. Log3 $name, 5, "EnOcean $name secure data RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6724. ($err, $rorg, $data) = EnOcean_sec_convertToNonsecure($hash, $rorg, $data);
  6725. if (defined $err) {
  6726. Log3 $name, 2, "EnOcean $name security ERROR: $err";
  6727. return "";
  6728. }
  6729. } elsif ($rorg eq "35") {
  6730. # pass second teach-in telegram
  6731. } else {
  6732. Log3 $name, 2, "EnOcean $name unsecure telegram locked";
  6733. return "";
  6734. }
  6735. if ($rorg eq "32") {
  6736. if (defined $eep) {
  6737. # reconstruct RORG
  6738. $rorg = substr($eep, 0, 2);
  6739. Log3 $name, 5, "EnOcean $name decrypted data RORG: 32 >> $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6740. } else {
  6741. # Teach-In telegram expected
  6742. #####
  6743. # telegram analyse needed >> 1BS, 4BS, UTE
  6744. if (length($data) == 14) {
  6745. $rorg = "D4";
  6746. } else {
  6747. Log3 $name, 2, "EnOcean $name security teach-in failed, UTE message is missing";
  6748. return "";
  6749. }
  6750. }
  6751. }
  6752. }
  6753. if ($rorg eq "A6") {
  6754. # addressing destination telegram (ADT)
  6755. # reconstruct RORG, DATA
  6756. $data =~ m/^(..)(.*)(........)$/;
  6757. ($rorg, $data) = ($1, $2);
  6758. $rorgname = $EnO_rorgname{$rorg};
  6759. if (!$rorgname) {
  6760. Log3 undef, 1, "EnOcean RORG $rorg received from $senderID unknown.";
  6761. return "";
  6762. }
  6763. if ($destinationID ne $3) {
  6764. Log3 $name, 1, "EnOcean $name ADT DestinationID wrong.";
  6765. return "";
  6766. }
  6767. Log3 $name, 1, "EnOcean $name ADT decapsulation RORG: $rorg DATA: $data DestinationID: $3";
  6768. }
  6769. # compute data
  6770. # extract data bytes $db[x] ... $db[0]
  6771. my @db;
  6772. my $dbCntr = 0;
  6773. for (my $strCntr = length($data) / 2 - 1; $strCntr >= 0; $strCntr --) {
  6774. $db[$dbCntr] = hex substr($data, $strCntr * 2, 2);
  6775. $dbCntr ++;
  6776. }
  6777. my $model = AttrVal($name, "model", "");
  6778. my $st = AttrVal($name, "subType", "");
  6779. my $subtypeReading = AttrVal($name, "subTypeReading", undef);
  6780. $st = $subtypeReading if (defined $subtypeReading);
  6781. if ($rorg eq "F6") {
  6782. # RPS Telegram
  6783. my $event = "state";
  6784. my $nu = (hex($status) & 0x10) >> 4;
  6785. # unused flags (AFAIK)
  6786. #push @event, "1:T21:".((hex($status) & 0x20) >> 5);
  6787. #push @event, "1:NU:$nu";
  6788. if ($st eq "FRW" || $st eq "smokeDetector.02") {
  6789. # smoke detector
  6790. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} != $db[0] || ReadingsVal($name, 'alarm', '') eq 'dead_sensor') {
  6791. if ($db[0] == 0x30) {
  6792. push @event, "3:alarm:off";
  6793. push @event, "3:battery:low";
  6794. $msg = ReadingsVal($name, 'state', 'off');
  6795. } elsif ($db[0] == 0x10) {
  6796. push @event, "3:battery:ok";
  6797. push @event, "3:alarm:smoke-alarm";
  6798. $msg = "smoke-alarm";
  6799. } elsif ($db[0] == 0) {
  6800. push @event, "3:alarm:off";
  6801. push @event, "3:battery:ok";
  6802. $msg = "off";
  6803. }
  6804. push @event, "3:$event:$msg";
  6805. $hash->{helper}{lastEvent} = $db[0];
  6806. }
  6807. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  6808. RemoveInternalTimer($hash->{helper}{alarmTimer});
  6809. InternalTimer(gettimeofday() + 1320, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  6810. } elsif ($st eq "windSpeed.00") {
  6811. # wind speed threshold detector
  6812. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} != $db[0] || ReadingsVal($name, 'alarm', '') eq 'dead_sensor') {
  6813. push @event, "3:alarm:off";
  6814. if ($db[0] == 0x30) {
  6815. push @event, "3:battery:low";
  6816. $msg = ReadingsVal($name, 'state', 'off');
  6817. } elsif ($db[0] == 0x10) {
  6818. push @event, "3:windSpeed:on";
  6819. push @event, "3:battery:ok";
  6820. $msg = "on";
  6821. } elsif ($db[0] == 0) {
  6822. push @event, "3:windSpeed:off";
  6823. push @event, "3:battery:ok";
  6824. $msg = "off";
  6825. }
  6826. push @event, "3:$event:$msg";
  6827. $hash->{helper}{lastEvent} = $db[0];
  6828. }
  6829. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  6830. RemoveInternalTimer($hash->{helper}{alarmTimer});
  6831. InternalTimer(gettimeofday() + 1320, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  6832. } elsif ($model =~ m/FAE14|FHK14|FHK61$/) {
  6833. # heating/cooling relay FAE14, FHK14, untested
  6834. $event = "controllerMode";
  6835. if ($db[0] == 0x30) {
  6836. # night reduction 2 K
  6837. push @event, "3:energyHoldOff:holdoff";
  6838. $msg = "auto";
  6839. } elsif ($db[0] == 0x10) {
  6840. # off
  6841. push @event, "3:energyHoldOff:normal";
  6842. $msg = "off";
  6843. } elsif ($db[0] == 0x70) {
  6844. # on
  6845. push @event, "3:energyHoldOff:normal";
  6846. $msg = "auto";
  6847. } elsif ($db[0] == 0x50) {
  6848. # night reduction 4 K
  6849. push @event, "3:energyHoldOff:holdoff";
  6850. $msg = "auto";
  6851. }
  6852. push @event, "3:$event:$msg";
  6853. } elsif ($st eq "gateway") {
  6854. # Eltako switching, dimming
  6855. if ($db[0] == 0x70) {
  6856. $msg = "on";
  6857. } elsif ($db[0] == 0x50) {
  6858. $msg = "off";
  6859. } elsif ($db[0] == 0x30) {
  6860. $event = 'alert';
  6861. $msg = "on";
  6862. } elsif ($db[0] == 0x10) {
  6863. $event = 'alert';
  6864. $msg = "off";
  6865. }
  6866. push @event, "3:$event:$msg";
  6867. } elsif ($st eq "manufProfile" && $manufID eq "00D") {
  6868. # Eltako shutter
  6869. if ($db[0] == 0x70) {
  6870. # open
  6871. push @event, "3:endPosition:open_ack";
  6872. $msg = "open_ack";
  6873. } elsif ($db[0] == 0x50) {
  6874. # closed
  6875. push @event, "3:position:100";
  6876. push @event, "3:anglePos:" . AttrVal($name, "angleMax", 90);
  6877. push @event, "3:endPosition:closed";
  6878. $msg = "closed";
  6879. } elsif ($db[0] == 0) {
  6880. # not reached or not available
  6881. push @event, "3:endPosition:not_reached";
  6882. $msg = "not_reached";
  6883. } elsif ($db[0] == 1) {
  6884. # up
  6885. push @event, "3:endPosition:not_reached";
  6886. $msg = "up";
  6887. } elsif ($db[0] == 2) {
  6888. # down
  6889. push @event, "3:endPosition:not_reached";
  6890. $msg = "down";
  6891. }
  6892. push @event, "3:$event:$msg";
  6893. } elsif ($st eq "occupSensor.01" && $model eq "tracker") {
  6894. # tracker
  6895. push @event, "3:button:" . ($db[0] & 0x70 ? "pressed" : "released");
  6896. } elsif ($st eq "switch.7F" && $manufID eq "00D") {
  6897. $msg = $EnO_ptm200btn[($db[0] & 0xE0) >> 5];
  6898. $msg .= "," . $EnO_ptm200btn[($db[0] & 0x0E) >> 1] if ($db[0] & 1);
  6899. $msg .= " released" if (!($db[0] & 0x10));
  6900. push @event, "3:buttons:" . ($db[0] & 0x10 ? "pressed" : "released");
  6901. if ($msg =~ m/A0/) {push @event, "3:channelA:A0";}
  6902. if ($msg =~ m/AI/) {push @event, "3:channelA:AI";}
  6903. if ($msg =~ m/B0/) {push @event, "3:channelB:B0";}
  6904. if ($msg =~ m/BI/) {push @event, "3:channelB:BI";}
  6905. if ($msg =~ m/C0/) {push @event, "3:channelC:C0";}
  6906. if ($msg =~ m/CI/) {push @event, "3:channelC:CI";}
  6907. if ($msg =~ m/D0/) {push @event, "3:channelD:D0";}
  6908. if ($msg =~ m/DI/) {push @event, "3:channelD:DI";}
  6909. push @event, "3:$event:$msg";
  6910. } else {
  6911. if ($nu) {
  6912. if ($st eq "keycard") {
  6913. # Key Card, not tested
  6914. $msg = "keycard_inserted" if ($db[0] == 112);
  6915. } elsif ($st eq "liquidLeakage") {
  6916. # liquid leakage sensor, not tested
  6917. $msg = "wet" if ($db[0] == 0x11);
  6918. } else {
  6919. # Theoretically there can be a released event with some of the A0, BI
  6920. # pins set, but with the plastic cover on this wont happen.
  6921. $msg = $EnO_ptm200btn[($db[0] & 0xE0) >> 5];
  6922. $msg .= "," . $EnO_ptm200btn[($db[0] & 0x0E) >> 1] if ($db[0] & 1);
  6923. $msg .= " released" if (!($db[0] & 0x10));
  6924. push @event, "3:buttons:" . ($db[0] & 0x10 ? "pressed" : "released");
  6925. if ($msg =~ m/A0/) {push @event, "3:channelA:A0";}
  6926. if ($msg =~ m/AI/) {push @event, "3:channelA:AI";}
  6927. if ($msg =~ m/B0/) {push @event, "3:channelB:B0";}
  6928. if ($msg =~ m/BI/) {push @event, "3:channelB:BI";}
  6929. if ($msg =~ m/C0/) {push @event, "3:channelC:C0";}
  6930. if ($msg =~ m/CI/) {push @event, "3:channelC:CI";}
  6931. if ($msg =~ m/D0/) {push @event, "3:channelD:D0";}
  6932. if ($msg =~ m/DI/) {push @event, "3:channelD:DI";}
  6933. }
  6934. } else {
  6935. if ($db[0] & 0xC0) {
  6936. # Only a Mechanical Handle is setting these bits when NU = 0
  6937. $msg = "closed" if ($db[0] == 0xF0);
  6938. $msg = "open" if ($db[0] == 0xE0);
  6939. $msg = "tilted" if ($db[0] == 0xD0);
  6940. $msg = "open_from_tilted" if ($db[0] == 0xC0);
  6941. } elsif ($st eq "keycard") {
  6942. $msg = "keycard_removed";
  6943. } elsif ($st eq "liquidLeakage") {
  6944. $msg = "dry";
  6945. } else {
  6946. $msg = (($db[0] & 0x10) ? "pressed" : "released");
  6947. push @event, "3:buttons:" . ($db[0] & 0x10 ? "pressed" : "released");
  6948. }
  6949. }
  6950. # released events are disturbing when using a remote, since it overwrites
  6951. # the "real" state immediately. In the case of an Eltako FSB14, FSB61 ...
  6952. # the state should remain released.
  6953. if ($msg =~ m/released$/ &&
  6954. AttrVal($name, "sensorMode", "switch") ne "pushbutton" &&
  6955. $model !~ m/(FT55|FSB14|FSB61|FSB70|FSM12|FSM61|FTS12)$/) {
  6956. $event = "buttons";
  6957. $msg = "released";
  6958. } else {
  6959. push @event, "3:$event:$msg";
  6960. }
  6961. }
  6962. } elsif ($rorg eq "D5") {
  6963. # 1BS telegram
  6964. if ($st eq "radioLinkTest") {
  6965. # Radio Link Test (EEP A5-3F-00)
  6966. @{$hash->{helper}{rlt}{param}} = ('parse', $hash, $data, $subDef, 'master', $RSSI);
  6967. EnOcean_RLT($hash->{helper}{rlt}{param});
  6968. } else {
  6969. # Single Input Contact (EEP D5-00-01)
  6970. # [Eltako FTK, STM-250]
  6971. push @event, "3:state:" . ($db[0] & 1 ? "closed" : "open");
  6972. if (!($db[0] & 8)) {
  6973. # teach-in
  6974. $attr{$name}{eep} = "D5-00-01";
  6975. $attr{$name}{manufID} = "7FF";
  6976. $attr{$name}{subType} = "contact";
  6977. push @event, "3:teach:1BS teach-in accepted EEP D5-00-01 Manufacturer: no ID";
  6978. Log3 $name, 2, "EnOcean $name teach-in EEP D5-00-01 Manufacturer: no ID";
  6979. # store attr subType, manufID ...
  6980. EnOcean_CommandSave(undef, undef);
  6981. }
  6982. }
  6983. } elsif ($rorg eq "A5") {
  6984. # 4BS telegram
  6985. if (($db[0] & 8) == 0) {
  6986. # Teach-In telegram
  6987. if ($teach || AttrVal($hash->{IODev}{NAME}, "learningMode", "demand") eq "always" || $st eq "radioLinkTest") {
  6988. if ($db[0] & 0x80) {
  6989. # 4BS Teach-In telegram with EEP and manufacturer ID
  6990. my $func = sprintf "%02X", ($db[3] >> 2);
  6991. my $type = sprintf "%02X", ((($db[3] & 3) << 5) | ($db[2] >> 3));
  6992. my $mid = sprintf "%03X", ((($db[2] & 7) << 8) | $db[1]);
  6993. # manufID to account for vendor-specific features
  6994. $attr{$name}{manufID} = $mid;
  6995. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  6996. my $st = "A5.$func.$type";
  6997. $attr{$name}{eep} = "A5-$func-$type";
  6998. if ($db[0] & 0x10) {
  6999. # 4BS teach-in bidirectional response received
  7000. Log3 $name, 5, "EnOcean $name 4BS teach-in response message from $senderID received";
  7001. if ($teach && exists($hash->{IODev}{helper}{"4BSRespWait"}{$destinationID})) {
  7002. if ($db[0] & 0x40) {
  7003. # EEP supported
  7004. if ($db[0] & 0x20) {
  7005. # SenderID stored
  7006. Log3 $name, 2, "EnOcean $name 4BS teach-in accepted by $senderID";
  7007. push @event, "3:teach:4BS teach-in accepted EEP $rorg-$func-$type Manufacturer: $mid";
  7008. $attr{$name}{comMode} = "biDir";
  7009. $attr{$name}{destinationID} = "unicast";
  7010. # substitute subDef with DEF
  7011. $attr{$name}{subDef} = $hash->{DEF};
  7012. $hash->{DEF} = $senderID;
  7013. $modules{EnOcean}{defptr}{$senderID} = $hash;
  7014. delete $modules{EnOcean}{defptr}{$destinationID};
  7015. # clear teach-in request
  7016. delete $hash->{IODev}{helper}{"4BSRespWait"}{$destinationID};
  7017. # store attr subType, manufID ...
  7018. EnOcean_CommandSave(undef, undef);
  7019. } else {
  7020. # SenderID not stored / deleted
  7021. Log3 $name, 2, "EnOcean $name 4BS request not accepted by $senderID";
  7022. push @event, "3:teach:4BS request not accepted EEP $rorg-$func-$type Manufacturer: $mid";
  7023. }
  7024. } else {
  7025. # EEP not suppported
  7026. Log3 $name, 2, "EnOcean $name 4BS EEP not supported by $senderID";
  7027. push @event, "3:teach:4BS EEP not supported EEP $rorg-$func-$type Manufacturer: $mid";
  7028. }
  7029. } else {
  7030. Log3 $name, 2, "EnOcean $name 4BS teach-in response message from $senderID ignored";
  7031. }
  7032. } else {
  7033. # 4BS teach-in query
  7034. $attr{$name}{teachMethod} = '4BS';
  7035. if(exists $EnO_eepConfig{$st}{attr}) {
  7036. push @event, "3:teach:4BS teach-in accepted EEP A5-$func-$type Manufacturer: $mid";
  7037. Log3 $name, 2, "EnOcean $name 4BS teach-in accepted EEP A5-$func-$type Manufacturer: $mid";
  7038. foreach my $attrCntr (keys %{$EnO_eepConfig{$st}{attr}}) {
  7039. if ($attrCntr eq "subDef") {
  7040. if (!defined AttrVal($name, $attrCntr, undef)) {
  7041. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_eepConfig{$st}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  7042. }
  7043. } else {
  7044. $attr{$name}{$attrCntr} = $EnO_eepConfig{$st}{attr}{$attrCntr};
  7045. }
  7046. }
  7047. if (exists($hash->{helper}{teachInWait}) && $hash->{helper}{teachInWait} =~ m/^4BS|STE$/) {
  7048. $attr{$filelogName}{logtype} = $EnO_eepConfig{$st}{GPLOT} . 'text'
  7049. if (exists $attr{$filelogName}{logtype});
  7050. EnOcean_CreateSVG(undef, $hash, undef);
  7051. delete $hash->{helper}{teachInWait};
  7052. }
  7053. $st = $EnO_eepConfig{$st}{attr}{subType};
  7054. } else {
  7055. push @event, "3:teach:4BS EEP not supported EEP A5-$func-$type Manufacturer: $mid";
  7056. Log3 $name, 2, "EnOcean $name 4BS EEP not supported EEP A5-$func-$type Manufacturer: $mid";
  7057. $attr{$name}{subType} = "raw";
  7058. $st = "raw";
  7059. }
  7060. if ($teach || $st eq "radioLinkTest") {
  7061. # bidirectional 4BS teach-in
  7062. if ($st eq "hvac.01" || $st eq "MD15") {
  7063. # EEP A5-20-01
  7064. $attr{$name}{comMode} = "biDir";
  7065. $attr{$name}{destinationID} = "unicast";
  7066. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7067. # teach-in response
  7068. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, "800FFFF0", $subDef, "00", $hash->{DEF});
  7069. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7070. readingsSingleUpdate($hash, 'operationMode', 'setpointTemp', 0);
  7071. #####
  7072. #EnOcean_hvac_01Cmd($hash, $packetType, 128); # 128 == 20 degree C
  7073. } elsif ($st eq "hvac.02") {
  7074. # EEP A5-20-02 not supported
  7075. # teach-in response
  7076. $data = sprintf "%06X90", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7077. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7078. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7079. } elsif ($st eq "hvac.03") {
  7080. # EEP A5-20-03 not supported
  7081. # teach-in response
  7082. $data = sprintf "%06X90", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7083. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7084. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7085. } elsif ($st eq "hvac.04") {
  7086. # heating radiator valve actuating drive (EEP A5-20-04)
  7087. $attr{$name}{comMode} = "biDir";
  7088. $attr{$name}{destinationID} = "unicast";
  7089. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7090. # teach-in response
  7091. $data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7092. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, "00", $hash->{DEF});
  7093. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7094. readingsSingleUpdate($hash, 'operationMode', 'setpointTemp', 0);
  7095. } elsif ($st eq "radioLinkTest") {
  7096. # Radio Link Test (EEP A5-3F-00)
  7097. if (ReadingsVal($name, "state", 'standby') eq 'standby') {
  7098. $attr{$name}{comMode} = "biDir";
  7099. $attr{$name}{destinationID} = "unicast";
  7100. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7101. # teach-in response, SenderID not stored
  7102. $data = sprintf "%06XD0", (hex($func) << 7 | hex($type)) << 11 | hex($attr{$name}{manufID});
  7103. #$data = sprintf "%06XD0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7104. #$data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7105. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, "00", $hash->{DEF});
  7106. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7107. @{$hash->{helper}{rlt}{param}} = ('start', $hash, undef, $subDef, 'master', $RSSI);
  7108. EnOcean_RLT($hash->{helper}{rlt}{param});
  7109. }
  7110. #} elsif ($st =~ m/^hvac\.1[0-1]$/) {
  7111. # EEP A5-20-10, A5-20-11
  7112. # teach-in response
  7113. # $data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7114. # EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7115. # Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7116. } elsif (AttrVal($name, "comMode", "") =~ m/^confirm|biDir$/) {
  7117. # confirm telegram requested, teach-in response sent
  7118. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7119. $data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7120. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, "00", $hash->{DEF});
  7121. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7122. #} else {
  7123. # EEP not supported
  7124. # teach-in response
  7125. # $data = sprintf "%06X90", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7126. # EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7127. # Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7128. }
  7129. }
  7130. }
  7131. # store attr subType, manufID ...
  7132. EnOcean_CommandSave(undef, undef);
  7133. # delete standard readings
  7134. CommandDeleteReading(undef, "$name sensor[0-9]");
  7135. CommandDeleteReading(undef, "$name D[0-9]");
  7136. } else {
  7137. # 4BS Teach-In without EEP and manufacturer ID
  7138. push @event, "3:teach:4BS teach-in accepted: No EEP profile identifier and no Manufacturer ID";
  7139. Log3 $name, 2, "EnOcean $name 4BS teach-in accepted. No EEP profile identifier and no Manufacturer ID";
  7140. $attr{$name}{subType} = "raw";
  7141. $st = "raw";
  7142. }
  7143. } else {
  7144. Log3 $name, 4, "EnOcean $name teach-in with subType $st locked, set transceiver in teach mode.";
  7145. return "";
  7146. }
  7147. } elsif ($st eq "hvac.01" || $st eq "MD15") {
  7148. # Battery Powered Actuator (EEP A5-20-01)
  7149. # [Kieback&Peter MD15-FTL-xx]
  7150. push @event, "3:energyInput:" . (($db[2] & 0x40) ? "enabled" : "disabled");
  7151. my $battery = ($db[2] & 0x10) ? "ok" : "low";
  7152. my $energyStorage;
  7153. if ($db[2] & 0x20) {
  7154. $energyStorage = 'charged';
  7155. $battery = 'ok';
  7156. } else {
  7157. $energyStorage = 'empty';
  7158. }
  7159. push @event, "3:battery:$battery";
  7160. push @event, "3:energyStorage:$energyStorage";
  7161. my $roomTemp = ReadingsVal($name, "roomTemp", 20);
  7162. if ($db[2] & 4) {
  7163. CommandDeleteReading(undef, "$name roomTemp");
  7164. } else {
  7165. $roomTemp = $db[1] * 40 / 255;
  7166. push @event, "3:roomTemp:" . sprintf "%0.1f", $roomTemp;
  7167. }
  7168. my $setpoint = $db[3];
  7169. push @event, "3:setpoint:$setpoint";
  7170. my $maintenanceMode = ReadingsVal($name, "maintenanceMode", ($db[2] & 0x80) ? 'on' : 'off');
  7171. # if ($db[2] & 0x80) {
  7172. # $maintenanceMode = 'on' if (!defined($maintenanceMode));
  7173. # } else {
  7174. # $maintenanceMode = 'off';
  7175. # }
  7176. push @event, "3:cover:" . (($db[2] & 8) ? "open" : "closed");
  7177. push @event, "3:window:" . (($db[2] & 2) ? "open" : "closed");
  7178. push @event, "3:actuatorState:". (($db[2] & 1) ? "obstructed" : "ok");
  7179. push @event, "3:selfCtrl:" . (($db[0] & 4) ? "on" : "off");
  7180. my $functionSelect = 0;
  7181. my $setpointSelect = 0;
  7182. my $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7183. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  7184. my $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7185. my $temperature = ReadingsVal($name, 'temperature', $roomTemp);
  7186. if (!defined(AttrVal($name, "temperatureRefDev", undef))) {
  7187. if ($db[2] & 4) {
  7188. CommandDeleteReading(undef, "$name temperature");
  7189. } else {
  7190. $temperature = $roomTemp;
  7191. readingsSingleUpdate($hash, 'temperature', sprintf("%0.1f", $temperature), 1);
  7192. }
  7193. }
  7194. Log3 $name, 5, "EnOcean $name EnOcean_parse SPT: $setpointTemp SPTS: $setpointTempSet";
  7195. my $operationMode = ReadingsVal($name, "operationMode", 'setpointTemp');
  7196. my $setpointSummerMode = AttrVal($name, "setpointSummerMode", 0);
  7197. my $summerMode = AttrVal($name, "summerMode", "off");
  7198. my $timeDiff = EnOcean_TimeDiff(ReadingsTimestamp($name, 'wakeUpCycle', undef));
  7199. my $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7200. my $wakeUpCycle = 600;
  7201. # calc wakeup cycle
  7202. if ($summerMode eq 'off') {
  7203. $summerMode = 0;
  7204. if ($timeDiff == 0) {
  7205. $wakeUpCycle = 1200;
  7206. } elsif ($timeDiff < 120) {
  7207. $wakeUpCycle = 120;
  7208. } elsif ($timeDiff > 1200) {
  7209. $wakeUpCycle = 1200;
  7210. } else {
  7211. $wakeUpCycle = int($timeDiff);
  7212. }
  7213. } else {
  7214. $summerMode = 8;
  7215. # ignore all commands
  7216. if ($waitingCmds ne "summerMode") {
  7217. $waitingCmds = "no_change";
  7218. CommandDeleteReading(undef, "$name waitingCmds");
  7219. }
  7220. if ($manufID eq '049') {
  7221. $wakeUpCycle = 28800;
  7222. } else {
  7223. $wakeUpCycle = 3600;
  7224. }
  7225. }
  7226. readingsSingleUpdate($hash, 'wakeUpCycle', $wakeUpCycle, 1);
  7227. # set alarm timer
  7228. CommandDeleteReading(undef, "$name alarm");
  7229. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'no_response_from_actuator', 1, 3);
  7230. RemoveInternalTimer($hash->{helper}{alarmTimer});
  7231. InternalTimer(gettimeofday() + $wakeUpCycle * 1.1, "EnOcean_readingsSingleUpdate", $hash->{helper}{alarmTimer}, 0);
  7232. my $actionCmd = AttrVal($name, "rcvRespAction", undef);
  7233. if (defined $actionCmd) {
  7234. my %specials = ("%ACTUATORSTATE" => (($db[2] & 1) ? "obstructed" : "ok"),
  7235. "%BATTERY" => $battery,
  7236. "%COVER" => (($db[2] & 8) ? "open" : "closed"),
  7237. "%ENERGYINPUT" => (($db[2] & 0x40) ? "enabled" : "disabled"),
  7238. "%ENERGYSTORAGE" => $energyStorage,
  7239. "%MAINTENANCEMODE" => $maintenanceMode,
  7240. "%NAME" => $name,
  7241. "%OPERATIONMODE" => $operationMode,
  7242. "%ROOMTEMP" => $roomTemp,
  7243. "%SELFCTRL" => (($db[0] & 4) ? "on" : "off"),
  7244. "%SETPOINT" => $setpoint,
  7245. "%SETPOINTTEMP" => $setpointTemp,
  7246. "%SUMMERMODE" => $summerMode,
  7247. "%TEMPERATURE" => $temperature,
  7248. "%WINDOW" => (($db[2] & 2) ? "open" : "closed"),
  7249. );
  7250. # action exec
  7251. $actionCmd = EvalSpecials($actionCmd, %specials);
  7252. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  7253. Log3 $name, 2, "Encean $name rcvRespAction ERROR: $ret" if($ret);
  7254. $maintenanceMode = ReadingsVal($name, "maintenanceMode", ($db[2] & 0x80) ? 'on' : 'off');
  7255. $operationMode = ReadingsVal($name, "operationMode", 'setpointTemp');
  7256. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7257. $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7258. $temperature = ReadingsVal($name, 'temperature', $roomTemp);
  7259. $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7260. }
  7261. if ($waitingCmds eq "valveOpens") {
  7262. # deactivate PID regulator
  7263. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7264. $setpointSet = 100;
  7265. $db[2] = 0x20;
  7266. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7267. push @event, "3:maintenanceMode:valveOpend:runInit";
  7268. push @event, "3:operationMode:off";
  7269. CommandDeleteReading(undef, "$name setpointSet");
  7270. CommandDeleteReading(undef, "$name setpointTemp");
  7271. CommandDeleteReading(undef, "$name setpointTempSet");
  7272. CommandDeleteReading(undef, "$name waitingCmds");
  7273. $functionSelect = 1;
  7274. $waitingCmds = 0x20;
  7275. } elsif ($waitingCmds eq "valveCloses") {
  7276. if ($maintenanceMode eq "valveOpend:runInit") {
  7277. $setpointSet = 100;
  7278. $db[2] = 0x20;
  7279. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7280. push @event, "3:maintenanceMode:runInit";
  7281. push @event, "3:operationMode:off";
  7282. $functionSelect = 1;
  7283. $waitingCmds = 0x80;
  7284. } else {
  7285. $setpointSet = 0;
  7286. $db[2] = 0x20;
  7287. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7288. push @event, "3:maintenanceMode:valveClosed";
  7289. push @event, "3:operationMode:off";
  7290. CommandDeleteReading(undef, "$name waitingCmds");
  7291. $functionSelect = 1;
  7292. $waitingCmds = 0x10;
  7293. }
  7294. # stop PID regulator
  7295. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7296. CommandDeleteReading(undef, "$name setpointSet");
  7297. CommandDeleteReading(undef, "$name setpointTemp");
  7298. CommandDeleteReading(undef, "$name setpointTempSet");
  7299. } elsif ($waitingCmds eq "runInit") {
  7300. # deactivate PID regulator
  7301. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7302. $setpointSet = 0;
  7303. $db[2] = 0x20;
  7304. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7305. push @event, "3:maintenanceMode:runInit";
  7306. push @event, "3:operationMode:off";
  7307. push @event, "3:waitingCmds:$operationMode";
  7308. #CommandDeleteReading(undef, "$name setpointSet");
  7309. #CommandDeleteReading(undef, "$name setpointTemp");
  7310. #CommandDeleteReading(undef, "$name setpointTempSet");
  7311. #CommandDeleteReading(undef, "$name waitingCmds");
  7312. $functionSelect = 1;
  7313. $waitingCmds = 0x80;
  7314. } elsif ($waitingCmds eq "liftSet") {
  7315. # deactivate PID regulator
  7316. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7317. $setpointSet = 0;
  7318. $db[2] = 0x20;
  7319. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7320. push @event, "3:maintenanceMode:listSet";
  7321. push @event, "3:operationMode:off";
  7322. push @event, "3:waitingCmds:$operationMode";
  7323. #CommandDeleteReading(undef, "$name setpointSet");
  7324. #CommandDeleteReading(undef, "$name setpointTemp");
  7325. #CommandDeleteReading(undef, "$name setpointTempSet");
  7326. #CommandDeleteReading(undef, "$name waitingCmds");
  7327. $functionSelect = 1;
  7328. $waitingCmds = 0x40;
  7329. } elsif ($waitingCmds eq "setpoint") {
  7330. # deactivate PID regulator
  7331. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7332. if ($maintenanceMode eq "valveOpend:runInit") {
  7333. $setpointSet = 100;
  7334. $db[2] = 0x20;
  7335. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7336. push @event, "3:maintenanceMode:runInit";
  7337. push @event, "3:operationMode:off";
  7338. $functionSelect = 1;
  7339. $waitingCmds = 0x80;
  7340. } else {
  7341. $db[2] = (40 - $temperature) * 255 / 40;
  7342. push @event, "3:maintenanceMode:off";
  7343. push @event, "3:operationMode:setpoint";
  7344. CommandDeleteReading(undef, "$name setpointTemp");
  7345. CommandDeleteReading(undef, "$name setpointTempSet");
  7346. CommandDeleteReading(undef, "$name waitingCmds");
  7347. $waitingCmds = 0;
  7348. }
  7349. } elsif ($waitingCmds eq "setpointTemp") {
  7350. if ($maintenanceMode eq "valveOpend:runInit") {
  7351. # deactivate PID regulator
  7352. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7353. $setpointSet = 100;
  7354. $db[2] = 0x20;
  7355. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7356. push @event, "3:maintenanceMode:runInit";
  7357. push @event, "3:operationMode:off";
  7358. $functionSelect = 1;
  7359. $waitingCmds = 0x80;
  7360. } else {
  7361. if (AttrVal($name, "pidCtrl", 'on') eq 'on') {
  7362. # activate PID regulator
  7363. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'actuator', '');
  7364. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7365. } else {
  7366. # deactivate PID regulator
  7367. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7368. # setpoint temperature
  7369. $setpointSet = $setpointTempSet * 255 / 40;
  7370. $setpointSelect = 4;
  7371. }
  7372. $setpointTemp = $setpointTempSet;
  7373. $db[2] = (40 - $temperature) * 255 / 40;
  7374. push @event, "3:setpointTemp:" . sprintf("%0.1f", $setpointTemp);
  7375. push @event, "3:maintenanceMode:off";
  7376. push @event, "3:operationMode:setpointTemp";
  7377. CommandDeleteReading(undef, "$name waitingCmds");
  7378. $waitingCmds = 0;
  7379. }
  7380. } elsif ($waitingCmds eq "summerMode") {
  7381. # deactivate PID regulator
  7382. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7383. $setpointSet = $setpointSummerMode;
  7384. $db[2] = (40 - $temperature) * 255 / 40;
  7385. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7386. push @event, "3:maintenanceMode:off";
  7387. push @event, "3:operationMode:summerMode";
  7388. #CommandDeleteReading(undef, "$name setpointSet");
  7389. CommandDeleteReading(undef, "$name setpointTemp");
  7390. CommandDeleteReading(undef, "$name setpointTempSet");
  7391. CommandDeleteReading(undef, "$name waitingCmds");
  7392. $waitingCmds = 0;
  7393. } elsif ($operationMode eq "setpoint") {
  7394. # deactivate PID regulator
  7395. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7396. if ($maintenanceMode eq "valveOpend:runInit") {
  7397. $setpointSet = 100;
  7398. $db[2] = 0x20;
  7399. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7400. push @event, "3:maintenanceMode:off";
  7401. push @event, "3:operationMode:setpoint";
  7402. $functionSelect = 1;
  7403. $waitingCmds = 0x80;
  7404. } else {
  7405. $db[2] = (40 - $temperature) * 255 / 40;
  7406. push @event, "3:maintenanceMode:off";
  7407. push @event, "3:operationMode:setpoint";
  7408. $waitingCmds = 0;
  7409. }
  7410. } elsif ($operationMode eq "setpointTemp") {
  7411. if ($maintenanceMode eq "valveOpend:runInit") {
  7412. # deactivate PID regulator
  7413. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7414. $setpointSet = 100;
  7415. $db[2] = 0x20;
  7416. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7417. push @event, "3:maintenanceMode:off";
  7418. push @event, "3:operationMode:setpointTemp";
  7419. $functionSelect = 1;
  7420. $waitingCmds = 0x80;
  7421. } else {
  7422. if (AttrVal($name, "pidCtrl", 'on') eq 'on') {
  7423. # activate PID regulator
  7424. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'actuator', '');
  7425. $setpointSet = ReadingsVal($name, "setpointSet", $setpointSet);
  7426. } else {
  7427. # deactivate PID regulator
  7428. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7429. # setpoint temperature
  7430. $setpointSet = $setpointTempSet * 255 / 40;
  7431. $setpointSelect = 4;
  7432. }
  7433. $db[2] = (40 - $temperature) * 255 / 40;
  7434. $setpointTemp = $setpointTempSet;
  7435. push @event, "3:setpointTemp:" . sprintf("%.1f", $setpointTemp);
  7436. push @event, "3:maintenanceMode:off";
  7437. push @event, "3:operationMode:setpointTemp";
  7438. $waitingCmds = 0;
  7439. }
  7440. } elsif ($operationMode eq "summerMode") {
  7441. # deactivate PID regulator
  7442. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7443. $setpointSet = $setpointSummerMode;
  7444. $db[2] = (40 - $temperature) * 255 / 40;
  7445. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7446. push @event, "3:maintenanceMode:off";
  7447. push @event, "3:operationMode:summerMode";
  7448. $waitingCmds = 0;
  7449. } elsif ($maintenanceMode eq "valveOpend:runInit") {
  7450. # deactivate PID regulator
  7451. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7452. $setpointSet = 100;
  7453. $db[2] = 0x20;
  7454. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7455. push @event, "3:maintenanceMode:valveOpend:runInit";
  7456. push @event, "3:operationMode:off";
  7457. #CommandDeleteReading(undef, "$name setpointSet");
  7458. #CommandDeleteReading(undef, "$name setpointTemp");
  7459. #CommandDeleteReading(undef, "$name setpointTempSet");
  7460. #CommandDeleteReading(undef, "$name waitingCmds");
  7461. $functionSelect = 1;
  7462. $waitingCmds = 0x20;
  7463. } elsif ($maintenanceMode eq "valveClosed") {
  7464. # stop PID regulator
  7465. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7466. $setpointSet = 0;
  7467. $db[2] = 0x20;
  7468. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7469. push @event, "3:maintenanceMode:valveClosed";
  7470. push @event, "3:operationMode:off";
  7471. #CommandDeleteReading(undef, "$name setpointSet");
  7472. #CommandDeleteReading(undef, "$name setpointTemp");
  7473. #CommandDeleteReading(undef, "$name setpointTempSet");
  7474. #CommandDeleteReading(undef, "$name waitingCmds");
  7475. $functionSelect = 1;
  7476. $waitingCmds = 0x10;
  7477. } else {
  7478. $db[2] = (40 - $temperature) * 255 / 40;
  7479. $waitingCmds = 0;
  7480. }
  7481. push @event, "3:state:T: " . sprintf("%0.1f", $temperature) . " SPT: " . sprintf("%.1f", $setpointTemp) . " SP: $setpoint";
  7482. # sent message to the actuator
  7483. $data = sprintf "%02X%02X%02X08", $setpointSet, $db[2], $waitingCmds | $summerMode | $setpointSelect | $functionSelect;
  7484. EnOcean_SndRadio(undef, $hash, $packetType, "A5", $data, $subDef, "00", $hash->{DEF});
  7485. } elsif ($st eq "hvac.04") {
  7486. # heating radiator valve actuating drive EEP A5-20-04)
  7487. my %failureCode = (
  7488. 17 => "measurement_error",
  7489. 18 => "battery_empty",
  7490. 20 => "frost_protection",
  7491. 33 => "blocked_valve",
  7492. 36 => "end_point_detection_error",
  7493. 40 => "no_valve",
  7494. 49 => "not_taught_in",
  7495. 53 => "no_response_from_controller",
  7496. 54 => "teach-in_error"
  7497. );
  7498. my $battery = "ok";
  7499. my %displayOrientation = (0 => 0, 90 => 1, 180 => 2, 270 => 3);
  7500. my $feedTemp = ReadingsVal($name, "feedTemp", 20);
  7501. my $roomTemp = ReadingsVal($name, "roomTemp", 20);
  7502. my $setpoint = $db[3];
  7503. push @event, "3:setpoint:$setpoint";
  7504. my $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7505. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  7506. my $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7507. my $temperature = ReadingsVal($name, "temperature", $roomTemp);
  7508. if ($db[0] & 2) {
  7509. if ($setpointTemp == $setpointTempSet) {
  7510. $setpointTemp = sprintf "%0.1f", ($db[2] * 20 / 255 + 10);
  7511. if ($setpointTemp != $setpointTempSet) {
  7512. # setpointTempSet has been changed by actuator
  7513. $setpointTempSet = $setpointTemp;
  7514. readingsSingleUpdate($hash, 'setpointTempSet', $setpointTempSet, 1);
  7515. }
  7516. } else {
  7517. # setpointTempSet has been changed by Fhem
  7518. $setpointTemp = sprintf "%0.1f", ($db[2] * 20 / 255 + 10);
  7519. }
  7520. push @event, "3:setpointTemp:$setpointTemp";
  7521. } else {
  7522. if ($db[0] & 0x80) {
  7523. # temperature measurement inactive
  7524. CommandDeleteReading(undef, "$name feedTemp");
  7525. } else {
  7526. $feedTemp = $db[2] * 60 / 255 + 20;
  7527. push @event, "3:feedTemp:" . sprintf("%0.1f", $feedTemp);
  7528. }
  7529. }
  7530. if ($db[0] & 1) {
  7531. # failure code
  7532. if (exists $failureCode{$db[1]}) {
  7533. push @event, "3:alarm:" . $failureCode{$db[1]};
  7534. $battery = "empty" if ($db[1] == 18);
  7535. } else {
  7536. CommandDeleteReading(undef, "$name alarm");
  7537. }
  7538. } else {
  7539. if ($db[0] & 0x80) {
  7540. # temperature measurement inactive
  7541. CommandDeleteReading(undef, "$name roomTemp");
  7542. } else {
  7543. # room temperature
  7544. $roomTemp = sprintf("%0.1f", ($db[1] * 20 / 255 + 10));
  7545. push @event, "3:roomTemp:$roomTemp";
  7546. CommandDeleteReading(undef, "$name alarm");
  7547. }
  7548. }
  7549. if (!defined(AttrVal($name, "temperatureRefDev", undef))) {
  7550. if ($db[0] & 0x80) {
  7551. # temperature measurement needed, activate temperature measurement
  7552. $attr{$name}{measurementCtrl} = 'enable';
  7553. EnOcean_CommandSave(undef, undef);
  7554. } else {
  7555. $temperature = $roomTemp;
  7556. readingsSingleUpdate($hash, 'temperature', $temperature, 1);
  7557. #push @event, "3:temperature:$temperature";
  7558. }
  7559. }
  7560. push @event, "3:measurementState:" . ($db[0] & 0x80 ? "inactive" : "active");
  7561. push @event, "3:blockKey:" . ($db[0] & 4 ? "yes" : "no");
  7562. push @event, "3:battery:$battery";
  7563. #push @event, "3:state:T: $temperature SPT: $setpointTemp SP: $setpoint";
  7564. if ($db[0] & 0x40) {
  7565. # status request
  7566. # action needed?
  7567. }
  7568. Log3 $name, 5, "EnOcean $name EnOcean_parse SPT: $setpointTemp SPTS: $setpointTempSet";
  7569. my $activatePID = AttrVal($name, 'pidCtrl', 'on') eq 'on' ? 'actuator' : 'stop';
  7570. my $blockKey = ((AttrVal($name, "blockKey", 'no') eq 'yes') ? 1 : 0) << 2;
  7571. my $displayOrientation = $displayOrientation{AttrVal($name, "displayOrientation", 0)} << 4;
  7572. my $maintenanceMode = ReadingsVal($name, "maintenanceMode", "off");
  7573. my $measurementCtrl = (AttrVal($name, 'measurementCtrl', 'enable') eq 'enable') ? 0 : 0x40;
  7574. #my $operationMode = ReadingsVal($name, "operationMode", "off");
  7575. my $operationMode = ReadingsVal($name, "operationMode", ((AttrVal($name, 'pidCtrl', 'on') eq 'on') ? 'setpointTemp' : 'setpoint'));
  7576. my $summerMode = AttrVal($name, "summerMode", "off");
  7577. my $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7578. my $wakeUpCycle = $wakeUpCycle{AttrVal($name, "wakeUpCycle", 300)};
  7579. if ($summerMode eq 'off' && $wakeUpCycle >= 50) {
  7580. # set default Wake-up Cycle (300 s)
  7581. $wakeUpCycle = 9;
  7582. } elsif ($summerMode eq 'on') {
  7583. if ($waitingCmds ne "summerMode") {
  7584. $waitingCmds = "no_change";
  7585. CommandDeleteReading(undef, "$name waitingCmds");
  7586. }
  7587. $setpointSet = 100;
  7588. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7589. $wakeUpCycle = 50 if ($wakeUpCycle < 50);
  7590. }
  7591. my $actionCmd = AttrVal($name, "rcvRespAction", undef);
  7592. if (defined $actionCmd) {
  7593. my %specials = ("%BATTERY" => $battery,
  7594. "%FEEDTEMP" => $feedTemp,
  7595. "%MAINTENANCEMODE" => $maintenanceMode,
  7596. "%NAME" => $name,
  7597. "%OPERATIONMODE" => $operationMode,
  7598. "%ROOMTEMP" => $roomTemp,
  7599. "%SETPOINT" => $setpoint,
  7600. "%SETPOINTTEMP" => $setpointTemp,
  7601. "%SUMMERMODE" => $summerMode,
  7602. "%TEMPERATURE" => $temperature,
  7603. );
  7604. # action exec
  7605. $actionCmd = EvalSpecials($actionCmd, %specials);
  7606. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  7607. Log3 $name, 2, "EnOcean $name rcvRespAction ERROR: $ret" if($ret);
  7608. $maintenanceMode = ReadingsVal($name, "maintenanceMode", 'off');
  7609. $operationMode = ReadingsVal($name, "operationMode", ((AttrVal($name, 'pidCtrl', 'on') eq 'on') ? 'setpointTemp' : 'setpoint'));
  7610. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7611. $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7612. $temperature = ReadingsVal($name, 'temperature', $roomTemp);
  7613. $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7614. }
  7615. if ($waitingCmds eq "valveOpens") {
  7616. # deactivate PID regulator
  7617. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7618. $setpointSet = 100;
  7619. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7620. push @event, "3:maintenanceMode:valveOpend:runInit";
  7621. push @event, "3:operationMode:off";
  7622. CommandDeleteReading(undef, "$name setpointSet");
  7623. CommandDeleteReading(undef, "$name setpointTemp");
  7624. CommandDeleteReading(undef, "$name setpointTempSet");
  7625. CommandDeleteReading(undef, "$name waitingCmds");
  7626. $waitingCmds = 1;
  7627. } elsif ($waitingCmds eq "valveCloses") {
  7628. if ($maintenanceMode eq "valveOpend:runInit") {
  7629. $setpointSet = 100;
  7630. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7631. push @event, "3:maintenanceMode:runInit";
  7632. push @event, "3:operationMode:off";
  7633. $waitingCmds = 2;
  7634. } else {
  7635. $setpointSet = 0;
  7636. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7637. push @event, "3:maintenanceMode:valveClosed";
  7638. push @event, "3:operationMode:off";
  7639. CommandDeleteReading(undef, "$name waitingCmds");
  7640. $waitingCmds = 3;
  7641. }
  7642. # stop PID regulator
  7643. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7644. CommandDeleteReading(undef, "$name setpointSet");
  7645. CommandDeleteReading(undef, "$name setpointTemp");
  7646. CommandDeleteReading(undef, "$name setpointTempSet");
  7647. } elsif ($waitingCmds eq "runInit") {
  7648. # deactivate PID regulator
  7649. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7650. $setpointSet = 100;
  7651. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7652. push @event, "3:maintenanceMode:runInit";
  7653. push @event, "3:operationMode:off";
  7654. CommandDeleteReading(undef, "$name setpointSet");
  7655. CommandDeleteReading(undef, "$name setpointTemp");
  7656. CommandDeleteReading(undef, "$name setpointTempSet");
  7657. CommandDeleteReading(undef, "$name waitingCmds");
  7658. $waitingCmds = 2;
  7659. } elsif ($waitingCmds eq "setpoint") {
  7660. # deactivate PID regulator
  7661. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7662. if ($maintenanceMode eq "valveOpend:runInit") {
  7663. $setpointSet = 100;
  7664. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7665. push @event, "3:maintenanceMode:runInit";
  7666. push @event, "3:operationMode:off";
  7667. $waitingCmds = 2;
  7668. } else {
  7669. push @event, "3:maintenanceMode:off";
  7670. push @event, "3:operationMode:setpoint";
  7671. #CommandDeleteReading(undef, "$name setpointSet");
  7672. CommandDeleteReading(undef, "$name setpointTemp");
  7673. CommandDeleteReading(undef, "$name setpointTempSet");
  7674. CommandDeleteReading(undef, "$name waitingCmds");
  7675. $waitingCmds = 0;
  7676. }
  7677. } elsif ($waitingCmds eq "setpointTemp") {
  7678. if ($maintenanceMode eq "valveOpend:runInit") {
  7679. # deactivate PID regulator
  7680. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7681. $setpointSet = 100;
  7682. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7683. push @event, "3:maintenanceMode:runInit";
  7684. push @event, "3:operationMode:off";
  7685. $waitingCmds = 2;
  7686. } else {
  7687. # activate PID regulator
  7688. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  7689. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7690. $setpointTemp = $setpointTempSet;
  7691. push @event, "3:setpointTemp:$setpointTemp";
  7692. push @event, "3:maintenanceMode:off";
  7693. push @event, "3:operationMode:setpointTemp";
  7694. #CommandDeleteReading(undef, "$name setpointSet");
  7695. #CommandDeleteReading(undef, "$name setpointTempSet");
  7696. CommandDeleteReading(undef, "$name waitingCmds");
  7697. $waitingCmds = 0;
  7698. }
  7699. } elsif ($waitingCmds eq "summerMode") {
  7700. # deactivate PID regulator
  7701. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7702. $setpointSet = 100;
  7703. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7704. push @event, "3:maintenanceMode:off";
  7705. push @event, "3:operationMode:summerMode";
  7706. #CommandDeleteReading(undef, "$name setpointSet");
  7707. CommandDeleteReading(undef, "$name setpointTemp");
  7708. CommandDeleteReading(undef, "$name setpointTempSet");
  7709. CommandDeleteReading(undef, "$name waitingCmds");
  7710. $waitingCmds = 0;
  7711. } elsif ($operationMode eq "setpoint") {
  7712. # deactivate PID regulator
  7713. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7714. if ($maintenanceMode eq "valveOpend:runInit") {
  7715. $setpointSet = 100;
  7716. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7717. push @event, "3:maintenanceMode:off";
  7718. push @event, "3:operationMode:setpoint";
  7719. $waitingCmds = 2;
  7720. } else {
  7721. push @event, "3:maintenanceMode:off";
  7722. push @event, "3:operationMode:setpoint";
  7723. #CommandDeleteReading(undef, "$name setpointSet");
  7724. #CommandDeleteReading(undef, "$name setpointTemp");
  7725. #CommandDeleteReading(undef, "$name setpointTempSet");
  7726. #CommandDeleteReading(undef, "$name waitingCmds");
  7727. $waitingCmds = 0;
  7728. }
  7729. } elsif ($operationMode eq "setpointTemp") {
  7730. if ($maintenanceMode eq "valveOpend:runInit") {
  7731. # deactivate PID regulator
  7732. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7733. $setpointSet = 100;
  7734. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7735. push @event, "3:maintenanceMode:off";
  7736. push @event, "3:operationMode:setpointTemp";
  7737. $waitingCmds = 2;
  7738. } else {
  7739. # activate PID regulator
  7740. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  7741. $setpointSet = ReadingsVal($name, "setpointSet", $setpointSet);
  7742. push @event, "3:setpointTemp:$setpointTemp";
  7743. push @event, "3:maintenanceMode:off";
  7744. push @event, "3:operationMode:setpointTemp";
  7745. #CommandDeleteReading(undef, "$name setpointSet");
  7746. #CommandDeleteReading(undef, "$name setpointTempSet");
  7747. #CommandDeleteReading(undef, "$name waitingCmds");
  7748. $waitingCmds = 0;
  7749. }
  7750. } elsif ($operationMode eq "summerMode") {
  7751. # deactivate PID regulator
  7752. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7753. $setpointSet = 100;
  7754. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7755. push @event, "3:maintenanceMode:off";
  7756. push @event, "3:operationMode:summerMode";
  7757. #CommandDeleteReading(undef, "$name setpointSet");
  7758. #CommandDeleteReading(undef, "$name setpointTemp");
  7759. #CommandDeleteReading(undef, "$name setpointTempSet");
  7760. #CommandDeleteReading(undef, "$name waitingCmds");
  7761. $waitingCmds = 0;
  7762. } else {
  7763. $waitingCmds = 0;
  7764. }
  7765. push @event, "3:state:T: $temperature SPT: $setpointTemp SP: $setpoint";
  7766. # sent message to the actuator
  7767. $data = sprintf "%02X%02X%02X%02X", $setpointSet,
  7768. ($setpointTempSet - 10) / 20 * 255,
  7769. (AttrVal($name, 'pidCtrl', 'on') eq 'on' ? 0 : 0x80) | $measurementCtrl | $wakeUpCycle,
  7770. $displayOrientation | 8 | $blockKey | $waitingCmds;
  7771. EnOcean_SndRadio(undef, $hash, $packetType, "A5", $data, $subDef, "00", $hash->{DEF});
  7772. } elsif ($st eq "hvac.10") {
  7773. # Generic HVAC Interface (EEP A5-20-10)
  7774. my %mode = (
  7775. 0 => "auto",
  7776. 1 => "heat",
  7777. 2 => "morning_warmup",
  7778. 3 => "cool",
  7779. 4 => "night_purge",
  7780. 5 => "precool",
  7781. 6 => "off",
  7782. 7 => "test",
  7783. 8 => "emergency_heat",
  7784. 9 => "fan_only",
  7785. 10 => "free_cool",
  7786. 11 => "ice",
  7787. 12 => "max_heat",
  7788. 13 => "eco",
  7789. 14 => "dehumidification",
  7790. 15 => "calibration",
  7791. 16 => "emergency_cool",
  7792. 17 => "emergency_stream",
  7793. 18 => "max_cool",
  7794. 19 => "hvc_load",
  7795. 20 => "no_load",
  7796. 31 => "auto_heat",
  7797. 32 => "auto_cool",
  7798. );
  7799. if (exists $mode{$db[3]}) {
  7800. push @event, "3:mode:$mode{$db[3]}";
  7801. } else {
  7802. push @event, "3:mode:unknown";
  7803. }
  7804. my %vanePosition = (
  7805. 0 => "auto",
  7806. 1 => "horizontal",
  7807. 2 => "position_2",
  7808. 3 => "position_3",
  7809. 4 => "position_4",
  7810. 5 => "vertical",
  7811. 6 => "swing",
  7812. 11 => "vertical_swing",
  7813. 12 => "horizontal_swing",
  7814. 13 => "hor_vert_swing",
  7815. 14 => "stop_swing",
  7816. );
  7817. my $vanePosition = $db[2] >> 4;
  7818. if (exists $vanePosition{$vanePosition}) {
  7819. push @event, "3:vanePosition:$vanePosition{$vanePosition}";
  7820. } else {
  7821. push @event, "3:vanePosition:unknown";
  7822. }
  7823. my $fanSpeed = $db[2] & 0x0F;
  7824. if ($fanSpeed == 0) {
  7825. push @event, "3:fanSpeed:auto";
  7826. } elsif ($fanSpeed > 0 && $fanSpeed < 15) {
  7827. push @event, "3:fanSpeed:" . $fanSpeed;
  7828. } else {
  7829. push @event, "3:fanSpeed:unknown";
  7830. }
  7831. if ($db[1] == 255) {
  7832. push @event, "3:ctrl:auto";
  7833. } elsif ($db[1] >= 0 && $db[1] <= 100) {
  7834. push @event, "3:ctrl:" . $db[1];
  7835. } else {
  7836. push @event, "3:ctrl:unknown";
  7837. }
  7838. my $occupancy = ($db[0] & 6) >> 1;
  7839. if ($occupancy == 0) {
  7840. push @event, "3:occupancy:occupied";
  7841. } elsif ($occupancy == 1) {
  7842. push @event, "3:occupancy:standby";
  7843. } elsif ($occupancy == 2) {
  7844. push @event, "3:occupancy:unoccupied";
  7845. } else {
  7846. push @event, "3:occupancy:off";
  7847. }
  7848. push @event, "3:powerSwitch:" . ($db[0] & 1 ? "on" : "off");
  7849. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  7850. } elsif ($st eq "hvac.11") {
  7851. # Generic HVAC Interface - Error Control (EEP A5-20-11)
  7852. push @event, "3:errorCode:" . hex(substr($data, 0, 4));
  7853. push @event, "3:otherDisable:" . ($db[1] & 8 ? "disabled" : "enabled");
  7854. push @event, "3:windowDisable:" . ($db[1] & 4 ? "disabled" : "enabled");
  7855. push @event, "3:keyCardDisable:" . ($db[1] & 2 ? "disabled" : "enabled");
  7856. push @event, "3:externalDisable:" . ($db[1] & 1 ? "disabled" : "enabled");
  7857. push @event, "3:remoteCtrl:" . ($db[0] & 4 ? "disabled" : "enabled");
  7858. push @event, "3:window:" . ($db[0] & 2 ? "closed" : "opened");
  7859. push @event, "3:alarm:" . ($db[0] & 1 ? "error" : "ok");
  7860. push @event, "3:state:" . ($db[0] & 1 ? "error" : "ok");
  7861. } elsif ($st =~ m/^tempSensor/) {
  7862. # Temperature Sensor with with different ranges (EEP A5-02-01 ... A5-02-1B)
  7863. # $db[1] is the temperature where 0x00 = max °C ... 0xFF = min °C
  7864. my $temp;
  7865. $temp = sprintf "%0.1f", 0 - $db[1] / 6.375 if ($st eq "tempSensor.01");
  7866. $temp = sprintf "%0.1f", 10 - $db[1] / 6.375 if ($st eq "tempSensor.02");
  7867. $temp = sprintf "%0.1f", 20 - $db[1] / 6.375 if ($st eq "tempSensor.03");
  7868. $temp = sprintf "%0.1f", 30 - $db[1] / 6.375 if ($st eq "tempSensor.04");
  7869. $temp = sprintf "%0.1f", 40 - $db[1] / 6.375 if ($st eq "tempSensor.05");
  7870. $temp = sprintf "%0.1f", 50 - $db[1] / 6.375 if ($st eq "tempSensor.06");
  7871. $temp = sprintf "%0.1f", 60 - $db[1] / 6.375 if ($st eq "tempSensor.07");
  7872. $temp = sprintf "%0.1f", 70 - $db[1] / 6.375 if ($st eq "tempSensor.08");
  7873. $temp = sprintf "%0.1f", 80 - $db[1] / 6.375 if ($st eq "tempSensor.09");
  7874. $temp = sprintf "%0.1f", 90 - $db[1] / 6.375 if ($st eq "tempSensor.0A");
  7875. $temp = sprintf "%0.1f", 100 - $db[1] / 6.375 if ($st eq "tempSensor.0B");
  7876. $temp = sprintf "%0.1f", 20 - $db[1] / 3.1875 if ($st eq "tempSensor.10");
  7877. $temp = sprintf "%0.1f", 30 - $db[1] / 3.1875 if ($st eq "tempSensor.11");
  7878. $temp = sprintf "%0.1f", 40 - $db[1] / 3.1875 if ($st eq "tempSensor.12");
  7879. $temp = sprintf "%0.1f", 50 - $db[1] / 3.1875 if ($st eq "tempSensor.13");
  7880. $temp = sprintf "%0.1f", 60 - $db[1] / 3.1875 if ($st eq "tempSensor.14");
  7881. $temp = sprintf "%0.1f", 70 - $db[1] / 3.1875 if ($st eq "tempSensor.15");
  7882. $temp = sprintf "%0.1f", 80 - $db[1] / 3.1875 if ($st eq "tempSensor.16");
  7883. $temp = sprintf "%0.1f", 90 - $db[1] / 3.1875 if ($st eq "tempSensor.17");
  7884. $temp = sprintf "%0.1f", 100 - $db[1] / 3.1875 if ($st eq "tempSensor.18");
  7885. $temp = sprintf "%0.1f", 110 - $db[1] / 3.1875 if ($st eq "tempSensor.19");
  7886. $temp = sprintf "%0.1f", 120 - $db[1] / 3.1875 if ($st eq "tempSensor.1A");
  7887. $temp = sprintf "%0.1f", 130 - $db[1] / 3.1875 if ($st eq "tempSensor.1B");
  7888. $temp = sprintf "%0.2f", 41.2 - (($db[2] << 8) | $db[1]) / 20 if ($st eq "tempSensor.20");
  7889. $temp = sprintf "%0.1f", 62.3 - (($db[2] << 8) | $db[1]) / 10 if ($st eq "tempSensor.30");
  7890. push @event, "3:temperature:$temp";
  7891. push @event, "3:state:$temp";
  7892. } elsif ($st eq "COSensor.01") {
  7893. # Gas Sensor, CO Sensor (EEP A5-09-01)
  7894. # [untested]
  7895. # $db[3] is the CO concentration where 0x00 = 0 ppm ... 0xFF = 255 ppm
  7896. # $db[1] is the temperature where 0x00 = 0 °C ... 0xFF = 255 °C
  7897. # $db[0] bit D1 temperature sensor available 0 = no, 1 = yes
  7898. my $coChannel1 = $db[3];
  7899. push @event, "3:CO:$coChannel1";
  7900. if ($db[0] & 2) {
  7901. my $temp = $db[1];
  7902. push @event, "3:temperature:$temp";
  7903. }
  7904. push @event, "3:state:$coChannel1";
  7905. } elsif ($st eq "COSensor.02") {
  7906. # Gas Sensor, CO Sensor (EEP A5-09-02)
  7907. # [untested]
  7908. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  7909. # $db[2] is the CO concentration where 0x00 = 0 ppm ... 0xFF = 1020 ppm
  7910. # $db[1] is the temperature where 0x00 = 0 °C ... 0xFF = 51 °C
  7911. # $db[0]_bit_1 temperature sensor available 0 = no, 1 = yes
  7912. my $coChannel1 = $db[2] << 2;
  7913. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  7914. push @event, "3:CO:$coChannel1";
  7915. if ($db[0] & 2) {
  7916. my $temp = sprintf "%0.1f", $db[1] * 0.2;
  7917. push @event, "3:temperature:$temp";
  7918. }
  7919. push @event, "3:voltage:$voltage";
  7920. push @event, "3:state:$coChannel1";
  7921. } elsif ($st eq "tempHumiCO2Sensor.01") {
  7922. # Gas Sensor, CO2 Sensor (EEP A5-09-04)
  7923. # [Thermokon SR04 CO2 *, Eltako FCOTF63, untested]
  7924. # $db[3] is the humidity where 0x00 = 0 %rH ... 0xC8 = 100 %rH
  7925. # $db[2] is the CO2 concentration where 0x00 = 0 ppm ... 0xFF = 2500 ppm
  7926. # $db[1] is the temperature where 0x00 = 0°C ... 0xFF = +51 °C
  7927. # $db[0] bit D2 humidity sensor available 0 = no, 1 = yes
  7928. # $db[0] bit D1 temperature sensor available 0 = no, 1 = yes
  7929. my $humi = "-";
  7930. my $temp = "-";
  7931. my $airQuality;
  7932. if ($db[0] & 4) {
  7933. $humi = $db[3] >> 1;
  7934. push @event, "3:humidity:$humi";
  7935. }
  7936. my $co2 = sprintf "%d", $db[2] * 10;
  7937. push @event, "3:CO2:$co2";
  7938. if ($db[0] & 2) {
  7939. $temp = sprintf "%0.1f", $db[1] * 51 / 255 ;
  7940. push @event, "3:temperature:$temp";
  7941. }
  7942. if ($co2 <= 400) {
  7943. $airQuality = "high";
  7944. } elsif ($co2 <= 600) {
  7945. $airQuality = "mean";
  7946. } elsif ($co2 <= 1000) {
  7947. $airQuality = "moderate";
  7948. } else {
  7949. $airQuality = "low";
  7950. }
  7951. push @event, "3:airQuality:$airQuality";
  7952. push @event, "3:state:T: $temp H: $humi CO2: $co2 AQ: $airQuality";
  7953. } elsif ($st eq "radonSensor.01") {
  7954. # Gas Sensor, Radon Sensor (EEP A5-09-06)
  7955. # [untested]
  7956. # $db[3]_bit_7 ... $db[2]_bit_6 is the radon activity where 0 = 0 Bq/m3 ... 1023 = 1023 Bq/m3
  7957. my $rn = $db[3] << 2 | $db[2] >> 6;
  7958. push @event, "3:Rn:$rn";
  7959. push @event, "3:state:$rn";
  7960. } elsif ($st eq "vocSensor.01") {
  7961. # Gas Sensor, VOC Sensor (EEP A5-09-05, A5-09-0C)
  7962. # [untested]
  7963. # $db[3]_bit_7 ... $db[2]_bit_0 is the VOC concentration where 0 = 0 ppb ... 65535 = 65535 ppb
  7964. # $db[1] is the VOC identification
  7965. # $db[0]_bit_1 ... $db[0]_bit_0 is the scale multiplier
  7966. my $vocSCM = $db[0] & 3;
  7967. if ($vocSCM == 3) {
  7968. $vocSCM = 10;
  7969. } elsif ($vocSCM == 2) {
  7970. $vocSCM = 1;
  7971. } elsif ($vocSCM == 1) {
  7972. $vocSCM = 0.1;
  7973. } else {
  7974. $vocSCM = 0.01;
  7975. }
  7976. my $vocConc = sprintf "%f", ($db[3] << 8 | $db[2]) * $vocSCM;
  7977. my %vocID = (
  7978. 0 => "VOCT",
  7979. 1 => "Formaldehyde",
  7980. 2 => "Benzene",
  7981. 3 => "Styrene",
  7982. 4 => "Toluene",
  7983. 5 => "Tetrachloroethylene",
  7984. 6 => "Xylene",
  7985. 7 => "n-Hexane",
  7986. 8 => "n-Octane",
  7987. 9 => "Cyclopentane",
  7988. 10 => "Methanol",
  7989. 11 => "Ethanol",
  7990. 12 => "1-Pentanol",
  7991. 13 => "Acetone",
  7992. 14 => "Ethylene Oxide",
  7993. 15 => "Acetaldehyde ue",
  7994. 16 => "Acetic Acid",
  7995. 17 => "Propionice Acid",
  7996. 18 => "Valeric Acid",
  7997. 19 => "Butyric Acid",
  7998. 20 => "Ammoniac",
  7999. 22 => "Hydrogen Sulfide",
  8000. 23 => "Dimethylsulfide",
  8001. 24 => "2-Butanol",
  8002. 25 => "2-Methylpropanol",
  8003. 26 => "Diethyl Ether",
  8004. 27 => "Naphthalene",
  8005. 28 => "4-Phenylcyclohexene",
  8006. 29 => "Limonene",
  8007. 30 => "Tricloroethylene",
  8008. 31 => "Isovaleric Acid",
  8009. 32 => "Indole",
  8010. 33 => "Cadaverine",
  8011. 34 => "Putrescine",
  8012. 35 => "Caproic Acid",
  8013. 255 => "Ozone",
  8014. );
  8015. if (exists $vocID{$db[1]}) {
  8016. push @event, "3:vocName:$vocID{$db[1]}";
  8017. } else {
  8018. push @event, "3:vocName:unknown";
  8019. }
  8020. push @event, "3:concentration:$vocConc";
  8021. push @event, "3:concentrationUnit:" . $db[0] & 4 ? 'ug/m3' : 'ppb';
  8022. push @event, "3:state:$vocConc";
  8023. } elsif ($st eq "particlesSensor.01") {
  8024. # Gas Sensor, Particles Sensor (EEP A5-09-07)
  8025. # [untested]
  8026. # $db[3]_bit_7 ... $db[2]_bit_7 is the particle concentration < 10 µm
  8027. # where 0 = 0 µg/m3 ... 511 = 511 µg/m3
  8028. # $db[2]_bit_6 ... $db[1]_bit_6 is the particle concentration < 2.5 µm
  8029. # where 0 = 0 µg/m3 ... 511 = 511 µg/m3
  8030. # $db[1]_bit_5 ... $db[0]_bit_5 is the particle concentration < 1 µm
  8031. # where 0 = 0 µg/m3 ... 511 = 511 µg/m3
  8032. # $db[0]_bit_2 = 1 = Sensor PM10 active
  8033. # $db[0]_bit_1 = 1 = Sensor PM2_5 active
  8034. # $db[0]_bit_0 = 1 = Sensor PM1 active
  8035. my $pm_10 = "inactive";
  8036. my $pm_2_5 = "inactive";
  8037. my $pm_1 = "inactive";
  8038. if ($db[0] & 4) {$pm_10 = $db[3] << 1 | $db[2] >> 7;}
  8039. if ($db[0] & 2) {$pm_2_5 = ($db[2] & 0x7F) << 1 | $db[1] >> 7;}
  8040. if ($db[0] & 1) {$pm_1 = ($db[1] & 0x3F) << 3 | $db[0] >> 5;}
  8041. push @event, "3:particles_10:$pm_10";
  8042. push @event, "3:particles_2_5:$pm_2_5";
  8043. push @event, "3:particles_1:$pm_1";
  8044. push @event, "3:state:PM10: $pm_10 PM2_5: $pm_2_5 PM1: $pm_1";
  8045. } elsif ($st eq "CO2Sensor.01") {
  8046. # CO2 Sensor (EEP A5-09-08, A5-09-09)
  8047. # [untested]
  8048. # $db[1] is the CO2 concentration where 0x00 = 0 ppm ... 0xFF = 2000 ppm
  8049. # $db[0]_bit_2 is power failure detection
  8050. my $co2 = $db[1] / 255 * 2000;
  8051. push @event, "3:powerFailureDetection:" . ($db[0] & 4 ? "detected" : "not_detected");
  8052. push @event, "3:CO2:$co2";
  8053. push @event, "3:state:$co2";
  8054. } elsif ($st eq "HSensor.01") {
  8055. # H Sensor (EEP A5-09-0A)
  8056. # [untested]
  8057. # $db[3]_$db[2] is the H concentration where 0x00 = 0 ppm ... 0xFFFF = 2000 ppm
  8058. my $hydro = ($db[3] << 8 | $db[2]) / 65535 * 2000;
  8059. push @event, "3:voltage:" . sprintf("%0.1f", (($db[0] & 0xF0) >> 4) / 15 * 3 + 2) if ($db[0] & 1);
  8060. push @event, "3:temperature:" . sprintf("%0.1f", $db[1] / 255 * 80 - 20) if ($db[0] & 2);
  8061. push @event, "3:H:" . sprintf "%0.2f", $hydro;
  8062. push @event, "3:state:" . sprintf "%0.2f", $hydro;
  8063. } elsif ($st eq "radiationSensor.01") {
  8064. # Radiation Sensor (EEP A5-09-0B)
  8065. # [untested]
  8066. # $db[2]_$db[1] is the radioactivity where 0x00 = 0 ... 0xFFFF = 65535
  8067. my %scaleMulti = (
  8068. 0 => 0.001,
  8069. 1 => 0.01,
  8070. 2 => 0.1,
  8071. 3 => 1,
  8072. 4 => 10,
  8073. 5 => 100,
  8074. 6 => 1000,
  8075. 7 => 10000,
  8076. 8 => 100000
  8077. );
  8078. my $scaleMulti = ($db[0] & 0xF0) >> 4;
  8079. my $scaleDecimals;
  8080. if ($scaleMulti <= 2) {
  8081. $scaleDecimals = "%0." . (3 - $scaleMulti) . "f";
  8082. } else {
  8083. $scaleDecimals = "%d"
  8084. }
  8085. $scaleMulti = $scaleMulti{$scaleMulti} if (exists $scaleMulti{$scaleMulti});
  8086. my %unit = (
  8087. 0 => "uSv/h",
  8088. 1 => "cpm",
  8089. 2 => "Bq/L",
  8090. 3 => "Bq/kg"
  8091. );
  8092. my $unit = ($db[0] & 6) >> 1;
  8093. $unit = $unit{$unit};
  8094. my $radioactivity = $db[2] << 8 | $db[1];
  8095. push @event, "3:radioactivity:" . sprintf "$scaleDecimals", $radioactivity * $scaleMulti;
  8096. push @event, "3:radioactivityUnit:$unit";
  8097. push @event, "3:voltage:" . sprintf("%0.1f", (($db[3] & 0xF0) >> 4) / 15 * 3 + 2) if ($db[0] & 1);
  8098. push @event, "3:state:" . sprintf "$scaleDecimals", $radioactivity * $scaleMulti;
  8099. } elsif ($st eq "roomSensorControl.05") {
  8100. # Room Sensor and Control Unit (EEP A5-10-01 ... A5-10-0D)
  8101. # [Eltako FTR55D, FTR55H, Thermokon SR04 *, Thanos SR *, untested]
  8102. # $db[3] is the fan speed or night reduction for Eltako
  8103. # $db[2] is the setpoint where 0x00 = min ... 0xFF = max or
  8104. # reference temperature for Eltako where 0x00 = 0°C ... 0xFF = 40°C
  8105. # $db[1] is the temperature where 0x00 = +40°C ... 0xFF = 0°C
  8106. # $db[0]_bit_0 is the occupy button, pushbutton or slide switch
  8107. my $temp = sprintf "%0.1f", 40 - $db[1] / 6.375;
  8108. if ($manufID eq "00D") {
  8109. my $nightReduction = 0;
  8110. $nightReduction = 1 if ($db[3] == 0x06);
  8111. $nightReduction = 2 if ($db[3] == 0x0C);
  8112. $nightReduction = 3 if ($db[3] == 0x13);
  8113. $nightReduction = 4 if ($db[3] == 0x19);
  8114. $nightReduction = 5 if ($db[3] == 0x1F);
  8115. my $setpointTemp = sprintf "%0.1f", $db[2] / 6.375;
  8116. push @event, "3:state:T: $temp SPT: $setpointTemp NR: $nightReduction";
  8117. push @event, "3:nightReduction:$nightReduction";
  8118. push @event, "3:setpointTemp:$setpointTemp";
  8119. } else {
  8120. my $fspeed = 3;
  8121. $fspeed = 2 if ($db[3] >= 145);
  8122. $fspeed = 1 if ($db[3] >= 165);
  8123. $fspeed = 0 if ($db[3] >= 190);
  8124. $fspeed = "auto" if ($db[3] >= 210);
  8125. my $switch = $db[0] & 1 ? "on" : "off";
  8126. push @event, "3:state:T: $temp SP: $db[2] F: $fspeed SW: $switch";
  8127. push @event, "3:fanStage:$fspeed";
  8128. push @event, "3:switch:$switch";
  8129. push @event, "3:setpoint:$db[2]";
  8130. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[2], 0, 255);
  8131. if (defined $setpointScaled) {
  8132. push @event, "3:setpointScaled:" . $setpointScaled;
  8133. }
  8134. }
  8135. push @event, "3:temperature:$temp";
  8136. } elsif ($st eq "roomSensorControl.01") {
  8137. # Room Sensor and Control Unit (EEP A5-04-01, A5-10-10 ... A5-10-14)
  8138. # [Thermokon SR04 * rH, Thanus SR *, untested]
  8139. # $db[3] is the setpoint where 0x00 = min ... 0xFF = max
  8140. # $db[2] is the humidity where 0x00 = 0%rH ... 0xFA = 100%rH
  8141. # $db[1] is the temperature where 0x00 = 0°C ... 0xFA = +40°C
  8142. # $db[0] bit D0 is the occupy button, pushbutton or slide switch
  8143. my $temp = sprintf "%0.1f", $db[1] * 40 / 250;
  8144. my $humi = sprintf "%d", $db[2] / 2.5;
  8145. my $switch = $db[0] & 1;
  8146. push @event, "3:humidity:$humi";
  8147. push @event, "3:temperature:$temp";
  8148. if ($manufID eq "039") {
  8149. my $brightness = sprintf "%d", $db[3] * 117;
  8150. push @event, "3:brightness:$brightness";
  8151. push @event, "3:state:T: $temp H: $humi B: $brightness";
  8152. } else {
  8153. push @event, "3:setpoint:$db[3]";
  8154. push @event, "3:state:T: $temp H: $humi SP: $db[3] SW: $switch";
  8155. push @event, "3:switch:$switch";
  8156. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[3], 0, 255);
  8157. if (defined $setpointScaled) {
  8158. push @event, "3:setpointScaled:" . $setpointScaled;
  8159. }
  8160. }
  8161. } elsif ($st eq "roomSensorControl.02") {
  8162. # Room Sensor and Control Unit (A5-10-15 ... A5-10-17)
  8163. # [untested]
  8164. # $db[2] bit D7 ... D2 is the setpoint where 0 = min ... 63 = max
  8165. # $db[2] bit D1 ... $db[1] bit D0 is the temperature where 0 = -10°C ... 1023 = +41.2°C
  8166. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8167. my $temp = sprintf "%0.2f", -10 + ((($db[2] & 3) << 8) | $db[1]) / 19.98;
  8168. my $setpoint = ($db[2] & 0xFC) >> 2;
  8169. my $presence = $db[0] & 1 ? "absent" : "present";
  8170. push @event, "3:state:T: $temp SP: $setpoint P: $presence";
  8171. push @event, "3:presence:$presence";
  8172. push @event, "3:setpoint:$setpoint";
  8173. push @event, "3:temperature:$temp";
  8174. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[2], 0, 255);
  8175. if (defined $setpointScaled) {
  8176. push @event, "3:setpointScaled:" . $setpointScaled;
  8177. }
  8178. } elsif ($st eq "roomSensorControl.18") {
  8179. # Room Sensor and Control Unit (A5-10-18)
  8180. # [untested]
  8181. # $db[3] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8182. # $db[2] is the setpoint where 250 = 0 °C ... 0 = 40 °C
  8183. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8184. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8185. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8186. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8187. my $lux = $db[3] << 2;
  8188. if ($db[3] == 251) {$lux = "over range";}
  8189. my $setpoint = sprintf "%0.1f", 40 - $db[2] * 40 / 250;
  8190. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8191. my $fanSpeed;
  8192. if ((($db[0] & 0x70) >> 4) == 0) {
  8193. $fanSpeed = "auto";
  8194. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8195. $fanSpeed = "off";
  8196. } else {
  8197. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8198. }
  8199. my $presence;
  8200. if ($db[0] & 2) {
  8201. $presence = "disabled";
  8202. } else {
  8203. $presence = $db[0] & 1 ? "absent" : "present";
  8204. }
  8205. push @event, "3:brightness:$lux";
  8206. push @event, "3:fan:$fanSpeed";
  8207. push @event, "3:presence:$presence";
  8208. push @event, "3:setpoint:$setpoint";
  8209. push @event, "3:temperature:$temp";
  8210. push @event, "3:state:T: $temp B: $lux F: $fanSpeed SP: $setpoint P: $presence";
  8211. } elsif ($st eq "roomSensorControl.19") {
  8212. # Room Sensor and Control Unit (A5-10-19)
  8213. # [untested]
  8214. # $db[3] is the humidity where min 0x00 = 0 %rH, max 0xFA = 10 %rH
  8215. # $db[2] is the setpoint where 250 = 0 °C ... 0 = 40 °C
  8216. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8217. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8218. # $db[0]_bit_1 is Occupany Button where 0 = pressed, 1 = released
  8219. # $db[0]_bit_0 is Occupany enable where 0 = enabled, 1 = disabled
  8220. my $humi = $db[3] / 2.5;
  8221. my $setpoint = sprintf "%0.1f", 40 - $db[2] * 40 / 250;
  8222. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8223. my $fanSpeed;
  8224. if ((($db[0] & 0x70) >> 4) == 0) {
  8225. $fanSpeed = "auto";
  8226. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8227. $fanSpeed = "off";
  8228. } else {
  8229. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8230. }
  8231. my $presence;
  8232. if ($db[0] & 1) {
  8233. $presence = "disabled";
  8234. } else {
  8235. $presence = $db[0] & 2 ? "absent" : "present";
  8236. }
  8237. push @event, "3:fan:$fanSpeed";
  8238. push @event, "3:humidity:$humi";
  8239. push @event, "3:presence:$presence";
  8240. push @event, "3:setpoint:$setpoint";
  8241. push @event, "3:temperature:$temp";
  8242. push @event, "3:state:T: $temp H: $humi F: $fanSpeed SP: $setpoint P: $presence";
  8243. } elsif ($st eq "roomSensorControl.1A") {
  8244. # Room Sensor and Control Unit (A5-10-1A)
  8245. # [untested]
  8246. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8247. # $db[3] > 0xFA is error code
  8248. # $db[2] is the setpoint where 250 = 0 °C ... 0 = 40 °C
  8249. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8250. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8251. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8252. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8253. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8254. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8255. my $setpoint = sprintf "%0.1f", 40 - $db[2] * 40 / 250;
  8256. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8257. my $fanSpeed;
  8258. if ((($db[0] & 0x70) >> 4) == 0) {
  8259. $fanSpeed = "auto";
  8260. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8261. $fanSpeed = "off";
  8262. } else {
  8263. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8264. }
  8265. my $presence;
  8266. if ($db[0] & 2) {
  8267. $presence = "disabled";
  8268. } else {
  8269. $presence = $db[0] & 1 ? "absent" : "present";
  8270. }
  8271. push @event, "3:fan:$fanSpeed";
  8272. push @event, "3:presence:$presence";
  8273. push @event, "3:setpoint:$setpoint";
  8274. push @event, "3:temperature:$temp";
  8275. push @event, "3:voltage:$voltage";
  8276. push @event, "3:state:T: $temp F: $fanSpeed SP: $setpoint P: $presence U: $voltage";
  8277. } elsif ($st eq "roomSensorControl.1B") {
  8278. # Room Sensor and Control Unit (A5-10-1B)
  8279. # [untested]
  8280. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8281. # $db[3] > 0xFA is error code
  8282. # $db[2] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8283. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8284. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8285. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8286. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8287. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8288. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8289. my $lux = $db[2] << 2;
  8290. if ($db[2] == 251) {$lux = "over range";}
  8291. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8292. my $fanSpeed;
  8293. if ((($db[0] & 0x70) >> 4) == 0) {
  8294. $fanSpeed = "auto";
  8295. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8296. $fanSpeed = "off";
  8297. } else {
  8298. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8299. }
  8300. my $presence;
  8301. if ($db[0] & 2) {
  8302. $presence = "disabled";
  8303. } else {
  8304. $presence = $db[0] & 1 ? "absent" : "present";
  8305. }
  8306. push @event, "3:brightness:$lux";
  8307. push @event, "3:fan:$fanSpeed";
  8308. push @event, "3:presence:$presence";
  8309. push @event, "3:temperature:$temp";
  8310. push @event, "3:voltage:$voltage";
  8311. push @event, "3:state:T: $temp B: $lux F: $fanSpeed P: $presence U: $voltage";
  8312. } elsif ($st eq "roomSensorControl.1C") {
  8313. # Room Sensor and Control Unit (A5-10-1C)
  8314. # [untested]
  8315. # $db[3] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8316. # $db[2] is the illuminance setpoint where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8317. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8318. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8319. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8320. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8321. my $lux = $db[3] << 2;
  8322. if ($db[3] == 251) {$lux = "over range";}
  8323. my $setpoint = $db[2] << 2;
  8324. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8325. my $fanSpeed;
  8326. if ((($db[0] & 0x70) >> 4) == 0) {
  8327. $fanSpeed = "auto";
  8328. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8329. $fanSpeed = "off";
  8330. } else {
  8331. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8332. }
  8333. my $presence;
  8334. if ($db[0] & 2) {
  8335. $presence = "disabled";
  8336. } else {
  8337. $presence = $db[0] & 1 ? "absent" : "present";
  8338. }
  8339. push @event, "3:brightness:$lux";
  8340. push @event, "3:fan:$fanSpeed";
  8341. push @event, "3:presence:$presence";
  8342. push @event, "3:setpoint:$setpoint";
  8343. push @event, "3:temperature:$temp";
  8344. push @event, "3:state:T: $temp B: $lux F: $fanSpeed SP: $setpoint P: $presence";
  8345. } elsif ($st eq "roomSensorControl.1D") {
  8346. # Room Sensor and Control Unit (A5-10-1D)
  8347. # [untested]
  8348. # $db[3] is the humidity where min 0x00 = 0 %rH, max 0xFA = 10 %rH
  8349. # $db[2] is the humidity setpoint where min 0x00 = 0 %rH, max 0xFA = 10 %rH
  8350. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8351. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8352. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8353. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8354. my $humi = sprintf "%d", $db[3] / 2.5;
  8355. my $setpoint = $db[2] / 2.5;
  8356. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8357. my $fanSpeed;
  8358. if ((($db[0] & 0x70) >> 4) == 0) {
  8359. $fanSpeed = "auto";
  8360. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8361. $fanSpeed = "off";
  8362. } else {
  8363. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8364. }
  8365. my $presence;
  8366. if ($db[0] & 2) {
  8367. $presence = "disabled";
  8368. } else {
  8369. $presence = $db[0] & 1 ? "absent" : "present";
  8370. }
  8371. push @event, "3:fan:$fanSpeed";
  8372. push @event, "3:humidity:$humi";
  8373. push @event, "3:presence:$presence";
  8374. push @event, "3:setpoint:$setpoint";
  8375. push @event, "3:temperature:$temp";
  8376. push @event, "3:state:T: $temp H: $humi F: $fanSpeed SP: $setpoint P: $presence";
  8377. } elsif ($st eq "roomSensorControl.1F") {
  8378. # Room Sensor and Control Unit (A5-10-1F)
  8379. # [untested]
  8380. # $db[3] is the fan speed
  8381. # $db[2] is the setpoint where 0 = 0 ... 255 = 255
  8382. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8383. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8384. # $db[0]_bit_6 ... $db[0]_bit_4 are flags
  8385. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8386. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8387. my $fanSpeed = "unknown";
  8388. if ($db[0] & 0x10) {
  8389. $fanSpeed = 3;
  8390. $fanSpeed = 2 if ($db[3] >= 145);
  8391. $fanSpeed = 1 if ($db[3] >= 165);
  8392. $fanSpeed = 0 if ($db[3] >= 190);
  8393. $fanSpeed = "auto" if ($db[3] >= 210);
  8394. }
  8395. my $setpoint = "unknown";
  8396. $setpoint = $db[2] if ($db[0] & 0x20);
  8397. my $temp = "unknown";
  8398. $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250 if ($db[0] & 0x40);
  8399. my $presence = "unknown";
  8400. $presence = "absent" if (!($db[0] & 2));
  8401. $presence = "present" if (!($db[0] & 1));
  8402. push @event, "3:fan:$fanSpeed";
  8403. push @event, "3:presence:$presence";
  8404. push @event, "3:setpoint:$setpoint";
  8405. push @event, "3:temperature:$temp";
  8406. push @event, "3:state:T: $temp F: $fanSpeed SP: $setpoint P: $presence";
  8407. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[2], 0, 255);
  8408. if (defined $setpointScaled) {
  8409. push @event, "3:setpointScaled:" . $setpointScaled;
  8410. }
  8411. } elsif ($st eq "roomSensorControl.20") {
  8412. # Room Operation Panel (A5-10-20, A5-10-21)
  8413. # [untested]
  8414. # $db[3] is the setpoint where 0 = 0 ... 255 = 255
  8415. # $db[2] is the humidity setpoint where min 0x00 = 0 %rH, max 0xFA = 100 %rH
  8416. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8417. # $db[0]_bit_6 ... $db[0]_bit_5 is setpoint mode
  8418. # $db[0]_bit_4 is battery state 0 = ok, 1 = low
  8419. # $db[0]_bit_0 is user activity where 0 = no, 1 = yes
  8420. my $humi = sprintf "%d", $db[2] / 2.5;
  8421. my $setpoint = $db[3];
  8422. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8423. my $setpointMode;
  8424. if ((($db[0] & 0x60) >> 5) == 3) {
  8425. $setpointMode = "reserved";
  8426. } elsif ((($db[0] & 0x60) >> 5) == 2) {
  8427. $setpointMode = "auto";
  8428. } elsif ((($db[0] & 0x60) >> 1) == 1){
  8429. $setpointMode = "frostProtection";
  8430. } else {
  8431. $setpointMode = "setpoint";
  8432. }
  8433. my $battery = ($db[0] & 0x10) ? "low" : "ok";
  8434. push @event, "3:activity:" . ($db[0] & 1 ? "yes" : "no");
  8435. push @event, "3:battery:$battery";
  8436. push @event, "3:humidity:$humi";
  8437. push @event, "3:setpoint:$setpoint";
  8438. push @event, "3:setpointMode:$setpointMode";
  8439. push @event, "3:temperature:$temp";
  8440. push @event, "3:state:T: $temp H: $humi SP: $setpoint B: $battery";
  8441. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[3], 0, 255);
  8442. if (defined $setpointScaled) {
  8443. push @event, "3:setpointScaled:" . $setpointScaled;
  8444. }
  8445. } elsif ($st eq "roomSensorControl.22") {
  8446. # Room Operation Panel (A5-10-22, A5-10-23)
  8447. my $setpoint = $db[3];
  8448. my $humi = sprintf "%d", $db[2] / 2.5;
  8449. my $temp = sprintf "%0.1f", $db[1] * 40 / 250;
  8450. my $fanSpeed;
  8451. if ((($db[0] & 0xE0) >> 5) == 4) {
  8452. $fanSpeed = 3;
  8453. } elsif ((($db[0] & 0xE0) >> 5) == 3) {
  8454. $fanSpeed = 2;
  8455. } elsif ((($db[0] & 0xE0) >> 5) == 2) {
  8456. $fanSpeed = 1;
  8457. } elsif ((($db[0] & 0xE0) >> 5) == 1){
  8458. $fanSpeed = "off";
  8459. } else {
  8460. $fanSpeed = "auto";
  8461. }
  8462. my $occupancy = ($db[0] & 1) ? "occupied" : "unoccupied";
  8463. push @event, "3:occupancy:$occupancy";
  8464. push @event, "3:humidity:$humi";
  8465. push @event, "3:setpoint:$setpoint";
  8466. push @event, "3:fanSpeed:$fanSpeed";
  8467. push @event, "3:temperature:$temp";
  8468. push @event, "3:state:T: $temp H: $humi SP: $setpoint F: $fanSpeed O: $occupancy";
  8469. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[3], 0, 255);
  8470. if (defined $setpointScaled) {
  8471. push @event, "3:setpointScaled:" . $setpointScaled;
  8472. }
  8473. } elsif ($st eq "tempHumiSensor.02") {
  8474. # Temperatur and Humidity Sensor(EEP A5-04-02)
  8475. # [Eltako FAFT60, FIFT63AP]
  8476. # $db[3] is the voltage where 0x59 = 2.5V ... 0x9B = 4V, only at Eltako
  8477. # $db[2] is the humidity where 0x00 = 0%rH ... 0xFA = 100%rH
  8478. # $db[1] is the temperature where 0x00 = -20°C ... 0xFA = +60°C
  8479. my $humi = sprintf "%d", $db[2] / 2.5;
  8480. my $temp = sprintf "%0.1f", -20 + $db[1] * 80 / 250;
  8481. my $battery = "unknown";
  8482. if ($manufID eq "00D") {
  8483. # Eltako sensor
  8484. my $voltage = sprintf "%0.1f", $db[3] * 6.58 / 255;
  8485. my $energyStorage = "unknown";
  8486. if ($db[3] <= 0x58) {
  8487. $energyStorage = "empty";
  8488. $battery = "low";
  8489. }
  8490. elsif ($db[3] <= 0xDC) {
  8491. $energyStorage = "charged";
  8492. $battery = "ok";
  8493. }
  8494. else {
  8495. $energyStorage = "full";
  8496. $battery = "ok";
  8497. }
  8498. push @event, "3:battery:$battery";
  8499. push @event, "3:energyStorage:$energyStorage";
  8500. push @event, "3:voltage:$voltage";
  8501. }
  8502. push @event, "3:state:T: $temp H: $humi B: $battery";
  8503. push @event, "3:humidity:$humi";
  8504. push @event, "3:temperature:$temp";
  8505. } elsif ($st eq "tempHumiSensor.03") {
  8506. # Temperatur and Humidity Sensor(EEP A5-04-03)
  8507. # [untested]
  8508. # $db[3] is the humidity where 0x00 = 0%rH ... 0xFF = 100%rH
  8509. # $db[2] .. $db[1] is the temperature where 0x00 = -20°C ... 0x3FF = +60°C
  8510. my $humi = sprintf "%d", $db[3] / 2.55;
  8511. my $temp = sprintf "%0.1f", -20 + ($db[2] << 8 | $db[1]) * 80 / 1023;
  8512. push @event, "3:state:T: $temp H: $humi";
  8513. push @event, "3:humidity:$humi";
  8514. push @event, "3:temperature:$temp";
  8515. push @event, "3:telegramType:" . ($db[0] & 1 ? "event" : "heartbeat");
  8516. } elsif ($st eq "baroSensor.01") {
  8517. # Barometric Sensor(EEP A5-04-03)
  8518. # [untested]
  8519. # $db[3] .. $db[2] is the barometric where 0x00 = 500 hPa ... 0x3FF = 1150 hPa
  8520. my $baro = sprintf "%d", 500 + ($db[2] << 8 | $db[1]) * 650 / 1023;
  8521. push @event, "3:state:$baro";
  8522. push @event, "3:airPressure:$baro";
  8523. push @event, "3:telegramType:" . ($db[0] & 1 ? "event" : "heartbeat");
  8524. } elsif ($st eq "lightSensor.01") {
  8525. # Light Sensor (EEP A5-06-01)
  8526. # [Eltako FAH60, FAH63, FIH63, Thermokon SR65 LI, untested]
  8527. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8528. # $db[3] is the low illuminance for Eltako devices where
  8529. # min 0x00 = 0 lx, max 0xFF = 100 lx, if $db[2] = 0
  8530. # $db[2] is the illuminance (ILL2) where min 0x00 = 300 lx, max 0xFF = 30000 lx
  8531. # $db[1] is the illuminance (ILL1) where min 0x00 = 600 lx, max 0xFF = 60000 lx
  8532. # $db[0]_bit_0 is Range select where 0 = ILL1, 1 = ILL2
  8533. my $lux;
  8534. my $voltage = "unknown";
  8535. if ($manufID eq "00D") {
  8536. if($db[2] == 0) {
  8537. $lux = sprintf "%d", $db[3] * 100 / 255;
  8538. } else {
  8539. $lux = sprintf "%d", $db[2] * 116.48 + 300;
  8540. }
  8541. } else {
  8542. $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8543. if($db[0] & 1) {
  8544. $lux = sprintf "%d", $db[2] * 116.48 + 300;
  8545. } else {
  8546. $lux = sprintf "%d", $db[1] * 232.94 + 600;
  8547. }
  8548. push @event, "3:voltage:$voltage";
  8549. }
  8550. push @event, "3:brightness:$lux";
  8551. push @event, "3:state:$lux";
  8552. } elsif ($st eq "lightSensor.02") {
  8553. # Light Sensor (EEP A5-06-02)
  8554. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8555. # $db[2] is the illuminance (ILL2) where min 0x00 = 0 lx, max 0xFF = 510 lx
  8556. # $db[1] is the illuminance (ILL1) where min 0x00 = 0 lx, max 0xFF = 1020 lx
  8557. # $db[0]_bit_0 is Range select where 0 = ILL1, 1 = ILL2
  8558. my $lux;
  8559. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8560. if($db[0] & 1) {
  8561. $lux = $db[2] << 1;
  8562. } else {
  8563. $lux = $db[1] << 2;
  8564. }
  8565. push @event, "3:voltage:$voltage";
  8566. push @event, "3:brightness:$lux";
  8567. push @event, "3:state:$lux";
  8568. } elsif ($st eq "lightSensor.03") {
  8569. # Light Sensor (EEP A5-06-03)
  8570. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8571. # $db[3] > 0xFA is error code
  8572. # $db[2]_bit_7 ... $db[1]_bit_6 is the illuminance where min 0x000 = 0 lx, max 0x3E8 = 1000 lx
  8573. my $lux = $db[2] << 2 | $db[1] >> 6;
  8574. if ($lux == 1001) {$lux = "over range";}
  8575. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8576. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8577. push @event, "3:voltage:$voltage";
  8578. push @event, "3:brightness:$lux";
  8579. push @event, "3:state:$lux";
  8580. } elsif ($st eq "lightSensor.04") {
  8581. # Light Sensor (EEP A5-06-04)
  8582. my $temperature;
  8583. if ($db[0] & 2) {
  8584. $temperature = sprintf "%0.1f", $db[3] * 80 / 255 - 20;
  8585. push @event, "3:temperature:$temperature";
  8586. } else {
  8587. $temperature = '-';
  8588. CommandDeleteReading(undef, "$name temperature");
  8589. }
  8590. my $brightness;
  8591. if ($db[0] & 1) {
  8592. $brightness = $db[2] << 8 | $db[1];
  8593. push @event, "3:brightness:$brightness";
  8594. } else {
  8595. $brightness = '-';
  8596. CommandDeleteReading(undef, "$name brightness");
  8597. }
  8598. my $energyStorage = sprintf "%d", ($db[0] >> 4) * 100 / 15;
  8599. my $battery;
  8600. if ($energyStorage <= 6) {
  8601. $battery = 'low';
  8602. push @event, "3:battery:low";
  8603. push @event, "3:energyStorage:$energyStorage";
  8604. } else {
  8605. $battery = 'ok';
  8606. push @event, "3:battery:ok";
  8607. push @event, "3:energyStorage:$energyStorage";
  8608. }
  8609. push @event, "3:state:T: $temperature E: $brightness B: $battery";
  8610. } elsif ($st eq "lightSensor.05") {
  8611. # Light Sensor (EEP A5-06-05)
  8612. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8613. # $db[2] is the illuminance (ILL2) where min 0x00 = 0 lx, max 0xFF = 5100 lx
  8614. # $db[1] is the illuminance (ILL1) where min 0x00 = 0 lx, max 0xFF = 1020000 lx
  8615. # $db[0]_bit_0 is Range select where 0 = ILL1, 1 = ILL2
  8616. my $lux;
  8617. if($db[0] & 1) {
  8618. $lux = sprintf "%d", $db[2] * 20;
  8619. } else {
  8620. $lux = sprintf "%d", $db[1] * 40;
  8621. }
  8622. push @event, "3:voltage:" . sprintf "%0.1f", $db[3] * 0.02;
  8623. push @event, "3:brightness:$lux";
  8624. push @event, "3:state:$lux";
  8625. } elsif ($st eq "occupSensor.01") {
  8626. # Occupancy Sensor (EEP A5-07-01)
  8627. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8628. # $db[3] > 0xFA is error code
  8629. # $db[2] is solar panel current where =0 uA ... 0xFF = 127 uA
  8630. # $db[1] is PIR Status (motion) where 0 ... 127 = off, 128 ... 255 = on
  8631. my $motion = "off";
  8632. if ($db[1] >= 128) {$motion = "on";}
  8633. if ($db[0] & 1) {push @event, "3:voltage:" . sprintf "%0.1f", $db[3] * 0.02;}
  8634. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8635. if ($manufID eq "00B") {
  8636. push @event, "3:current:" . sprintf "%0.1f", $db[2] / 2;
  8637. if ($db[0] & 2) {
  8638. push @event, "3:sensorType:ceiling";
  8639. } else {
  8640. push @event, "3:sensorType:wall";
  8641. }
  8642. }
  8643. if ($model eq "tracker") {
  8644. @{$hash->{helper}{motionTimer}} = ($hash, 'motion', 'off', 1, 5);
  8645. @{$hash->{helper}{stateTimer}} = ($hash, 'state', 'off', 1, 5);
  8646. RemoveInternalTimer($hash->{helper}{motionTimer});
  8647. RemoveInternalTimer($hash->{helper}{stateTimer});
  8648. InternalTimer(gettimeofday() + AttrVal($name, 'trackerWakeUpCycle', 30) * 1.1, 'EnOcean_readingsSingleUpdate', $hash->{helper}{motionTimer}, 0);
  8649. InternalTimer(gettimeofday() + AttrVal($name, 'trackerWakeUpCycle', 30) * 1.1, 'EnOcean_readingsSingleUpdate', $hash->{helper}{stateTimer}, 0);
  8650. }
  8651. if (!exists($hash->{helper}{lastVoltage}) || $hash->{helper}{lastVoltage} != $db[3]) {
  8652. push @event, "3:battery:" . ($db[3] * 0.02 > 2.8 ? "ok" : "low");
  8653. $hash->{helper}{lastVoltage} = $db[3];
  8654. }
  8655. push @event, "3:button:" . ($db[0] & 4 ? "released" : "pressed") if ($manufID eq "7FF");
  8656. push @event, "3:motion:$motion";
  8657. push @event, "3:state:$motion";
  8658. } elsif ($st eq "occupSensor.02") {
  8659. # Occupancy Sensor (EEP A5-07-02)
  8660. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8661. # $db[3] > 0xFA is error code
  8662. # $db[0]_bit_7 is PIR Status (motion) where 0 = off, 1 = on
  8663. my $motion = $db[0] >> 7 ? "on" : "off";
  8664. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8665. push @event, "3:battery:" . ($db[3] * 0.02 > 2.9 ? "ok" : "low");
  8666. push @event, "3:motion:$motion";
  8667. push @event, "3:voltage:" . sprintf "%0.1f", $db[3] * 0.02;
  8668. push @event, "3:state:$motion";
  8669. } elsif ($st eq "occupSensor.03") {
  8670. # Occupancy Sensor (EEP A5-07-03)
  8671. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8672. # $db[3] > 0xFA is error code
  8673. # $db[2]_bit_7 ... $db[1]_bit_6 is the illuminance where min 0x000 = 0 lx, max 0x3E8 = 1000 lx
  8674. # $db[0]_bit_7 is PIR Status (motion) where 0 = off, 1 = on
  8675. my $motion = $db[0] >> 7 ? "on" : "off";
  8676. my $lux = $db[2] << 2 | $db[1] >> 6;
  8677. if ($lux == 1001) {$lux = "over range";}
  8678. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8679. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8680. push @event, "3:battery:" . ($db[3] * 0.02 > 2.9 ? "ok" : "low");
  8681. push @event, "3:brightness:$lux";
  8682. push @event, "3:motion:$motion";
  8683. push @event, "3:voltage:$voltage";
  8684. push @event, "3:state:M: $motion E: $lux U: $voltage";
  8685. } elsif ($st =~ m/^lightTempOccupSensor/) {
  8686. # Light, Temperatur and Occupancy Sensor (EEP A5-08-01 ... A5-08-03)
  8687. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8688. # $db[2] is the illuminance where min 0x00 = 0 lx, max 0xFF = 510 lx, 1020 lx, (2048 lx)
  8689. # $db[1] is the temperature whrere 0x00 = 0 °C ... 0xFF = 51 °C or -30 °C ... 50°C
  8690. # $db[0]_bit_1 is PIR Status (motion) where 0 = on, 1 = off
  8691. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8692. my $lux;
  8693. my $temp;
  8694. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8695. my $motion = $db[0] & 2 ? "off" : "on";
  8696. my $presence = $db[0] & 1 ? "absent" : "present";
  8697. if ($st eq "lightTempOccupSensor.01") {
  8698. # Light, Temperatur and Occupancy Sensor (EEP A5-08-01)
  8699. # [Eltako FABH63, FBH55, FBH63, FIBH63]
  8700. if ($manufID eq "00D") {
  8701. $lux = sprintf "%d", $db[2] * 2048 / 255;
  8702. push @event, "3:state:M: $motion E: $lux";
  8703. } else {
  8704. $lux = $db[2] << 1;
  8705. $temp = sprintf "%0.1f", $db[1] * 0.2;
  8706. push @event, "3:state:M: $motion E: $lux P: $presence T: $temp U: $voltage";
  8707. push @event, "3:presence:$presence";
  8708. push @event, "3:temperature:$temp";
  8709. push @event, "3:voltage:$voltage";
  8710. }
  8711. } elsif ($st eq "lightTempOccupSensor.02") {
  8712. # Light, Temperatur and Occupancy Sensor (EEP A5-08-02)
  8713. $lux = $db[2] << 2;
  8714. $temp = sprintf "%0.1f", $db[1] * 0.2;
  8715. push @event, "3:state:M: $motion E: $lux P: $presence T: $temp U: $voltage";
  8716. push @event, "3:presence:$presence";
  8717. push @event, "3:temperature:$temp";
  8718. push @event, "3:voltage:$voltage";
  8719. } elsif ($st eq "lightTempOccupSensor.03") {
  8720. # Light, Temperatur and Occupancy Sensor (EEP A5-08-03)
  8721. $lux = $db[2] * 6;
  8722. $temp = sprintf "%0.1f", -30 + $db[1] * 80 / 255;
  8723. push @event, "3:state:M: $motion E: $lux P: $presence T: $temp U: $voltage";
  8724. push @event, "3:presence:$presence";
  8725. push @event, "3:temperature:$temp";
  8726. push @event, "3:voltage:$voltage";
  8727. }
  8728. push @event, "3:brightness:$lux";
  8729. push @event, "3:motion:$motion";
  8730. } elsif ($st eq "lightCtrlState.01") {
  8731. # Lighting Controller State (EEP A5-11-01)
  8732. # $db[3] is the illumination where 0x00 = 0 lx ... 0xFF = 510 lx
  8733. # $db[2] is the illumination Setpoint where 0x00 = 0 ... 0xFF = 255
  8734. # $db[1] is the Dimming Output Level where 0x00 = 0 ... 0xFF = 255
  8735. # $db[0]_bit_7 is the Repeater state where 0 = disabled, 1 = enabled
  8736. # $db[0]_bit_6 is the Power Relay Timer state where 0 = disabled, 1 = enabled
  8737. # $db[0]_bit_5 is the Daylight Harvesting state where 0 = disabled, 1 = enabled
  8738. # $db[0]_bit_4 is the Dimming mode where 0 = switching, 1 = dimming
  8739. # $db[0]_bit_2 is the Magnet Contact state where 0 = open, 1 = closed
  8740. # $db[0]_bit_1 is the Occupancy (prensence) state where 0 = absent, 1 = present
  8741. # $db[0]_bit_0 is the Power Relay state where 0 = off, 1 = on
  8742. push @event, "3:brightness:" . ($db[3] << 1);
  8743. push @event, "3:illum:$db[2]";
  8744. push @event, "3:dim:$db[1]";
  8745. push @event, "3:powerRelayTimer:" . ($db[0] & 0x80 ? "enabled" : "disabled");
  8746. push @event, "3:repeater:" . ($db[0] & 0x40 ? "enabled" : "disabled");
  8747. push @event, "3:daylightHarvesting:" . ($db[0] & 0x20 ? "enabled" : "disabled");
  8748. push @event, "3:mode:" . ($db[0] & 0x10 ? "dimming" : "switching");
  8749. push @event, "3:contact:" . ($db[0] & 4 ? "closed" : "open");
  8750. push @event, "3:presence:" . ($db[0] & 2 ? "present" : "absent");
  8751. push @event, "3:powerSwitch:" . ($db[0] & 1 ? "on" : "off");
  8752. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  8753. } elsif ($st eq "tempCtrlState.01") {
  8754. # Temperature Controller Output (EEP A5-11-02)
  8755. # $db[3] is the Control Variable where 0x00 = 0 % ... 0xFF = 100 %
  8756. # $db[2] is the Fan Stage
  8757. # $db[1] is the Actual Setpoint where 0x00 = 0 °C ... 0xFF = 51.2 °C
  8758. # $db[0]_bit_7 is the Alarm state where 0 = no, 1 = yes
  8759. # $db[0]_bit_6 ... $db[0]_bit_5 is the Controller Mode
  8760. # $db[0]_bit_4 is the Controller State where 0 = auto, 1 = override
  8761. # $db[0]_bit_2 is the Energy hold-off where 0 = normal, 1 = hold-off
  8762. # $db[0]_bit_1 ... $db[0]_bit_0is the Occupancy (prensence) state where 0 = present
  8763. # 1 = absent, 3 = standby, 4 = frost
  8764. push @event, "3:controlVar:" . sprintf "%d", $db[3] * 100 / 255;
  8765. if (($db[2] & 3) == 0) {
  8766. push @event, "3:fan:0";
  8767. } elsif (($db[2] & 3) == 1){
  8768. push @event, "3:fan:1";
  8769. } elsif (($db[2] & 3) == 2){
  8770. push @event, "3:fan:2";
  8771. } elsif (($db[2] & 3) == 3){
  8772. push @event, "3:fan:3";
  8773. } elsif ($db[2] == 255){
  8774. push @event, "3:fan:unknown";
  8775. }
  8776. push @event, "3:fanMode:" . ($db[2] & 0x10 ? "auto" : "manual");
  8777. my $setpointTemp = sprintf "%0.1f", $db[1] * 0.2;
  8778. push @event, "3:setpointTemp:$setpointTemp";
  8779. push @event, "3:alarm:" . ($db[0] & 1 ? "on" : "off");
  8780. my $controllerMode = ($db[0] & 0x60) >> 5;
  8781. if ($controllerMode == 0) {
  8782. push @event, "3:controllerMode:auto";
  8783. } elsif ($controllerMode == 1) {
  8784. push @event, "3:controllerMode:heating";
  8785. } elsif ($controllerMode == 2) {
  8786. push @event, "3:controllerMode:cooling";
  8787. } elsif ($controllerMode == 3) {
  8788. push @event, "3:controllerMode:off";
  8789. }
  8790. push @event, "3:controllerState:" . ($db[0] & 0x10 ? "override" : "auto");
  8791. push @event, "3:energyHoldOff:" . ($db[0] & 4 ? "holdoff" : "normal");
  8792. if (($db[0] & 3) == 0) {
  8793. push @event, "3:presence:present";
  8794. } elsif (($db[0] & 3) == 1){
  8795. push @event, "3:presence:absent";
  8796. } elsif (($db[0] & 3) == 2){
  8797. push @event, "3:presence:standby";
  8798. } elsif (($db[0] & 3) == 3){
  8799. push @event, "3:presence:frost";
  8800. }
  8801. push @event, "3:state:$setpointTemp";
  8802. } elsif ($st eq "shutterCtrlState.01") {
  8803. # Blind Status (EEP A5-11-03)
  8804. # $db[3] is the Shutter Position where 0 = 0 % ... 100 = 100 %
  8805. # $db[2]_bit_7 is the Angle sign where 0 = positive, 1 = negative
  8806. # $db[2]_bit_6 ... $db[2]_bit_0 where 0 = 0° ... 90 = 180°
  8807. # $db[1]_bit_7 is the Position Value Flag where 0 = no available, 1 = available
  8808. # $db[1]_bit_6 is the Angle Value Flag where 0 = no available, 1 = available
  8809. # $db[1]_bit_5 ... $db[1]_bit_4 is the Error State (alarm)
  8810. # $db[1]_bit_3 ... $db[1]_bit_2 is the End-position State
  8811. # $db[1]_bit_1 ... $db[1]_bit_0 is the Shutter State
  8812. # $db[0]_bit_7 is the Service Mode where 0 = no, 1 = yes
  8813. # $db[0]_bit_6 is the Position Mode where 0 = normal, 1 = inverse
  8814. if ($db[1] & 0x80) {
  8815. push @event, "3:position:" . $db[3];
  8816. }
  8817. my $anglePos = ($db[2] & 0x7F) << 1;
  8818. if ($db[2] & 0x80) {$anglePos *= -1;}
  8819. if ($db[1] & 0x40) {
  8820. push @event, "3:anglePos:" . $anglePos;
  8821. }
  8822. my $alarm = ($db[1] & 0x30) >> 4;
  8823. if ($alarm == 0) {
  8824. push @event, "3:alarm:off";
  8825. } elsif ($alarm == 1){
  8826. push @event, "3:alarm:no_endpoints_defined";
  8827. } elsif ($alarm == 2){
  8828. push @event, "3:alarm:on";
  8829. } elsif ($alarm == 3){
  8830. push @event, "3:alarm:not_used";
  8831. }
  8832. my $endPosition = ($db[1] & 0x0C) >> 2;
  8833. if ($endPosition == 0) {
  8834. push @event, "3:endPosition:not_available";
  8835. push @event, "3:state:not_available";
  8836. } elsif ($endPosition == 1) {
  8837. push @event, "3:endPosition:not_reached";
  8838. push @event, "3:state:not_reached";
  8839. } elsif ($endPosition == 2) {
  8840. push @event, "3:endPosition:open";
  8841. push @event, "3:state:open";
  8842. } elsif ($endPosition == 3){
  8843. push @event, "3:endPosition:closed";
  8844. push @event, "3:state:closed";
  8845. }
  8846. my $shutterState = $db[1] & 3;
  8847. if (($db[1] & 3) == 0) {
  8848. push @event, "3:shutterState:not_available";
  8849. } elsif (($db[1] & 3) == 1) {
  8850. push @event, "3:shutterState:stopped";
  8851. } elsif (($db[1] & 3) == 2){
  8852. push @event, "3:shutterState:opens";
  8853. } elsif (($db[1] & 3) == 3){
  8854. push @event, "3:shutterState:closes";
  8855. }
  8856. push @event, "3:serviceOn:" . ($db[0] & 0x80 ? "yes" : "no");
  8857. push @event, "3:positionMode:" . ($db[0] & 0x40 ? "inverse" : "normal");
  8858. } elsif ($st eq "lightCtrlState.02") {
  8859. # Extended Lighting Status (EEP A5-11-04)
  8860. # $db[3] the contents of the variable depends on the parameter mode
  8861. # $db[2] the contents of the variable depends on the parameter mode
  8862. # $db[1] the contents of the variable depends on the parameter mode
  8863. # $db[0]_bit_7 is the Service Mode where 0 = no, 1 = yes
  8864. # $db[0]_bit_6 is the operating hours flag where 0 = not_available, 1 = available
  8865. # $db[0]_bit_5 ... $db[0]_bit_4 is the Error State (alarm)
  8866. # $db[0]_bit_2 ... $db[0]_bit_1 is the parameter mode
  8867. # $db[0]_bit_0 is the lighting status where 0 = off, 1 = on
  8868. push @event, "3:serviceOn:" . ($db[1] & 0x80 ? "yes" : "no");
  8869. my $alarm = ($db[0] & 0x30) >> 4;
  8870. if ($alarm == 0) {
  8871. push @event, "3:alarm:off";
  8872. } elsif ($alarm == 1){
  8873. push @event, "3:alarm:lamp_failure";
  8874. } elsif ($alarm == 2){
  8875. push @event, "3:alarm:internal_failure";
  8876. } elsif ($alarm == 3){
  8877. push @event, "3:alarm:external_periphery_failure";
  8878. }
  8879. my $mode = ($db[0] & 6) >> 1;
  8880. if ($mode == 0) {
  8881. # dimmer value and lamp operating hours
  8882. push @event, "3:dim:$db[3]";
  8883. if ($db[0] & 40) {
  8884. push @event, "3:lampOpHours:" . ($db[2] << 8 | $db[1]);
  8885. } else {
  8886. push @event, "3:lampOpHours:unknown";
  8887. }
  8888. } elsif ($mode == 1){
  8889. # RGB value
  8890. push @event, "3:red:$db[3]";
  8891. push @event, "3:green:$db[2]";
  8892. push @event, "3:blue:$db[1]";
  8893. push @event, "3:rgb:" . substr($data, 0, 6);
  8894. } elsif ($mode == 2){
  8895. # energy metering value
  8896. my @measureUnit = ("mW", "W", "kW", "MW", "Wh", "kWh", "MWh", "GWh",
  8897. "mA", "A", "mV", "V");
  8898. if ($db[1] < 4) {
  8899. push @event, "3:power:" . ($db[3] << 8 | $db[2]);
  8900. push @event, "3:powerUnit:" . $measureUnit[$db[1]];
  8901. } elsif ($db[1] < 8) {
  8902. push @event, "3:energy:" . ($db[3] << 8 | $db[2]);
  8903. push @event, "3:energyUnit:" . $measureUnit[$db[1]];
  8904. } elsif ($db[1] == 8) {
  8905. push @event, "3:current:" . ($db[3] << 8 | $db[2]);
  8906. push @event, "3:currentUnit:" . $measureUnit[$db[1]];
  8907. } elsif ($db[1] == 9) {
  8908. push @event, "3:current:" . sprintf "%0.1f", ($db[3] << 8 | $db[2]) / 10;
  8909. push @event, "3:currentUnit:" . $measureUnit[$db[1]];
  8910. } elsif ($db[1] == 10) {
  8911. push @event, "3:voltage:" . ($db[3] << 8 | $db[2]);
  8912. push @event, "3:voltageUnit:" . $measureUnit[$db[1]];
  8913. } elsif ($db[1] == 11) {
  8914. push @event, "3:voltage:" . sprintf "%0.1f", ($db[3] << 8 | $db[2]) / 10;
  8915. push @event, "3:voltageUnit:" . $measureUnit[$db[1]];
  8916. } else {
  8917. push @event, "3:measuredValue:" . ($db[3] << 8 | $db[2]);
  8918. push @event, "3:measureUnit:unknown";
  8919. }
  8920. } elsif ($mode == 3){
  8921. # not used
  8922. }
  8923. push @event, "3:powerSwitch:" . ($db[0] & 1 ? "on" : "off");
  8924. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  8925. } elsif ($st eq "switch.05") {
  8926. # Dual Channel Switch Actuator
  8927. # (A5-11-05)
  8928. if ($db[0] & 1) {
  8929. push @event, "3:workingMode:" . (($db[0] & 0x70) >> 4);
  8930. push @event, "3:channel1:" . ($db[0] & 2 ? "on" : "off");
  8931. push @event, "3:channel2:" . ($db[0] & 4 ? "on" : "off");
  8932. push @event, "3:state:1: " . ($db[0] & 2 ? "on" : "off") . " 2: " . ($db[0] & 4 ? "on" : "off");
  8933. }
  8934. } elsif ($st =~ m/^autoMeterReading\.0[0-3]$/ || $st eq "actuator.01" && $manufID eq "033") {
  8935. # Automated meter reading (AMR) (EEP A5-12-00 ... A5-12-03)
  8936. # $db[3] (MSB) + $db[2] + $db[1] (LSB) is the Meter reading
  8937. # $db[0]_bit_7 ... $db[0]_bit_4 is the Measurement channel
  8938. # $db[0]_bit_2 is the Data type where 0 = cumulative value, 1 = current value
  8939. # $db[0]_bit_1 ... $db[0]_bit_0 is the Divisor where 0 = x/1, 1 = x/10,
  8940. # 2 = x/100, 3 = x/1000
  8941. my $dataType = ($db[0] & 4) >> 2;
  8942. my $divisor = $db[0] & 3;
  8943. my $meterReading;
  8944. if ($divisor == 3) {
  8945. $meterReading = sprintf "%.3f", ($db[3] << 16 | $db[2] << 8 | $db[1]) / 1000;
  8946. } elsif ($divisor == 2) {
  8947. $meterReading = sprintf "%.2f", ($db[3] << 16 | $db[2] << 8 | $db[1]) / 100;
  8948. } elsif ($divisor == 1) {
  8949. $meterReading = sprintf "%.1f", ($db[3] << 16 | $db[2] << 8 | $db[1]) / 10;
  8950. } else {
  8951. $meterReading = $db[3] << 16 | $db[2] << 8 | $db[1];
  8952. }
  8953. my $channel = $db[0] >> 4;
  8954. if ($st eq "autoMeterReading.00") {
  8955. # Automated meter reading (AMR), Counter (EEP A5-12-01)
  8956. # [Thermokon SR-MI-HS, untested]
  8957. if ($dataType == 1) {
  8958. # current value
  8959. push @event, "3:currentValue" . sprintf('%02d', $channel) . ":$meterReading";
  8960. push @event, "3:state:$meterReading";
  8961. } else {
  8962. # cumulative counter
  8963. push @event, "3:counter" . sprintf('%02d', $channel) . ":$meterReading";
  8964. }
  8965. } elsif ($st eq "autoMeterReading.01" || $st eq "actuator.01" && $manufID eq "033") {
  8966. # Automated meter reading (AMR), Electricity (EEP A5-12-01)
  8967. # [Eltako FSS12, FWZ12, DSZ14DRS, DSZ14WDRS, DWZ61]
  8968. # $db[0]_bit_7 ... $db[0]_bit_4 is the Tariff info
  8969. # $db[0]_bit_2 is the Data type where 0 = cumulative value kWh,
  8970. # 1 = current value W
  8971. if ($db[0] == 0x8F && $manufID eq "00D") {
  8972. # Eltako, read meter serial number
  8973. my $serialNumber;
  8974. if ($db[1] == 0) {
  8975. # first 2 digits of the serial number
  8976. $serialNumber = substr(ReadingsVal($name, "serialNumber", "S-------"), 4, 4);
  8977. $serialNumber = sprintf "S-%01x%01x%4s", $db[3] >> 4, $db[3] & 0x0F, $serialNumber;
  8978. } else {
  8979. # last 4 digits of the serial number
  8980. $serialNumber = substr(ReadingsVal($name, "serialNumber", "S---"), 0, 4);
  8981. $serialNumber = sprintf "%4s%01x%01x%01x%01x", $serialNumber,
  8982. $db[2] >> 4, $db[2] & 0x0F, $db[3] >> 4, $db[3] & 0x0F;
  8983. }
  8984. push @event, "3:serialNumber:$serialNumber";
  8985. } elsif ($dataType == 1) {
  8986. # momentary power
  8987. push @event, "3:power:$meterReading";
  8988. if (!($st eq "actuator.01" && $manufID eq "033")) {
  8989. push @event, "3:state:$meterReading";
  8990. }
  8991. } else {
  8992. # power consumption
  8993. push @event, "3:energy$channel:$meterReading";
  8994. push @event, "3:currentTariff:$channel";
  8995. }
  8996. } elsif ($st eq "autoMeterReading.02" || $st eq "autoMeterReading.03") {
  8997. # Automated meter reading (AMR), Gas, Water (EEP A5-12-02, A5-12-03)
  8998. if ($dataType == 1) {
  8999. # current value
  9000. push @event, "3:flowrate:$meterReading";
  9001. push @event, "3:state:$meterReading";
  9002. } else {
  9003. # cumulative counter
  9004. push @event, "3:consumption$channel:$meterReading";
  9005. push @event, "3:currentTariff:$channel";
  9006. }
  9007. }
  9008. } elsif ($st =~ m/^autoMeterReading\.0[45]$/) {
  9009. # $db[1] is the temperature 0 .. 0xFF >> -40 ... 40
  9010. # $db[0]_bit_1 ... $db[0]_bit_0 is the battery level
  9011. my $temperature = sprintf "%0.1f", ($db[1] / 255 * 80) - 40;
  9012. my $battery = $db[0] & 3;
  9013. if ($battery == 3) {
  9014. $battery = "empty";
  9015. } elsif ($battery == 2) {
  9016. $battery = "low";
  9017. } elsif ($battery == 1) {
  9018. $battery = "ok";
  9019. } else {
  9020. $battery = "full";
  9021. }
  9022. push @event, "3:battery:$battery";
  9023. push @event, "3:temperature:$temperature";
  9024. if ($st eq "autoMeterReading.04") {
  9025. # Automated meter reading (AMR), Temperature, Load (EEP A5-12-04)
  9026. # $db[3] ... $db[2]_bit_2 is the Current Value in gram
  9027. my $weight = $db[3] << 6 | $db[2];
  9028. push @event, "3:weight:$weight";
  9029. push @event, "3:state:T: $temperature W: $weight B: $battery";
  9030. } elsif ($st eq "autoMeterReading.05") {
  9031. # Automated meter reading (AMR), Temperature, Container (EEP A5-12-05)
  9032. # $db[3] ... $db[2]_bit_6 is position sensor
  9033. my @sp;
  9034. $sp[0] = ($db[3] & 128) >> 7;
  9035. $sp[1] = ($db[3] & 64) >> 6;
  9036. $sp[2] = ($db[3] & 32) >> 5;
  9037. $sp[3] = ($db[3] & 16) >> 4;
  9038. $sp[4] = ($db[3] & 8) >> 3;
  9039. $sp[5] = ($db[3] & 4) >> 2;
  9040. $sp[6] = ($db[3] & 2) >> 1;
  9041. $sp[7] = $db[3] & 1;
  9042. $sp[8] = ($db[2] & 128) >> 7;
  9043. $sp[9] = ($db[2] & 64) >> 6;
  9044. my $amount = 0;
  9045. for (my $spCntr = 0; $spCntr <= 9; $spCntr ++) {
  9046. push @event, "3:location" . $spCntr . ":" . ($sp[$spCntr] ? "possessed" : "not_possessed");
  9047. $amount += $sp[$spCntr];
  9048. }
  9049. push @event, "3:amount:$amount";
  9050. push @event, "3:state:T: $temperature L: " . $sp[0] . $sp[1] . " " . $sp[2] . $sp[3] .
  9051. " " . $sp[4] . $sp[5] . " " . $sp[6] . $sp[7] . " " . $sp[8] . $sp[9] . " B: $battery";
  9052. }
  9053. } elsif ($st eq "autoMeterReading.10") {
  9054. # Automated meter reading (AMR), current meter 16 channels (EEP A5-12-10)
  9055. my $meterReading = hex(substr($data, 0, 6)) / 10 ** ($db[0] & 3);
  9056. my $channel = sprintf '%02d', $db[0] & 0xF0 >> 4;
  9057. my $scaleDecimals = "%0." . ($db[0] & 3) . "f";
  9058. push @event, "3:currentTariff:$channel";
  9059. if ($db[0] & 4) {
  9060. # current
  9061. push @event, "3:current$channel:" . sprintf "$scaleDecimals", $meterReading;
  9062. push @event, "3:state:" . sprintf "$scaleDecimals", $meterReading;
  9063. } else {
  9064. # electric charge
  9065. push @event, "3:electricChange$channel:" . sprintf "$scaleDecimals", $meterReading;
  9066. }
  9067. } elsif ($st eq "environmentApp") {
  9068. # Environmental Applications (EEP A5-13-01 ... EEP A5-13-06, EEP A5-13-10)
  9069. # [Eltako FWS61]
  9070. # $db[0]_bit_7 ... $db[0]_bit_4 is the Identifier
  9071. my $identifier = $db[0] >> 4;
  9072. if ($identifier == 1) {
  9073. # Weather Station (EEP A5-13-01)
  9074. # $db[3] is the dawn sensor where 0x00 = 0 lx ... 0xFF = 999 lx
  9075. # $db[2] is the temperature where 0x00 = -40 °C ... 0xFF = 80 °C
  9076. # $db[1] is the wind speed where 0x00 = 0 m/s ... 0xFF = 70 m/s
  9077. # $db[0]_bit_2 is day / night where 0 = day, 1 = night
  9078. # $db[0]_bit_1 is rain indication where 0 = no (no rain), 1 = yes (rain)
  9079. my $dawn = sprintf "%d", $db[3] * 999 / 255;
  9080. my $temp = sprintf "%0.1f", -40 + $db[2] * 120 / 255;
  9081. my $windSpeed = sprintf "%0.1f", $db[1] * 70 / 255;
  9082. my $dayNight = $db[0] & 4 ? "night" : "day";
  9083. my $isRaining = $db[0] & 2 ? "yes" : "no";
  9084. push @event, "3:brightness:$dawn";
  9085. push @event, "3:dayNight:$dayNight";
  9086. push @event, "3:isRaining:$isRaining";
  9087. push @event, "3:temperature:$temp";
  9088. push @event, "3:windSpeed:$windSpeed";
  9089. push @event, "3:state:T: $temp B: $dawn W: $windSpeed IR: $isRaining";
  9090. } elsif ($identifier == 2) {
  9091. # Sun Intensity (EEP A5-13-02)
  9092. # $db[3] is the sun exposure west where 0x00 = 1 lx ... 0xFF = 150 klx
  9093. # $db[2] is the sun exposure south where 0x00 = 1 lx ... 0xFF = 150 klx
  9094. # $db[1] is the sun exposure east where 0x00 = 1 lx ... 0xFF = 150 klx
  9095. # $db[0]_bit_2 is hemisphere where 0 = north, 1 = south
  9096. push @event, "3:hemisphere:" . ($db[0] & 4 ? "south" : "north");
  9097. push @event, "3:sunWest:" . sprintf "%d", 1 + $db[3] * 149999 / 255;
  9098. push @event, "3:sunSouth:" . sprintf "%d", 1 + $db[2] * 149999 / 255;
  9099. push @event, "3:sunEast:" . sprintf "%d", 1 + $db[1] * 149999 / 255;
  9100. } elsif ($identifier == 3) {
  9101. # Date exchange (EEP A5-13-03)
  9102. push @event, "3:date:" . ($db[1] + 2000) . '-' . $db[2] . '-' . $db[3];
  9103. } elsif ($identifier == 4) {
  9104. # Time und Day exchange (EEP A5-13-04)
  9105. my @day = ('', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
  9106. my $day = ($db[3] & 0xF0) >> 4;
  9107. push @event, "3:weekday:" . $day[$day];
  9108. if ($db[0] & 4) {
  9109. # 12 h time format
  9110. push @event, "3:time:" . ($db[3] & 0x0F) . ':' . $db[2] . ':' . $db[1] . ' ' . ($db[1] & 2 ? 'PM' : 'AM');
  9111. } else {
  9112. push @event, "3:time:" . ($db[3] & 0x0F) . ':' . $db[2] . ':' . $db[1];
  9113. }
  9114. push @event, "3:timeSource:" . ($db[0] & 1 ? 'GPS' : 'RTC');
  9115. } elsif ($identifier == 5) {
  9116. # Direction exchange (EEP A5-13-05)
  9117. push @event, "3:elevation:" . ($db[3] - 90);
  9118. push @event, "3:azimuth:" . hex(substr($data, 2, 4));
  9119. } elsif ($identifier == 6) {
  9120. # Geographic Position exchange (EEP A5-13-06)
  9121. push @event, "3:latitude:" . sprintf("%0.3f", hex(substr($data, 0, 1) . substr($data, 2, 2)) / 22.75 - 90);
  9122. push @event, "3:longitude:" . sprintf("%0.3f", hex(substr($data, 1, 1) . substr($data, 4, 2)) / 13.375 - 180);
  9123. } elsif ($identifier == 7) {
  9124. # Sun Position and Radiation (EEP A5-13-10)
  9125. # $db[3]_bit_7 ... $db[3]_bit_1 is Sun Elevation where 0 = 0 ° ... 90 = 90 °
  9126. # $db[3]_bit_0 is day / night where 0 = day, 1 = night
  9127. # $db[2] is Sun Azimuth where 0 = -90 ° ... 180 = 90 °
  9128. # $db[1] and $db[0]_bit_2 ... $db[0]_bit_0 is Solar Radiation where
  9129. # 0 = 0 W/m2 ... 2000 = 2000 W/m2
  9130. my $sunElev = $db[3] >> 1;
  9131. my $sunAzim = $db[2] - 90;
  9132. my $solarRad = $db[1] << 3 | $db[0] & 7;
  9133. push @event, "3:dayNight:" . ($db[3] & 1 ? "night" : "day");
  9134. push @event, "3:solarRadiation:$solarRad";
  9135. push @event, "3:sunAzimuth:$sunAzim";
  9136. push @event, "3:sunElevation:$sunElev";
  9137. push @event, "3:state:SRA: $solarRad SNA: $sunAzim SNE: $sunElev";
  9138. } else {
  9139. # EEP A5-13-03 ... EEP A5-13-06 not implemented
  9140. }
  9141. } elsif ($st eq "windSensor.01") {
  9142. # Wind Sensor (EEP A5-13-07)
  9143. my @windDirection = ('NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N');
  9144. push @event, "3:battery:" . ($db[0] & 1 ? 'low' : 'ok');
  9145. push @event, "3:windDirection:" . $windDirection[$db[3]];
  9146. push @event, "3:windSpeedAverage:" . $db[2] / 1.275;
  9147. push @event, "3:windSpeedMax:" . $db[1] / 1.275;
  9148. push @event, "3:state:" . $db[2] / 1.275;
  9149. } elsif ($st eq "rainSensor.01") {
  9150. # Rain Sensor (EEP A5-13-08)
  9151. my $ras = ($db[3] & 0x40) >> 6;
  9152. my $rfa = ($db[3] & 0x3F) / 10;
  9153. my $rfc = hex(substr($data, 2, 4));
  9154. my $rain = $rfc * 0.6875 * (1 + $ras * $rfa / 100);
  9155. push @event, "3:battery:" . ($db[0] & 1 ? 'low' : 'ok');
  9156. push @event, "3:rain:$rain";
  9157. push @event, "3:state:$rain";
  9158. } elsif ($st eq "multiFuncSensor") {
  9159. # Multi-Func Sensor (EEP A5-14-01 ... A5-14-06)
  9160. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  9161. # $db[3] > 0xFA is error code
  9162. # $db[2] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  9163. # $db[0]_bit_1 is Vibration where 0 = off, 1 = on
  9164. # $db[0]_bit_0 is Contact where 0 = closed, 1 = open
  9165. my $lux = $db[2] << 2;
  9166. if ($db[2] == 251) {$lux = "over range";}
  9167. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  9168. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  9169. my $vibration = $db[0] & 2 ? "on" : "off";
  9170. my $contact = $db[0] & 1 ? "open" : "closed";
  9171. push @event, "3:brightness:$lux";
  9172. push @event, "3:contact:$contact";
  9173. push @event, "3:vibration:$vibration";
  9174. push @event, "3:voltage:$voltage";
  9175. push @event, "3:state:C: $contact V: $vibration E: $lux U: $voltage";
  9176. } elsif ($st eq "doorContact") {
  9177. # dual door contact (EEP A5-14-07, A5-14-08)
  9178. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} ne $data) {
  9179. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  9180. my $doorContact = $db[0] & 4 ? 'open' : 'closed';
  9181. my $lockContact = $db[0] & 2 ? 'unlocked' : 'locked';
  9182. my $vibration = $db[0] & 1 ? 'on' : 'off';
  9183. push @event, "3:voltage:$voltage";
  9184. push @event, "3:contact:$doorContact";
  9185. push @event, "3:block:$lockContact";
  9186. push @event, "3:vibration:$vibration";
  9187. push @event, "3:state:C: $doorContact B: $lockContact V: $vibration U: $voltage";
  9188. $hash->{helper}{lastEvent} = $data;
  9189. }
  9190. CommandDeleteReading(undef, "$name alarm");
  9191. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  9192. RemoveInternalTimer($hash->{helper}{alarmTimer});
  9193. InternalTimer(gettimeofday() + 66, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  9194. } elsif ($st eq "windowContact") {
  9195. # window contact (EEP A5-14-09, A5-14-0A)
  9196. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} ne $data) {
  9197. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  9198. my %window = (0 => 'closed', 1 => 'tilt', 2 => 'reserved', 3 => 'open');
  9199. my $window = $window{(($db[0] & 6) >> 1)};
  9200. my $vibration = $db[0] & 1 ? 'on' : 'off';
  9201. push @event, "3:voltage:$voltage";
  9202. push @event, "3:window:$window";
  9203. push @event, "3:vibration:$vibration";
  9204. push @event, "3:state:W: $window V: $vibration U: $voltage";
  9205. $hash->{helper}{lastEvent} = $data;
  9206. }
  9207. CommandDeleteReading(undef, "$name alarm");
  9208. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  9209. RemoveInternalTimer($hash->{helper}{alarmTimer});
  9210. InternalTimer(gettimeofday() + 66, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  9211. } elsif ($st =~ m/^digitalInput\.0[12]$/) {
  9212. # Digital Input (EEP A5-30-01, A5-30-02)
  9213. my $contact;
  9214. if ($st eq "digitalInput.01") {
  9215. # Single Input Contact, Batterie Monitor (EEP A5-30-01)
  9216. # [Thermokon SR65 DI, untested]
  9217. # $db[2] is the supply voltage, if >= 121 = battery ok
  9218. # $db[1] is the input state, if <= 195 = contact closed
  9219. my $battery = $db[2] >= 121 ? "ok" : "low";
  9220. $contact = $db[1] <= 195 ? "closed" : "open";
  9221. push @event, "3:battery:$battery";
  9222. } else {
  9223. # Single Input Contact (EEP A5-30-02)
  9224. # $db[0]_bit_0 is the input state where 0 = closed, 1 = open
  9225. $contact = $db[0] & 1 ? "open" : "closed";
  9226. }
  9227. push @event, "3:contact:$contact";
  9228. push @event, "3:state:$contact";
  9229. } elsif ($st eq "digitalInput.03") {
  9230. # 4 digital inputs, wake, temperature (EEP A5-30-03)
  9231. my $in0 = $db[1] & 1;
  9232. my $in1 = ($db[1] & 2) > 1;
  9233. my $in2 = ($db[1] & 4) > 2;
  9234. my $in3 = ($db[1] & 8) > 3;
  9235. my $wake = $db[1] & 16 ? 'high' : 'low';
  9236. my $temperature = sprintf "%0.1f", 40 - $db[2] * 40 / 255;
  9237. push @event, "3:in0:$in0";
  9238. push @event, "3:in1:$in1";
  9239. push @event, "3:in2:$in2";
  9240. push @event, "3:in3:$in3";
  9241. push @event, "3:wake:$wake";
  9242. push @event, "3:temperature:$temperature";
  9243. push @event, "3:state:T: $temperature I: " . $in0 . $in1 . $in2 . $in3 . " W: " . $wake;
  9244. } elsif ($st eq "digitalInput.04") {
  9245. # 3 digital inputs, 1 digital input 8 bit (EEP A5-30-04)
  9246. my $in0 = $db[0] & 1;
  9247. my $in1 = ($db[0] & 2) > 1;
  9248. my $in2 = ($db[0] & 4) > 2;
  9249. my $in3 = $db[1];
  9250. push @event, "3:in0:$in0";
  9251. push @event, "3:in1:$in1";
  9252. push @event, "3:in2:$in2";
  9253. push @event, "3:in3:$in3";
  9254. push @event, "3:state:" . $in0 . $in1 . $in2 . " " . $in3;
  9255. } elsif ($st eq "digitalInput.05") {
  9256. # single input contact, retransmission, battery monitor (EEP A5-30-05)
  9257. my $signalIdx = $db[1] & 0x7F;
  9258. my $signalIdxLast = ReadingsVal($name, "signalIdx", undef);
  9259. my $signalType = $db[1] & 0x80 ? "heartbeat" : "event";
  9260. push @event, "3:voltage:" . sprintf "%0.1f", $db[2] / 255 * 3.3;
  9261. push @event, "3:signalIdx:$signalIdx";
  9262. push @event, "3:telegramType:$signalType";
  9263. if (defined $signalIdxLast) {
  9264. if ($signalIdx == $signalIdxLast + 1 || $signalIdx == 0 && $signalIdxLast == 127) {
  9265. push @event, "3:state:$signalType";
  9266. } else {
  9267. push @event, "3:state:error";
  9268. }
  9269. } else {
  9270. push @event, "3:state:$signalType";
  9271. }
  9272. } elsif ($st eq "gateway") {
  9273. # Gateway (EEP A5-38-08)
  9274. # $db[3] is the command ID ($gwCmdID)
  9275. # Eltako devices not send teach-in telegrams
  9276. if(($db[0] & 8) == 0) {
  9277. # teach-in, identify and store command type in attr gwCmd
  9278. my $gwCmd = AttrVal($name, "gwCmd", undef);
  9279. if (!$gwCmd) {
  9280. $gwCmd = $EnO_gwCmd[$db[3] - 1];
  9281. $attr{$name}{gwCmd} = $gwCmd;
  9282. }
  9283. }
  9284. if ($db[3] == 1) {
  9285. # Switching
  9286. # Eltako devices not send A5 telegrams
  9287. push @event, "3:executeTime:" . sprintf "%0.1f", (($db[2] << 8) | $db[1]) / 10;
  9288. push @event, "3:block:" . ($db[0] & 4 ? "lock" : "unlock");
  9289. push @event, "3:executeType" . ($db[0] & 2 ? "delay" : "duration");
  9290. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  9291. } elsif ($db[3] == 2) {
  9292. # Dimming
  9293. # $db[0]_bit_2 is store final value, not used, because
  9294. # dimming value is always stored
  9295. push @event, "3:rampTime:$db[1]";
  9296. push @event, "3:state:" . ($db[0] & 0x01 ? "on" : "off");
  9297. if ($db[0] & 4) {
  9298. # Relative Dimming Range
  9299. push @event, "3:dim:" . sprintf "%d", $db[2] * 100 / 255;
  9300. } else {
  9301. push @event, "3:dim:$db[2]";
  9302. }
  9303. push @event, "3:dimValueLast:$db[2]" if ($db[2] > 0);
  9304. } elsif ($db[3] == 3) {
  9305. # Setpoint shift
  9306. # $db1 is setpoint shift where 0 = -12.7 K ... 255 = 12.8 K
  9307. my $setpointShift = sprintf "%0.1f", -12.7 + $db[1] / 10;
  9308. push @event, "3:setpointShift:$setpointShift";
  9309. push @event, "3:state:$setpointShift";
  9310. } elsif ($db[3] == 4) {
  9311. # Basic Setpoint
  9312. # $db1 is setpoint where 0 = 0 °C ... 255 = 51.2 °C
  9313. my $setpoint = sprintf "%0.1f", $db[1] / 5;
  9314. push @event, "3:setpoint:$setpoint";
  9315. push @event, "3:state:$setpoint";
  9316. } elsif ($db[3] == 5) {
  9317. # Control variable
  9318. # $db1 is control variable override where 0 = 0 % ... 255 = 100 %
  9319. push @event, "3:controlVar:" . sprintf "%d", $db[1] * 100 / 255;
  9320. my $controllerMode = ($db[0] & 0x60) >> 5;
  9321. if ($controllerMode == 0) {
  9322. push @event, "3:controllerMode:auto";
  9323. push @event, "3:state:auto";
  9324. } elsif ($controllerMode == 1) {
  9325. push @event, "3:controllerMode:heating";
  9326. push @event, "3:state:heating";
  9327. } elsif ($controllerMode == 2){
  9328. push @event, "3:controllerMode:cooling";
  9329. push @event, "3:state:cooling";
  9330. } elsif ($controllerMode == 3){
  9331. push @event, "3:controllerMode:off";
  9332. push @event, "3:state:off";
  9333. }
  9334. push @event, "3:controllerState:" . ($db[0] & 0x10 ? "override" : "auto");
  9335. push @event, "3:energyHoldOff:" . ($db[0] & 4 ? "holdoff" : "normal");
  9336. my $occupancy = $db[0] & 3;
  9337. if ($occupancy == 0) {
  9338. push @event, "3:presence:present";
  9339. } elsif ($occupancy == 1){
  9340. push @event, "3:presence:absent";
  9341. } elsif ($occupancy == 2){
  9342. push @event, "3:presence:standby";
  9343. }
  9344. } elsif ($db[3] == 6) {
  9345. # Fan stage
  9346. if ($db[1] == 0) {
  9347. push @event, "3:fan:0";
  9348. push @event, "3:state:0";
  9349. } elsif ($db[1] == 1) {
  9350. push @event, "3:fan:1";
  9351. push @event, "3:state:1";
  9352. } elsif ($db[1] == 2) {
  9353. push @event, "3:fan:2";
  9354. push @event, "3:state:2";
  9355. } elsif ($db[1] == 3) {
  9356. push @event, "3:fan:3";
  9357. push @event, "3:state:3";
  9358. } elsif ($db[1] == 255) {
  9359. push @event, "3:fan:auto";
  9360. push @event, "3:state:auto";
  9361. }
  9362. } else {
  9363. push @event, "3:state:Gateway Command ID $db[3] unknown.";
  9364. }
  9365. } elsif ($st eq "energyManagement.01") {
  9366. # Energy Management, Demand Response
  9367. # (A5-37-01)
  9368. EnOcean_energyManagement_01Parse($hash, @db);
  9369. } elsif ($st eq "manufProfile") {
  9370. # Manufacturer Specific Applications (EEP A5-3F-7F)
  9371. if ($manufID eq "002") {
  9372. # [Thermokon SR65 3AI, untested]
  9373. # $db[3] is the input 3 where 0x00 = 0 V ... 0xFF = 10 V
  9374. # $db[2] is the input 2 where 0x00 = 0 V ... 0xFF = 10 V
  9375. # $db[1] is the input 1 where 0x00 = 0 V ... 0xFF = 10 V
  9376. my $input3 = sprintf "%0.2f", $db[3] * 10 / 255;
  9377. my $input2 = sprintf "%0.2f", $db[2] * 10 / 255;
  9378. my $input1 = sprintf "%0.2f", $db[1] * 10 / 255;
  9379. push @event, "3:input1:$input1";
  9380. push @event, "3:input2:$input2";
  9381. push @event, "3:input3:$input3";
  9382. push @event, "3:state:I1: $input1 I2: $input2 I3: $input3";
  9383. } elsif ($manufID eq "005") {
  9384. # omnio
  9385. if ($db[0] == 0x0C) {
  9386. # omnio UPH 2330/1x
  9387. my $channel = ($db[1] & 0xF0) > 4;
  9388. my $emergencyMode = $db[1] & 8 ? "on" : "off";
  9389. my $window = $db[1] & 4 ? "open" : "closed";
  9390. my $nightReduction = $db[1] & 2 ? "on" : "off";
  9391. my $state = $db[1] & 1 ? "on" : "off";
  9392. my $temperature = sprintf "%0.1f", $db[2] * 40 / 250;
  9393. my $setpointTemp = sprintf "%0.1f", $db[3] * 40 / 250;
  9394. push @event, "3:emergencyMode" . $channel . ":$emergencyMode";
  9395. push @event, "3:window" . $channel . ":$window";
  9396. push @event, "3:nightReduction" . $channel . ":$nightReduction";
  9397. push @event, "3:temperature" . $channel . ":$temperature";
  9398. push @event, "3:setpointTemp" . $channel . ":$setpointTemp";
  9399. push @event, "3:state:$state";
  9400. }
  9401. } elsif ($manufID eq "00D") {
  9402. # [Eltako shutter]
  9403. my $angleMax = AttrVal($name, "angleMax", 90);
  9404. my $angleMin = AttrVal($name, "angleMin", -90);
  9405. my $anglePos = ReadingsVal($name, ".anglePosStart", undef);
  9406. my $angleTime = AttrVal($name, "angleTime", 0);
  9407. my $position = ReadingsVal($name, ".positionStart", undef);
  9408. my $shutTime = AttrVal($name, "shutTime", 255);
  9409. my $shutTimeStop = ($db[3] << 8 | $db[2]) * 0.1;
  9410. my $state;
  9411. $angleMax = 90 if ($angleMax !~ m/^[+-]?\d+$/);
  9412. $angleMax = 180 if ($angleMax > 180);
  9413. $angleMax = -180 if ($angleMax < -180);
  9414. $angleMin = -90 if ($angleMin !~ m/^[+-]?\d+$/);
  9415. $angleMin = 180 if ($angleMin > 180);
  9416. $angleMin = -180 if ($angleMin < -180);
  9417. ($angleMax, $angleMin) = ($angleMin, $angleMax) if ($angleMin > $angleMax);
  9418. $angleMax ++ if ($angleMin == $angleMax);
  9419. $angleTime = 0 if ($angleTime !~ m/^[+-]?\d+$/);
  9420. $angleTime = 6 if ($angleTime > 6);
  9421. $angleTime = 0 if ($angleTime < 0);
  9422. $shutTime = 255 if ($shutTime !~ m/^[+-]?\d+$/);
  9423. $shutTime = 255 if ($shutTime > 255);
  9424. $shutTime = 1 if ($shutTime < 1);
  9425. if ($db[0] == 0x0A) {
  9426. push @event, "3:block:unlock";
  9427. } elsif ($db[0] == 0x0E) {
  9428. push @event, "3:block:lock";
  9429. }
  9430. if (defined $position) {
  9431. if ($db[1] == 1) {
  9432. # up
  9433. $position -= $shutTimeStop / $shutTime * 100;
  9434. if ($angleTime) {
  9435. $anglePos -= ($angleMax - $angleMin) * $shutTimeStop / $angleTime;
  9436. if ($anglePos < $angleMin) {
  9437. $anglePos = $angleMin;
  9438. }
  9439. } else {
  9440. $anglePos = $angleMin;
  9441. }
  9442. if ($position <= 0) {
  9443. $anglePos = 0;
  9444. $position = 0;
  9445. push @event, "3:endPosition:open";
  9446. $state = "open";
  9447. } else {
  9448. push @event, "3:endPosition:not_reached";
  9449. $state = "stop";
  9450. }
  9451. push @event, "3:anglePos:" . sprintf("%d", $anglePos);
  9452. push @event, "3:position:" . sprintf("%d", $position);
  9453. push @event, "3:.anglePosStart:" . sprintf("%d", $anglePos);
  9454. push @event, "3:.positionStart:" . sprintf("%d", $position);
  9455. } elsif ($db[1] == 2) {
  9456. # down
  9457. $position += $shutTimeStop / $shutTime * 100;
  9458. if ($angleTime) {
  9459. $anglePos += ($angleMax - $angleMin) * $shutTimeStop / $angleTime;
  9460. if ($anglePos > $angleMax) {
  9461. $anglePos = $angleMax;
  9462. }
  9463. } else {
  9464. $anglePos = $angleMax;
  9465. }
  9466. if($position > 100) {
  9467. $anglePos = $angleMax;
  9468. $position = 100;
  9469. push @event, "3:endPosition:closed";
  9470. $state = "closed";
  9471. } else {
  9472. push @event, "3:endPosition:not_reached";
  9473. $state = "stop";
  9474. }
  9475. push @event, "3:anglePos:" . sprintf("%d", $anglePos);
  9476. push @event, "3:position:" . sprintf("%d", $position);
  9477. push @event, "3:.anglePosStart:" . sprintf("%d", $anglePos);
  9478. push @event, "3:.positionStart:" . sprintf("%d", $position);
  9479. } else {
  9480. $state = "not_reached";
  9481. }
  9482. push @event, "3:state:$state";
  9483. }
  9484. } else {
  9485. # Unknown Application
  9486. push @event, "3:state:Manufacturer Specific Application unknown";
  9487. }
  9488. } elsif ($st eq "PM101") {
  9489. # Light and Presence Sensor [Omnio Ratio eagle-PM101]
  9490. # The sensor also sends switching commands (RORG F6) with the senderID-1
  9491. # $db[2] is the illuminance where 0x00 = 0 lx ... 0xFF = 1000 lx
  9492. my $channel2 = $db[0] & 2 ? "on" : "off";
  9493. push @event, "3:brightness:" . ($db[2] << 2);
  9494. push @event, "3:channel1:" . ($db[0] & 1 ? "on" : "off");
  9495. push @event, "3:channel2:" . $channel2;
  9496. push @event, "3:motion:" . $channel2;
  9497. push @event, "3:state:" . $channel2;
  9498. } elsif ($st eq "radioLinkTest") {
  9499. # Radio Link Test (EEP A5-3F-00)
  9500. @{$hash->{helper}{rlt}{param}} = ('parse', $hash, $data, $subDef, 'master', $RSSI);
  9501. EnOcean_RLT($hash->{helper}{rlt}{param});
  9502. } elsif ($st eq "raw") {
  9503. # raw
  9504. push @event, "3:state:RORG: $rorg DATA: $data STATUS: $status ODATA: $odata";
  9505. } else {
  9506. # unknown devices
  9507. push @event, "3:state:$db[3]";
  9508. push @event, "3:sensor1:$db[3]";
  9509. push @event, "3:sensor2:$db[2]";
  9510. push @event, "3:sensor3:$db[1]";
  9511. push @event, "3:D3:" . ($db[0] & 8 ? 1 : 0);
  9512. push @event, "3:D2:" . ($db[0] & 4 ? 1 : 0);
  9513. push @event, "3:D1:" . ($db[0] & 2 ? 1 : 0);
  9514. push @event, "3:D0:" . ($db[0] & 1 ? 1 : 0);
  9515. }
  9516. } elsif ($rorg eq "D2") {
  9517. # VLD telegram
  9518. if ($st eq "roomCtrlPanel.00") {
  9519. # EEP D2-10-01 - D2-10-03
  9520. my ($key, $val);
  9521. # message identifier
  9522. my $mid = hex(substr($data, 0, 2)) >> 5;
  9523. # message continuation flag
  9524. my $mcf = hex(substr($data, 0, 2)) & 3;
  9525. my ($irc, $fbc, $gmt);
  9526. if ($mcf == 0) {
  9527. # message complete
  9528. # read stored telegrams
  9529. if (!defined($hash->{helper}{$mid}{messagePart})) {
  9530. $hash->{helper}{$mid}{messagePart} = 1;
  9531. $hash->{helper}{$mid}{data}{1} = $data;
  9532. } else {
  9533. $hash->{helper}{$mid}{messagePart} += 1;
  9534. $hash->{helper}{$mid}{data}{$hash->{helper}{$mid}{messagePart}} = $data;
  9535. }
  9536. if ($mid == 4) {
  9537. CommandDeleteAttr(undef, "$name timeProgram1");
  9538. CommandDeleteAttr(undef, "$name timeProgram2");
  9539. CommandDeleteAttr(undef, "$name timeProgram3");
  9540. CommandDeleteAttr(undef, "$name timeProgram4");
  9541. }
  9542. for (my $partCntr = $hash->{helper}{$mid}{messagePart}; $partCntr > 0; $partCntr --) {
  9543. $data = $hash->{helper}{$mid}{data}{$partCntr};
  9544. delete $hash->{helper}{$mid}{data}{$partCntr};
  9545. if ($partCntr == 1) {
  9546. delete $hash->{helper}{$mid}{messagePart};
  9547. } else {
  9548. $hash->{helper}{$mid}{messagePart} --;
  9549. }
  9550. $dbCntr = 0;
  9551. for (my $strCntr = length($data) / 2 - 1; $strCntr >= 0; $strCntr --) {
  9552. $db[$dbCntr] = hex substr($data, $strCntr * 2, 2);
  9553. $dbCntr++;
  9554. }
  9555. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write MID $mid DATA $data to part $partCntr";
  9556. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write 1 MID $mid DATA $data to " . sprintf "%02X%02X%02X%02X%02X%02X", $db[5], $db[4], $db[3], $db[2], $db[1], $db[0];
  9557. if ($mid == 0) {
  9558. # general message
  9559. $irc = ($db[0] & 56) >> 3;
  9560. $fbc = ($db[0] & 6) >> 1;
  9561. $gmt = $db[0] & 1;
  9562. #push @event, "3:general:$data";
  9563. } elsif ($mid == 1) {
  9564. # data message
  9565. my $temperature = "-";
  9566. $temperature = sprintf "%.1f", $db[0] / 254 * 40 if ($db[2] & 1);
  9567. push @event, "3:temperature:$temperature";
  9568. my $setpointTemp = "-";
  9569. $setpointTemp = sprintf "%.1f", $db[1] / 254 * 40 if ($db[2] & 2);
  9570. push @event, "3:setpointTemp:$setpointTemp";
  9571. my $roomCtrlMode = ($db[2] & 12) >> 2;
  9572. if ($roomCtrlMode == 3) {
  9573. $roomCtrlMode = "buildingProtection";
  9574. } elsif ($roomCtrlMode == 2) {
  9575. $roomCtrlMode = "preComfort";
  9576. } elsif ($roomCtrlMode == 1) {
  9577. $roomCtrlMode = "economy";
  9578. } else{
  9579. $roomCtrlMode = "comfort";
  9580. }
  9581. push @event, "3:roomCtrlMode:$roomCtrlMode";
  9582. my $heating = ($db[2] & 48) >> 4;
  9583. if ($heating == 3) {
  9584. $heating = "auto";
  9585. } elsif ($heating == 2) {
  9586. $heating = "off";
  9587. } elsif ($heating == 1) {
  9588. $heating = "on";
  9589. } else{
  9590. $heating = "-";
  9591. }
  9592. if ($heating ne "-") {
  9593. push @event, "3:heating:$heating";
  9594. }
  9595. my $cooling = ($db[2] & 192) >> 6;
  9596. if ($cooling == 3) {
  9597. $cooling = "auto";
  9598. } elsif ($cooling == 2) {
  9599. $cooling = "off";
  9600. } elsif ($cooling == 1) {
  9601. $cooling = "on";
  9602. } else{
  9603. $cooling = "-";
  9604. }
  9605. if ($cooling ne "-") {
  9606. push @event, "3:cooling:$cooling";
  9607. }
  9608. my $occupancy = $db[3] & 3;
  9609. if ($occupancy == 3) {
  9610. $occupancy = "reserved";
  9611. } elsif ($occupancy == 2) {
  9612. $occupancy = "absent";
  9613. } elsif ($occupancy == 1) {
  9614. $occupancy = "present";
  9615. } else{
  9616. $occupancy = "-";
  9617. }
  9618. if ($occupancy eq "-") {
  9619. $occupancy = ReadingsVal($name, "occupancy", "-");
  9620. } else {
  9621. push @event, "3:occupancy:$occupancy";
  9622. }
  9623. my $motion = ($db[3] & 12) >> 2;
  9624. if ($motion == 3) {
  9625. $motion = "reserved";
  9626. } elsif ($motion == 2) {
  9627. $motion = "on";
  9628. } elsif ($motion == 1) {
  9629. $motion = "off";
  9630. } else{
  9631. $motion = "-";
  9632. }
  9633. if ($motion eq "-") {
  9634. $motion = ReadingsVal($name, "motion", "-");
  9635. } else {
  9636. push @event, "3:motion:$motion";
  9637. }
  9638. push @event, "3:solarPowered:" . ($db[3] & 16 ? "no" : "yes");
  9639. my $battery = ($db[3] & 96) >> 5;
  9640. if ($battery == 3) {
  9641. $battery = "empty";
  9642. } elsif ($battery == 2) {
  9643. $battery = "low";
  9644. } elsif ($battery == 1) {
  9645. $battery = "ok";
  9646. } else{
  9647. $battery = "-";
  9648. }
  9649. if ($battery ne "-") {
  9650. push @event, "3:battery:$battery";
  9651. }
  9652. my $window = $db[4] & 3;
  9653. if ($window == 3) {
  9654. $window = "reserved";
  9655. } elsif ($window == 2) {
  9656. $window = "open";
  9657. } elsif ($window == 1) {
  9658. $window = "closed";
  9659. } else{
  9660. $window = "-";
  9661. }
  9662. if ($window ne "-") {
  9663. push @event, "3:window:$window";
  9664. }
  9665. push @event, "3:moldWarning:" . ($db[4] & 4 ? "on" : "off");
  9666. push @event, "3:customWarning1:" . ($db[4] & 8 ? "on" : "off");
  9667. push @event, "3:customWarning2:" . ($db[4] & 16 ? "on" : "off");
  9668. push @event, "3:fanSpeedMode:" . ($db[4] & 64 ? "local" : "central");
  9669. my $fanSpeed = 0;
  9670. $fanSpeed = sprintf "%d", $db[5] & 127 if ($db[4] & 128);
  9671. push @event, "3:fanSpeed:$fanSpeed";
  9672. my $humi = "-";
  9673. $humi = sprintf "%d", $db[6] / 2.55 if ($db[5] & 128);
  9674. push @event, "3:humidity:$humi";
  9675. push @event, "3:state:T: $temperature H: $humi F: $fanSpeed SPT: $setpointTemp O: $occupancy M: $motion";
  9676. } elsif ($mid == 2) {
  9677. # configuration message
  9678. $attr{$name}{blockFanSpeed} = $db[6] & 1 ? "no" : "yes";
  9679. $attr{$name}{blockSetpointTemp} = $db[6] & 2 ? "no" : "yes";
  9680. $attr{$name}{blockOccupancy} = $db[6] & 4 ? "no" : "yes";
  9681. $attr{$name}{blockTimeProgram} = $db[6] & 8 ? "no" : "yes";
  9682. $attr{$name}{blockDateTime} = $db[6] & 16 ? "no" : "yes";
  9683. $attr{$name}{blockDisplay} = $db[6] & 32 ? "no" : "yes";
  9684. $attr{$name}{blockTemp} = $db[6] & 64 ? "no" : "yes";
  9685. $attr{$name}{blockMotion} = $db[6] & 128 ? "no" : "yes";
  9686. my $pollInterval = $db[5] >> 2;
  9687. if ($pollInterval == 63) {
  9688. $attr{$name}{pollInterval} = 1440;
  9689. } elsif ($pollInterval == 62) {
  9690. $attr{$name}{pollInterval} = 720;
  9691. } elsif ($pollInterval == 61) {
  9692. $attr{$name}{pollInterval} = 180;
  9693. } else {
  9694. $attr{$name}{pollInterval} = $pollInterval;
  9695. }
  9696. $attr{$name}{blockKey} = $db[5] & 2 ? "no" : "yes";
  9697. my $displayContent = $db[4] >> 5;
  9698. my %displayContent = (7 => "humidity",
  9699. 6 => "off",
  9700. 5 => "setpointTemp",
  9701. 4 => "tempertureExtern",
  9702. 3 => "temperatureIntern",
  9703. 2 => "time",
  9704. 1 => "default",
  9705. 0 => "no_change"
  9706. );
  9707. while (($key, $val) = each(%displayContent)) {
  9708. $attr{$name}{displayContent} = $val if ($key == $displayContent);
  9709. }
  9710. my $temperatureScale = ($db[4] & 24) >> 3;
  9711. my %temperatureScale = (3 => "F",
  9712. 2 => "C",
  9713. 1 => "default",
  9714. 0 => "no_change"
  9715. );
  9716. while (($key, $val) = each(%temperatureScale)) {
  9717. $attr{$name}{temperatureScale} = $val if ($key == $temperatureScale);
  9718. }
  9719. $attr{$name}{daylightSavingTime} = $db[4] & 4 ? "not_supported" : "supported";
  9720. my $timeNotation = $db[4] & 3;
  9721. if ($timeNotation == 0) {
  9722. $attr{$name}{timeNotation} = "no_change";
  9723. } elsif ($timeNotation == 1) {
  9724. $attr{$name}{timeNotation} = "default";
  9725. } elsif ($timeNotation == 2) {
  9726. $attr{$name}{timeNotation} = 24;
  9727. } elsif ($timeNotation == 3) {
  9728. $attr{$name}{timeNotation} = 12;
  9729. }
  9730. EnOcean_CommandSave(undef, undef);
  9731. } elsif ($mid == 3) {
  9732. # room control setup
  9733. my $setpointComfort = "-";
  9734. $setpointComfort = sprintf "%.1f", $db[1] / 254 * 40 if ($db[0] & 1);
  9735. push @event, "3:setpointComfortTemp:$setpointComfort";
  9736. my $setpointEconomy = "-";
  9737. $setpointEconomy = sprintf "%.1f", $db[2] / 254 * 40 if ($db[0] & 2);
  9738. push @event, "3:setpointEconomyTemp:$setpointEconomy";
  9739. my $setpointPreComfort = "-";
  9740. $setpointPreComfort = sprintf "%.1f", $db[3] / 254 * 40 if ($db[0] & 4);
  9741. push @event, "3:setpointPreComfortTemp:$setpointPreComfort";
  9742. my $setpointBuildingProtection = "-";
  9743. $setpointBuildingProtection = sprintf "%.1f", $db[3] / 254 * 40 if ($db[0] & 8);
  9744. push @event, "3:setpointBuildingProtectionTemp:$setpointBuildingProtection";
  9745. } elsif ($mid == 4) {
  9746. # time program setup
  9747. my $timeProgram = "timeProgram" . $partCntr;
  9748. my $period = $db[0] >> 4;
  9749. my $periodVal = "";
  9750. my %period = (15 => "FrMo",
  9751. 14 => "FrSu",
  9752. 13 => "ThFr",
  9753. 12 => "WeFr",
  9754. 11 => "TuTh",
  9755. 10 => "MoWe",
  9756. 9 => "Su",
  9757. 8 => "Sa",
  9758. 7 => "Fr",
  9759. 6 => "Th",
  9760. 5 => "We",
  9761. 4 => "Tu",
  9762. 3 => "Mo",
  9763. 2 => "SaSu",
  9764. 1 => "MoFr",
  9765. 0 => "MoSu"
  9766. );
  9767. while (($key, $val) = each(%period)) {
  9768. $periodVal = $val if ($key == $period);
  9769. }
  9770. my $roomCtrlMode = ($db[0] & 12) >> 2;
  9771. if ($roomCtrlMode == 3) {
  9772. $roomCtrlMode = "buildingProtection";
  9773. } elsif ($roomCtrlMode == 2) {
  9774. $roomCtrlMode = "preComfort";
  9775. } elsif ($roomCtrlMode == 1) {
  9776. $roomCtrlMode = "economy";
  9777. } else{
  9778. $roomCtrlMode = "comfort";
  9779. }
  9780. my ($startHour, $startMinute, $endHour, $endMinute) = ($db[1], $db[2], $db[3], $db[4]);
  9781. $startHour = $startHour < 10 ? $startHour = "0" . $startHour : $startHour;
  9782. $startMinute = $startMinute < 10 ? $startMinute = "0" . $startMinute : $startMinute;
  9783. $endHour = $endHour < 10 ? $endHour = "0" . $endHour : $endHour;
  9784. $endMinute = $endMinute < 10 ? $endMinute = "0" . $endMinute : $endMinute;
  9785. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write 2 MID $mid DATA $data to " . sprintf "%02X%02X%02X%02X%02X%02X", $db[5], $db[4], $db[3], $db[2], $db[1], $db[0];
  9786. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write 3 MID $mid DATA $data to $timeProgram VAL: $periodVal $startHour:$startMinute $endHour:$endMinute $roomCtrlMode";
  9787. $attr{$name}{$timeProgram} = "$periodVal $startHour:$startMinute $endHour:$endMinute $roomCtrlMode";
  9788. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write 4 MID $mid DATA $data to $timeProgram VAL: $attr{$name}{$timeProgram}";
  9789. EnOcean_CommandSave(undef, undef);
  9790. }
  9791. }
  9792. ($err, $response) = EnOcean_roomCtrlPanel_00Snd(undef, $hash, $packetType, $mid, $mcf, $irc, $fbc, $gmt);
  9793. } elsif ($mcf == 1) {
  9794. # message incomplete
  9795. if (!defined($hash->{helper}{$mid}{messagePart})) {
  9796. $hash->{helper}{$mid}{messagePart} = 1;
  9797. } elsif ($hash->{helper}{$mid}{messagePart} >= 4) {
  9798. # max 4 message parts stored
  9799. for (my $partCntr = 1; $partCntr < $hash->{helper}{$mid}{messagePart}; $partCntr ++) {
  9800. $hash->{helper}{$mid}{data}{$partCntr} = $hash->{helper}{$mid}{data}{$partCntr + 1};
  9801. }
  9802. } else {
  9803. $hash->{helper}{$mid}{messagePart} += 1;
  9804. }
  9805. $hash->{helper}{$mid}{data}{$hash->{helper}{$mid}{messagePart}} = $data;
  9806. #Log3 $name, 2, "EnOcean $name EnOcean_Parse store MID $mid DATA $data to messagePart $hash->{helper}{$mid}{messagePart}";
  9807. ($err, $response) = EnOcean_roomCtrlPanel_00Snd(undef, $hash, $packetType, $mid, $mcf, undef, undef, undef);
  9808. }
  9809. } elsif ($st eq "actuator.01") {
  9810. # Electronic switches and dimmers with Energy Measurement and Local Control
  9811. # (D2-01-00 - D2-01-12)
  9812. my $channel = (hex substr($data, 2, 2)) & 0x1F;
  9813. if ($channel == 31) {$channel = "Input";}
  9814. my $cmd = hex substr($data, 1, 1);
  9815. if ($cmd == 4) {
  9816. # actuator status response
  9817. my $overCurrentOff;
  9818. my $error;
  9819. my $localControl;
  9820. my $dim;
  9821. push @event, "3:powerFailure" . $channel . ":" . ($db[2] & 0x80 ? "enabled" : "disabled");
  9822. push @event, "3:powerFailureDetection" . $channel . ":" . ($db[2] & 0x40 ? "detected" : "not_detected");
  9823. if (($db[1] & 0x80) == 0) {
  9824. $overCurrentOff = "ready";
  9825. } else {
  9826. $overCurrentOff = "executed";
  9827. }
  9828. push @event, "3:overCurrentOff" . $channel . ":" . $overCurrentOff;
  9829. if ((($db[1] & 0x60) >> 5) == 1) {
  9830. $error = "warning";
  9831. } elsif ((($db[1] & 0x60) >> 5) == 2) {
  9832. $error = "failure";
  9833. } elsif ((($db[1] & 0x60) >> 5) == 3) {
  9834. $error = "not_supported";
  9835. } else {
  9836. $error = "ok";
  9837. }
  9838. push @event, "3:error" . $channel . ":" . $error;
  9839. if (($db[0] & 0x80) == 0) {
  9840. $localControl = "disabled";
  9841. } else {
  9842. $localControl = "enabled";
  9843. }
  9844. push @event, "3:localControl" . $channel . ":" . $localControl;
  9845. my $dimValue = $db[0] & 0x7F;
  9846. if ($dimValue == 0) {
  9847. push @event, "3:channel" . $channel . ":off";
  9848. push @event, "3:state:off";
  9849. } else {
  9850. push @event, "3:channel" . $channel . ":on";
  9851. push @event, "3:state:on";
  9852. }
  9853. if ($channel ne "Input") {
  9854. push @event, "3:dim:" . $dimValue;
  9855. push @event, "3:dim" . $channel . ":" . $dimValue;
  9856. } else {
  9857. push @event, "3:dim" . $channel . ":" . $dimValue;
  9858. }
  9859. } elsif ($cmd == 7) {
  9860. # actuator measurement response
  9861. my $unit = $db[4] >> 5;
  9862. if ($unit == 1) {
  9863. #$unit = "Wh";
  9864. $unit = "KWh";
  9865. push @event, "3:energyUnit" . $channel . ":" . $unit;
  9866. push @event, "3:energy" . $channel . ":" . sprintf("%.3f", (hex substr($data, 4, 8)) / 1000);
  9867. } elsif ($unit == 2) {
  9868. $unit = "KWh";
  9869. push @event, "3:energyUnit" . $channel . ":" . $unit;
  9870. push @event, "3:energy" . $channel . ":" . hex substr($data, 4, 8);
  9871. } elsif ($unit == 3) {
  9872. $unit = "W";
  9873. push @event, "3:powerUnit" . $channel . ":" . $unit;
  9874. push @event, "3:power" . $channel . ":" . hex substr($data, 4, 8);
  9875. } elsif ($unit == 4) {
  9876. $unit = "KW";
  9877. push @event, "3:powerUnit" . $channel . ":" . $unit;
  9878. push @event, "3:power" . $channel . ":" . hex substr($data, 4, 8);
  9879. } else {
  9880. $unit = "Ws";
  9881. push @event, "3:energyUnit" . $channel . ":" . $unit;
  9882. push @event, "3:energy" . $channel . ":" . hex substr($data, 4, 8);
  9883. }
  9884. } elsif ($cmd == 10) {
  9885. # pilot wire mode response
  9886. my $roomCtrlMode = $db[0] & 3;
  9887. my %roomCtrlMode = (
  9888. 0 => "off",
  9889. 1 => "comfort",
  9890. 2 => "economy",
  9891. 3 => "buildingProtection",
  9892. 4 => "comfort-1",
  9893. 5 => "comfort-2"
  9894. );
  9895. push @event, "3:roomCtrlMode" . $roomCtrlMode{$roomCtrlMode} if (exists $roomCtrlMode{$roomCtrlMode});
  9896. } elsif ($cmd == 13) {
  9897. # external interface settings
  9898. push @event, "3:autoOffTime" . $channel . ":" . sprintf("%0.1f", hex(substr($data, 4, 4)) * 0.1);
  9899. push @event, "3:delayOffTime" . $channel . ":" . sprintf("%0.1f", hex(substr($data, 8, 4)) * 0.1);
  9900. my $extSwitchMode = ($db[0] & 0xC0) >> 6;
  9901. my %extSwitchMode = (
  9902. 0 => "unavailable",
  9903. 1 => "switch",
  9904. 2 => "pushbutton",
  9905. 3 => "auto"
  9906. );
  9907. push @event, "3:extSwitchMode" . $extSwitchMode{$extSwitchMode} if (exists $extSwitchMode{$extSwitchMode});
  9908. push @event, "3:extSwitchType" . ($db[0] & 0x20 ? 'direction' : 'toggle');
  9909. } else {
  9910. # unknown response
  9911. }
  9912. } elsif ($st eq "switch.00" || $st eq "windowHandle.10") {
  9913. if ($db[0] == 1) {
  9914. push @event, "3:state:open_from_tilted";
  9915. } elsif ($db[0] == 2) {
  9916. push @event, "3:state:closed";
  9917. } elsif ($db[0] == 3) {
  9918. push @event, "3:state:open";
  9919. } elsif ($db[0] == 4) {
  9920. push @event, "3:state:tilted";
  9921. } elsif ($db[0] == 5) {
  9922. push @event, "3:state:AI,B0";
  9923. push @event, "3:channelA:AI";
  9924. push @event, "3:channelB:B0";
  9925. push @event, "3:energyBow:pressed";
  9926. } elsif ($db[0] == 6) {
  9927. CommandDeleteReading(undef, "$name channel.*");
  9928. push @event, "3:state:pressed34";
  9929. push @event, "3:energyBow:pressed";
  9930. } elsif ($db[0] == 7) {
  9931. push @event, "3:state:A0,B0";
  9932. push @event, "3:channelA:A0";
  9933. push @event, "3:channelB:B0";
  9934. push @event, "3:energyBow:pressed";
  9935. } elsif ($db[0] == 8) {
  9936. if (AttrVal($name, "sensorMode", "switch") eq "pushbutton") {
  9937. push @event, "3:state:pressed";
  9938. }
  9939. push @event, "3:energyBow:pressed";
  9940. } elsif ($db[0] == 9) {
  9941. push @event, "3:state:AI,BI";
  9942. push @event, "3:channelA:AI";
  9943. push @event, "3:channelB:BI";
  9944. push @event, "3:energyBow:pressed";
  9945. } elsif ($db[0] == 10) {
  9946. push @event, "3:state:A0,BI";
  9947. push @event, "3:channelA:A0";
  9948. push @event, "3:channelB:BI";
  9949. push @event, "3:energyBow:pressed";
  9950. } elsif ($db[0] == 11) {
  9951. push @event, "3:state:BI";
  9952. push @event, "3:channelB:BI";
  9953. push @event, "3:energyBow:pressed";
  9954. } elsif ($db[0] == 12) {
  9955. push @event, "3:state:B0";
  9956. push @event, "3:channelB:B0";
  9957. push @event, "3:energyBow:pressed";
  9958. } elsif ($db[0] == 13) {
  9959. push @event, "3:state:AI";
  9960. push @event, "3:channelA:AI";
  9961. push @event, "3:energyBow:pressed";
  9962. } elsif ($db[0] == 14) {
  9963. push @event, "3:state:A0";
  9964. push @event, "3:channelA:A0";
  9965. push @event, "3:energyBow:pressed";
  9966. } elsif ($db[0] == 15) {
  9967. if (AttrVal($name, "sensorMode", "switch") eq "pushbutton") {
  9968. push @event, "3:state:released";
  9969. }
  9970. push @event, "3:energyBow:released";
  9971. }
  9972. } elsif ($st =~ m/^blindsCtrl\.0[01]$/) {
  9973. # EEP D2-05-0x
  9974. my $channel = (($db[0] & 0xF0) >> 4) + 1;
  9975. my $cmd = $db[0] & 0x0F;
  9976. if ($cmd == 4) {
  9977. # actuator status response
  9978. if ($db[3] == 0) {
  9979. push @event, "3:state:open";
  9980. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":open";
  9981. push @event, "3:position" . sprintf('%02d', $channel) . ":" . $db[3];
  9982. push @event, "3:position:" . $db[3];
  9983. } elsif ($db[3] == 100) {
  9984. push @event, "3:state:closed";
  9985. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":closed";
  9986. push @event, "3:position" . sprintf('%02d', $channel) . ":" . $db[3];
  9987. push @event, "3:position:" . $db[3];
  9988. } elsif ($db[3] == 127) {
  9989. push @event, "3:state:unknown";
  9990. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":unknown";
  9991. push @event, "3:position" . sprintf('%02d', $channel) . ":unknown";
  9992. push @event, "3:position:" . $db[3];
  9993. } else {
  9994. push @event, "3:state:" . $db[3];
  9995. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":not_reached";
  9996. push @event, "3:position" . sprintf('%02d', $channel) . ":" . $db[3];
  9997. push @event, "3:position:" . $db[3];
  9998. }
  9999. if ($db[2] == 127) {
  10000. push @event, "3:anglePos" . sprintf('%02d', $channel) . ":unknown";
  10001. } else {
  10002. push @event, "3:anglePos" . sprintf('%02d', $channel) . ":" . $db[2];
  10003. push @event, "3:anglePos:" . $db[2];
  10004. }
  10005. if ($db[1] == 0) {
  10006. push @event, "3:block" . sprintf('%02d', $channel) . ":unlock";
  10007. } elsif ($db[1] == 1) {
  10008. push @event, "3:block" . sprintf('%02d', $channel) . ":lock";
  10009. } elsif ($db[1] == 2) {
  10010. push @event, "3:block" . sprintf('%02d', $channel) . ":alarm";
  10011. } else {
  10012. push @event, "3:block" . sprintf('%02d', $channel) . ":reserved";
  10013. }
  10014. } else {
  10015. # unknown response
  10016. }
  10017. } elsif ($st eq "multisensor.01") {
  10018. #####
  10019. # Multisensor Windows Handle
  10020. # (D2-06-01)
  10021. # message type
  10022. my $msgType = hex(substr($data, 0, 2));
  10023. my $blinkInterval = 0;
  10024. my $updateInterval = 0;
  10025. my $waitingCmds = ReadingsVal($name, "waitingCmds", undef);
  10026. if ($msgType == 0) {
  10027. # sensor values
  10028. my %onOffTrigger = (
  10029. 0 => "off",
  10030. 1 => "on",
  10031. 14 => "invalid",
  10032. 15 => "not_supported",
  10033. );
  10034. my $onOffTrigger = $db[8] >> 4;
  10035. if (exists $onOffTrigger{$onOffTrigger}) {
  10036. push @event, "3:burglaryAlarm:$onOffTrigger{$onOffTrigger}";
  10037. } else {
  10038. push @event, "3:burglaryAlarm:unknown";
  10039. }
  10040. $onOffTrigger = $db[8] & 15;
  10041. if (exists $onOffTrigger{$onOffTrigger}) {
  10042. push @event, "3:protectionAlarm:$onOffTrigger{$onOffTrigger}";
  10043. } else {
  10044. push @event, "3:protectionAlarm:unknown";
  10045. }
  10046. my %handlePosition = (
  10047. 0 => "unknown",
  10048. 1 => "up",
  10049. 2 => "down",
  10050. 3 => "left",
  10051. 4 => "right",
  10052. 14 => "invalid",
  10053. 15 => "not_supported"
  10054. );
  10055. my %handleRPS = (
  10056. 1 => 'D0',
  10057. 2 => 'F0',
  10058. 3 => 'E0',
  10059. 4 => 'E0'
  10060. );
  10061. my $handlePosition = $db[7] >> 4;
  10062. if (exists $handlePosition{$handlePosition}) {
  10063. push @event, "3:handle:$handlePosition{$handlePosition}";
  10064. } else {
  10065. push @event, "3:handle:unknown";
  10066. }
  10067. # forward handle position (RPS telegam)
  10068. if (exists($handleRPS{$handlePosition}) && defined(AttrVal($name, "subDefH", undef))) {
  10069. EnOcean_SndRadio(undef, $hash, $packetType, "F6", $handleRPS{$handlePosition}, AttrVal($name, "subDefH", "00000000"), '20', 'FFFFFFFF');
  10070. }
  10071. my %windowState = (
  10072. 0 => "undef",
  10073. 1 => "not_tilted",
  10074. 2 => "tilted",
  10075. 14 => "invalid",
  10076. 15 => "not_supported"
  10077. );
  10078. my %window1BS = (
  10079. 1 => '09',
  10080. 2 => '08'
  10081. );
  10082. my $windowState = $db[7] & 15;
  10083. if (exists $windowState{$windowState}) {
  10084. push @event, "3:window:$windowState{$windowState}";
  10085. } else {
  10086. push @event, "3:window:unknown";
  10087. }
  10088. # forward window state (1BS telegam)
  10089. if (exists($window1BS{$windowState}) && defined(AttrVal($name, "subDefW", undef))) {
  10090. EnOcean_SndRadio(undef, $hash, $packetType, "D5", $window1BS{$windowState}, AttrVal($name, "subDefW", "00000000"), '00', 'FFFFFFFF');
  10091. }
  10092. my %button = (
  10093. 0 => "no_change",
  10094. 1 => "pressed",
  10095. 2 => "released",
  10096. 14 => "invalid",
  10097. 15 => "not_supported"
  10098. );
  10099. my $button = $db[6] >> 4;
  10100. if (exists $button{$button}) {
  10101. if ($button == 0 && ReadingsVal($name, "buttonRight", 'unknown') eq 'unknown') {
  10102. push @event, "3:buttonRight:unknown";
  10103. } elsif ($button == 0) {
  10104. } else {
  10105. push @event, "3:buttonRight:$button{$button}";
  10106. }
  10107. } else {
  10108. push @event, "3:buttonRight:unknown";
  10109. }
  10110. $button = $db[6] & 15;
  10111. if (exists $button{$button}) {
  10112. if ($button == 0 && ReadingsVal($name, "buttonLeft", 'unknown') eq 'unknown') {
  10113. push @event, "3:buttonLeft:unknown";
  10114. } elsif ($button == 0) {
  10115. } else {
  10116. push @event, "3:buttonLeft:$button{$button}";
  10117. }
  10118. } else {
  10119. push @event, "3:buttonLeft:unknown";
  10120. }
  10121. my $motion = $db[5] >> 4;
  10122. if (exists $onOffTrigger{$motion}) {
  10123. push @event, "3:motion:$onOffTrigger{$motion}";
  10124. } else {
  10125. push @event, "3:motion:unknown";
  10126. }
  10127. my %vacation = (
  10128. 0 => "no_change",
  10129. 1 => "absent",
  10130. 2 => "present",
  10131. 14 => "invalid",
  10132. 15 => "not_supported"
  10133. );
  10134. my $vacation = $db[5] & 15;
  10135. if (exists $vacation{$vacation}) {
  10136. if ($vacation == 0 && ReadingsVal($name, "presence", 'unknown') eq 'unknown') {
  10137. push @event, "3:presence:unknown";
  10138. } elsif ($vacation == 0) {
  10139. } else {
  10140. push @event, "3:presence:$vacation{$vacation}";
  10141. }
  10142. } else {
  10143. push @event, "3:presence:unknown";
  10144. }
  10145. my $temperature;
  10146. if ($db[4] <= 250) {
  10147. $temperature = sprintf "%0.1f", $db[4] * 80 / 250 - 20;
  10148. push @event, "3:temperature:$temperature";
  10149. } elsif ($db[4] <= 254) {
  10150. $temperature = '-';
  10151. push @event, "3:temperature:invalid";
  10152. } elsif ($db[4] <= 255) {
  10153. $temperature = '-';
  10154. push @event, "3:temperature:not_supported";
  10155. } else {
  10156. $temperature = '-';
  10157. push @event, "3:temperature:unknown";
  10158. }
  10159. my $humidity;
  10160. if ($db[3] <= 200) {
  10161. $humidity = $db[3] / 2;
  10162. push @event, "3:humidity:$humidity";
  10163. } elsif ($db[3] <= 254) {
  10164. $humidity = '-';
  10165. push @event, "3:humidity:invalid";
  10166. } elsif ($db[3] <= 255) {
  10167. $humidity = '-';
  10168. push @event, "3:humidity:not_supported";
  10169. } else {
  10170. $humidity = '-';
  10171. push @event, "3:humidity:unknown";
  10172. }
  10173. my $brightness = hex(substr($data, 14, 4));
  10174. if ($brightness <= 60000) {
  10175. push @event, "3:brightness:$brightness";
  10176. } elsif ($brightness == 60001) {
  10177. $brightness = '-';
  10178. push @event, "3:brightness:over_range";
  10179. } elsif ($brightness == 65534) {
  10180. $brightness = '-';
  10181. push @event, "3:brightness:invalid";
  10182. } elsif ($brightness == 65535) {
  10183. $brightness = '-';
  10184. push @event, "3:brightness:not_supported";
  10185. } else {
  10186. $brightness = '-';
  10187. push @event, "3:brightness:unknown";
  10188. }
  10189. my $energyStorage = ($db[0] >> 3) * 5;
  10190. my $battery;
  10191. if ($energyStorage <= 5) {
  10192. $battery = 'low';
  10193. push @event, "3:battery:low";
  10194. push @event, "3:energyStorage:$energyStorage";
  10195. } elsif ($energyStorage <= 100) {
  10196. $battery = 'ok';
  10197. push @event, "3:battery:ok";
  10198. push @event, "3:energyStorage:$energyStorage";
  10199. } else {
  10200. $battery = '-';
  10201. push @event, "3:battery:-";
  10202. $energyStorage = '-';
  10203. push @event, "3:energyStorage:unknown";
  10204. }
  10205. push @event, "3:state:T: $temperature H: $humidity E: $brightness M: $onOffTrigger{$motion}";
  10206. } elsif ($msgType == 0x10) {
  10207. # configuration report
  10208. if (defined $waitingCmds) {
  10209. $waitingCmds = $db[3] & 0x80 ? $waitingCmds & 0xDF | 32 : $waitingCmds & 0xDF;
  10210. }
  10211. push @event, "3:presence:" . ($db[3] & 0x80 ? 'absent' : 'present');
  10212. push @event, "3:handleClosedClick:" . ($db[3] & 0x40 ? 'enabled' : 'disabled');
  10213. push @event, "3:batteryLowClick:" . ($db[3] & 0x20 ? 'enabled' : 'disabled');
  10214. $updateInterval = hex(substr($data, 4, 4));
  10215. if ($updateInterval <= 4) {
  10216. $updateInterval = '-';
  10217. push @event, "3:updateInterval:unknown";
  10218. } else {
  10219. push @event, "3:updateInterval:$updateInterval";
  10220. }
  10221. $blinkInterval = $db[0];
  10222. if ($blinkInterval <= 2) {
  10223. $blinkInterval = '-';
  10224. push @event, "3:blinkInterval:unknown";
  10225. } else {
  10226. push @event, "3:blinkInterval:$blinkInterval";
  10227. }
  10228. } elsif ($msgType == 0x20) {
  10229. # log data 01
  10230. push @event, "3:powerOns:" . substr($data, 2, 8);
  10231. push @event, "3:alarms:" . substr($data, 10, 8);
  10232. } elsif ($msgType == 0x21) {
  10233. # log data 02
  10234. push @event, "3:handleMoveClosed:" . substr($data, 2, 8);
  10235. push @event, "3:handleMoveOpend:" . substr($data, 10, 8);
  10236. push @event, "3:handleMoveTilted:" . substr($data, 18, 8);
  10237. } elsif ($msgType == 0x22) {
  10238. # log data 03
  10239. push @event, "3:windowTilts:" . substr($data, 2, 8);
  10240. } elsif ($msgType == 0x23) {
  10241. # log data 04
  10242. push @event, "3:buttonRightPresses:" . substr($data, 2, 8);
  10243. push @event, "3:buttonLeftPresses:" . substr($data, 10, 8);
  10244. } else {
  10245. }
  10246. if (defined $waitingCmds) {
  10247. $updateInterval = 0;
  10248. $blinkInterval = 0;
  10249. if ($waitingCmds & 1) {
  10250. $waitingCmds &= 0xFE;
  10251. $updateInterval = ReadingsVal($name, "updateIntervalSet", 0);
  10252. $updateInterval = $updateInterval =~ m/^\d+$/ ? $updateInterval : 0;
  10253. $blinkInterval = ReadingsVal($name, "blinkIntervalSet", 0);
  10254. $blinkInterval = $blinkInterval =~ m/^\d+$/ ? $blinkInterval : 0;
  10255. CommandDeleteReading(undef, "$name .*Set");
  10256. }
  10257. CommandDeleteReading(undef, "$name waitingCmds");
  10258. $data = sprintf "80%02X%04X%02X", $waitingCmds, $updateInterval, $blinkInterval;
  10259. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  10260. #EnOcean_multisensor_01Snd($crtl, $hash, $packetType);
  10261. }
  10262. } elsif ($st eq "roomCtrlPanel.01") {
  10263. # Room Control Panel
  10264. # (D2-11-01 - D2-11-08)
  10265. my $msgType = hex(substr($data, 1, 1));
  10266. my $setpointType = ReadingsVal($name, "setpointType", 'setpointShift');
  10267. my $waitingCmds = ReadingsVal($name, "waitingCmds", 0);
  10268. if (($waitingCmds & 0x80) == 0) {
  10269. $setpointType = hex(substr($data, 0, 1)) & 8 ? 'setpointTemp' : 'setpointShift';
  10270. push @event, "3:setpointType:$setpointType";
  10271. }
  10272. if ($msgType == 2) {
  10273. my $trigger = ($db[5] & 0x60) >> 5;
  10274. my %trigger = (0 => 'heartbeat', 1 => 'sensor', 2 => 'input');
  10275. push @event, "3:trigger:" . $trigger{$trigger};
  10276. my $temperature = sprintf "%0.1f", $db[4] / 255 * 40;
  10277. push @event, "3:temperature:$temperature";
  10278. my $humidity = sprintf "%d", $db[3] / 2.5;
  10279. push @event, "3:humidity:$humidity";
  10280. my $setpointShiftMax = ($db[0] & 0xF0) >> 4;
  10281. push @event, "3:setpointShiftMax:$setpointShiftMax";
  10282. my $setpointShift = int(0.5 + $db[2] * $setpointShiftMax / 128 * 10) / 10 - $setpointShiftMax;
  10283. push @event, "3:setpointShift:" . sprintf "%0.1f", $setpointShift;
  10284. push @event, "3:setpointBase:$db[1]";
  10285. push @event, "3:setpointTemp:" . sprintf "%0.1f", ($db[1] + $setpointShift);
  10286. my %fanSpeed = (0 => 'auto', 1 => 'off', 2 => 1, 3 => 2, 4 => 3);
  10287. my $fanSpeed = ($db[0] & 0xE) >> 1;
  10288. push @event, "3:fanSpeed:" . $fanSpeed{$fanSpeed};
  10289. push @event, "3:occupancy:" . ($db[0] & 1 ? 'occupied' : 'unoccupied');
  10290. push @event, "3:state:T: $temperature H: $humidity SPT: " . ($db[1] + $setpointShift) . " F: " . $fanSpeed{$fanSpeed};
  10291. }
  10292. CommandDeleteReading(undef, "$name waitingCmds");
  10293. } elsif ($st eq "fanCtrl.00") {
  10294. # Fan Control
  10295. # (D2-20-00 - D2-20-02)
  10296. if ($db[3] & 1) {
  10297. # fan status message
  10298. my $fanSpeed = $db[0];
  10299. my $humidity = $db[1];
  10300. my $roomSize = $db[2] & 15;
  10301. my $roomSizeRef = ($db[2] & 0x30) >> 4;
  10302. my $humidityCtrl = ($db[2] & 0xC0) >> 6;
  10303. my $serviceInfo = ($db[3] & 14) >> 1;
  10304. my $opMode = ($db[3] & 0xF0) >> 4;
  10305. my %roomSizeTbl = (
  10306. 0 => 25,
  10307. 1 => 50,
  10308. 2 => 75,
  10309. 3 => 100,
  10310. 4 => 125,
  10311. 5 => 150,
  10312. 6 => 175,
  10313. 7 => 200,
  10314. 8 => 225,
  10315. 9 => 250,
  10316. 10 => 275,
  10317. 11 => 300,
  10318. 12 => 325,
  10319. 13 => 350,
  10320. 14 => "max",
  10321. 15 => "no_change"
  10322. );
  10323. if ($opMode == 0) {
  10324. push @event, "3:state:off";
  10325. } elsif ($opMode == 1) {
  10326. push @event, "3:state:on";
  10327. } elsif ($opMode == 15) {
  10328. push @event, "3:state:not_supported";
  10329. }
  10330. if ($serviceInfo == 0) {
  10331. push @event, "3:error:ok";
  10332. } elsif ($serviceInfo == 1) {
  10333. push @event, "3:error:air_filter";
  10334. } elsif ($serviceInfo == 2) {
  10335. push @event, "3:error:hardware";
  10336. } elsif ($serviceInfo == 7) {
  10337. push @event, "3:error:not_supported";
  10338. }
  10339. if ($humidityCtrl == 0) {
  10340. push @event, "3:humidityCtrl:disabled";
  10341. } elsif ($humidityCtrl == 1) {
  10342. push @event, "3:humidityCtrl:enabled";
  10343. } elsif ($humidityCtrl == 3) {
  10344. push @event, "3:humidityCtrl:not_supported";
  10345. }
  10346. if ($roomSizeRef == 0) {
  10347. push @event, "3:roomSizeRef:used";
  10348. } elsif ($roomSizeRef == 1) {
  10349. push @event, "3:roomSizeRef:not_used";
  10350. } elsif ($roomSizeRef == 3) {
  10351. push @event, "3:roomSizeRef:not_supported";
  10352. }
  10353. if ($roomSize < 15) {
  10354. push @event, "3:roomSize:" . $roomSizeTbl{$roomSize};
  10355. }
  10356. if ($humidity >= 0 && $humidity <= 100) {
  10357. push @event, "3:humidity:$humidity";
  10358. } elsif ($humidity == 255) {
  10359. push @event, "3:humidity:not_supported";
  10360. }
  10361. if ($fanSpeed >= 0 && $fanSpeed <= 100) {
  10362. push @event, "3:fanSpeed:$fanSpeed";
  10363. } elsif ($fanSpeed == 255) {
  10364. push @event, "3:fanSpeed:not_supported";
  10365. }
  10366. }
  10367. } elsif ($st eq "currentClamp.00") {
  10368. # AC current clamp (EEP D2-32-00)
  10369. if ($db[2] & 0x80) {
  10370. # power fail
  10371. push @event, "3:current1:0";
  10372. push @event, "3:state:I1: 0";
  10373. } else {
  10374. my $current1 = hex(substr($data, 2, 3));
  10375. if ($db[2] & 0x40) {
  10376. # divisor = 1/10
  10377. $current1 = $current1 / 10;
  10378. push @event, "3:current1:" . sprintf "%0.1f", $current1;
  10379. push @event, "3:state:I1: " . sprintf "%0.1f", $current1;
  10380. } else {
  10381. push @event, "3:current1:" . $current1;
  10382. push @event, "3:state:I1: " . $current1;
  10383. }
  10384. }
  10385. } elsif ($st eq "currentClamp.01") {
  10386. # AC current clamp (EEP D2-32-01)
  10387. if ($db[3] & 0x80) {
  10388. # power fail
  10389. push @event, "3:current1:0";
  10390. push @event, "3:current2:0";
  10391. push @event, "3:state:I1: 0 I2: 0";
  10392. } else {
  10393. my $current1 = hex(substr($data, 2, 3));
  10394. my $current2 = hex(substr($data, 5, 3));
  10395. if ($db[3] & 0x40) {
  10396. # divisor = 1/10
  10397. $current1 = $current1 / 10;
  10398. $current2 = $current2 / 10;
  10399. push @event, "3:current1:" . sprintf "%0.1f", $current1;
  10400. push @event, "3:current2:" . sprintf "%0.1f", $current2;
  10401. push @event, "3:state:I1: " . sprintf("%0.1f", $current1) . " I2: " . sprintf("%0.1f", $current2);
  10402. } else {
  10403. push @event, "3:current1:" . $current1;
  10404. push @event, "3:current2:" . $current2;
  10405. push @event, "3:state:I1: $current1 I2: $current2";
  10406. }
  10407. }
  10408. } elsif ($st eq "currentClamp.02") {
  10409. # AC current clamp (EEP D2-32-02)
  10410. if ($db[5] & 0x80) {
  10411. # power fail
  10412. push @event, "3:current1:0";
  10413. push @event, "3:current2:0";
  10414. push @event, "3:current3:0";
  10415. push @event, "3:state:I1: 0 I2: 0 I3: 0";
  10416. } else {
  10417. my $current1 = hex(substr($data, 2, 3));
  10418. my $current2 = hex(substr($data, 5, 3));
  10419. my $current3 = hex(substr($data, 8, 3));
  10420. if ($db[5] & 0x40) {
  10421. # divisor = 1/10
  10422. $current1 = $current1 / 10;
  10423. $current2 = $current2 / 10;
  10424. $current3 = $current3 / 10;
  10425. push @event, "3:current1:" . sprintf "%0.1f", $current1;
  10426. push @event, "3:current2:" . sprintf "%0.1f", $current2;
  10427. push @event, "3:current3:" . sprintf "%0.1f", $current3;
  10428. push @event, "3:state:I1: " . sprintf("%0.1f", $current1) . " I2: " . sprintf("%0.1f", $current2) . " I3: " . sprintf("%0.1f", $current3);
  10429. } else {
  10430. push @event, "3:current1:" . $current1;
  10431. push @event, "3:current2:" . $current2;
  10432. push @event, "3:current3:" . $current3;
  10433. push @event, "3:state:I1: $current1 I2: $current2 I3: $current3";
  10434. }
  10435. }
  10436. } elsif ($st eq "ledCtrlState.00") {
  10437. # LED Controller Status (EEP D2-40-00)
  10438. if ($db[1] & 0x80) {
  10439. # powerSwitch
  10440. push @event, "3:powerSwitch:on";
  10441. push @event, "3:state:on";
  10442. } else {
  10443. push @event, "3:powerSwitch:off";
  10444. push @event, "3:state:off";
  10445. }
  10446. if ($db[1] & 0x40) {
  10447. # Demand Response Mode
  10448. push @event, "3:demandResp:on";
  10449. } else {
  10450. push @event, "3:demandResp:off";
  10451. }
  10452. if ($db[1] & 0x20) {
  10453. # Daylight Harvesting
  10454. push @event, "3:daylightHarvesting:on";
  10455. } else {
  10456. push @event, "3:daylightHarvesting:off";
  10457. }
  10458. my $occupancy = ($db[1] & 0x18) >> 3;
  10459. if ($occupancy == 0) {
  10460. push @event, "3:occupany:unoccupied";
  10461. } elsif ($occupancy == 1) {
  10462. push @event, "3:occupany:occupied";
  10463. } else {
  10464. push @event, "3:occupany:unknown";
  10465. }
  10466. push @event, "3:telegramType:" . ($db[1] & 4 ? "event" : "heartbeat");
  10467. if ($db[0] >= 0 && $db[0] <= 200) {
  10468. push @event, "3:dim:" . sprintf "%0.1f", $db[0] / 2;
  10469. }
  10470. } elsif ($st eq "ledCtrlState.01") {
  10471. # LED Controller Status (EEP D2-40-01)
  10472. if ($db[3] & 0x80) {
  10473. # powerSwitch
  10474. push @event, "3:powerSwitch:on";
  10475. push @event, "3:state:on";
  10476. } else {
  10477. push @event, "3:powerSwitch:off";
  10478. push @event, "3:state:off";
  10479. }
  10480. if ($db[3] & 0x40) {
  10481. # Demand Response Mode
  10482. push @event, "3:demandResp:on";
  10483. } else {
  10484. push @event, "3:demandResp:off";
  10485. }
  10486. if ($db[3] & 0x20) {
  10487. # Daylight Harvesting
  10488. push @event, "3:daylightHarvesting:on";
  10489. } else {
  10490. push @event, "3:daylightHarvesting:off";
  10491. }
  10492. my $occupancy = ($db[3] & 0x18) >> 3;
  10493. if ($occupancy == 0) {
  10494. push @event, "3:occupany:unoccupied";
  10495. } elsif ($occupancy == 1) {
  10496. push @event, "3:occupany:occupied";
  10497. } else {
  10498. push @event, "3:occupany:unknown";
  10499. }
  10500. push @event, "3:telegramType:" . ($db[3] & 4 ? "event" : "heartbeat");
  10501. my ($red, $green, $blue) = ('00', '00', '00');
  10502. if ($db[2] >= 0 && $db[2] <= 200) {
  10503. push @event, "3:red:" . sprintf "%0.1f", $db[2] / 2;
  10504. $red = sprintf "%02X", abs($db[2] / 200 * 255);
  10505. }
  10506. if ($db[1] >= 0 && $db[1] <= 200) {
  10507. push @event, "3:green:" . sprintf "%0.1f", $db[1] / 2;
  10508. $green = sprintf "%02X", abs($db[1] / 200 * 255);
  10509. }
  10510. if ($db[0] >= 0 && $db[0] <= 200) {
  10511. push @event, "3:blue:" . sprintf "%0.1f", $db[0] / 2;
  10512. $blue = sprintf "%02X", abs($db[0] / 200 * 255);
  10513. }
  10514. push @event, "3:rgb:" . $red . $green . $blue;
  10515. } elsif ($st eq "heatRecovery.00") {
  10516. # heat recovery ventilation
  10517. # (D2-50-00)
  10518. my $msgType = hex(substr($data, 0, 1)) >> 1;
  10519. if ($msgType == 2) {
  10520. my $ventilation = 'unknown';
  10521. my %ventilation = (
  10522. 0 => "off",
  10523. 1 => 1,
  10524. 2 => 2,
  10525. 3 => 3,
  10526. 4 => 4,
  10527. 11 => "auto",
  10528. 12 => "demand",
  10529. 13 => "supplyAir",
  10530. 14 => "exhaustAir"
  10531. );
  10532. $ventilation = $db[13] & 15;
  10533. $ventilation = $ventilation{$ventilation} if (exists $ventilation{$ventilation});
  10534. push @event, "3:ventilation:$ventilation";
  10535. push @event, "3:fireplaceSafetyMode:" . ($db[12] & 8 ? 'enabled' : 'disabled');
  10536. push @event, "3:heatExchangerBypass:" . ($db[12] & 4 ? 'opened' : 'closed');
  10537. push @event, "3:supplyAirFlap:" . ($db[12] & 2 ? 'opened' : 'closed');
  10538. push @event, "3:exhaustAirFlap:" . ($db[12] & 1 ? 'opened' : 'closed');
  10539. push @event, "3:defrost:" . ($db[11] & 0x80 ? 'on' : 'off');
  10540. push @event, "3:coolingProtection:" . ($db[11] & 0x40 ? 'on' : 'off');
  10541. push @event, "3:outdoorAirHeater:" . ($db[11] & 0x20 ? 'on' : 'off');
  10542. push @event, "3:supplyAirHeater:" . ($db[11] & 0x10 ? 'on' : 'off');
  10543. push @event, "3:drainHeater:" . ($db[11] & 8 ? 'on' : 'off');
  10544. push @event, "3:timerMode:" . ($db[11] & 4 ? 'on' : 'off');
  10545. push @event, "3:filterMaintenance:" . ($db[11] & 2 ? 'required' : 'not_required');
  10546. push @event, "3:weeklyTimer:" . ($db[11] & 1 ? 'on' : 'off');
  10547. push @event, "3:roomTempCtrl:" . ($db[10] & 0x80 ? 'on' : 'off');
  10548. my $airQuatity = $db[10] & 0x7F;
  10549. if ($airQuatity <= 100) {
  10550. push @event, "3:airQuality1:$airQuatity";
  10551. } else {
  10552. CommandDeleteReading(undef, "$name airQuality1");
  10553. }
  10554. push @event, "3:deviceMode:" . ($db[9] & 0x80 ? 'slave' : 'master');
  10555. $airQuatity = $db[9] & 0x7F;
  10556. if ($airQuatity <= 100) {
  10557. push @event, "3:airQuality2:$airQuatity";
  10558. } else {
  10559. CommandDeleteReading(undef, "$name airQuality2");
  10560. }
  10561. my $outdoorTemp = ($db[8] & 0xFE) >> 1;
  10562. #$outdoorTemp -= $outdoorTemp if ($outdoorTemp & 0x40);
  10563. $outdoorTemp -= 64;
  10564. push @event, "3:outdoorTemp:$outdoorTemp";
  10565. my $supplyTemp = ($db[8] & 1) << 6 | ($db[7] & 0xFC) >> 2;
  10566. #$supplyTemp -= $supplyTemp if ($supplyTemp & 0x40);
  10567. $supplyTemp -= 64;
  10568. push @event, "3:supplyTemp:$supplyTemp";
  10569. my $roomTemp = ($db[7] & 3) << 5 | ($db[6] & 0xF8) >> 3;
  10570. #$roomTemp -= $roomTemp if ($roomTemp & 0x40);
  10571. $roomTemp -= 64;
  10572. push @event, "3:roomTemp:$roomTemp";
  10573. my $exhaustTemp = ($db[6] & 7) << 4 | ($db[5] & 0xF0) >> 4;
  10574. #$exhaustTemp -= $exhaustTemp if ($exhaustTemp & 0x40);
  10575. $exhaustTemp -= 64;
  10576. push @event, "3:exhaustTemp:$exhaustTemp";
  10577. push @event, "3:supplyAirFlow:". (($db[5] & 0x0F) << 2 | ($db[4] & 0xFC) >> 2);
  10578. push @event, "3:exhaustAirFlow:" . (($db[4] & 3) << 8 | $db[3]);
  10579. push @event, "3:supplyFanSpeed:". ($db[2] << 4 | ($db[1] & 0xF0) >> 4);
  10580. push @event, "3:exhaustFanSpeed:" . (($db[1] & 0x0F) << 8 | $db[0]);
  10581. push @event, "3:state:$ventilation";
  10582. } elsif ($msgType == 3) {
  10583. push @event, "3:SWVersion:" . (($db[13] & 0x0F) << 8 | $db[12]);
  10584. push @event, "3:operationHours:" . (($db[11] << 8 | $db[10]) * 3);
  10585. push @event, "3:input:" . sprintf("%02b %02b", $db[9], $db[8]);
  10586. push @event, "3:output:" . sprintf("%02b %02b", $db[7], $db[6]);
  10587. push @event, "3:info:" . sprintf("%02b %02b", $db[5], $db[4]);
  10588. push @event, "3:fault:" . sprintf("%02b %02b %02b %02b", $db[3], $db[2], $db[1], $db[0]);
  10589. }
  10590. } elsif ($st eq "valveCtrl.00") {
  10591. # Valve Control
  10592. # (D2-A0-01)
  10593. $db[0] &= 3;
  10594. if (AttrVal($name, "devMode", "master") eq "slave") {
  10595. # devMode slave
  10596. if ($db[0] == 1 || $db[0] == 3) {
  10597. push @event, "3:state:closes";
  10598. } elsif ($db[0] == 2) {
  10599. push @event, "3:state:opens";
  10600. } elsif ($db[0] == 0) {
  10601. my $state = ReadingsVal($name, "state", "-");
  10602. if ($state eq "closed" || $state eq "closes") {
  10603. $state = "01";
  10604. } elsif ($state eq "open" || $state eq "opens") {
  10605. $state = "02";
  10606. } else {
  10607. $state = "00";
  10608. }
  10609. EnOcean_SndRadio(undef, $hash, 1, "D2", $state, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  10610. }
  10611. } else {
  10612. #devMode master
  10613. if ($db[0] == 1) {
  10614. push @event, "3:state:closed";
  10615. } elsif ($db[0] == 2) {
  10616. push @event, "3:state:open";
  10617. } elsif ($db[0] == 0 || $db[0] == 3) {
  10618. push @event, "3:state:-";
  10619. }
  10620. }
  10621. } elsif ($st eq "liquidLeakage.51") {
  10622. # liquid leakage sensor
  10623. push @event, "3:state:" . $db[0] & 3 ? 'wet' : 'dry';
  10624. } elsif ($st eq "raw") {
  10625. # raw
  10626. push @event, "3:state:RORG: $rorg DATA: $data STATUS: $status ODATA: $odata";
  10627. # display data bytes $db[0] ... $db[x]
  10628. for (my $dbCntr = 0; $dbCntr <= $#db; $dbCntr++) {
  10629. push @event, "3:DB_" . $dbCntr . ":" . $db[$dbCntr];
  10630. }
  10631. } else {
  10632. # unknown devices
  10633. push @event, "3:state:$data";
  10634. }
  10635. } elsif ($rorg eq "D1") {
  10636. # MSC telegram
  10637. if ($st eq "actuator.01") {
  10638. if ($manufID eq "033") {
  10639. if (substr($data, 3, 1) == 4) {
  10640. my $getParam = ReadingsVal($name, "getParam", 0);
  10641. if ($getParam == 8) {
  10642. push @event, "3:loadClassification:no";
  10643. push @event, "3:loadLink:" . ($db[1] & 16 ? "connected" : "disconnected");
  10644. push @event, "3:loadOperation:3-wire";
  10645. push @event, "3:loadState:" . ($db[1] & 64 ? "on" : "off");
  10646. CommandDeleteReading(undef, "$name getParam");
  10647. } elsif ($getParam == 7) {
  10648. if ($db[0] & 4) {
  10649. push @event, "3:devTempState:warning";
  10650. } elsif ($db[0] & 2) {
  10651. push @event, "3:devTempState:max";
  10652. } else {
  10653. push @event, "3:devTempState:ok";
  10654. }
  10655. push @event, "3:mainsPower:" . ($db[0] & 8 ? "failure" : "ok");
  10656. if ($db[1] == 0xFF) {
  10657. push @event, "3:devTemp:invalid";
  10658. } else {
  10659. push @event, "3:devTemp:" . $db[1];
  10660. }
  10661. CommandDeleteReading(undef, "$name getParam");
  10662. } elsif ($getParam == 9) {
  10663. push @event, "3:voltage:" . sprintf("%.2f", (hex(substr($data, 4, 4)) * 0.01));
  10664. CommandDeleteReading(undef, "$name getParam");
  10665. } elsif ($getParam == 0x81) {
  10666. $hash->{READINGS}{serialNumber}{VAL} = substr($data, 4, 4);
  10667. $hash->{READINGS}{getParam}{VAL} = 0x82;
  10668. EnOcean_SndRadio(undef, $hash, $packetType, "D1", "033182", AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  10669. } elsif ($getParam == 0x82) {
  10670. push @event, "3:serialNumber:" . $hash->{READINGS}{serialNumber}{VAL} . substr($data, 4, 4);
  10671. CommandDeleteReading(undef, "$name getParam");
  10672. }
  10673. }
  10674. } elsif ($manufID eq "046") {
  10675. my $cmd = hex(substr($data, 4, 2));
  10676. if ($cmd == 3) {
  10677. push @event, "3:firmwareVersion:" . substr($data, 6, 6);
  10678. } elsif ($cmd == 5) {
  10679. push @event, "3:taughtInDevNum:$db[0]";
  10680. } elsif ($cmd == 7) {
  10681. CommandDeleteReading(undef, "$name taughtInDevID.*");
  10682. push @event, "3:taughtInDevID" . sprintf('%02d', $db[4]) . ":" . substr($data, 8, 8);
  10683. }
  10684. }
  10685. } elsif ($st eq "raw") {
  10686. # raw
  10687. push @event, "3:state:RORG: $rorg DATA: $data STATUS: $status ODATA: $odata";
  10688. push @event, "3:manufID:" . substr($data, 0, 3);
  10689. # display data bytes $db[0] ... $db[x]
  10690. for (my $dbCntr = 0; $dbCntr <= $#db; $dbCntr++) {
  10691. push @event, "3:DB_" . $dbCntr . ":" . $db[$dbCntr];
  10692. }
  10693. } else {
  10694. # unknown devices
  10695. if(AttrVal($name, "blockUnknownMSC", "no") eq "yes") {
  10696. push @event, "3:MSC:$data";
  10697. }
  10698. }
  10699. } elsif ($rorg eq "D0") {
  10700. my %smartAckMailbox = (0 => 'empty', 1 => 'not_exits', 2 => 'reset');
  10701. push @event, "3:smartAckMailbox:" . $smartAckMailbox{$db[0]};
  10702. } elsif ($rorg eq "B2") {
  10703. # GP complete data (GPCD)
  10704. my ($channel, $channelName, $value, $gpDef, $resolution) = (0, undef, undef, AttrVal($name, 'gpDef', undef), undef);
  10705. return "generic profil not defined" if (!defined $gpDef);
  10706. my @gpDef = split("[ \t][ \t]*", $gpDef);
  10707. my ($readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType);
  10708. $data = EnOcean_convHexToBit($data);
  10709. while (defined $gpDef[$channel]) {
  10710. ($channelName, undef, undef, undef, undef, $resolution, undef, undef, undef, undef) = split(':', $gpDef[$channel]);
  10711. $resolution = 0 if (!defined $resolution);
  10712. $data =~ m/^(.{$EnO_resolution[$resolution]})(.*)$/;
  10713. $value = hex(unpack('H8', pack('B32', '0' x (32 - $EnO_resolution[$resolution]) . $1)));
  10714. $data = $2;
  10715. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType)=
  10716. EnOcean_gpConvDataToValue (undef, $hash, $channel, $value, $gpDef[$channel]);
  10717. $channel ++;
  10718. next if (defined $err);
  10719. push @event, "3:$readingName:" . sprintf("$readingFormat", $readingValue);
  10720. push @event, "3:" . $readingName . "Unit:$readingUnit";
  10721. push @event, "3:" . $readingName . "ValueType:$valueType";
  10722. push @event, "3:" . $readingName . "ChannelType:$readingType";
  10723. }
  10724. } elsif ($rorg eq "B3") {
  10725. # GP selective data (GPSD)
  10726. my $gpDef = AttrVal($name, "gpDef", undef);
  10727. return "generic profil not defined" if (!defined $gpDef);
  10728. my @gpDef = split("[ \t][ \t]*", $gpDef);
  10729. my ($channel, $channelName, $resolution, $value);
  10730. my ($readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType);
  10731. #Log3 $name, 2, "EnOcean $name parse GPSD data: $data start";
  10732. $data =~ m/^(.)(.*)$/;
  10733. my $header = hex $1;
  10734. $data = substr(EnOcean_convHexToBit($data), 4);
  10735. #Log3 $name, 2, "EnOcean $name parse GPSD header: $header data: $data start";
  10736. for (my $cntr = 1; $cntr <= $header; $cntr ++) {
  10737. $data =~ m/^(.{6})(.*)$/;
  10738. ($channel, $data) = (unpack('C', pack('B8', '00' . $1)), $2);
  10739. #Log3 $name, 2, "EnOcean $name parse GPSD channel: $channel data: $data";
  10740. if (defined $gpDef[$channel]) {
  10741. ($channelName, undef, undef, undef, undef, $resolution, undef, undef, undef, undef) = split(':', $gpDef[$channel]);
  10742. $resolution = 0 if (!defined $resolution || $resolution eq '');
  10743. $data =~ m/^(.{$EnO_resolution[$resolution]})(.*)$/;
  10744. $value = hex(unpack('H8', pack('B32', '0' x (32 - $EnO_resolution[$resolution]) . $1)));
  10745. $data = $2;
  10746. #Log3 $name, 2, "EnOcean $name parse GPSD channel: $channel value: " . $value . " data: $data";
  10747. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType) =
  10748. EnOcean_gpConvDataToValue(undef, $hash, $channel, $value, $gpDef[$channel]);
  10749. push @event, "3:$readingName:" . sprintf("$readingFormat", $readingValue);
  10750. push @event, "3:" . $readingName . "Unit:$readingUnit";
  10751. push @event, "3:" . $readingName . "ValueType:$valueType";
  10752. push @event, "3:" . $readingName . "ChannelType:$readingType";
  10753. }
  10754. }
  10755. } elsif ($rorg eq "B0" && $teach) {
  10756. # GP teach in request (GPTI)
  10757. #
  10758. $data =~ m/^(....)(.*)$/;
  10759. my $header = hex($1);
  10760. $data = $2;
  10761. my $purpose = ($header & 12) >> 2;
  10762. if ($purpose == 0 || ($purpose == 2 && AttrVal($name, "subType", "") ne "genericProfile")) {
  10763. # teach-in request
  10764. $attr{$name}{comMode} = $header & 16 ? "biDir" : "uniDir";
  10765. $attr{$name}{eep} = "B0-00-00";
  10766. $attr{$name}{manufID} = sprintf "%03X", ($header & 0xFFE0) >> 5;
  10767. $attr{$name}{subType} = "genericProfile";
  10768. $attr{$name}{teachMethod} = 'GP';
  10769. my $channel = 0;
  10770. my $channelDir = "I";
  10771. my $channelDef;
  10772. my $channelName;
  10773. my $channelType;
  10774. my $cntr = 0;
  10775. my $dataOutboundDefLen = 0;
  10776. my @gpDef;
  10777. my $signalType;
  10778. #Log3 $name, 2, "EnOcean $name parse GPTI header: $header data: $data start";
  10779. $data = EnOcean_convHexToBit($data);
  10780. #Log3 $name, 2, "EnOcean $name parse GPTI data: $data start";
  10781. while (length($data) >= 12) {
  10782. last if ($cntr > 64);
  10783. $cntr ++;
  10784. $data =~ m/^(..)(.{8})(.*)$/;
  10785. $channelType = unpack('C', pack('B8', '000000' . $1));
  10786. $signalType = unpack('C', pack('B8', $2));
  10787. $data = $3;
  10788. #Log3 $name, 2, "EnOcean $name parse GPTI channel: $channel channelType: $channelType signalType: $signalType data: $data";
  10789. if ($channelType == 0) {
  10790. # teach-in information
  10791. if ($signalType == 1) {
  10792. # outbound channel description
  10793. $channelDir = "O";
  10794. $data =~ m/^(.{8})(.*)$/;
  10795. $dataOutboundDefLen = unpack('C', pack('B8', $1));
  10796. $data = $2;
  10797. } elsif ($signalType == 2) {
  10798. # produkt ID
  10799. $data =~ m/^(.{32})(.*)$/;
  10800. $attr{$name}{productID} = EnOcean_convBitToHex($1);
  10801. $data = $2;
  10802. }
  10803. } elsif ($channelType == 1) {
  10804. # data
  10805. $data =~ m/^(..)(....)(.{8})(....)(.{8})(....)(.*)$/;
  10806. $channelDef = $channelDir . ':' . $channelType . ':' . $signalType . ':' .
  10807. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2)) . ':' .
  10808. unpack('c', pack('B8', $3)) . ':' . unpack('C', pack('B8', '0000' . $4)) . ':' .
  10809. unpack('c', pack('B8', $5)) . ':' . unpack('C', pack('B8', '0000' . $6));
  10810. $data = $7;
  10811. if (defined $EnO_gpValueData{$signalType}{name}) {
  10812. $channelName = $EnO_gpValueData{$signalType}{name};
  10813. } else {
  10814. $channelName = "none";
  10815. }
  10816. $gpDef[$channel] = $channelName . ':' . $channelDef;
  10817. $channel ++;
  10818. } elsif ($channelType == 2) {
  10819. # flag
  10820. $data =~ m/^(..)(.*)$/;
  10821. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  10822. unpack('C', pack('B8', '000000' . $1));
  10823. $data = $2;
  10824. if (defined $EnO_gpValueFlag{$signalType}{name}) {
  10825. $channelName = $EnO_gpValueFlag{$signalType}{name};
  10826. } else {
  10827. $channelName = "none";
  10828. }
  10829. $gpDef[$channel] = $channelName . ':' . $channelDef;
  10830. $channel ++;
  10831. } elsif ($channelType == 3) {
  10832. # enumeration
  10833. $data =~ m/^(..)(....)(.*)$/;
  10834. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  10835. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2));
  10836. $data = $3;
  10837. if (defined $EnO_gpValueEnum{$signalType}{name}) {
  10838. $channelName = $EnO_gpValueEnum{$signalType}{name};
  10839. } else {
  10840. $channelName = "none";
  10841. }
  10842. $gpDef[$channel] = $channelName . ':' . $channelDef;
  10843. $channel ++;
  10844. }
  10845. }
  10846. $attr{$name}{gpDef} = join(' ', @gpDef);
  10847. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  10848. # send GP Teach-In Response message
  10849. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  10850. $data = sprintf "%04X", ((hex(AttrVal($name, "manufID", "7FF")) << 5) | 8);
  10851. EnOcean_SndCdm(undef, $hash, $packetType, "B1", $data, $subDef, "00", $senderID);
  10852. Log3 $name, 2, "EnOcean $name GP teach-in response sent to $senderID";
  10853. }
  10854. my $mid = $attr{$name}{manufID};
  10855. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10856. push @event, "3:teach:GP teach-in accepted Manufacturer: $mid";
  10857. Log3 $name, 2, "EnOcean $name GP teach-in accepted Manufacturer: $mid";
  10858. # store attr subType, manufID, gpDef ...
  10859. EnOcean_CommandSave(undef, undef);
  10860. } elsif ($purpose == 1 || ($purpose == 2 && AttrVal($name, "subType", "") eq "genericProfile")) {
  10861. # teach-in deletion request
  10862. $deleteDevice = $name;
  10863. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  10864. # send GP Teach-In Deletion Response message
  10865. $data = sprintf "%04X", (hex(AttrVal($name, "manufID", "7FF")) << 5) | 16;
  10866. EnOcean_SndCdm(undef, $hash, $packetType, "B1", $data, AttrVal($name, "subDef", "00000000"), "00", $senderID);
  10867. Log3 $name, 2, "EnOcean $name GP teach-in deletion response send to $senderID";
  10868. }
  10869. Log3 $name, 2, "EnOcean $name GP teach-in delete request executed";
  10870. }
  10871. } elsif ($rorg eq "B1" && $teach) {
  10872. # GP teach-in response (GPTR)
  10873. $data =~ m/^(....)(.*)$/;
  10874. my $header = hex($1);
  10875. $data = $2;
  10876. my $mid = sprintf "%03X", ($header & 0xFFE0) >> 5;
  10877. my $purpose = ($header & 24) >> 3;
  10878. if (exists $hash->{IODev}{helper}{gpRespWait}{$destinationID}) {
  10879. if ($purpose == 0) {
  10880. # teach-in rejected generally
  10881. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "in") {
  10882. push @event, "3:teach:GP teach-in rejected";
  10883. Log3 $name, 2, "EnOcean $name GP teach-in rejected by $senderID";
  10884. }
  10885. # clear teach-in request
  10886. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10887. } elsif ($purpose == 1) {
  10888. # teach-in accepted
  10889. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "in") {
  10890. $attr{$name}{manufID} = $mid;
  10891. # substitute subDef with DEF
  10892. $attr{$name}{subDef} = $hash->{DEF};
  10893. $hash->{DEF} = $senderID;
  10894. $modules{EnOcean}{defptr}{$senderID} = $hash;
  10895. delete $modules{EnOcean}{defptr}{$destinationID};
  10896. EnOcean_CommandSave(undef, undef);
  10897. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10898. push @event, "3:teach:GP teach-in accepted Manufacturer: $mid";
  10899. Log3 $name, 2, "EnOcean $name GP teach-in accepted by $senderID";
  10900. }
  10901. # clear teach-in request
  10902. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10903. } elsif ($purpose == 2) {
  10904. # teach-out accepted
  10905. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "out") {
  10906. if (defined $attr{$name}{subDef}) {
  10907. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  10908. $hash->{DEF} = $attr{$name}{subDef};
  10909. $modules{EnOcean}{defptr}{$hash->{DEF}} = $hash;
  10910. delete $attr{$name}{subDef};
  10911. EnOcean_CommandSave(undef, undef);
  10912. }
  10913. push @event, "3:teach:GP teach-out accepted";
  10914. Log3 $name, 2, "EnOcean $name GP teach-out accepted";
  10915. }
  10916. # clear teach-in request
  10917. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10918. } else {
  10919. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "in") {
  10920. # rejected channels outbound or inbound, sent teach-in response with teach-out
  10921. $data = sprintf "%04X", (hex(AttrVal($name, "manufID", "7FF")) << 5) | 16;
  10922. EnOcean_SndCdm(undef, $hash, $packetType, "B1", $data, $destinationID, "00", $senderID);
  10923. push @event, "3:teach:GP teach-in channels rejected, sent teach-out";
  10924. Log3 $name, 2, "EnOcean $name GP teach-in channels rejected, sent teach-out to $senderID";
  10925. }
  10926. # clear teach-in request
  10927. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10928. }
  10929. } else {
  10930. Log3 $name, 2, "EnOcean $name GP teach-in response from $senderID received, teach-in request unknown";
  10931. }
  10932. } elsif ($rorg eq "D4" && $teach) {
  10933. # UTE - Universal Uni- and Bidirectional Teach-In / Teach-Out
  10934. #
  10935. Log3 $name, 5, "EnOcean $name UTE teach-in received from $senderID";
  10936. my $rorg = sprintf "%02X", $db[0];
  10937. my $func = sprintf "%02X", $db[1];
  10938. my $type = sprintf "%02X", $db[2];
  10939. my $mid = sprintf "%03X", ((($db[3] & 7) << 8) | $db[4]);
  10940. my $devChannel = $db[5];
  10941. my $comMode = $db[6] & 0x80 ? "biDir" : "uniDir";
  10942. my $comModeUTE = AttrVal($hash->{IODev}{NAME}, "comModeUTE", "auto");
  10943. $comMode = $comModeUTE if ($comModeUTE ne 'auto');
  10944. my $subType = "$rorg.$func.$type";
  10945. if (($db[6] & 0xF) == 0) {
  10946. # Teach-In Query telegram received
  10947. my $teachInReq = ($db[6] & 0x30) >> 4;
  10948. if ($teachInReq == 0 || $teachInReq == 2) {
  10949. # Teach-In Request
  10950. $attr{$name}{teachMethod} = 'UTE';
  10951. if(exists $EnO_eepConfig{$subType}) {
  10952. # Teach-In EEP supported
  10953. foreach my $attrCntr (keys %{$EnO_eepConfig{$subType}{attr}}) {
  10954. $attr{$name}{$attrCntr} = $EnO_eepConfig{$subType}{attr}{$attrCntr};
  10955. }
  10956. $attr{$name}{manufID} = $mid;
  10957. $attr{$name}{devChannel} = $devChannel;
  10958. $attr{$name}{comMode} = $comMode;
  10959. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10960. $attr{$name}{eep} = "$rorg-$func-$type";
  10961. if (exists($hash->{helper}{teachInWait}) && $hash->{helper}{teachInWait} =~ m/^UTE|STE$/) {
  10962. $attr{$filelogName}{logtype} = $EnO_eepConfig{$subType}{GPLOT} . 'text'
  10963. if (exists $attr{$filelogName}{logtype});
  10964. EnOcean_CreateSVG(undef, $hash, undef);
  10965. delete $hash->{helper}{teachInWait};
  10966. }
  10967. $subType = $EnO_eepConfig{$subType}{attr}{subType};
  10968. #$attr{$name}{subType} = $subType;
  10969. push @event, "3:teach:UTE teach-in accepted EEP $rorg-$func-$type Manufacturer: $mid";
  10970. if (!($db[6] & 0x40)) {
  10971. # UTE Teach-In-Response expected
  10972. # send UTE Teach-In Response message
  10973. $data = (sprintf "%02X", $db[6] & 0x80 | 0x11) . substr($data, 2, 12);
  10974. if ($comMode eq "biDir") {
  10975. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", $comMode);
  10976. } else {
  10977. $subDef = "00000000";
  10978. }
  10979. EnOcean_SndRadio(undef, $hash, $packetType, "D4", $data, $subDef, "00", $senderID);
  10980. Log3 $name, 2, "EnOcean $name UTE teach-in response send to $senderID";
  10981. }
  10982. Log3 $name, 2, "EnOcean $name UTE teach-in accepted EEP $rorg-$func-$type Manufacturer: $mid";
  10983. } else {
  10984. # Teach-In EEP not supported
  10985. $attr{$name}{subType} = "raw";
  10986. $attr{$name}{manufID} = $mid;
  10987. $attr{$name}{devChannel} = $devChannel;
  10988. $attr{$name}{comMode} = $comMode;
  10989. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10990. push @event, "3:teach:UTE teach-in accepted EEP $rorg-$func-$type not supported Manufacturer: $mid";
  10991. # send EEP Teach-In Response message
  10992. if (!($db[6] & 0x40)) {
  10993. # UTE Teach-In-Response expected
  10994. # send UTE Teach-In Response message
  10995. $data = (sprintf "%02X", $db[6] & 0x80 | 0x31) . substr($data, 2, 12);
  10996. EnOcean_SndRadio(undef, $hash, $packetType, "D4", $data, "00000000", "00", $senderID);
  10997. Log3 $name, 2, "EnOcean $name UTE teach-in response send to $senderID";
  10998. }
  10999. Log3 $name, 2, "EnOcean $name UTE teach-in accepted EEP $rorg-$func-$type not supported Manufacturer: $mid";
  11000. }
  11001. # store attr subType, manufID ...
  11002. EnOcean_CommandSave(undef, undef);
  11003. } elsif ($teachInReq == 1) {
  11004. # Teach-In Deletion Request
  11005. $deleteDevice = $name;
  11006. if (!($db[6] & 0x40)) {
  11007. # UTE Teach-In Deletion Response expected
  11008. # send UTE Teach-In Deletion Response message
  11009. $data = (sprintf "%02X", $db[6] & 0x80 | 0x21) . substr($data, 2, 12);
  11010. EnOcean_SndRadio(undef, $hash, $packetType, "D4", $data, AttrVal($name, "subDef", "00000000"), "00", $senderID);
  11011. Log3 $name, 2, "EnOcean $name UTE teach-in deletion response send to $senderID";
  11012. }
  11013. Log3 $name, 2, "EnOcean $name UTE teach-in delete request executed";
  11014. }
  11015. } else {
  11016. # Teach-In Respose telegram received
  11017. my $teachInAccepted = ($db[6] & 0x30) >> 4;
  11018. Log3 $name, 5, "EnOcean $name UTE teach-in response message from $senderID received";
  11019. if (exists $hash->{IODev}{helper}{UTERespWait}{$destinationID}) {
  11020. if ($comMode eq "uniDir") {
  11021. $attr{$name}{manufID} = $mid;
  11022. if ($teachInAccepted == 0) {
  11023. $teachInAccepted = "request not accepted";
  11024. } elsif ($teachInAccepted == 1){
  11025. $teachInAccepted = "teach-in accepted";
  11026. } elsif ($teachInAccepted == 2){
  11027. $teachInAccepted = "teach-out accepted";
  11028. } else {
  11029. $teachInAccepted = "EEP not supported";
  11030. }
  11031. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  11032. push @event, "3:teach:UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11033. Log3 $name, 2, "EnOcean $name UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11034. } else {
  11035. if ($hash->{IODev}{helper}{UTERespWait}{$destinationID}{teachInReq} eq "in") {
  11036. # Teach-In Request
  11037. if ($teachInAccepted == 0) {
  11038. $teachInAccepted = "request not accepted";
  11039. } elsif ($teachInAccepted == 1){
  11040. $teachInAccepted = "teach-in accepted";
  11041. $attr{$name}{subDef} = $hash->{DEF};
  11042. $hash->{DEF} = $senderID;
  11043. $modules{EnOcean}{defptr}{$senderID} = $hash;
  11044. delete $modules{EnOcean}{defptr}{$destinationID};
  11045. $attr{$name}{manufID} = $mid;
  11046. # store attr subType, manufID ...
  11047. EnOcean_CommandSave(undef, undef);
  11048. } elsif ($teachInAccepted == 2){
  11049. $teachInAccepted = "teach-out accepted";
  11050. } else {
  11051. $teachInAccepted = "EEP not supported";
  11052. }
  11053. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  11054. push @event, "3:teach:UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11055. Log3 $name, 2, "EnOcean $name UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11056. } elsif ($hash->{IODev}{helper}{UTERespWait}{$destinationID}{teachInReq} eq "out") {
  11057. # Teach-In Deletion Request
  11058. if ($teachInAccepted == 0) {
  11059. $teachInAccepted = "request not accepted";
  11060. } elsif ($teachInAccepted == 1){
  11061. $teachInAccepted = "teach-in accepted";
  11062. } elsif ($teachInAccepted == 2){
  11063. $teachInAccepted = "teach-out accepted";
  11064. if (defined $attr{$name}{subDef}) {
  11065. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  11066. $hash->{DEF} = $attr{$name}{subDef};
  11067. $modules{EnOcean}{defptr}{$hash->{DEF}} = $hash;
  11068. delete $attr{$name}{subDef};
  11069. EnOcean_CommandSave(undef, undef);
  11070. }
  11071. } else {
  11072. $teachInAccepted = "EEP not supported";
  11073. }
  11074. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  11075. push @event, "3:teach:UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11076. Log3 $name, 2, "EnOcean $name UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11077. }
  11078. }
  11079. # clear teach-in request
  11080. delete $hash->{IODev}{helper}{UTERespWait}{$destinationID};
  11081. } else {
  11082. # teach-in request unknown, delete response device, no action
  11083. $deleteDevice = $name;
  11084. Log3 $name, 2, "EnOcean $name UTE teach-in request unknown";
  11085. }
  11086. }
  11087. } elsif ($rorg eq "35" && $teach) {
  11088. # Secure Teach-In
  11089. ($err, $msg) = EnOcean_sec_parseTeachIn($hash, $data, $subDef, $destinationID);
  11090. if (defined $err) {
  11091. Log3 $name, 2, "EnOcean $name secure teach-in ERROR: $err";
  11092. return "";
  11093. }
  11094. Log3 $name, 3, "EnOcean $name secure teach-in $msg";
  11095. EnOcean_CommandSave(undef, undef);
  11096. return "";
  11097. } elsif ($rorg eq "C6" && $smartAckLearn) {
  11098. # Smart Ack Learn Request
  11099. #####
  11100. $data =~ m/^(....)(..)(..)(..)(..)(........)$/;
  11101. my $subType = "$2.$3.$4";
  11102. my $postmasterID = '0' x 8;
  11103. my $mid = '7FF';
  11104. my $responseTime = 150;
  11105. my $sendData = '';
  11106. if (exists $EnO_eepConfig{$subType}) {
  11107. if (($db[9] & 0xF8) == 0xF8) {
  11108. # Smart Ack send by sensor
  11109. $attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType};
  11110. $attr{$name}{eep} = "$3-$4-$5";
  11111. $mid = substr(sprintf("%04X", hex($1) & 0x7FF), 1);
  11112. $attr{$name}{manufID} = $mid;
  11113. $mid = $EnO_manuf{$mid} if(exists $EnO_manuf{$mid});
  11114. $attr{$name}{repeaterID} = $6;
  11115. $postmasterID = $6;
  11116. $attr{$name}{postmasterID} = $postmasterID;
  11117. $attr{$name}{teachMethod} = 'smartAck';
  11118. $hash->{SmartAckRSSI} = - hex($db[4]);
  11119. foreach my $attrCntr (keys %{$EnO_eepConfig{$subType}{attr}}) {
  11120. if ($attrCntr ne "subDef") {
  11121. $attr{$name}{$attrCntr} = $EnO_eepConfig{$subType}{attr}{$attrCntr};
  11122. }
  11123. }
  11124. if (defined AttrVal($name, 'subDef', undef)) {
  11125. $subDef = $attr{$name}{subDef};
  11126. } else {
  11127. $subDef = EnOcean_CheckSenderID('getNextID', $hash->{IODev}{NAME}, "00000000");
  11128. $attr{$name}{subDef} = $subDef;
  11129. }
  11130. # create mailbox
  11131. $sendData = sprintf "03%04X00%04X%04X", $responseTime, $postmasterID, $hash->{DEF};
  11132. EnOcean_SndRadio(undef, $hash, 6, $rorg, $sendData, $subDef, '00', $hash->{DEF});
  11133. # next commands will be sent with a delay
  11134. #usleep($responseTime * 1000);
  11135. # send learn reply
  11136. $sendData = sprintf "01%04X00%04X", $responseTime, $hash->{DEF};
  11137. EnOcean_SndRadio(undef, $hash, 1, 'C7', $sendData, $subDef, '00', $hash->{DEF});
  11138. push @event, "3:teach:Smart Ack teach-in accepted EEP " . $attr{$name}{eep} . " Manufacturer: $mid";
  11139. Log3 $name, 2, "EnOcean $name Smart Ack teach-in accepted EEP " . $attr{$name}{eep} . " Manufacturer: $mid";
  11140. EnOcean_CommandSave(undef, undef);
  11141. }
  11142. } else {
  11143. # EEP not supported
  11144. # send learn reply
  11145. $sendData = sprintf "01%04X10%04X", $responseTime, $hash->{DEF};
  11146. EnOcean_SndRadio(undef, $hash, 1, 'C7', $sendData, '0' x 8, '00', $hash->{DEF});
  11147. CommandDelete(undef, $name);
  11148. Log3 $name, 2, "EnOcean $name Smart Ack teach-in not accepted EEP " . $attr{$name}{eep} . " Manufacturer: $mid";
  11149. }
  11150. } elsif ($packetType == 7) {
  11151. # packet type REMOTE_MAN_COMMAND
  11152. my $remoteCode = AttrVal($name, 'remoteCode', '0' x 8);
  11153. my $remoteLastStatusReturnCode = $manufID eq '7FF' ? '00' : '04';
  11154. my $remoteManagement = AttrVal($name, "remoteManagement", "off");
  11155. my $sendData = '';
  11156. push @event, "3:remoteLastFunctionNumber:" . sprintf("%03X", $funcNumber);
  11157. if ($funcNumber == 1 && $remoteManagement eq 'client') {
  11158. # unlock
  11159. if ($data eq uc($remoteCode) && !exists($hash->{RemoteClientUnlockFailed})) {
  11160. $hash->{RemoteClientUnlock} = 1;
  11161. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  11162. RemoveInternalTimer(\%functionHash);
  11163. InternalTimer(gettimeofday() + 1800, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  11164. Log3 $name, 2, "EnOcean $name RMCC unlock request executed.";
  11165. } else {
  11166. $remoteLastStatusReturnCode = '02';
  11167. $hash->{RemoteClientUnlockFailed} = 1;
  11168. my %functionHash = (hash => $hash, param => 'RemoteClientUnlockFailed');
  11169. RemoveInternalTimer(\%functionHash);
  11170. InternalTimer(gettimeofday() + 30, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  11171. Log3 $name, 2, "EnOcean $name RMCC unlock request not executed, remote Code $data wrong.";
  11172. }
  11173. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11174. } elsif ($funcNumber == 2 && $remoteManagement eq 'client') {
  11175. # lock
  11176. if ($hash->{RemoteClientUnlock} && $data eq uc($remoteCode)) {
  11177. delete $hash->{RemoteClientUnlock};
  11178. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  11179. RemoveInternalTimer(\%functionHash);
  11180. Log3 $name, 2, "EnOcean $name RMCC lock request executed.";
  11181. } else {
  11182. $remoteLastStatusReturnCode = '02';
  11183. Log3 $name, 2, "EnOcean $name RMCC lock request not executed.";
  11184. }
  11185. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11186. } elsif ($funcNumber == 3 && $remoteManagement eq 'client') {
  11187. # set code
  11188. if ($hash->{RemoteClientUnlock} && $data =~ m/^[A-Fa-f0-9]{8}$/ && uc($data) ne 'FFFFFFFF') {
  11189. $attr{$name}{remoteCode} = $data;
  11190. EnOcean_CommandSave(undef, undef);
  11191. Log3 $name, 2, "EnOcean $name RMCC set code request executed.";
  11192. } else {
  11193. $remoteLastStatusReturnCode = '05';
  11194. Log3 $name, 2, "EnOcean $name RMCC set code request not executed.";
  11195. }
  11196. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11197. } elsif ($funcNumber == 4 && $remoteManagement eq 'client') {
  11198. # query ID
  11199. if ($hash->{RemoteClientUnlock}) {
  11200. my $eepRcv = hex(substr($data, 0, 6)) >> 3;
  11201. my $rorg = sprintf "%02X", ($eepRcv >> 13);
  11202. my $func = sprintf "%02X", (($eepRcv & 0x1F80) >> 7);
  11203. my $type = sprintf "%02X", ($eepRcv & 127);
  11204. $eepRcv = "$rorg-$func-$type";
  11205. if ($hash->{RemoteClientUnlock} && $eep eq $eepRcv) {
  11206. $sendData = '06040' . AttrVal($name, 'manufID', '7FF') . substr($data, 0, 4) . sprintf("%02X", hex(substr($data, 4, 2)) & 0xF8);
  11207. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11208. Log3 $name, 2, "EnOcean $name RMCC query ID answer sent.";
  11209. } else {
  11210. $remoteLastStatusReturnCode = '03';
  11211. Log3 $name, 2, "EnOcean $name RMCC query ID request not executed, EEP $eepRcv wrong or client locked.";
  11212. }
  11213. } else {
  11214. $remoteLastStatusReturnCode = '07';
  11215. Log3 $name, 2, "EnOcean $name RMCC query ID request not executed.";
  11216. }
  11217. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11218. } elsif ($funcNumber == 5 && $remoteManagement eq 'client') {
  11219. # action
  11220. if ($hash->{RemoteClientUnlock}) {
  11221. Log3 $name, 2, "EnOcean $name RMCC action request executed";
  11222. } else {
  11223. $remoteLastStatusReturnCode = '01';
  11224. Log3 $name, 2, "EnOcean $name RMCC action request not executed.";
  11225. }
  11226. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11227. } elsif ($funcNumber == 6 && $remoteManagement eq 'client') {
  11228. # ping
  11229. my $eep = AttrVal($name, "eep", "C5-00-00");
  11230. if ($eep =~ m/^([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})$/i) {
  11231. $eep = (((hex($1) << 6) | hex($2)) << 7) | hex($3);
  11232. } else {
  11233. $eep = (((hex("C5") << 6) | hex("00")) << 7) | hex("00");
  11234. }
  11235. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11236. push @event, "3:remoteRSSI:" . -$RSSI;
  11237. $sendData = '06060' . AttrVal($name, 'manufID', '7FF') . sprintf("%04X%02X", $eep << 3, $RSSI);
  11238. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11239. Log3 $name, 2, "EnOcean $name RMCC ping answer executed";
  11240. } elsif ($funcNumber == 7 && $remoteManagement eq 'client') {
  11241. # query function
  11242. if ($hash->{RemoteClientUnlock}) {
  11243. $sendData = '06070' . AttrVal($name, 'manufID', '7FF') . '020107FF';
  11244. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11245. Log3 $name, 2, "EnOcean $name RMCC query function answer sent.";
  11246. } else {
  11247. $remoteLastStatusReturnCode = '07';
  11248. Log3 $name, 2, "EnOcean $name RMCC query function request not executed.";
  11249. }
  11250. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11251. } elsif ($funcNumber == 8 && $remoteManagement eq 'client') {
  11252. # query status
  11253. if ($hash->{RemoteClientUnlock}) {
  11254. $sendData = '06080' . AttrVal($name, 'manufID', '7FF') . '000' . ReadingsVal($name, "remoteLastFunctionNumber", "000") .
  11255. ReadingsVal($name, "$remoteLastStatusReturnCode", '00');
  11256. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11257. Log3 $name, 2, "EnOcean $name RMCC query status answer sent.";
  11258. } else {
  11259. $remoteLastStatusReturnCode = '07';
  11260. Log3 $name, 2, "EnOcean $name RMCC query status request not executed.";
  11261. }
  11262. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11263. } elsif ($funcNumber == 0x201) {
  11264. $data =~ m/^(..)(..)(..)(..)$/;
  11265. my ($rorg, $func, $type, $flag) = ($1, $2, $3, hex($4));
  11266. if ($flag == 1) {
  11267. # learn in
  11268. if (exists $EnO_eepConfig{"$rorg.$func.$type"}) {
  11269. $attr{$name}{eep} = "$rorg-$func-$type";
  11270. #$attr{$name}{remoteID} = $remoteID if (defined $remoteID);
  11271. $attr{$name}{remoteManagement} = "client";
  11272. $attr{$name}{teachMethod} = 'RPC';
  11273. foreach my $attrCntr (keys %{$EnO_eepConfig{"$rorg.$func.$type"}{attr}}) {
  11274. if ($attrCntr eq "subDef") {
  11275. if (!exists $attr{$name}{$attrCntr}) {
  11276. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_eepConfig{"$rorg.$func.$type"}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  11277. }
  11278. } else {
  11279. $attr{$name}{$attrCntr} = $EnO_eepConfig{"$rorg.$func.$type"}{attr}{$attrCntr};
  11280. }
  11281. }
  11282. EnOcean_CreateSVG(undef, $hash, $attr{$name}{eep});
  11283. push @event, "3:teach:RPC teach-in accepted EEP $rorg-$func-$type Manufacturer: " .
  11284. (exists($EnO_manuf{$manufID}) ? $EnO_manuf{$manufID} : $manufID);
  11285. Log3 $name, 2, "EnOcean $name RPC teach-in with EEP $rorg-$func-$type ManufacturerID: $manufID accepted.";
  11286. } else {
  11287. Log3 $name, 2, "EnOcean $name RPC teach-in with EEP $rorg-$func-$type ManufacturerID: $manufID not supported.";
  11288. }
  11289. } elsif ($flag == 3) {
  11290. # learn out
  11291. #Log3 $name, 2, "EnOcean $name device $name deleted";
  11292. CommandDelete(undef, $name);
  11293. Log3 $name, 2, "EnOcean $name RPC teach-out with EEP $rorg-$func-$type ManufacturerID: $manufID executed.";
  11294. EnOcean_CommandSave(undef, undef);
  11295. } else {
  11296. Log3 $name, 2, "EnOcean $name RPC learn function $flag not supported";
  11297. }
  11298. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11299. } elsif ($funcNumber == 0x240 && $remoteManagement eq 'manager') {
  11300. # acknowledge
  11301. $remoteLastStatusReturnCode = '00';
  11302. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11303. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11304. Log3 $name, 2, "EnOcean $name RPC acknowledge received";
  11305. } elsif ($funcNumber == 0x604 && $remoteManagement eq 'manager') {
  11306. # query id answer
  11307. my $eep = hex(substr($data, 0, 6)) >> 3;
  11308. my $rorg = sprintf "%02X", ($eep >> 13);
  11309. my $func = sprintf "%02X", (($eep & 0x1F80) >> 7);
  11310. my $type = sprintf "%02X", ($eep & 127);
  11311. $attr{$name}{remoteManufID} = $manufID;
  11312. $manufID = $EnO_manuf{$manufID} if($EnO_manuf{$manufID});
  11313. $attr{$name}{remoteEEP} = "$rorg-$func-$type";
  11314. my $subType = "$rorg.$func.$type";
  11315. #$attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType} if($EnO_manuf{$subType});
  11316. $remoteLastStatusReturnCode = '00';
  11317. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11318. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11319. Log3 $name, 2, "EnOcean $name RMCC query ID answer received EEP $rorg-$func-$type Manufacturer: $manufID";
  11320. EnOcean_CommandSave(undef, undef);
  11321. } elsif ($funcNumber == 0x606 && $remoteManagement eq 'manager') {
  11322. # ping answer
  11323. my $eep = hex(substr($data, 0, 6)) >> 3;
  11324. my $rorg = sprintf "%02X", ($eep >> 13);
  11325. my $func = sprintf "%02X", (($eep & 0x1F80) >> 7);
  11326. my $type = sprintf "%02X", ($eep & 127);
  11327. $attr{$name}{remoteManufID} = $manufID;
  11328. $manufID = $EnO_manuf{$manufID} if($EnO_manuf{$manufID});
  11329. $attr{$name}{remoteEEP} = "$rorg-$func-$type";
  11330. my $subType = "$rorg.$func.$type";
  11331. #$attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType} if($EnO_manuf{$subType});
  11332. push @event, "3:remoteRSSI:" . -$RSSI;
  11333. $remoteLastStatusReturnCode = '00';
  11334. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11335. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11336. Log3 $name, 2, "EnOcean $name RMCC ping answer received EEP $rorg-$func-$type Manufacturer: $manufID";
  11337. EnOcean_CommandSave(undef, undef);
  11338. } elsif ($funcNumber == 0x607 && $remoteManagement eq 'manager') {
  11339. # query function answer
  11340. CommandDeleteReading(undef, "$name remoteFunction.*");
  11341. my $count = 1;
  11342. my $len = length($data);
  11343. while ($len > 0) {
  11344. $data =~ m/^.(...).(...)(.*)$/;
  11345. push @event, "3:remoteFunction" . sprintf("%02d", $count) . ":$1:$2:" . (exists($EnO_extendedRemoteFunctionCode{hex($1)}) ? $EnO_extendedRemoteFunctionCode{hex($1)} : '-');
  11346. $count ++;
  11347. $data = $3;
  11348. $len -= 8;
  11349. }
  11350. $remoteLastStatusReturnCode = '00';
  11351. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11352. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11353. Log3 $name, 2, "EnOcean $name RMCC query function answer received";
  11354. } elsif ($funcNumber == 0x608 && $remoteManagement eq 'manager') {
  11355. # query status answer
  11356. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11357. push @event, "3:remoteLastFunctionNumber:" . substr($data, 3, 3);
  11358. push @event, "3:remoteLastStatusReturnCode:" . substr($data, 6, 2);
  11359. Log3 $name, 2, "EnOcean $name RMCC query status answer received LastFunction: " . substr($data, 3, 3) .
  11360. " LastFunctionCode: " . substr($data, 6, 2);
  11361. } elsif ($funcNumber == 0x810 && $remoteManagement eq 'manager') {
  11362. # teach-in supported link tables response
  11363. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11364. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11365. my $supportFlags = hex(substr($data, 0, 2));
  11366. my $linkTableInCurrent = substr($data, 6, 2) && $supportFlags & 0x10 ? substr($data, 6, 2) : '00';
  11367. my $linkTableInMax = substr($data, 8, 2) && $supportFlags & 0x10 ? substr($data, 8, 2) : '00';
  11368. my $linkTableOutCurrent = substr($data, 2, 2) && $supportFlags & 0x20 ? substr($data, 2, 2) : '00';
  11369. my $linkTableOutMax = substr($data, 4, 2) && $supportFlags & 0x20 ? substr($data, 4, 2) : '00';
  11370. push @event, "3:remoteLearn:" . ($supportFlags & 0x80 ? 'supported' : 'not_supported');
  11371. push @event, "3:remoteLinkTableIn:" . ($supportFlags & 0x10 ? 'supported' : 'not_supported');
  11372. push @event, "3:remoteLinkTableOut:" . ($supportFlags & 0x20 ? 'supported' : 'not_supported');
  11373. push @event, "3:remoteLinkTableInCurrent:" . $linkTableInCurrent if ($supportFlags & 0x10);
  11374. push @event, "3:remoteLinkTableInMax:" . $linkTableInMax if ($supportFlags & 0x10);
  11375. push @event, "3:remoteLinkTableOutCurrent:" . $linkTableOutCurrent if ($supportFlags & 0x20);
  11376. push @event, "3:remoteLinkTableOutMax:" . $linkTableOutMax if ($supportFlags & 0x20);
  11377. push @event, "3:remoteTeach:" . ($supportFlags & 0x40 ? 'supported' : 'not_supported');
  11378. Log3 $name, 2, "EnOcean $name RPC teach-in supported link tables response received Data: $data";
  11379. # request outbound table
  11380. #$hash->{IODev}{helper}{remoteAnswerWait}{0x821}{hash} = $hash;
  11381. #$hash->{IODev}{helper}{remoteLinkTableStartRef} = 0;
  11382. #my %functionHash = (hash => $hash, param => 0x821);
  11383. #RemoveInternalTimer(\%functionHash);
  11384. #InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  11385. #$sendData = '022107FF';
  11386. #EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11387. #Log3 $name, 2, "EnOcean $name RPC request teach-in outbound table";
  11388. } elsif ($funcNumber == 0x811 && $remoteManagement eq 'manager') {
  11389. # link table response
  11390. CommandDeleteReading(undef, "$name remoteLinkTableDesc.*");
  11391. $data =~ m/^(..)(.*)$/;
  11392. my $direction = hex($1) & 0x80 ? 'Out' : 'In';
  11393. $data = $2;
  11394. while (length($data) > 0) {
  11395. $data =~ m/^(..)(........)(..)(..)(..)(..)(.*)$/;
  11396. push @event, "3:remoteLinkTableDesc" . $direction . "$1:S2:S3-S4-$5:$6";
  11397. $data = $7;
  11398. }
  11399. $remoteLastStatusReturnCode = '00';
  11400. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11401. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11402. Log3 $name, 2, "EnOcean $name RPC link table response received";
  11403. } elsif ($funcNumber == 0x813 && $remoteManagement eq 'manager') {
  11404. # link table GP response
  11405. CommandDeleteReading(undef, "$name remoteLinkTableGPDesc.*");
  11406. $data =~ m/^(..)(.*)$/;
  11407. my $direction = hex($1) & 0x80 ? 'Out' : 'In';
  11408. $data = $2;
  11409. my $channel = 0;
  11410. my $channelDir = hex($1) & 0x80 ? 'O' : 'I';
  11411. my $channelDef;
  11412. my $channelName;
  11413. my $channelType;
  11414. my $dataOutboundDefLen = 0;
  11415. my $gpData;
  11416. my @gpDef;
  11417. my $gpIdx;
  11418. my $signalType;
  11419. while (length($data) > 0) {
  11420. $data =~ m/^(..)(.{12})(.*)$/;
  11421. $gpIdx = $1;
  11422. $gpData = EnOcean_convHexToBit($2);
  11423. $data = $3;
  11424. $gpData =~ m/^(..)(.{8})(.*)$/;
  11425. $channelType = unpack('C', pack('B8', '000000' . $1));
  11426. $signalType = unpack('C', pack('B8', $2));
  11427. $data = $3;
  11428. #Log3 $name, 2, "EnOcean $name parse RPC link table GP idx: $gpIdx channelType: $channelType signalType: $signalType data: $data";
  11429. if ($channelType == 0) {
  11430. # teach-in information
  11431. if ($signalType == 1) {
  11432. # outbound channel description
  11433. } elsif ($signalType == 2) {
  11434. # produkt ID
  11435. }
  11436. } elsif ($channelType == 1) {
  11437. # data
  11438. $gpData =~ m/^(..)(....)(.{8})(....)(.{8})(....)(.*)$/;
  11439. $channelDef = $channelDir . ':' . $channelType . ':' . $signalType . ':' .
  11440. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2)) . ':' .
  11441. unpack('c', pack('B8', $3)) . ':' . unpack('C', pack('B8', '0000' . $4)) . ':' .
  11442. unpack('c', pack('B8', $5)) . ':' . unpack('C', pack('B8', '0000' . $6));
  11443. if (defined $EnO_gpValueData{$signalType}{name}) {
  11444. $channelName = $EnO_gpValueData{$signalType}{name};
  11445. } else {
  11446. $channelName = "none";
  11447. }
  11448. $gpDef[$channel] = $channelName . ':' . $channelDef;
  11449. } elsif ($channelType == 2) {
  11450. # flag
  11451. $gpData =~ m/^(..)(.*)$/;
  11452. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  11453. unpack('C', pack('B8', '000000' . $1));
  11454. if (defined $EnO_gpValueFlag{$signalType}{name}) {
  11455. $channelName = $EnO_gpValueFlag{$signalType}{name};
  11456. } else {
  11457. $channelName = "none";
  11458. }
  11459. $gpDef[$channel] = $channelName . ':' . $channelDef;
  11460. } elsif ($channelType == 3) {
  11461. # enumeration
  11462. $gpData =~ m/^(..)(....)(.*)$/;
  11463. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  11464. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2));
  11465. if (defined $EnO_gpValueEnum{$signalType}{name}) {
  11466. $channelName = $EnO_gpValueEnum{$signalType}{name};
  11467. } else {
  11468. $channelName = "none";
  11469. }
  11470. $gpDef[$channel] = $channelName . ':' . $channelDef;
  11471. }
  11472. push @event, "3:remoteLinkTableGPDesc" . $direction . "$gpIdx:$gpDef[0]";
  11473. }
  11474. $remoteLastStatusReturnCode = '00';
  11475. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11476. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11477. Log3 $name, 2, "EnOcean $name RPC link table GP response received";
  11478. } elsif ($funcNumber == 0x827 && $remoteManagement eq 'manager') {
  11479. # product ID answer
  11480. $manufID = substr($data, 1, 3);
  11481. $attr{$name}{remoteManufID} = $manufID;
  11482. $manufID = $EnO_manuf{$manufID} if($EnO_manuf{$manufID});
  11483. $remoteLastStatusReturnCode = '00';
  11484. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11485. $sendData = '024007FF';
  11486. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11487. push @event, "3:remoteProductID:" . substr($data, 4, 8);
  11488. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11489. Log3 $name, 2, "EnOcean $name RPC Product ID answer received ProductID: " . substr($data, 4, 8) . " Manufacturer: $manufID";
  11490. Log3 $name, 2, "EnOcean $name RPC acknowledge sent";
  11491. EnOcean_CommandSave(undef, undef);
  11492. } elsif ($funcNumber == 0x830 && $remoteManagement eq 'manager') {
  11493. # device config response
  11494. CommandDeleteReading(undef, "$name remoteDevCfg.*");
  11495. my $idx;
  11496. my $valueLen;
  11497. while (length($data) > 0) {
  11498. $data =~ m/^(....)(..)(.*)$/;
  11499. $idx = $1;
  11500. $valueLen = hex($2) * 2;
  11501. $data = $3;
  11502. $data =~ m/^(.{$valueLen})(.*)$/;
  11503. push @event, "3:remoteDevCfg$idx:S1";
  11504. $data = $2;
  11505. }
  11506. $remoteLastStatusReturnCode = '00';
  11507. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11508. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11509. Log3 $name, 2, "EnOcean $name RPC device configuration response received";
  11510. } elsif ($funcNumber == 0x832 && $remoteManagement eq 'manager') {
  11511. # link based configuration response
  11512. $data =~ m/^(..)(..)(.*)$/;
  11513. my $direction = hex($1) & 0x80 ? 'Out' : 'In';
  11514. my $linkTableIdx = $2;
  11515. CommandDeleteReading(undef, "$name remoteLinkCfg$direction$linkTableIdx.*");
  11516. $data = $3;
  11517. my $idx;
  11518. my $valueLen;
  11519. while (length($data) > 0) {
  11520. $data =~ m/^(....)(..)(.*)$/;
  11521. $idx = $1;
  11522. $valueLen = hex($2) * 2;
  11523. $data = $3;
  11524. $data =~ m/^(.{$valueLen})(.*)$/;
  11525. push @event, "3:remoteLinkCfg$direction$linkTableIdx:$idx:S1";
  11526. $data = $2;
  11527. }
  11528. $remoteLastStatusReturnCode = '00';
  11529. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11530. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11531. Log3 $name, 2, "EnOcean $name RPC link table response received";
  11532. } elsif ($funcNumber == 0x850 && $remoteManagement eq 'manager') {
  11533. # query status answer
  11534. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11535. my $repeaterFunction = 'off';
  11536. if (($db[0] & 0xC0) == 0) {
  11537. $repeaterFunction = 'off';
  11538. } elsif (($db[0] & 0xC0) == 0x40) {
  11539. $repeaterFunction = 'on';
  11540. } elsif (($db[0] & 0xC0) == 0x80) {
  11541. $repeaterFunction = 'filter';
  11542. }
  11543. push @event, "3:remoteRepeaterFunction:$repeaterFunction";
  11544. push @event, "3:remoteRepeaterLevel:" . (($db[0] & 0x30) == 0x20 ? 2 : 1);
  11545. push @event, "3:remoteRepeaterFilter:" . ($db[0] & 8 ? 'OR' : 'AND');
  11546. Log3 $name, 2, "EnOcean $name RPC repeater functions response received";
  11547. } else {
  11548. Log3 $name, 2, "EnOcean $name RMCC/RPC function number " . sprintf("%03X", $funcNumber) . " not supported.";
  11549. }
  11550. } elsif ($rorg eq "C5" && $packetType == 1) {
  11551. # remote management >> packetType = 7
  11552. return $name;
  11553. }
  11554. readingsBeginUpdate($hash);
  11555. for(my $i = 0; $i < int(@event); $i++) {
  11556. # Flag & 1: reading, Flag & 2: changed. Currently ignored.
  11557. my ($flag, $vn, $vv) = split(':', $event[$i], 3);
  11558. readingsBulkUpdate($hash, $vn, $vv);
  11559. my @cmdObserve = ($name, $vn, $vv);
  11560. EnOcean_observeParse(2, $hash, @cmdObserve);
  11561. }
  11562. readingsEndUpdate($hash, 1);
  11563. if (defined $deleteDevice) {
  11564. # delete device and save config
  11565. CommandDelete(undef, $deleteDevice);
  11566. Log3 $name, 2, "EnOcean $name device $deleteDevice deleted";
  11567. if (defined $oldDevice) {
  11568. Log3 $name, 2, "EnOcean $name renamed $oldDevice to $deleteDevice";
  11569. CommandRename(undef, "$oldDevice $deleteDevice");
  11570. EnOcean_CommandSave(undef, undef);
  11571. return $deleteDevice;
  11572. } else {
  11573. EnOcean_CommandSave(undef, undef);
  11574. return '';
  11575. }
  11576. }
  11577. return $name;
  11578. }
  11579. sub EnOcean_Attr(@)
  11580. {
  11581. my ($cmd, $name, $attrName, $attrVal) = @_;
  11582. my $hash = $defs{$name};
  11583. # return if attribute list is incomplete
  11584. return undef if (!$init_done);
  11585. my $err;
  11586. my $loglevel = 2;
  11587. my $waitingCmds = AttrVal($name, "waitingCmds", 0);
  11588. if ($attrName eq "angleTime") {
  11589. my $channel;
  11590. my $data;
  11591. if (!defined $attrVal) {
  11592. if (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11593. # no rotation
  11594. $data = "7FFF0007F5";
  11595. EnOcean_SndRadio(undef, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11596. }
  11597. } elsif (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11598. my @attrVal = split(':', $attrVal);
  11599. for (my $channel = 0; $channel <= $#attrVal && $channel < 4; $channel ++) {
  11600. if ($attrVal[$channel] =~ m/^\d+(\.\d+)?$/ && $attrVal[$channel] >= 0 && $attrVal[$channel] <= 2.54) {
  11601. if ($attrVal[$channel] < 0.01) {
  11602. $attrVal[$channel] = 0;
  11603. } else {
  11604. $attrVal[$channel] = int($attrVal[$channel] * 100);
  11605. }
  11606. $data = sprintf "7FFF%02X07%02X", $attrVal[$channel], $channel << 4 | 5;
  11607. EnOcean_SndRadio(0.2 + $channel * 0.5, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11608. } else {
  11609. $err = "attribute-value [$attrName] = $attrVal wrong";
  11610. }
  11611. }
  11612. } elsif (AttrVal($name, "subType", "") eq "manufProfile" && AttrVal($name, "manufID", "") eq "00D" &&
  11613. $attrVal =~ m/^[+-]?\d+?$/ && $attrVal >= 1 && $attrVal <= 6) {
  11614. } else {
  11615. $err = "attribute-value [$attrName] = $attrVal wrong";
  11616. #Log3 $name, 2, "EnOcean $name attribute-value [$attrName] = $attrVal wrong";
  11617. #CommandDeleteAttr(undef, "$name $attrName");
  11618. }
  11619. } elsif ($attrName eq "alarmAction") {
  11620. my $data;
  11621. if (!defined $attrVal) {
  11622. if (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11623. # no alarm action
  11624. $data = "7FFFFF00F5";
  11625. EnOcean_SndRadio(undef, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11626. }
  11627. } elsif (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11628. my @attrVal = split(':', $attrVal);
  11629. for (my $channel = 0; $channel <= $#attrVal && $channel < 4; $channel ++) {
  11630. if ($attrVal =~ m/no|stop|opens|closes$/) {
  11631. my $alarmAction = 0;
  11632. if ($attrVal[$channel] eq "no") {
  11633. $alarmAction = 0;
  11634. } elsif ($attrVal[$channel] eq "stop") {
  11635. $alarmAction = 1;
  11636. } elsif ($attrVal[$channel] eq "opens") {
  11637. $alarmAction = 2;
  11638. } elsif ($attrVal[$channel] eq "closes") {
  11639. $alarmAction = 3;
  11640. } else {
  11641. $err = "attribute-value [$attrName] = $attrVal wrong";
  11642. }
  11643. $data = sprintf "7FFFFF%02X%02X", $alarmAction, $channel << 4 | 5;
  11644. EnOcean_SndRadio(0.2 + $channel * 0.5, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11645. } else {
  11646. $err = "attribute-value [$attrName] = $attrVal wrong";
  11647. }
  11648. }
  11649. } else {
  11650. $err = "attribute-value [$attrName] = $attrVal wrong";
  11651. }
  11652. } elsif ($attrName =~ m/^block.*/) {
  11653. if (!defined $attrVal){
  11654. } elsif ($attrVal =~ m/^(no|yes)$/) {
  11655. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11656. $waitingCmds |= 64;
  11657. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11658. }
  11659. } else {
  11660. $err = "attribute-value [$attrName] = $attrVal wrong";
  11661. }
  11662. } elsif ($attrName eq "comMode") {
  11663. if (!defined $attrVal){
  11664. } elsif ($attrVal !~ m/^biDir|uniDir|confirm$/) {
  11665. $err = "attribute-value [$attrName] = $attrVal wrong";
  11666. }
  11667. } elsif ($attrName eq "creator") {
  11668. if (!defined $attrVal){
  11669. } elsif ($attrVal !~ m/^autocreate|manual$/) {
  11670. $err = "attribute-value [$attrName] = $attrVal wrong";
  11671. }
  11672. } elsif ($attrName eq "dataEnc") {
  11673. if (!defined $attrVal){
  11674. } elsif ($attrVal !~ m/^VAES|AES-CBC$/) {
  11675. $err = "attribute-value [$attrName] = $attrVal wrong";
  11676. }
  11677. } elsif ($attrName eq "daylightSavingTime") {
  11678. if (!defined $attrVal){
  11679. } elsif ($attrVal =~ m/^(supported|not_supported)$/) {
  11680. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11681. $waitingCmds |= 64;
  11682. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11683. }
  11684. } else {
  11685. $err = "attribute-value [$attrName] = $attrVal wrong";
  11686. }
  11687. } elsif ($attrName eq "defaultChannel") {
  11688. my $defaultChannel = '';
  11689. my $subType = AttrVal($name, "subType", "");
  11690. if ($subType eq "actuator.01") {
  11691. $defaultChannel = join("|", @EnO_defaultChannel);
  11692. } elsif ($subType =~ m/^blindsCtrl\.0[01]$/) {
  11693. $defaultChannel = '[1234]|all';
  11694. }
  11695. if (!defined $attrVal){
  11696. } elsif ($attrVal !~ m/^($defaultChannel)$/) {
  11697. $err = "attribute-value [$attrName] = $attrVal wrong";
  11698. }
  11699. } elsif ($attrName eq "demandRespAction") {
  11700. if (!defined $attrVal){
  11701. } else {
  11702. my %specials = ("%TARGETNAME" => $name,
  11703. "%NAME" => $name,
  11704. "%TARGETTYPE" => '',
  11705. "%TYPE" => '',
  11706. "%LEVEL" => '',
  11707. "%SETPOINT" => '',
  11708. "%POWERUSAGE" => '',
  11709. "%POWERUSAGESCALE" => '',
  11710. "%POWERUSAGELEVEL" => '',
  11711. "%TARGETSTATE" => '',
  11712. "%STATE" => ''
  11713. );
  11714. $err = perlSyntaxCheck($attrVal, %specials);
  11715. }
  11716. } elsif ($attrName eq "demandRespRandomTime") {
  11717. if (!defined $attrVal) {
  11718. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 1) {
  11719. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11720. }
  11721. } elsif ($attrName =~ m/^(demandRespMax|demandRespMin)$/) {
  11722. if (!defined $attrVal){
  11723. } elsif ($attrVal !~ m/^(A0|AI|B0|BI|C0|CI|D0|DI)$/) {
  11724. $err = "attribute-value [$attrName] = $attrVal wrong";
  11725. CommandDeleteAttr(undef, "$name $attrName");
  11726. }
  11727. } elsif ($attrName eq "demandRespThreshold") {
  11728. if (!defined $attrVal) {
  11729. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 0 || $attrVal > 15) {
  11730. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11731. }
  11732. } elsif ($attrName eq "devChannel") {
  11733. if (!defined $attrVal){
  11734. } elsif ($attrVal =~ m/^[\dA-Fa-f]{2}$/) {
  11735. # actions see EnOcean_Notify, global ATTR
  11736. } elsif ($attrVal =~ m/^\d+$/ && $attrVal >= 0 && $attrVal <= 255) {
  11737. } else {
  11738. $err = "attribute-value [$attrName] = $attrVal wrong";
  11739. }
  11740. } elsif ($attrName eq "devMode") {
  11741. if (!defined $attrVal){
  11742. } elsif ($attrVal !~ m/^master|slave$/) {
  11743. $err = "attribute-value [$attrName] = $attrVal wrong";
  11744. }
  11745. } elsif ($attrName eq "devUpdate") {
  11746. if (!defined $attrVal){
  11747. } elsif ($attrVal !~ m/^(off|auto|demand|polling|interrupt)$/) {
  11748. $err = "attribute-value [$attrName] = $attrVal wrong";
  11749. }
  11750. } elsif ($attrName =~ m/^dimMax|dimMin$/) {
  11751. if (!defined $attrVal){
  11752. } elsif ($attrVal !~ m/^off|[\d+]$/) {
  11753. $err = "attribute-value [$attrName] = $attrVal wrong";
  11754. }
  11755. } elsif ($attrName eq "displayContent") {
  11756. if (!defined $attrVal){
  11757. } elsif ($attrVal =~ m/^(humidity|off|setpointTemp|tempertureExtern|temperatureIntern|time|default|no_change)$/) {
  11758. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11759. $waitingCmds |= 64;
  11760. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11761. }
  11762. } else {
  11763. $err = "attribute-value [$attrName] = $attrVal wrong";
  11764. }
  11765. } elsif ($attrName eq "displayOrientation") {
  11766. if (!defined $attrVal){
  11767. } elsif ($attrVal !~ m/^0|90|180|270$/) {
  11768. $err = "attribute-value [$attrName] = $attrVal wrong";
  11769. }
  11770. } elsif ($attrName eq "eep" || $attrName eq "remoteEEP") {
  11771. if (!defined $attrVal){
  11772. } elsif ($attrVal !~ m/^[\dA-Fa-f]{2}-[\dA-Fa-f]{2}-[\dA-Fa-f]{2}$/) {
  11773. $err = "attribute-value [$attrName] = $attrVal wrong";
  11774. }
  11775. } elsif ($attrName eq "model") {
  11776. if (!defined $attrVal){
  11777. } else {
  11778. # set model specific attributes
  11779. foreach my $attrCntr (keys %{$EnO_models{$attrVal}{attr}}) {
  11780. if ($attrCntr eq "remoteID") {
  11781. if (exists $hash->{DEF}) {
  11782. $attr{$name}{$attrCntr} = $hash->{DEF};
  11783. } else {
  11784. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_models{$attrVal}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  11785. }
  11786. } else {
  11787. $attr{$name}{$attrCntr} = $EnO_models{$attrVal}{attr}{$attrCntr};
  11788. }
  11789. }
  11790. if (exists $EnO_models{$attrVal}{xml}) {
  11791. # read xml device description to $hash->{helper}
  11792. if ($xmlFunc == 1) {
  11793. my $xmlFile = $attr{global}{modpath} . $EnO_models{$attrVal}{xml}{xmlDescrLocation};
  11794. if (-e -f -r $xmlFile) {
  11795. $hash->{helper} = $xml->XMLin($xmlFile);
  11796. if (exists $hash->{helper}{Device}) {
  11797. } else {
  11798. Log3 $name, 2, "EnOcean $name <attr> Device Description not defined";
  11799. }
  11800. } else {
  11801. Log3 $name, 2, "EnOcean $name <attr> Device Description file $xmlFile not exists";
  11802. }
  11803. } else {
  11804. Log3 $name, 2, "EnOcean $name <attr> XML functions are not available";
  11805. }
  11806. }
  11807. }
  11808. } elsif ($attrName eq "gpDef") {
  11809. if (!defined $attrVal){
  11810. } else {
  11811. my @gpDef = split("[ \t][ \t]*", $attrVal);
  11812. my ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax);
  11813. for (my $channel = 0; $channel < @gpDef; $channel ++) {
  11814. my @err;
  11815. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  11816. split(':', $gpDef[$channel]);
  11817. push(@err, "channelName") if (!defined $channelName);
  11818. push(@err, "channelDir") if (!defined($channelDir) || $channelDir !~ m/^O|I$/);
  11819. push(@err, "channelType") if (!defined($channelType) || $channelType !~ m/^\d+$/ || $channelType > 3);
  11820. push(@err, "signalType") if (!defined($signalType) || $signalType !~ m/^\d+$/ || $signalType > 255);
  11821. push(@err, "valueType") if (!defined($valueType) || $valueType !~ m/^\d+$/ || $valueType > 3);
  11822. if ($channelType == 1 || $channelType == 3) {
  11823. push(@err, "resolution") if (!defined($resolution) || $resolution !~ m/^\d+$/ || $resolution > 12);
  11824. }
  11825. if ($channelType == 1) {
  11826. push(@err, "engMin") if (!defined($engMin) || $engMin !~ m/^[+-]?\d+$/ || $engMin < -128 || $engMin > 127);
  11827. push(@err, "scalingMin") if (!defined($scalingMin) || $scalingMin !~ m/^\d+$/ || $scalingMin < 1 || $scalingMin > 13);
  11828. push(@err, "engMax") if (!defined($engMax) || $engMax !~ m/^[+-]?\d+$/ || $engMax < -128 || $engMax > 127);
  11829. push(@err, "scalingMax") if (!defined($scalingMax) || $scalingMax !~ m/^\d+$/ || $scalingMax < 1 || $scalingMax > 13);
  11830. }
  11831. $err = "attribute-value $attrName/channel " . sprintf('%02d', $channel) . ": " .
  11832. join(', ', @err) . " wrong" if (defined $err[0]);
  11833. }
  11834. }
  11835. } elsif ($attrName eq "humidity") {
  11836. if (!defined $attrVal) {
  11837. } elsif ($attrVal =~ m/^\d+$/ && $attrVal >= 0 && $attrVal <= 100) {
  11838. } else {
  11839. #RemoveInternalTimer($hash);
  11840. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11841. }
  11842. } elsif ($attrName =~ m/^key/) {
  11843. if (!defined $attrVal){
  11844. } elsif ($attrVal !~ m/^[\dA-Fa-f]{32}$/) {
  11845. $err = "attribute-value [$attrName] = $attrVal wrong";
  11846. }
  11847. } elsif ($attrName eq "macAlgo") {
  11848. if (!defined $attrVal){
  11849. } elsif ($attrVal !~ m/^no|[3-4]$/) {
  11850. $err = "attribute-value [$attrName] = $attrVal wrong";
  11851. }
  11852. } elsif ($attrName eq "manufID" || $attrName eq "remoteManufID") {
  11853. if (!defined $attrVal){
  11854. } elsif ($attrVal !~ m/^[0-7][\dA-Fa-f]{2}$/) {
  11855. $err = "attribute-value [$attrName] = $attrVal wrong";
  11856. }
  11857. } elsif ($attrName eq "measurementCtrl") {
  11858. if (!defined $attrVal){
  11859. } elsif ($attrVal !~ m/^disable|enable$/) {
  11860. $err = "attribute-value [$attrName] = $attrVal wrong";
  11861. }
  11862. } elsif ($attrName eq "observe") {
  11863. if (!defined $attrVal){
  11864. } elsif (lc($attrVal) !~ m/^(off|on)$/) {
  11865. $err = "attribute-value [$attrName] = $attrVal wrong";
  11866. }
  11867. } elsif ($attrName eq "observeCmdRepetition") {
  11868. if (!defined $attrVal){
  11869. } elsif ($attrVal !~ m/^[1-5]$/) {
  11870. $err = "attribute-value [$attrName] = $attrVal wrong";
  11871. }
  11872. } elsif ($attrName eq "observeErrorAction") {
  11873. if (!defined $attrVal){
  11874. } else {
  11875. my %specials = ("%NAME" => $name,
  11876. "%FAILEDDEV" => '',
  11877. "%TYPE" => '',
  11878. "%EVENT" => ''
  11879. );
  11880. $err = perlSyntaxCheck($attrVal, %specials);
  11881. }
  11882. } elsif ($attrName eq "observeInterval") {
  11883. if (!defined $attrVal){
  11884. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 1) {
  11885. $err = "attribute-value [$attrName] = $attrVal wrong";
  11886. }
  11887. } elsif ($attrName eq "observeLogic") {
  11888. if (!defined $attrVal){
  11889. } elsif (lc($attrVal) !~ m/^and|or$/) {
  11890. $err = "attribute-value [$attrName] = $attrVal wrong";
  11891. }
  11892. } elsif ($attrName eq "pidActorErrorAction") {
  11893. if (!defined $attrVal){
  11894. } elsif ($attrVal !~ m/^errorPos|freeze$/) {
  11895. $err = "attribute-value [$attrName] = $attrVal wrong";
  11896. }
  11897. } elsif ($attrName eq "pidCtrl") {
  11898. if (!defined $attrVal){
  11899. } elsif (lc($attrVal) eq "on") {
  11900. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  11901. } elsif (lc($attrVal) eq "off") {
  11902. EnOcean_setPID(undef, $hash, 'stop', '');
  11903. } else {
  11904. $err = "attribute-value [$attrName] = $attrVal wrong";
  11905. }
  11906. } elsif ($attrName eq "pidActorErrorPos") {
  11907. if (!defined $attrVal) {
  11908. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 0 || $attrVal > 100) {
  11909. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11910. }
  11911. } elsif ($attrName eq "pidDeltaTreshold") {
  11912. my $reFloatpos = '^([\\+]?\\d+\\.?\d*$)';
  11913. if (!defined $attrVal) {
  11914. } elsif ($attrVal !~ m/$reFloatpos/) {
  11915. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11916. }
  11917. } elsif ($attrName eq "pidSensorTimeout") {
  11918. if (!defined $attrVal) {
  11919. } elsif ($attrVal !~ m/^\d+?$/) {
  11920. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11921. }
  11922. } elsif ($attrName =~ m/^pidActorLimitLower|pidActorLimitUpper$/) {
  11923. if (!defined $attrVal) {
  11924. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 0 || $attrVal > 100) {
  11925. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11926. }
  11927. } elsif ($attrName =~ m/^pidFactor_.$/) {
  11928. my $reFloatpos = '^([\\+]?\\d+\\.?\d*$)';
  11929. if (!defined $attrVal) {
  11930. } elsif ($attrVal !~ m/$reFloatpos/) {
  11931. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11932. }
  11933. } elsif ($attrName eq "pollInterval") {
  11934. if (!defined $attrVal) {
  11935. } elsif ($attrVal =~ m/^\d+?$/) {
  11936. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11937. $waitingCmds |= 64;
  11938. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11939. }
  11940. } else {
  11941. #RemoveInternalTimer($hash);
  11942. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11943. }
  11944. } elsif ($attrName eq "productID") {
  11945. if (!defined $attrVal){
  11946. } elsif ($attrVal !~ m/^[\dA-Fa-f]{8}$/) {
  11947. $err = "attribute-value [$attrName] = $attrVal wrong";
  11948. }
  11949. } elsif ($attrName eq "rampTime") {
  11950. if (!defined $attrVal){
  11951. } elsif ($attrVal =~ m/^\d+?$/) {
  11952. if (AttrVal($name, "subType", "") eq "gateway") {
  11953. if ($attrVal < 0 || $attrVal > 255) {
  11954. $err = "attribute-value [$attrName] = $attrVal wrong";
  11955. }
  11956. } elsif (AttrVal($name, "subType", "") eq "lightCtrl.01") {
  11957. if ($attrVal < 0 || $attrVal > 65535) {
  11958. $err = "attribute-value [$attrName] = $attrVal wrong";
  11959. }
  11960. } else {
  11961. $err = "attribute-value [$attrName] = $attrVal wrong";
  11962. }
  11963. } else {
  11964. $err = "attribute $attrName not supported for subType " . AttrVal($name, "subType", "");
  11965. }
  11966. } elsif ($attrName eq "releasedChannel") {
  11967. if (!defined $attrVal){
  11968. } elsif ($attrVal !~ m/^A|B|C|D|I|0|auto$/) {
  11969. $err = "attribute-value [$attrName] = $attrVal wrong";
  11970. }
  11971. } elsif ($attrName eq "rcvRespAction") {
  11972. if (!defined $attrVal){
  11973. } elsif (AttrVal($name, "subType", "") eq "hvac.01") {
  11974. my %specials = ("%ACTUATORSTATE" => '',
  11975. "%BATTERY" => '',
  11976. "%COVER" => '',
  11977. "%ENERGYINPUT" => '',
  11978. "%ENERGYSTORAGE" => '',
  11979. "%MAINTENANCEMODE" => '',
  11980. "%NAME" => $name,
  11981. "%OPERATIONMODE" => '',
  11982. "%ROOMTEMP" => '',
  11983. "%SELFCTRL" => '',
  11984. "%SETPOINT" => '',
  11985. "%SETPOINTTEMP" => '',
  11986. "%SUMMERMODE" => '',
  11987. "%TEMPERATURE" => '',
  11988. "%WINDOW" => ''
  11989. );
  11990. $err = perlSyntaxCheck($attrVal, %specials);
  11991. } elsif (AttrVal($name, "subType", "") eq "hvac.04") {
  11992. my %specials = ("%BATTERY" => '',
  11993. "%FEEDTEMP" => '',
  11994. "%MAINTENANCEMODE" => '',
  11995. "%NAME" => $name,
  11996. "%OPERATIONMODE" => '',
  11997. "%ROOMTEMP" => '',
  11998. "%SETPOINT" => '',
  11999. "%SETPOINTTEMP" => '',
  12000. "%SUMMERMODE" => '',
  12001. "%TEMPERATURE" => ''
  12002. );
  12003. $err = perlSyntaxCheck($attrVal, %specials);
  12004. }
  12005. } elsif ($attrName eq "remoteID") {
  12006. if (!defined $attrVal){
  12007. # delete old pointer
  12008. delete $modules{EnOcean}{defptr}{$attr{$name}{$attrName}} if (exists($attr{$name}{$attrName}) && $attr{$name}{$attrName} ne $hash->{DEF});
  12009. } elsif ($attrVal =~ m/^[\dA-F]{8}$/) {
  12010. # delete old pointer
  12011. delete $modules{EnOcean}{defptr}{$attr{$name}{$attrName}} if (exists($attr{$name}{$attrName}) && $attr{$name}{$attrName} ne $hash->{DEF});
  12012. $modules{EnOcean}{defptr}{$attrVal} = $hash;
  12013. } else {
  12014. $err = "attribute-value [$attrName] = $attrVal wrong";
  12015. }
  12016. } elsif ($attrName eq "remoteManagement") {
  12017. if (!defined $attrVal){
  12018. } elsif ($attrVal !~ m/^client|manager|off$/) {
  12019. $err = "attribute-value [$attrName] = $attrVal wrong";
  12020. }
  12021. } elsif ($attrName eq "reposition") {
  12022. if (!defined $attrVal){
  12023. } elsif ($attrVal !~ m/^directly|opens|closes$/) {
  12024. $err = "attribute-value [$attrName] = $attrVal wrong";
  12025. }
  12026. } elsif ($attrName =~ m/^rlcRcv|rlcSnd$/) {
  12027. if (!defined $attrVal){
  12028. } elsif (AttrVal($name, "rlcAlgo", "") eq "2++" && $attrVal =~ m/^[\dA-Fa-f]{4}$/) {
  12029. } elsif (AttrVal($name, "rlcAlgo", "") eq "3++" && $attrVal =~ m/^[\dA-Fa-f]{6}$/) {
  12030. } else {
  12031. $err = "attribute-value [$attrName] = $attrVal wrong";
  12032. }
  12033. } elsif ($attrName eq "rlcAlgo") {
  12034. if (!defined $attrVal){
  12035. } elsif ($attrVal !~ m/^no|2++|3++$/) {
  12036. $err = "attribute-value [$attrName] = $attrVal wrong";
  12037. }
  12038. } elsif ($attrName eq "rlcTX") {
  12039. if (!defined $attrVal){
  12040. } elsif (lc($attrVal) !~ m/^true|false$/) {
  12041. $err = "attribute-value [$attrName] = $attrVal wrong";
  12042. }
  12043. } elsif ($attrName eq "rltType") {
  12044. if (!defined $attrVal){
  12045. } elsif ($attrVal !~ m/^1BS|4BS$/) {
  12046. $err = "attribute-value [$attrName] = $attrVal wrong";
  12047. }
  12048. } elsif ($attrName eq "rltRepeat") {
  12049. if (!defined $attrVal){
  12050. } elsif ($attrVal =~ m/^\d+?$/ && $attrVal >= 16 && $attrVal <= 256) {
  12051. } else {
  12052. $err = "attribute-value [$attrName] = $attrVal wrong";
  12053. }
  12054. } elsif ($attrName eq "remoteCode") {
  12055. if (!defined $attrVal){
  12056. } elsif ($attrVal !~ m/^[\dA-Fa-f]{8}$/ || $attrVal eq "00000000" || uc($attrVal) eq "FFFFFFFF") {
  12057. $err = "attribute-value [$attrName] = $attrVal wrong";
  12058. }
  12059. } elsif ($attrName eq "secLevel") {
  12060. if (!defined $attrVal){
  12061. } elsif ($attrVal !~ m/^encapsulation|encryption|off$/) {
  12062. $err = "attribute-value [$attrName] = $attrVal wrong";
  12063. }
  12064. } elsif ($attrName eq "secMode") {
  12065. if (!defined $attrVal){
  12066. } elsif ($attrVal !~ m/^rcv|snd|bidir$/) {
  12067. $err = "attribute-value [$attrName] = $attrVal wrong";
  12068. }
  12069. } elsif ($attrName eq "sendDevStatus") {
  12070. if (!defined $attrVal){
  12071. } elsif ($attrVal !~ m/^no|yes$/) {
  12072. $err = "attribute-value [$attrName] = $attrVal wrong";
  12073. }
  12074. } elsif ($attrName eq "serviceOn") {
  12075. if (!defined $attrVal){
  12076. } elsif ($attrVal !~ m/^(no|yes)$/) {
  12077. $err = "attribute-value [$attrName] = $attrVal wrong";
  12078. }
  12079. } elsif ($attrName eq "setCmdTrigger") {
  12080. if (!defined $attrVal){
  12081. } elsif ($attrVal !~ m/^man|refDev$/) {
  12082. $err = "attribute-value [$attrName] = $attrVal wrong";
  12083. }
  12084. } elsif ($attrName eq "setpointSummerMode") {
  12085. if (!defined $attrVal){
  12086. } elsif ($attrVal !~ m/^\d+$/ && $attrVal >= 0 && $attrVal <= 100) {
  12087. $err = "attribute-value [$attrName] = $attrVal wrong";
  12088. }
  12089. } elsif ($attrName eq "settingAccuracy") {
  12090. if (!defined $attrVal){
  12091. } elsif ($attrVal !~ m/^high|low$/) {
  12092. $err = "attribute-value [$attrName] = $attrVal wrong";
  12093. }
  12094. } elsif ($attrName eq "shutTime") {
  12095. my $data;
  12096. if (!defined $attrVal) {
  12097. if (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  12098. # set shutTime to max
  12099. $data = "7530FF07F5";
  12100. EnOcean_SndRadio(undef, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12101. }
  12102. } elsif (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  12103. my @attrVal = split(':', $attrVal);
  12104. for (my $channel = 0; $channel <= $#attrVal && $channel < 4; $channel ++) {
  12105. if ($attrVal[$channel] =~ m/^\d+$/ && $attrVal[$channel] >= 5 && $attrVal[$channel] <= 300) {
  12106. $attrVal[$channel] = int($attrVal[$channel] * 100);
  12107. $data = sprintf "%04XFF07%02X", $attrVal[$channel], $channel << 4 | 5;
  12108. EnOcean_SndRadio(0.2 + $channel * 0.5, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12109. } else {
  12110. $err = "attribute-value [$attrName] = $attrVal wrong";
  12111. }
  12112. }
  12113. } elsif (AttrVal($name, "subType", "") eq "manufProfile" && AttrVal($name, "manufID", "") eq "00D" &&
  12114. $attrVal =~ m/^[+-]?\d+$/ && $attrVal >= 1 && $attrVal <= 255) {
  12115. } else {
  12116. $err = "attribute-value [$attrName] = $attrVal wrong";
  12117. }
  12118. } elsif ($attrName eq "summerMode") {
  12119. if (!defined $attrVal){
  12120. } elsif ($attrVal eq 'on') {
  12121. if (AttrVal($name, 'subType', '') =~ m/^hvac\.0(1|4)$/ && AttrVal($name, 'summerMode', 'off') eq 'off') {
  12122. readingsBeginUpdate($hash);
  12123. readingsBulkUpdate($hash, 'waitingCmds', 'summerMode');
  12124. readingsBulkUpdate($hash, 'operationModeRestore', ReadingsVal($name, 'operationMode', 'setpoint'));
  12125. readingsBulkUpdate($hash, 'setpointTempRestore', ReadingsVal($name, 'setpointTemp', 20));
  12126. readingsBulkUpdate($hash, 'operationMode', 'setpoint');
  12127. readingsEndUpdate($hash, 0);
  12128. } else {
  12129. # attr not changed
  12130. }
  12131. } elsif ($attrVal eq 'off') {
  12132. if (AttrVal($name, 'subType', '') =~ m/^hvac\.0(1|4)$/ && AttrVal($name, 'summerMode', 'off') eq 'on') {
  12133. readingsBeginUpdate($hash);
  12134. readingsBulkUpdate($hash, 'waitingCmds', 'runInit');
  12135. readingsBulkUpdate($hash, 'operationMode', ReadingsVal($name, 'operationModeRestore', 'setpoint'));
  12136. readingsBulkUpdate($hash, 'setpointTemp', ReadingsVal($name, 'setpointTempRestore', 20));
  12137. readingsEndUpdate($hash, 0);
  12138. CommandDeleteReading(undef, "$name .*Restore");
  12139. } else {
  12140. # attr not changed
  12141. }
  12142. } else {
  12143. $err = "attribute-value [$attrName] = $attrVal wrong";
  12144. }
  12145. } elsif ($attrName =~ m/^subDef.?|postmasterID/) {
  12146. if (!defined $attrVal){
  12147. } elsif ($attrVal eq "getNextID") {
  12148. # actions see EnOcean_Notify, global ATTR
  12149. } elsif ($attrVal !~ m/^[\dA-Fa-f]{8}$/) {
  12150. $err = "attribute-value [$attrName] = $attrVal wrong";
  12151. }
  12152. } elsif ($attrName eq "switchHysteresis") {
  12153. if (!defined $attrVal) {
  12154. } elsif ($attrVal =~ m/^\d+(\.\d+)?$/ && $attrVal >= 0.1) {
  12155. } else {
  12156. #RemoveInternalTimer($hash);
  12157. $err = "attribute-value [$attrName] = $attrVal is not a valid number";
  12158. }
  12159. } elsif ($attrName eq "teachMethod") {
  12160. if (!defined $attrVal){
  12161. } elsif ($attrVal !~ m/^1BS|4BS|confirm|GP|RPS|smartAck|STE|UTE$$/) {
  12162. $err = "attribute-value [$attrName] = $attrVal wrong";
  12163. }
  12164. } elsif ($attrName eq "temperatureScale") {
  12165. if (!defined $attrVal){
  12166. } elsif ($attrVal =~ m/^(C|F|default|no_change)$/) {
  12167. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12168. $waitingCmds |= 64;
  12169. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  12170. }
  12171. } else {
  12172. $err = "attribute-value [$attrName] = $attrVal wrong";
  12173. }
  12174. } elsif ($attrName eq "timeNotation") {
  12175. if (!defined $attrVal){
  12176. } elsif ($attrVal =~ m/^(12|24|default|no_change)$/) {
  12177. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12178. $waitingCmds |= 64;
  12179. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  12180. }
  12181. } else {
  12182. $err = "attribute-value [$attrName] = $attrVal wrong";
  12183. }
  12184. } elsif ($attrName =~ m/^timeProgram[1-4]$/) {
  12185. if (!defined $attrVal){
  12186. } elsif ($attrVal =~ m/^(FrMo|FrSu|ThFr|WeFr|TuTh|MoWe|SaSu|MoFr|MoSu|Su|Sa|Fr|Th|We|Tu|Mo)\s+(\d*?):(00|15|30|45)\s+(\d*?):(00|15|30|45)\s+(comfort|economy|preComfort|buildingProtection)$/) {
  12187. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12188. # delete remote and send new time program
  12189. delete $hash->{helper}{4}{telegramWait};
  12190. $hash->{helper}{4}{telegramWait}{substr($attrName,-1,1) + 0} = 1;
  12191. for (my $messagePartCntr = 1; $messagePartCntr <= 4; $messagePartCntr ++) {
  12192. if (defined AttrVal($name, "timeProgram" . $messagePartCntr, undef)) {
  12193. $hash->{helper}{4}{telegramWait}{$messagePartCntr} = 1;
  12194. }
  12195. }
  12196. $waitingCmds |= 528;
  12197. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  12198. }
  12199. } else {
  12200. $err = "attribute-value [$attrName] = $attrVal wrong";
  12201. }
  12202. } elsif ($attrName eq "trackerWakeUpCycle") {
  12203. if (!defined $attrVal){
  12204. } elsif ($attrVal !~ m/^10|20|30|40|60|120|180|240|3600|86400$/) {
  12205. $err = "attribute-value [$attrName] = $attrVal wrong";
  12206. }
  12207. } elsif ($attrName eq "updateState") {
  12208. if (!defined $attrVal){
  12209. } elsif ($attrVal !~ m/^default|yes|no$/) {
  12210. $err = "attribute-value [$attrName] = $attrVal wrong";
  12211. }
  12212. } elsif ($attrName eq "uteResponseRequest") {
  12213. if (!defined $attrVal){
  12214. } elsif ($attrVal !~ m/^(yes|no)$/) {
  12215. $err = "attribute-value [$attrName] = $attrVal wrong";
  12216. }
  12217. } elsif ($attrName eq "wakeUpCycle") {
  12218. my $wakeUpCycle = join("|", keys %wakeUpCycle);
  12219. if (!defined $attrVal){
  12220. } elsif ($attrVal =~ m/^$wakeUpCycle$/) {
  12221. if ($attrVal >= 1500 && AttrVal($name, 'wakeUpCycle', 300) < 1500) {
  12222. # switch to summer mode
  12223. $attr{$name}{summerMode} = 'on';
  12224. readingsSingleUpdate($hash, 'waitingCmds', 'summerMode', 0);
  12225. } elsif ($attrVal < 1500 && AttrVal($name, 'wakeUpCycle', 300) >= 1500) {
  12226. # runInit necessary before switch to operation mode
  12227. $attr{$name}{summerMode} = 'off';
  12228. readingsSingleUpdate($hash, 'waitingCmds', 'runInit', 0);
  12229. }
  12230. } else {
  12231. $err = "attribute-value [$attrName] = $attrVal wrong";
  12232. }
  12233. }
  12234. return $err;
  12235. }
  12236. sub EnOcean_Notify(@)
  12237. {
  12238. my ($hash, $dev) = @_;
  12239. my $name = $hash->{NAME};
  12240. my $devName = $dev->{NAME};
  12241. return undef if (AttrVal($name ,"disable", 0) > 0);
  12242. my $max = int(@{$dev->{CHANGED}});
  12243. for (my $i = 0; $i < $max; $i++) {
  12244. my $s = $dev->{CHANGED}[$i];
  12245. $s = "" if(!defined($s));
  12246. if ($devName eq $name) {
  12247. my @parts = split(/: | /, $s);
  12248. #####
  12249. if (exists($hash->{helper}{stopped}) && !$hash->{helper}{stopped} && $parts[0] eq "temperature") {
  12250. # PID regulator: calc gradient for delta as base for d-portion calculation
  12251. my $setpointTemp = ReadingsVal($name, "setpointTemp", undef);
  12252. my $temperature = $parts[1];
  12253. # ---- build difference current - old value
  12254. # calc difference of delta/deltaOld
  12255. my $delta = $setpointTemp - $temperature if (defined($setpointTemp));
  12256. my $deltaOld = ($hash->{helper}{deltaOld} + 0) if (defined($hash->{helper}{deltaOld}));
  12257. my $deltaDiff = ($delta - $deltaOld) if (defined($delta) && defined($deltaOld));
  12258. # ----- build difference of timestamps
  12259. my $deltaOldTsStr = $hash->{helper}{deltaOldTS};
  12260. my $deltaOldTsNum = time_str2num($deltaOldTsStr) if (defined($deltaOldTsStr));
  12261. my $nowTsNum = gettimeofday();
  12262. my $tsDiff = ($nowTsNum - $deltaOldTsNum)
  12263. if (defined($deltaOldTsNum) && (($nowTsNum - $deltaOldTsNum) > 0));
  12264. # ----- calculate gradient of delta
  12265. my $deltaGradient = $deltaDiff / $tsDiff
  12266. if (defined($deltaDiff) && defined($tsDiff) && ($tsDiff > 0 ));
  12267. $deltaGradient = 0 if ( !defined($deltaGradient) );
  12268. # ----- store results
  12269. $hash->{helper}{deltaGradient} = $deltaGradient;
  12270. $hash->{helper}{deltaOld} = $delta;
  12271. $hash->{helper}{deltaOldTS} = TimeNow();
  12272. Log3 $name, 5, "EnOcean $name <notify> $devName $s";
  12273. }
  12274. } elsif ($devName eq "global" && $s =~ m/^RENAMED ([^ ]*) ([^ ]*)$/) {
  12275. if (defined AttrVal($name, "temperatureRefDev", undef)) {
  12276. if (AttrVal($name, "temperatureRefDev", undef) eq $1) {
  12277. CommandAttr(undef, "$name temperatureRefDev $2");
  12278. }
  12279. } elsif (defined AttrVal($name, "setpointRefDev", undef)) {
  12280. if (AttrVal($name, "setpointRefDev", undef) eq $1) {
  12281. CommandAttr(undef, "$name setpointRefDev $2");
  12282. }
  12283. } elsif (defined AttrVal($name, "setpointTempRefDev", undef)) {
  12284. if (AttrVal($name, "setpointTempRefDev", undef) eq $1) {
  12285. CommandAttr(undef, "$name setpointTempRefDev $2");
  12286. }
  12287. } elsif (defined AttrVal($name, "humidityRefDev", undef)) {
  12288. if (AttrVal($name, "humidityRefDev", undef) eq $1) {
  12289. CommandAttr(undef, "$name humidityRefDev $2");
  12290. }
  12291. } elsif (defined AttrVal($name, "observeRefDev", undef)) {
  12292. if (AttrVal($name, "observeRefDev", undef) eq $1) {
  12293. CommandAttr(undef, "$name observeRefDev $2");
  12294. }
  12295. } elsif (defined AttrVal($name, "demandRespRefDev", undef)) {
  12296. if (AttrVal($name, "demandRespRefDev", undef) eq $1) {
  12297. CommandAttr(undef, "$name demandRespRefDev $2");
  12298. }
  12299. }
  12300. #Log3($name, 5, "EnOcean $name <notify> RENAMED old: $1 new: $2");
  12301. } elsif ($devName eq "global" && $s =~ m/^DELETED ([^ ]*)$/) {
  12302. # delete attribute *RefDev
  12303. if (defined AttrVal($name, "temperatureRefDev", undef)) {
  12304. if (AttrVal($name, "temperatureRefDev", undef) eq $1) {
  12305. CommandDeleteAttr(undef, "$name temperatureRefDev");
  12306. }
  12307. } elsif (defined AttrVal($name, "setpointRefDev", undef)) {
  12308. if (AttrVal($name, "setpointRefDev", undef) eq $1) {
  12309. CommandDeleteAttr(undef, "$name setpointRefDev");
  12310. }
  12311. } elsif (defined AttrVal($name, "setpointTempRefDev", undef)) {
  12312. if (AttrVal($name, "setpointTempRefDev", undef) eq $1) {
  12313. CommandDeleteAttr(undef, "$name setpointTempRefDev");
  12314. }
  12315. } elsif (defined AttrVal($name, "humidityRefDev", undef)) {
  12316. if (AttrVal($name, "humidityRefDev", undef) eq $1) {
  12317. CommandDeleteAttr(undef, "$name humidityRefDev");
  12318. }
  12319. } elsif (defined AttrVal($name, "observeRefDev", undef)) {
  12320. if (AttrVal($name, "observeRefDev", undef) eq $1) {
  12321. CommandDeleteAttr(undef, "$name observeRefDev");
  12322. }
  12323. } elsif (defined AttrVal($name, "demandRespRefDev", undef)) {
  12324. if (AttrVal($name, "demandRespRefDev", undef) eq $1) {
  12325. CommandDeleteAttr(undef, "$name demandRespRefDev");
  12326. }
  12327. }
  12328. #Log3($name, 5, "EnOcean $name <notify> DELETED $1");
  12329. } elsif ($devName eq "global" && $s =~ m/^DEFINED ([^ ]*)$/) {
  12330. my $definedName = $1;
  12331. if ($name eq $definedName) {
  12332. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  12333. # control PID regulatior
  12334. if (AttrVal($name, 'pidCtrl', 'on') eq 'on' && ReadingsVal($name, 'maintenanceMode', 'off') eq 'off') {
  12335. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  12336. } else {
  12337. EnOcean_setPID(undef, $hash, 'stop', '');
  12338. }
  12339. }
  12340. }
  12341. # teach-in response actions
  12342. # delete temporary teach-in response device, see V9333_02
  12343. #Log3($name, 2, "EnOcean $name <notify> DEFINED $definedName");
  12344. } elsif ($devName eq "global" && $s =~ m/^INITIALIZED$/) {
  12345. # assign remote management defptr
  12346. if (exists $attr{$name}{remoteID}) {
  12347. $modules{EnOcean}{defptr}{$attr{$name}{remoteID}} = $hash;
  12348. }
  12349. if (AttrVal($name ,"subType", "") eq "roomCtrlPanel.00") {
  12350. CommandDeleteReading(undef, "$name waitingCmds");
  12351. }
  12352. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  12353. # control PID regulatior
  12354. if (AttrVal($name, 'pidCtrl', 'on') eq 'on' && ReadingsVal($name, 'maintenanceMode', 'off') eq 'off') {
  12355. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  12356. } else {
  12357. EnOcean_setPID(undef, $hash, 'stop', '');
  12358. }
  12359. }
  12360. if (exists($attr{$name}{subType}) && $attr{$name}{subType} eq "switch.05") {
  12361. my @getCmd = ($name, 'state');
  12362. EnOcean_Get($hash, @getCmd);
  12363. }
  12364. EnOcean_ReadDevDesc(undef, $hash);
  12365. #Log3($name, 2, "EnOcean $name <notify> INITIALIZED");
  12366. } elsif ($devName eq "global" && $s =~ m/^REREADCFG$/) {
  12367. # assign remote management defptr
  12368. if (exists $attr{$name}{remoteID}) {
  12369. $modules{EnOcean}{defptr}{$attr{$name}{remoteID}} = $hash;
  12370. }
  12371. if (AttrVal($name ,"subType", "") eq "roomCtrlPanel.00") {
  12372. CommandDeleteReading(undef, "$name waitingCmds");
  12373. }
  12374. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  12375. # control PID regulatior
  12376. if (AttrVal($name, 'pidCtrl', 'on') eq 'on' && ReadingsVal($name, 'maintenanceMode', 'off') eq 'off') {
  12377. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  12378. } else {
  12379. EnOcean_setPID(undef, $hash, 'stop', '');
  12380. }
  12381. }
  12382. EnOcean_ReadDevDesc(undef, $hash);
  12383. #Log3($name, 2, "EnOcean $name <notify> REREADCFG");
  12384. } elsif ($devName eq "global" && $s =~ m/^ATTR ([^ ]*) ([^ ]*) ([^ ]*)$/) {
  12385. my ($sdev, $attrName, $attrVal) = ($1, $2, $3);
  12386. #Log3 $name, 5, "EnOcean $name <notify> ATTR $1 $2 $3";
  12387. if ($name eq $sdev && $attrName =~ m/^subDef.?/ && $attrVal eq "getNextID") {
  12388. $attr{$name}{$attrName} = '0' x 8;
  12389. $attr{$name}{$attrName} = EnOcean_CheckSenderID("getNextID", $defs{$name}{IODev}{NAME}, "00000000");
  12390. Log3 $name, 2, "EnOcean set $name attribute $attrName to " . $attr{$name}{$attrName};
  12391. } elsif ($attrName eq "devChannel" && $attrVal =~ m/^[\dA-Fa-f]{2}$/) {
  12392. # convert old format
  12393. $attr{$name}{$attrName} = hex $attrVal;
  12394. }
  12395. } elsif ($devName eq "global" && $s =~ m/^DELETEATTR ([^ ]*)$/) {
  12396. #Log3($name, 5, "EnOcean $name <notify> DELETEATTR $1");
  12397. } elsif ($devName eq "global" && $s =~ m/^MODIFIED ([^ ]*)$/) {
  12398. #Log3($name, 5, "EnOcean $name <notify> MODIFIED");
  12399. } elsif ($devName eq "global" && $s =~ m/^SAVE$/) {
  12400. #Log3($name, 5, "EnOcean $name <notify> SAVE");
  12401. } elsif ($devName eq "global" && $s =~ m/^SHUTDOWN$/) {
  12402. #Log3($name, 5, "EnOcean $name <notify> SHUTDOWN");
  12403. } else {
  12404. my @parts = split(/: | /, $s);
  12405. if (defined AttrVal($name, "observeRefDev", undef)) {
  12406. my @observeRefDev = split("[ \t][ \t]*", AttrVal($name, "observeRefDev", undef));
  12407. if (grep /^$devName$/, @observeRefDev) {
  12408. my ($reading, $value) = ("", "");
  12409. $reading = shift @parts;
  12410. if (!defined($parts[0]) || @parts > 1) {
  12411. $value = $s;
  12412. $reading = "state";
  12413. } else {
  12414. $value = $parts[0];
  12415. }
  12416. my @cmdObserve = ($devName, $reading, $value);
  12417. EnOcean_observeParse(2, $hash, @cmdObserve);
  12418. #Log3($name, 5, "EnOcean $name <notify> observeRefDev: $devName $reading: $value");
  12419. }
  12420. }
  12421. if (defined AttrVal($name, "demandRespRefDev", undef)) {
  12422. my @demandRespRefDev = split("[ \t][ \t]*", AttrVal($name, "demandRespRefDev", undef));
  12423. if (grep /^$devName$/, @demandRespRefDev) {
  12424. my @cmdDemandResponse;
  12425. my $actionCmd = AttrVal($name, "demandRespAction", undef);
  12426. if (defined $actionCmd) {
  12427. if ($parts[0] =~ m/^on|off$/) {
  12428. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set $parts[0]");
  12429. my %specials = ("%TARGETNAME" => $name,
  12430. "%NAME" => $devName,
  12431. "%TARGETTYPE" => $hash->{TYPE},
  12432. "%TYPE" => $dev->{TYPE},
  12433. "%LEVEL" => ReadingsVal($devName, "level", 15),
  12434. "%SETPOINT" => ReadingsVal($devName, "setpoint", 255),
  12435. "%POWERUSAGE" => ReadingsVal($devName, "powerUsage", 100),
  12436. "%POWERUSAGESCALE" => ReadingsVal($devName, "powerUsageScale", "max"),
  12437. "%POWERUSAGELEVEL" => ReadingsVal($devName, "powerUsageLevel", "max"),
  12438. "%TARGETSTATE" => ReadingsVal($name, "state", ""),
  12439. "%STATE" => ReadingsVal($devName, "state", "off")
  12440. );
  12441. # action exec
  12442. $actionCmd = EvalSpecials($actionCmd, %specials);
  12443. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  12444. Log3 $name, 2, "EnOcean $name demandRespAction ERROR: $ret" if($ret);
  12445. }
  12446. } elsif (AttrVal($name, "subType", "") =~ m/^switch.*$/ || AttrVal($name, "subTypeSet", "") =~ m/^switch.*$/) {
  12447. if ($parts[0] eq "powerUsageLevel" && $parts[1] eq "max") {
  12448. @cmdDemandResponse = ($name, AttrVal($name, "demandRespMax", "B0"));
  12449. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12450. EnOcean_Set($hash, @cmdDemandResponse);
  12451. } elsif ($parts[0] eq "powerUsageLevel" && $parts[1] eq "min") {
  12452. @cmdDemandResponse = ($name, AttrVal($name, "demandRespMin", "BI"));
  12453. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12454. EnOcean_Set($hash, @cmdDemandResponse);
  12455. }
  12456. } elsif (AttrVal($name, "subType", "") eq "gateway" && AttrVal($name, "gwCmd", "") eq "switching") {
  12457. if ($parts[0] eq "powerUsageLevel" && $parts[1] eq "max") {
  12458. @cmdDemandResponse = ($name, "on");
  12459. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12460. EnOcean_Set($hash, @cmdDemandResponse);
  12461. } elsif ($parts[0] eq "powerUsageLevel" && $parts[1] eq "min") {
  12462. @cmdDemandResponse = ($name, "off");
  12463. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12464. EnOcean_Set($hash, @cmdDemandResponse);
  12465. }
  12466. } elsif ((AttrVal($name, "subType", "") eq "gateway" && AttrVal($name, "gwCmd", "") eq "dimming")
  12467. || AttrVal($name, "subType", "") eq "actuator.01") {
  12468. if ($parts[0] eq "powerUsage") {
  12469. if (ReadingsVal($devName, "powerUsageScale", "max") eq "rel") {
  12470. @cmdDemandResponse = ($name, "dim", $parts[1] * ReadingsVal($name, "dimValueLast", 100) / 100);
  12471. } else {
  12472. @cmdDemandResponse = ($name, "dim", $parts[1]);
  12473. }
  12474. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12475. EnOcean_Set($hash, @cmdDemandResponse);
  12476. }
  12477. } elsif ((AttrVal($name, "subType", "") eq "roomSensorControl.05" && AttrVal($name, "manufID", "") eq "00D")) {
  12478. if ($parts[0] eq "level") {
  12479. @cmdDemandResponse = ($name, "nightReduction", int(5 - 1/3 * $parts[1]));
  12480. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12481. EnOcean_Set($hash, @cmdDemandResponse);
  12482. }
  12483. } elsif (AttrVal($name, "subType", "") eq "lightCtrl.01") {
  12484. if ($parts[0] eq "setpoint") {
  12485. @cmdDemandResponse = ($name, "dim", $parts[1]);
  12486. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12487. EnOcean_Set($hash, @cmdDemandResponse);
  12488. }
  12489. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.01") {
  12490. if ($parts[0] eq "setpoint") {
  12491. @cmdDemandResponse = ($name, "setpoint", $parts[1]);
  12492. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12493. EnOcean_Set($hash, @cmdDemandResponse);
  12494. }
  12495. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.05") {
  12496. if ($parts[0] eq "setpoint") {
  12497. @cmdDemandResponse = ($name, $parts[0], $parts[1]);
  12498. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12499. EnOcean_Set($hash, @cmdDemandResponse);
  12500. }
  12501. } elsif (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12502. if ($parts[0] eq "powerUsageLevel" && $parts[1] eq "max") {
  12503. @cmdDemandResponse = ($name, "roomCtrlMode", "comfort");
  12504. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12505. EnOcean_Set($hash, @cmdDemandResponse);
  12506. } elsif ($parts[0] eq "powerUsageLevel" && $parts[1] eq "min") {
  12507. @cmdDemandResponse = ($name, "roomCtrlMode", "economy");
  12508. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12509. EnOcean_Set($hash, @cmdDemandResponse);
  12510. }
  12511. }
  12512. }
  12513. }
  12514. if (defined(AttrVal($name, "humidityRefDev", undef)) && AttrVal($name, "setCmdTrigger", "man") eq "refDev") {
  12515. if ($devName eq AttrVal($name, "humidityRefDev", "")) {
  12516. if ($parts[0] eq "humidity") {
  12517. if (AttrVal($name, "subType", "") eq "roomSensorControl.01") {
  12518. my @setCmd = ($name, "setpoint");
  12519. EnOcean_Set($hash, @setCmd);
  12520. }
  12521. }
  12522. }
  12523. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12524. }
  12525. if (defined(AttrVal($name, "temperatureRefDev", undef)) && AttrVal($name, "setCmdTrigger", "man") eq "refDev") {
  12526. # sent a setpoint or setpointTemp telegram
  12527. if ($devName eq AttrVal($name, "temperatureRefDev", "")) {
  12528. if ($parts[0] eq "temperature") {
  12529. if (AttrVal($name, "subType", "") eq "roomSensorControl.05" && AttrVal($name, "manufID", "") eq "00D") {
  12530. my @setCmd = ($name, "setpointTemp");
  12531. EnOcean_Set($hash, @setCmd);
  12532. } elsif (AttrVal($name, "subType", "") eq "fanCtrl.00") {
  12533. my @setCmd = ($name, "setpointTemp");
  12534. EnOcean_Set($hash, @setCmd);
  12535. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.01") {
  12536. my @setCmd = ($name, "setpoint");
  12537. EnOcean_Set($hash, @setCmd);
  12538. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.05") {
  12539. my @setCmd = ($name, "setpoint");
  12540. EnOcean_Set($hash, @setCmd);
  12541. }
  12542. }
  12543. }
  12544. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12545. }
  12546. if (defined(AttrVal($name, "temperatureRefDev", undef)) &&
  12547. $devName eq AttrVal($name, "temperatureRefDev", "") &&
  12548. $parts[0] eq "temperature") {
  12549. if (AttrVal($name, "subType", "") eq "hvac.01") {
  12550. readingsSingleUpdate($hash, "temperature", $parts[1], 1);
  12551. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12552. }
  12553. if (AttrVal($name, "subType", "") eq "hvac.04" && AttrVal($name, "measurementCtrl", "enable") eq 'disable') {
  12554. readingsSingleUpdate($hash, "temperature", $parts[1], 1);
  12555. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12556. }
  12557. }
  12558. if (defined(AttrVal($name, "setpointRefDev", undef)) &&
  12559. $devName eq AttrVal($name, "setpointRefDev", "") &&
  12560. $parts[0] eq "setpoint") {
  12561. if (AttrVal($name, "subType", '') =~ m/^hvac\.0(1|4)$/) {
  12562. my @setCmd = ($name, "setpoint", $parts[1]);
  12563. EnOcean_Set($hash, @setCmd);
  12564. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12565. }
  12566. }
  12567. if (defined(AttrVal($name, "setpointTempRefDev", undef)) &&
  12568. $devName eq AttrVal($name, "setpointTempRefDev", "") &&
  12569. $parts[0] eq "setpointTemp") {
  12570. if (AttrVal($name, "subType", '') =~ m/^hvac\.0(1|4)$/) {
  12571. if (ReadingsVal($name, "setpointTemp", 0) != $parts[1]) {
  12572. my @setCmd = ($name, "setpointTemp", $parts[1]);
  12573. EnOcean_Set($hash, @setCmd);
  12574. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12575. }
  12576. }
  12577. }
  12578. }
  12579. }
  12580. return undef;
  12581. }
  12582. # ADT encapsulation
  12583. sub
  12584. EnOcean_Encapsulation($$$$)
  12585. {
  12586. my ($packetType, $rorg, $data, $destinationID) = @_;
  12587. if ($destinationID eq "FFFFFFFF") {
  12588. return ($rorg, $data);
  12589. } else {
  12590. $data = $rorg . $data;
  12591. return ("A6", $data);
  12592. }
  12593. }
  12594. # set PID regulator
  12595. sub EnOcean_setPID($$$) {
  12596. my ($crtl, $hash, $cmd, $adjust) = @_;
  12597. my $name = $hash->{NAME};
  12598. my ($err, $response, $logLevel) = (undef, 'start', 5);
  12599. @{$hash->{helper}{calcPID}} = (undef, $hash, $cmd);
  12600. if ($cmd eq 'stop' || AttrVal($name, 'pidCtrl', 'on') eq 'off') {
  12601. $hash->{helper}{stopped} = 1;
  12602. readingsSingleUpdate($hash, "pidState", 'stopped', 0);
  12603. RemoveInternalTimer($hash->{helper}{calcPID});
  12604. $response = 'stopped';
  12605. } elsif ($cmd eq 'start' || $cmd eq 'actuator') {
  12606. $hash->{helper}{stopped} = 0;
  12607. $hash->{helper}{adjust} = $adjust;
  12608. RemoveInternalTimer($hash->{helper}{calcPID});
  12609. ($err, $logLevel, $response) = EnOcean_calcPID($hash->{helper}{calcPID});
  12610. }
  12611. return ($err, $logLevel, $response);
  12612. }
  12613. # calc valve setpoint (PID regulator)
  12614. sub EnOcean_calcPID($) {
  12615. my ($pidParam) = @_;
  12616. my ($crtl, $hash, $cmd) = @$pidParam;
  12617. my $name = $hash->{NAME};
  12618. my ($err, $response, $logLevel, $setpoint) = (undef, $cmd, 5, 0);
  12619. #####
  12620. my $reUINT = '^([\\+]?\\d+)$'; # uint without whitespaces
  12621. my $re01 = '^([0,1])$'; # only 0,1
  12622. my $reINT = '^([\\+,\\-]?\\d+$)'; # int
  12623. my $reFloatpos = '^([\\+]?\\d+\\.?\d*$)'; # gleitpunkt positiv float
  12624. my $reFloat = '^([\\+,\\-]?\\d+\\.?\d*$)'; # float
  12625. my $sensor = $name;
  12626. my $reading = 'temperature';
  12627. my $regexp = $reFloat;
  12628. my $DEBUG_Sensor = AttrVal( $name, 'pidDebugSensor', '0' ) eq '1';
  12629. my $DEBUG_Actuation = AttrVal( $name, 'pidDebugActuation', '0' ) eq '1';
  12630. my $DEBUG_Delta = AttrVal( $name, 'pidDebugDelta', '0' ) eq '1';
  12631. my $DEBUG_Calc = AttrVal( $name, 'pidDebugCalc', '0' ) eq '1';
  12632. my $DEBUG_Update = AttrVal( $name, 'pidDebugUpdate', '0' ) eq '1';
  12633. my $DEBUG = $DEBUG_Sensor || $DEBUG_Actuation || $DEBUG_Calc || $DEBUG_Delta || $DEBUG_Update;
  12634. my $actuation = "";
  12635. my $actuationDone = ReadingsVal( $name, 'setpointSet', ReadingsVal( $name, 'setpoint', ""));
  12636. my $actuationCalc = ReadingsVal( $name, 'setpointCalc', "" );
  12637. my $actuationCalcOld = $actuationCalc;
  12638. my $actorTimestamp =
  12639. ( $hash->{helper}{actorTimestamp} )
  12640. ? $hash->{helper}{actorTimestamp}
  12641. : FmtDateTime( gettimeofday() - 3600 * 24 );
  12642. my $desired = '';
  12643. my $sensorStr = ReadingsVal($name, 'temperature',"");
  12644. my $sensorValue = "";
  12645. my $sensorTS = ReadingsTimestamp($name, 'temperature', undef);
  12646. my $sensorIsAlive = 0;
  12647. my $iPortion = ReadingsVal( $name, 'p_i', 0 );
  12648. my $pPortion = ReadingsVal( $name, 'p_p', "" );
  12649. my $dPortion = ReadingsVal( $name, 'p_d', "" );
  12650. my $stateStr = "";
  12651. CommandDeleteReading(undef, "$name pidAlarm");
  12652. my $deltaOld = ReadingsVal( $name, 'delta', 0 );
  12653. my $delta = "";
  12654. my $deltaGradient = ( $hash->{helper}{deltaGradient} ) ? $hash->{helper}{deltaGradient} : 0;
  12655. my $calcReq = 0;
  12656. my $readingUpdateReq = '';
  12657. # ---------------- check conditions
  12658. while (1)
  12659. {
  12660. # --------------- retrive values from attributes
  12661. my $wakeUpCycle = AttrVal($name, 'wakeUpCycle', ReadingsVal($name, 'wakeUpCycle', 300));
  12662. my $pidCycle = $wakeUpCycle / 3;
  12663. $pidCycle = 10 if ($pidCycle < 10);
  12664. $hash->{helper}{actorInterval} = 10;
  12665. $hash->{helper}{actorThreshold} = 0;
  12666. $hash->{helper}{actorKeepAlive} = $pidCycle;
  12667. $hash->{helper}{actorValueDecPlaces} = 0;
  12668. $hash->{helper}{actorErrorAction} = AttrVal($name, 'pidActorErrorAction', 'freeze');
  12669. $hash->{helper}{actorErrorPos} = AttrVal($name, 'pidActorErrorPos', 0);
  12670. $hash->{helper}{calcInterval} = $pidCycle;
  12671. $hash->{helper}{deltaTreshold} = AttrVal($name, 'pidDeltaTreshold', 0);
  12672. if (AttrVal($name, 'measurementCtrl', 'enable') eq 'enable') {
  12673. $hash->{helper}{sensorTimeout} = $wakeUpCycle * 4;
  12674. } else {
  12675. $hash->{helper}{sensorTimeout} = AttrVal($name, 'pidSensorTimeout', 3600);
  12676. }
  12677. $hash->{helper}{reverseAction} = 0;
  12678. $hash->{helper}{updateInterval} = $pidCycle;
  12679. $hash->{helper}{actorLimitLower} = AttrVal($name, 'pidActorLimitLower', 0);
  12680. my $actorLimitLower = $hash->{helper}{actorLimitLower};
  12681. $hash->{helper}{actorLimitUpper} = AttrVal($name, 'pidActorLimitUpper', 100);
  12682. my $actorLimitUpper = $hash->{helper}{actorLimitUpper};
  12683. $hash->{helper}{factor_P} = AttrVal($name, 'pidFactor_P', 25);
  12684. $hash->{helper}{factor_I} = AttrVal($name, 'pidFactor_I', 0.25);
  12685. $hash->{helper}{factor_D} = AttrVal($name, 'pidFactor_D', 0);
  12686. if ($hash->{helper}{stopped}) {
  12687. $stateStr = "stopped";
  12688. last;
  12689. }
  12690. $desired = ReadingsVal( $name, 'setpointTempSet', ReadingsVal($name, 'setpointTemp', ""));
  12691. #my $desired = ReadingsVal( $name, $hash->{helper}{desiredName}, "" );
  12692. # sensor found
  12693. #PID20_Log $hash, 2, "--------------------------" if ($DEBUG);
  12694. #PID20_Log $hash, 2, "S1 sensorStr:$sensorStr sensorTS:$sensorTS" if ($DEBUG_Sensor);
  12695. if ( !$sensorStr && !$stateStr ) {
  12696. $stateStr = "alarm";
  12697. $err = 'no_temperature_value';
  12698. }
  12699. # sensor alive
  12700. if ( $sensorStr && $sensorTS )
  12701. {
  12702. my $timeDiff = EnOcean_TimeDiff($sensorTS);
  12703. $sensorIsAlive = 1 if ( $timeDiff <= $hash->{helper}{sensorTimeout} );
  12704. $sensorStr =~ m/$regexp/;
  12705. $sensorValue = $1;
  12706. $sensorValue = "" if ( !defined($sensorValue) );
  12707. #PID20_Log $hash, 2,
  12708. # "S2 timeOfDay:"
  12709. # . gettimeofday()
  12710. # . " timeDiff:$timeDiff sensorTimeout:"
  12711. # . $hash->{helper}{sensorTimeout}
  12712. # . " --> sensorIsAlive:$sensorIsAlive"
  12713. # if ($DEBUG_Sensor);
  12714. }
  12715. # sensor dead
  12716. if (!$sensorIsAlive && !$stateStr) {
  12717. $stateStr = "alarm";
  12718. $err = 'dead_sensor';
  12719. }
  12720. # missing desired
  12721. if ($desired eq "" && !$stateStr) {
  12722. $stateStr = "alarm";
  12723. $err = 'setpoint_device_missing';
  12724. }
  12725. # check delta threshold
  12726. $delta = ( $desired ne "" && $sensorValue ne "" ) ? $desired - $sensorValue : "";
  12727. $calcReq = 1 if ( !$stateStr && $delta ne "" && ( abs($delta) >= abs( $hash->{helper}{deltaTreshold} ) ) );
  12728. #PID20_Log $hash, 2,
  12729. # "D1 desired[" . ( $desired ne "" ) ? sprintf( "%.1f", $desired )
  12730. # : "" . "] - sensorValue: [" . ( $sensorValue ne "" ) ? sprintf( "%.1f", $sensorValue )
  12731. # : "" . "] = delta[" . ( $delta ne "" ) ? sprintf( "%.2f", $delta )
  12732. # : "" . "] calcReq:$calcReq"
  12733. # if ($DEBUG_Delta);
  12734. #request for calculation
  12735. # ---------------- calculation request
  12736. if ($calcReq)
  12737. {
  12738. # reverse action requested
  12739. my $workDelta = ( $hash->{helper}{reverseAction} == 1 ) ? -$delta : $delta;
  12740. my $deltaOld = -$deltaOld if ( $hash->{helper}{reverseAction} == 1 );
  12741. # calc p-portion
  12742. $pPortion = $workDelta * $hash->{helper}{factor_P};
  12743. # calc d-Portion
  12744. $dPortion = ($deltaGradient) * $hash->{helper}{calcInterval} * $hash->{helper}{factor_D};
  12745. # calc i-portion respecting windUp
  12746. # freeze i-portion if windUp is active
  12747. my $isWindup = $actuationCalcOld
  12748. && ( ( $workDelta > 0 && $actuationCalcOld > $actorLimitUpper )
  12749. || ( $workDelta < 0 && $actuationCalcOld < $actorLimitLower ) );
  12750. if ( $hash->{helper}{adjust} ne "" )
  12751. {
  12752. $iPortion = $hash->{helper}{adjust} - ( $pPortion + $dPortion );
  12753. $iPortion = $actorLimitUpper if ( $iPortion > $actorLimitUpper );
  12754. $iPortion = $actorLimitLower if ( $iPortion < $actorLimitLower );
  12755. #PID20_Log $hash, 5, "adjust request with:" . $hash->{helper}{adjust} . " ==> p_i:$iPortion";
  12756. $hash->{helper}{adjust} = "";
  12757. } elsif ( !$isWindup ) # integrate only if no windUp
  12758. {
  12759. # normalize the intervall to minute=60 seconds
  12760. $iPortion = $iPortion + $workDelta * $hash->{helper}{factor_I} * $hash->{helper}{calcInterval} / 60;
  12761. $hash->{helper}{isWindUP} = 0;
  12762. }
  12763. $hash->{helper}{isWindUP} = $isWindup;
  12764. # check callback for iPortion
  12765. my $iportionCallBeforeSetting = AttrVal( $name, 'pidIPortionCallBeforeSetting', undef );
  12766. if ( defined($iportionCallBeforeSetting) && exists &$iportionCallBeforeSetting )
  12767. {
  12768. #PID20_Log $hash, 5, 'start callback ' . $iportionCallBeforeSetting . ' with iPortion:' . $iPortion;
  12769. no strict "refs";
  12770. $iPortion = &$iportionCallBeforeSetting( $name, $iPortion );
  12771. use strict "refs";
  12772. #PID20_Log $hash, 5, 'return value of ' . $iportionCallBeforeSetting . ':' . $iPortion;
  12773. }
  12774. # calc actuation
  12775. $actuationCalc = $pPortion + $iPortion + $dPortion;
  12776. #PID20_Log $hash, 2, "P1 delta:" . sprintf( "%.2f", $delta ) . " isWindup:$isWindup" if ($DEBUG_Calc);
  12777. #PID20_Log $hash, 2,
  12778. # "P2 pPortion:"
  12779. # . sprintf( "%.2f", $pPortion )
  12780. # . " iPortion:"
  12781. # . sprintf( "%.2f", $iPortion )
  12782. # . " dPortion:"
  12783. # . sprintf( "%.2f", $dPortion )
  12784. # . " actuationCalc:"
  12785. # . sprintf( "%.2f", $actuationCalc )
  12786. # if ($DEBUG_Calc);
  12787. }
  12788. $readingUpdateReq = 1; # in each case update readings
  12789. # ---------------- acutation request
  12790. my $noTrouble = ( $desired ne "" && $sensorIsAlive );
  12791. # check actor fallback in case of sensor fault
  12792. if (!$sensorIsAlive && ($hash->{helper}{actorErrorAction} eq "errorPos")) {
  12793. #$stateStr .= "- force pid-output to errorPos";
  12794. $err .= ':actuator_in_errorPos';
  12795. $actuationCalc = $hash->{helper}{actorErrorPos};
  12796. $actuationCalc = "" if ( !defined($actuationCalc) );
  12797. }
  12798. # check acutation diff
  12799. $actuation = $actuationCalc;
  12800. # limit $actuation
  12801. $actuation = $actorLimitUpper if ( $actuation ne "" && ( $actuation > $actorLimitUpper ) );
  12802. $actuation = $actorLimitLower if ( $actuation ne "" && ( $actuation < $actorLimitLower ) );
  12803. # check if round request
  12804. my $fmt = "%." . $hash->{helper}{actorValueDecPlaces} . "f";
  12805. $actuation = sprintf( $fmt, $actuation ) if ( $actuation ne "" );
  12806. my $actuationDiff = abs( $actuation - $actuationDone )
  12807. if ( $actuation ne "" && $actuationDone ne "" );
  12808. #PID20_Log $hash, 2,
  12809. # "A1 act:$actuation actDone:$actuationDone "
  12810. # . " actThreshold:"
  12811. # . $hash->{helper}{actorThreshold}
  12812. # . " actDiff:$actuationDiff"
  12813. # if ($DEBUG_Actuation);
  12814. # check threshold-condition for actuation
  12815. my $rsTS = $actuationDone ne "" && $actuationDiff >= $hash->{helper}{actorThreshold};
  12816. # ...... special handling if acutation is in the black zone between actorLimit and (actorLimit - actorThreshold)
  12817. # upper range
  12818. my $rsUp =
  12819. $actuationDone ne ""
  12820. && $actuation > $actorLimitUpper - $hash->{helper}{actorThreshold}
  12821. && $actuationDiff != 0
  12822. && $actuation >= $actorLimitUpper;
  12823. # low range
  12824. my $rsDown =
  12825. $actuationDone ne ""
  12826. && $actuation < $actorLimitLower + $hash->{helper}{actorThreshold}
  12827. && $actuationDiff != 0
  12828. && $actuation <= $actorLimitLower;
  12829. # upper or lower limit are exceeded
  12830. my $rsLimit = $actuationDone ne "" && ( $actuationDone < $actorLimitLower || $actuationDone > $actorLimitUpper );
  12831. my $actuationByThreshold = ( ( $rsTS || $rsUp || $rsDown ) && $noTrouble );
  12832. #PID20_Log $hash, 2, "A2 rsTS:$rsTS rsUp:$rsUp rsDown:$rsDown noTrouble:$noTrouble"
  12833. # if ($DEBUG_Actuation);
  12834. # check time condition for actuation
  12835. my $actTimeDiff = EnOcean_TimeDiff($actorTimestamp); # $actorTimestamp is valid in each case
  12836. my $actuationByTime = ($noTrouble) && ( $actTimeDiff > $hash->{helper}{actorInterval} );
  12837. #PID20_Log $hash, 2,
  12838. # "A3 actTS:$actorTimestamp"
  12839. # . " actTimeDiff:"
  12840. # . sprintf( "%.2f", $actTimeDiff )
  12841. # . " actInterval:"
  12842. # . $hash->{helper}{actorInterval}
  12843. # . "-->actByTime:$actuationByTime "
  12844. # if ($DEBUG_Actuation);
  12845. # check keep alive condition for actuation
  12846. my $actuationKeepAliveReq = ( $actTimeDiff >= $hash->{helper}{actorKeepAlive} )
  12847. if ( defined($actTimeDiff) && $actuation ne "" );
  12848. # build total actuation request
  12849. my $actuationReq = (
  12850. ( $actuationByThreshold && $actuationByTime )
  12851. || $actuationKeepAliveReq # request by keep alive
  12852. || $rsLimit # upper or lower limit are exceeded
  12853. || $actuationDone eq "" # startup condition
  12854. ) && $actuation ne ""; # acutation is initialized
  12855. #PID20_Log $hash, 2,
  12856. # "A4 (actByTh:$actuationByThreshold && actByTime:$actuationByTime)"
  12857. # . "||actKeepAlive:$actuationKeepAliveReq"
  12858. # . "||rsLimit:$rsLimit=actnReq:$actuationReq"
  12859. # if ($DEBUG_Actuation);
  12860. # ................ perform output to actor
  12861. if ($actuationReq)
  12862. {
  12863. $readingUpdateReq = 1; # update the readings
  12864. # check calback for actuation
  12865. my $actorCallBeforeSetting = AttrVal( $name, 'pidActorCallBeforeSetting', undef );
  12866. if ( defined($actorCallBeforeSetting) && exists &$actorCallBeforeSetting )
  12867. {
  12868. #PID20_Log $hash, 5, 'start callback ' . $actorCallBeforeSetting . ' with actuation:' . $actuation;
  12869. no strict "refs";
  12870. $actuation = &$actorCallBeforeSetting( $name, $actuation );
  12871. use strict "refs";
  12872. #PID20_Log $hash, 5, 'return value of ' . $actorCallBeforeSetting . ':' . $actuation;
  12873. }
  12874. #build command for fhem
  12875. #PID20_Log $hash, 5,
  12876. # "actor:"
  12877. # . $hash->{helper}{actor}
  12878. # . " actorCommand:"
  12879. # . $hash->{helper}{actorCommand}
  12880. # . " actuation:"
  12881. # . $actuation;
  12882. #my $cmd = sprintf( "set %s %s %g", $hash->{helper}{actor}, $hash->{helper}{actorCommand}, $actuation );
  12883. # execute command
  12884. my $ret;
  12885. #$ret = fhem $cmd;
  12886. $setpoint = $actuation;
  12887. $actuationDone = $actuation;
  12888. # note timestamp
  12889. $hash->{helper}{actorTimestamp} = TimeNow();
  12890. my $retStr = "";
  12891. $retStr = " with return-value:" . $ret if ( defined($ret) && ( $ret ne '' ) );
  12892. #PID20_Log $hash, 3, "<$cmd> " . $retStr;
  12893. }
  12894. my $updateAlive = ( $actuation ne "" )
  12895. && EnOcean_TimeDiff( ReadingsTimestamp( $name, 'setpointSet', gettimeofday() ) ) >= $hash->{helper}{updateInterval};
  12896. # my $updateReq = ( ( $actuationReq || $updateAlive ) && $actuation ne "" );
  12897. # PID20_Log $hash, 2, "U1 actReq:$actuationReq updateAlive:$updateAlive --> updateReq:$updateReq" if ($DEBUG_Update);
  12898. # ---------------- update request
  12899. if ($readingUpdateReq)
  12900. {
  12901. readingsBeginUpdate($hash);
  12902. #readingsBulkUpdate( $hash, $hash->{helper}{desiredName}, $desired ) if ( $desired ne "" );
  12903. #readingsBulkUpdate( $hash, $hash->{helper}{measuredName}, $sensorValue ) if ( $sensorValue ne "" );
  12904. readingsBulkUpdate( $hash, 'p_p', $pPortion ) if ( $pPortion ne "" );
  12905. readingsBulkUpdate( $hash, 'p_d', $dPortion ) if ( $dPortion ne "" );
  12906. readingsBulkUpdate( $hash, 'p_i', $iPortion ) if ( $iPortion ne "" );
  12907. readingsBulkUpdate( $hash, 'setpointSet', $actuationDone) if ($actuationDone ne "");
  12908. readingsBulkUpdate( $hash, 'setpointCalc', $actuationCalc ) if ( $actuationCalc ne "" );
  12909. readingsBulkUpdate( $hash, 'delta', $delta ) if ( $delta ne "" );
  12910. readingsEndUpdate( $hash, 1 );
  12911. #PID20_Log $hash, 5, "readings updated";
  12912. }
  12913. last;
  12914. } # end while
  12915. # ........ update statePID.
  12916. $stateStr = 'idle' if ($stateStr eq '' && !$calcReq);
  12917. $stateStr = 'processing' if ($stateStr eq '' && $calcReq);
  12918. #PID20_Log $hash, 2, "C1 stateStr:$stateStr calcReq:$calcReq" if ($DEBUG_Calc);
  12919. #......... timer setup
  12920. #my $next = gettimeofday() + $hash->{helper}{calcInterval};
  12921. #RemoveInternalTimer($name); # prevent multiple timers for same hash
  12922. #InternalTimer( $next, "PID20_Calc", $name, 1 );
  12923. #PID20_Log $hash, 2, "InternalTimer next:".FmtDateTime($next)." PID20_Calc name:$name DEBUG_Calc:$DEBUG_Calc";
  12924. readingsBeginUpdate($hash);
  12925. readingsBulkUpdate($hash, 'pidState', $stateStr);
  12926. readingsBulkUpdate($hash, 'pidAlarm', $err) if (defined $err);
  12927. readingsEndUpdate($hash, 1);
  12928. Log3($name, 5, "EnOcean $name EnOcean_calcPID Cmd: $cmd pidState: $stateStr T: $sensorValue SP: $setpoint SPT: $desired");
  12929. @{$hash->{helper}{calcPID}} = (undef, $hash, 'periodic');
  12930. RemoveInternalTimer($hash->{helper}{calcPID});
  12931. InternalTimer(gettimeofday() + $hash->{helper}{calcInterval} * 1.02, "EnOcean_calcPID", $hash->{helper}{calcPID}, 0);
  12932. return ($err, $logLevel, $response);
  12933. }
  12934. # sent message to Multisnesor Window Handle (EEP D2-06-01)
  12935. sub
  12936. EnOcean_multisensor_01Snd($$$)
  12937. {
  12938. my ($crtl, $hash, $packetType) = @_;
  12939. my $name = $hash->{NAME};
  12940. my ($data, $err, $response, $logLevel);
  12941. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12942. return ($err, $response);
  12943. }
  12944. # sent message to Room Control Panel (EEP D2-10-xx)
  12945. sub
  12946. EnOcean_roomCtrlPanel_00Snd($$$$$$$$)
  12947. {
  12948. my ($crtl, $hash, $packetType, $mid, $mcf, $irc, $fbc, $gmt) = @_;
  12949. my $name = $hash->{NAME};
  12950. my ($data, $err, $response, $logLevel);
  12951. my $messagePart = 1;
  12952. if ($mid == 0) {
  12953. # general massage
  12954. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  12955. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12956. if ($err) {
  12957. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  12958. } else {
  12959. Log3 $name, $logLevel, "EnOcean $name $response";
  12960. }
  12961. if (!defined($irc)) {
  12962. } elsif ($irc == 0) {
  12963. # acknowledge request
  12964. } elsif ($irc == 1) {
  12965. # data request
  12966. } elsif ($irc == 2) {
  12967. # configuration request
  12968. } elsif ($irc == 3) {
  12969. # room control request
  12970. } elsif ($irc == 4) {
  12971. # time program request
  12972. }
  12973. if (!defined($fbc)) {
  12974. } elsif ($fbc == 0) {
  12975. # acknowledge / heartbeat
  12976. } elsif ($fbc == 1) {
  12977. # telegram repetition request
  12978. } elsif ($fbc == 2) {
  12979. # message repetition request
  12980. } elsif ($fbc == 3) {
  12981. # reserved
  12982. }
  12983. if (!defined($gmt)) {
  12984. } elsif ($gmt == 0) {
  12985. # information request
  12986. } elsif ($gmt == 1) {
  12987. # feetback
  12988. }
  12989. } elsif ($mid == 1) {
  12990. # data message
  12991. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  12992. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12993. if ($err) {
  12994. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  12995. } else {
  12996. Log3 $name, $logLevel, "EnOcean $name $response";
  12997. }
  12998. } elsif ($mid == 2) {
  12999. # configuration message
  13000. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  13001. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  13002. if ($err) {
  13003. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  13004. } else {
  13005. Log3 $name, $logLevel, "EnOcean $name $response";
  13006. }
  13007. } elsif ($mid == 3) {
  13008. # room control setup
  13009. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  13010. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  13011. if ($err) {
  13012. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  13013. } else {
  13014. Log3 $name, $logLevel, "EnOcean $name $response";
  13015. }
  13016. } elsif ($mid == 4) {
  13017. # time program setup
  13018. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  13019. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  13020. if ($err) {
  13021. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  13022. } else {
  13023. Log3 $name, $logLevel, "EnOcean $name $response";
  13024. }
  13025. }
  13026. return ($err, $response);
  13027. }
  13028. # generate command to Room Control Panel (EEP D2-10-xx)
  13029. sub
  13030. EnOcean_roomCtrlPanel_00Cmd($$$$)
  13031. {
  13032. my ($crtl, $hash, $mcf, $messagePart) = @_;
  13033. my $name = $hash->{NAME};
  13034. my $data = "0000";
  13035. my $err;
  13036. my $response = "acknowledge send";
  13037. my $logLevel = 4;
  13038. # Waitings Commands (waitingCmds)
  13039. # 1 = sent data request
  13040. # 2 = sent data message
  13041. # 4 = sent configuration message (time)
  13042. # 8 = sent room control setup
  13043. # 16 = sent time program setup
  13044. # 32 = sent configuration request
  13045. # 64 = sent configuration message
  13046. # 128 = sent room control setup request
  13047. # 256 = sent time program request
  13048. # 512 = sent delete time program
  13049. my $waitingCmds = ReadingsVal($name, "waitingCmds", 0);
  13050. if ($mcf == 0) {
  13051. # message complete
  13052. if ($waitingCmds & 8) {
  13053. # room control setup waiting
  13054. my ($db5, $db4, $db3, $db2, $db1, $db0) = (96, 0, 0, 0, 0, 0, 0);
  13055. if (defined ReadingsVal($name, "setpointComfortTempSet", undef)) {
  13056. $db1 = ReadingsVal($name, "setpointComfortTempSet", 0) * 255 / 40;
  13057. $db0 = $db0 | 1;
  13058. CommandDeleteReading(undef, "$name setpointComfortTempSet");
  13059. }
  13060. if (defined ReadingsVal($name, "setpointEconomyTempSet", undef)) {
  13061. $db2 = ReadingsVal($name, "setpointEconomyTempSet", 0) * 255 / 40;
  13062. $db0 = $db0 | 2;
  13063. CommandDeleteReading(undef, "$name setpointEconomyTempSet");
  13064. }
  13065. if (defined ReadingsVal($name, "setpointPreComfortTempSet", undef)) {
  13066. $db3 = ReadingsVal($name, "setpointPreComfortTempSet", 0) * 255 / 40;
  13067. $db0 = $db0 | 4;
  13068. CommandDeleteReading(undef, "$name setpointPreComfortTempSet");
  13069. }
  13070. if (defined ReadingsVal($name, "setpointBuildingProtectionTempSet", undef)) {
  13071. $db4 = ReadingsVal($name, "setpointBuildingProtectionTempSet", 0) * 255 / 40;
  13072. $db0 = $db0 | 8;
  13073. CommandDeleteReading(undef, "$name setpointBuildingProtectionTempSet");
  13074. }
  13075. $data = sprintf "%02X%02X%02X%02X%02X%02X", $db5, $db4, $db3, $db2, $db1, $db0;
  13076. # clear command
  13077. $waitingCmds = $waitingCmds & 247 + 0xFF00;
  13078. $response = "room control setup send $data";
  13079. $logLevel = 2;
  13080. } elsif ($waitingCmds & 64 || $waitingCmds & 4) {
  13081. # configuration message waiting
  13082. my ($sec, $min, $hour, $day, $month, $year) = localtime();
  13083. my ($key, $val);
  13084. $month += 1;
  13085. $year += 1900;
  13086. my ($db7, $db6, $db5, $db4, $db1, $db0) = (64, 0, 0, 0, $min << 2, $hour << 3);
  13087. $db6 |= 1 if (AttrVal($name, "blockFanSpeed", "no") ne "yes" );
  13088. $db6 |= 2 if (AttrVal($name, "blockSetpointTemp", "no") ne "yes" );
  13089. $db6 |= 4 if (AttrVal($name, "blockOccupancy", "no") ne "yes" );
  13090. $db6 |= 8 if (AttrVal($name, "blockTimeProgram", "no") ne "yes" );
  13091. $db6 |= 16 if (AttrVal($name, "blockDateTime", "no") ne "yes" );
  13092. $db6 |= 32 if (AttrVal($name, "blockDisplay", "no") ne "yes" );
  13093. $db6 |= 64 if (AttrVal($name, "blockTemp", "no") ne "yes" );
  13094. $db6 |= 128 if (AttrVal($name, "blockMotion", "no") ne "yes" );
  13095. $db5 = AttrVal($name, "pollInterval", 10);
  13096. if ($db5 > 60 && $db5 <= 180) {
  13097. $db5 = 61;
  13098. } elsif ($db5 > 180 && $db5 <= 720) {
  13099. $db5 = 62;
  13100. } elsif ($db5 > 720) {
  13101. $db5 = 63;
  13102. }
  13103. $db5 = $db5 << 2;
  13104. $db5 |= 2 if (AttrVal($name, "blockKey", "no") ne "yes" );
  13105. my $displayContent = AttrVal($name, "displayContent", "no_change");
  13106. my $displayContentVal = 0;
  13107. my %displayContent = ("humidity" => 7,
  13108. "off" => 6,
  13109. "setpointTemp" => 5,
  13110. "tempertureExtern" => 4,
  13111. "temperatureIntern" => 3,
  13112. "time" => 2,
  13113. "default" => 1,
  13114. "no_change" => 0
  13115. );
  13116. while (($key, $val) = each(%displayContent)) {
  13117. $displayContentVal = $val if ($key eq $displayContent);
  13118. }
  13119. my $temperatureScale = AttrVal($name, "temperatureScale", "no_change");
  13120. my $temperatureScaleVal = 0;
  13121. my %temperatureScale = ("F" => 3,
  13122. "C" => 2,
  13123. "default" => 1,
  13124. "no_change" => 0
  13125. );
  13126. while (($key, $val) = each(%temperatureScale)) {
  13127. $temperatureScaleVal = $val if ($key eq $temperatureScale);
  13128. }
  13129. my $daylightSavingTimeVal = 0;
  13130. $daylightSavingTimeVal = 1 if (AttrVal($name, "daylightSavingTime", "supported") eq "not_supported");
  13131. my $timeNotation = AttrVal($name, "timeNotation", "no_change");
  13132. my $timeNotationVal = 0;
  13133. if ($timeNotation eq "no_change") {
  13134. $timeNotationVal = 0;
  13135. } elsif ($timeNotation eq "default") {
  13136. $timeNotationVal = 1;
  13137. } elsif ($timeNotation == 24) {
  13138. $timeNotationVal = 2;
  13139. } elsif ($timeNotation == 12) {
  13140. $timeNotationVal = 3;
  13141. }
  13142. $db4 = (($displayContentVal << 2 | $temperatureScaleVal) << 1 | $daylightSavingTimeVal) << 2 | $timeNotationVal;
  13143. my $db32 = ($day << 4 | $month) << 7 | $year - 2000;
  13144. if ($waitingCmds & 4) {
  13145. $db0 |= 1;
  13146. # clear time command
  13147. $waitingCmds &= 251 + 0xFF00;
  13148. }
  13149. if ($waitingCmds & 64) {
  13150. # clear config command
  13151. $waitingCmds &= 191 + 0xFF00;
  13152. }
  13153. $data = sprintf "%02X%02X%02X%02X%04X%02X%02X", $db7, $db6, $db5, $db4, $db32, $db1, $db0;
  13154. $response = "configuration message send $data";
  13155. $logLevel = 2;
  13156. } elsif ($waitingCmds & 2) {
  13157. # data message waiting
  13158. my ($db7, $db6, $db5, $db4, $db3, $db2, $db1, $db0) = (32, 0, 0, 0, 0, 0, 0, 0, 0);
  13159. if (defined ReadingsVal($name, "setpointTempSet", undef)) {
  13160. $db1 = ReadingsVal($name, "setpointTempSet", 0) * 255 / 40;
  13161. $db2 |= 2;
  13162. CommandDeleteReading(undef, "$name setpointTempSet");
  13163. }
  13164. my $heatingSet;
  13165. if (defined ReadingsVal($name, "heatingSet", undef)) {
  13166. $heatingSet = ReadingsVal($name, "heatingSet", 0);
  13167. } else {
  13168. $heatingSet = ReadingsVal($name, "heating", 0);
  13169. }
  13170. if ($heatingSet eq "no_change") {
  13171. $heatingSet = 0;
  13172. } elsif ($heatingSet eq "on") {
  13173. $heatingSet = 1;
  13174. } elsif ($heatingSet eq "off") {
  13175. $heatingSet = 2;
  13176. } elsif ($heatingSet eq "auto") {
  13177. $heatingSet = 3;
  13178. }
  13179. $db2 |= $heatingSet << 4;
  13180. CommandDeleteReading(undef, "$name heatingSet");
  13181. my $coolingSet;
  13182. if (defined ReadingsVal($name, "coolingSet", undef)) {
  13183. $coolingSet = ReadingsVal($name, "coolingSet", 0);
  13184. } else {
  13185. $coolingSet = ReadingsVal($name, "cooling", 0);
  13186. }
  13187. if ($coolingSet eq "no_change") {
  13188. $coolingSet = 0;
  13189. } elsif ($coolingSet eq "on") {
  13190. $coolingSet = 1;
  13191. } elsif ($coolingSet eq "off") {
  13192. $coolingSet = 2;
  13193. } elsif ($coolingSet eq "auto") {
  13194. $coolingSet = 3;
  13195. }
  13196. $db2 |= $coolingSet << 6;
  13197. CommandDeleteReading(undef, "$name coolingSet");
  13198. my $roomCtrlModeSet;
  13199. if (defined ReadingsVal($name, "roomCtrlModeSet", undef)) {
  13200. $roomCtrlModeSet = ReadingsVal($name, "roomCtrlModeSet", 0);
  13201. } else {
  13202. $roomCtrlModeSet = ReadingsVal($name, "roomCtrlMode", 0);
  13203. }
  13204. if ($roomCtrlModeSet eq "comfort") {
  13205. $roomCtrlModeSet = 0;
  13206. } elsif ($roomCtrlModeSet eq "economy") {
  13207. $roomCtrlModeSet = 1;
  13208. } elsif ($roomCtrlModeSet eq "preComfort") {
  13209. $roomCtrlModeSet = 2;
  13210. } elsif ($roomCtrlModeSet eq "buildingProtection") {
  13211. $roomCtrlModeSet = 3;
  13212. }
  13213. $db2 |= $roomCtrlModeSet << 2;
  13214. CommandDeleteReading(undef, "$name roomCtrlModeSet");
  13215. my $windowSet;
  13216. if (defined ReadingsVal($name, "windowSet", undef)) {
  13217. $windowSet = ReadingsVal($name, "windowSet", 0);
  13218. } else {
  13219. $windowSet = ReadingsVal($name, "window", 0);
  13220. }
  13221. if ($windowSet eq "no_change") {
  13222. $windowSet = 0;
  13223. } elsif ($windowSet eq "closed") {
  13224. $windowSet = 1;
  13225. } elsif ($windowSet eq "open") {
  13226. $windowSet = 2;
  13227. } elsif ($windowSet eq "reserved") {
  13228. $windowSet = 3;
  13229. }
  13230. $db4 |= $windowSet;
  13231. CommandDeleteReading(undef, "$name windowSet");
  13232. my $fanSpeedModeSet;
  13233. if (defined ReadingsVal($name, "fanSpeedModeSet", undef)) {
  13234. $fanSpeedModeSet = ReadingsVal($name, "fanSpeedModeSet", 0);
  13235. } else {
  13236. $fanSpeedModeSet = ReadingsVal($name, "fanSpeedMode", 0);
  13237. }
  13238. $db4 |= 64 if ($fanSpeedModeSet eq "local");
  13239. CommandDeleteReading(undef, "$name fanSpeedModeSet");
  13240. if (defined ReadingsVal($name, "fanSpeedSet", undef)) {
  13241. $db5 = ReadingsVal($name, "fanSpeedSet", 0);
  13242. $db4 |= 128;
  13243. CommandDeleteReading(undef, "$name fanSpeedSet");
  13244. }
  13245. $data = sprintf "%02X%02X%02X%02X%02X%02X%02X%02X", $db7, $db6, $db5, $db4, $db3, $db2, $db1, $db0;
  13246. # clear command
  13247. $waitingCmds = $waitingCmds & 253 + 0xFF00;
  13248. $response = "data message send";
  13249. $logLevel = 2;
  13250. } elsif ($waitingCmds & 512) {
  13251. # delete time program command waiting
  13252. $data = "800000000001";
  13253. # clear command
  13254. $waitingCmds = $waitingCmds & 0xFDFF;
  13255. $response = "delete time program send";
  13256. $logLevel = 2;
  13257. } elsif ($waitingCmds & 16) {
  13258. # time program setup waiting
  13259. my ($db5, $endMinute, $endHour, $startMinute, $startHour, $db0) = (128, 0, 0, 0, 0, 0, 0);
  13260. my ($key, $val);
  13261. my $messagePartCntr;
  13262. for ($messagePartCntr = 4; $messagePartCntr >= 1; $messagePartCntr --) {
  13263. if ($hash->{helper}{4}{telegramWait}{$messagePartCntr}) {
  13264. $hash->{helper}{4}{telegramWait}{$messagePartCntr} = 0;
  13265. my $timeProgram = AttrVal($name, "timeProgram" . $messagePartCntr, undef);
  13266. my @timeProgram = split("[ \t][ \t]*", $timeProgram);
  13267. my ($period, $roomCtrlMode) = ($timeProgram[0], $timeProgram[3]);
  13268. ($startHour, $startMinute) = split(':', $timeProgram[1]);
  13269. ($endHour, $endMinute) = split(':', $timeProgram[2]);
  13270. my $periodVal = 0;
  13271. my %period = ("FrMo" => 15,
  13272. "FrSu" => 14,
  13273. "ThFr" => 13,
  13274. "WeFr" => 12,
  13275. "TuTh" => 11,
  13276. "MoWe" => 10,
  13277. "Su" => 9,
  13278. "Sa" => 8,
  13279. "Fr" => 7,
  13280. "Th" => 6,
  13281. "We" => 5,
  13282. "Tu" => 4,
  13283. "Mo" => 3,
  13284. "SaSu" => 2,
  13285. "MoFr" => 1,
  13286. "MoSu" => 0
  13287. );
  13288. while (($key, $val) = each(%period)) {
  13289. $periodVal = $val if ($key eq $period);
  13290. }
  13291. if ($roomCtrlMode eq "buildingProtection") {
  13292. $roomCtrlMode = 3;
  13293. } elsif ($roomCtrlMode eq "preComfort") {
  13294. $roomCtrlMode = 2;
  13295. } elsif ($roomCtrlMode eq "economy") {
  13296. $roomCtrlMode = 1;
  13297. } else{
  13298. $roomCtrlMode = 0;
  13299. }
  13300. if ($messagePartCntr > 1) {
  13301. # set mcf flag
  13302. $db5 |= 1;
  13303. } else {
  13304. # clear command
  13305. $waitingCmds = $waitingCmds & 239 + 0xFF00;
  13306. }
  13307. $data = sprintf "%02X%02X%02X%02X%02X%02X", $db5, $endMinute, $endHour, $startMinute, $startHour, $periodVal << 4 | $roomCtrlMode << 2;
  13308. $response = "time program setup send";
  13309. $logLevel = 2;
  13310. last;
  13311. }
  13312. }
  13313. } elsif ($waitingCmds & 1) {
  13314. # data request waiting
  13315. $data = "0009";
  13316. # clear command
  13317. $waitingCmds = $waitingCmds & 254 + 0xFF00;
  13318. $response = "data request send";
  13319. $logLevel = 2;
  13320. } elsif ($waitingCmds & 32) {
  13321. # configuration request waiting
  13322. $data = "0011";
  13323. # clear command
  13324. $waitingCmds = $waitingCmds & 223 + 0xFF00;
  13325. $response = "configuration request send";
  13326. $logLevel = 2;
  13327. } elsif ($waitingCmds & 128) {
  13328. # room control setup request waiting
  13329. $data = "0019";
  13330. # clear command
  13331. $waitingCmds = $waitingCmds & 127 + 0xFF00;
  13332. $response = "room control setup request send";
  13333. $logLevel = 2;
  13334. } elsif ($waitingCmds & 256) {
  13335. # time program request waiting
  13336. $data = "0021";
  13337. # clear command
  13338. $waitingCmds = $waitingCmds & 0xFEFF;
  13339. $response = "time program request send";
  13340. $logLevel = 2;
  13341. }
  13342. if ($waitingCmds == 0) {
  13343. CommandDeleteReading(undef, "$name waitingCmds");
  13344. } else {
  13345. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  13346. }
  13347. } elsif ($mcf == 1) {
  13348. # message incomplete
  13349. $response = "acknowledge send, wating for next part of the message";
  13350. $logLevel = 2;
  13351. } elsif ($mcf == 2) {
  13352. # automatic message control
  13353. $response = "acknowledge send, automatic message control";
  13354. $logLevel = 2;
  13355. } elsif ($mcf == 3) {
  13356. # reserved
  13357. }
  13358. return ($err, $response, $data, $logLevel);
  13359. }
  13360. # create SVG devices
  13361. sub EnOcean_CreateSVG($$$)
  13362. {
  13363. my ($ctrl, $hash, $eepSVG) = @_;
  13364. my $name = $hash->{NAME};
  13365. my ($autocreateHash, $autocreateName, $autocreateDeviceRoom, $autocreateWeblinkRoom) =
  13366. (undef, 'autocreate', 'EnOcean', 'Plots');
  13367. my $filelogName = "FileLog_$name";
  13368. my ($cmd, $eep, $weblinkName, $weblinkHash, $ret);
  13369. if (defined($eepSVG) && $eepSVG =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  13370. $eep = uc("$1.$2.$3");
  13371. } elsif (exists($attr{$name}{eep}) && $attr{$name}{eep} =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  13372. $eep = uc("$1.$2.$3");
  13373. } else {
  13374. return undef;
  13375. }
  13376. # find autocreate device
  13377. while (($autocreateName, $autocreateHash) = each(%defs)) {
  13378. last if ($defs{$autocreateName}{TYPE} eq "autocreate");
  13379. }
  13380. # delete old SVG devices
  13381. if (defined($ctrl) && $ctrl eq 'del' || !exists($defs{$filelogName})) {
  13382. while (($weblinkName, $weblinkHash) = each(%defs)) {
  13383. if ($weblinkName =~ /^SVG_$name.*/) {
  13384. CommandDelete(undef, $weblinkName);
  13385. Log3 $hash->{NAME}, 5, "EnOcean_CreateSVG: device $weblinkName deleted";
  13386. }
  13387. }
  13388. }
  13389. if (!defined(AttrVal($autocreateName, "disable", undef)) && exists($defs{$filelogName})) {
  13390. if (exists $EnO_eepConfig{$eep}{GPLOT}) {
  13391. # add GPLOT parameters
  13392. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . $attr{$filelogName}{logtype}
  13393. if (!exists($attr{$filelogName}{logtype}) || $attr{$filelogName}{logtype} eq 'text');
  13394. if (AttrVal($autocreateName, "weblink", 1)) {
  13395. $autocreateWeblinkRoom = $attr{$autocreateName}{weblink_room} if (exists $attr{$autocreateName}{weblink_room});
  13396. $autocreateWeblinkRoom = 'EnOcean' if ($autocreateWeblinkRoom eq '%TYPE');
  13397. $autocreateWeblinkRoom = $name if ($autocreateWeblinkRoom eq '%NAME');
  13398. $autocreateWeblinkRoom = $attr{$name}{room} if (exists $attr{$name}{room});
  13399. my $wnr = 1;
  13400. #create SVG devices
  13401. foreach my $wdef (split(/,/, $EnO_eepConfig{$eep}{GPLOT})) {
  13402. next if(!$wdef);
  13403. my ($gplotfile, $stuff) = split(/:/, $wdef);
  13404. next if(!$gplotfile);
  13405. $weblinkName = "SVG_$name";
  13406. $weblinkName .= "_$wnr" if($wnr > 1);
  13407. $wnr++;
  13408. next if (exists $defs{$weblinkName});
  13409. $cmd = "$weblinkName SVG $filelogName:$gplotfile:CURRENT";
  13410. Log3 $weblinkName, 2, "EnOcean define $cmd";
  13411. $ret = CommandDefine(undef, $cmd);
  13412. if($ret) {
  13413. Log3 $weblinkName, 2, "EnOcean ERROR: define $cmd: $ret";
  13414. last;
  13415. }
  13416. $attr{$weblinkName}{room} = $autocreateWeblinkRoom;
  13417. $attr{$weblinkName}{title} = '"' . $name . ' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
  13418. $ret = CommandSet(undef, "$weblinkName copyGplotFile");
  13419. if($ret) {
  13420. Log3 $weblinkName, 2, "EnOcean ERROR: set $weblinkName copyGplotFile: $ret";
  13421. last;
  13422. }
  13423. }
  13424. }
  13425. }
  13426. }
  13427. return undef;
  13428. }
  13429. #CommandSave
  13430. sub EnOcean_CommandSave($$)
  13431. {
  13432. my ($ctrl, $param) = @_;
  13433. # find autocreate device
  13434. my ($autocreateHash, $autocreateName);
  13435. while (($autocreateName, $autocreateHash) = each(%defs)) {
  13436. last if ($defs{$autocreateName}{TYPE} eq "autocreate");
  13437. }
  13438. my $autosave = AttrVal($autocreateName, "autosave", undef);
  13439. if (!defined $autosave) {
  13440. CommandSave($ctrl, $param) if (AttrVal("global", "autosave", 1));
  13441. } elsif ($autosave) {
  13442. CommandSave($ctrl, $param);
  13443. }
  13444. return;
  13445. }
  13446. sub EnOcean_readingsSingleUpdate($) {
  13447. my ($readingParam) = @_;
  13448. my ($hash, $readingName, $readingVal, $ctrl, $log) = @$readingParam;
  13449. if (defined $hash) {
  13450. readingsSingleUpdate($hash, $readingName, $readingVal, $ctrl) ;
  13451. Log3 $hash->{NAME}, $log, "EnOcean " . $hash->{NAME} . " EVENT $readingName: $readingVal" if ($log);
  13452. }
  13453. return;
  13454. }
  13455. sub EnOcean_4BSRespWait($$$) {
  13456. my ($ctrl, $hash, $subDef) = @_;
  13457. my $IODev = $hash->{IODev}{NAME};
  13458. my $IOHash = $defs{$IODev};
  13459. $hash->{IODev}{helper}{"4BSRespWait"}{$subDef}{teachInReq} = "out";
  13460. $hash->{IODev}{helper}{"4BSRespWait"}{$subDef}{hash} = $hash;
  13461. if (!exists($hash->{IODev}{Teach})) {
  13462. # enable teach-in receiving for 3 sec
  13463. $hash->{IODev}{Teach} = 1;
  13464. my %timeoutHash = (hash => $IOHash, function => "4BSRespTimeout", helper => "4BSRespWait");
  13465. RemoveInternalTimer(\%timeoutHash);
  13466. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  13467. }
  13468. return;
  13469. }
  13470. # Check SenderIDs
  13471. sub EnOcean_CheckSenderID($$$)
  13472. {
  13473. my ($ctrl, $IODev, $senderID) = @_;
  13474. if (!defined $IODev) {
  13475. my (@listIODev, %listIODev);
  13476. foreach my $dev (keys %defs) {
  13477. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13478. push(@listIODev, $defs{$dev}{IODev}{NAME});
  13479. }
  13480. @listIODev = sort grep(!$listIODev{$_}++, @listIODev);
  13481. if (@listIODev == 1) {
  13482. $IODev = $listIODev[0];
  13483. }
  13484. }
  13485. my $unusedID = 0;
  13486. $unusedID = hex($defs{$IODev}{BaseID}) if ($defs{$IODev}{BaseID});
  13487. my $IDCntr1;
  13488. my $IDCntr2;
  13489. if ($unusedID == 0) {
  13490. $IDCntr1 = 0;
  13491. $IDCntr2 = 0;
  13492. } else {
  13493. $IDCntr1 = $unusedID + 1;
  13494. $IDCntr2 = $unusedID + 127;
  13495. }
  13496. if ($ctrl eq "getBaseID") {
  13497. # get TCM BaseID of the EnOcean device
  13498. if ($defs{$IODev}{BaseID}) {
  13499. $senderID = $defs{$IODev}{BaseID}
  13500. } else {
  13501. $senderID = "0" x 8;
  13502. }
  13503. } elsif ($ctrl eq "getUsedID") {
  13504. # find and sort used SenderIDs
  13505. my @listID;
  13506. my %listID;
  13507. foreach my $dev (keys %defs) {
  13508. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13509. push(@listID, grep(hex($_) >= $IDCntr1 && hex($_) <= $IDCntr2, $defs{$dev}{DEF}));
  13510. push(@listID, $attr{$dev}{subDef}) if ($attr{$dev}{subDef});
  13511. push(@listID, $attr{$dev}{subDefA}) if ($attr{$dev}{subDefA});
  13512. push(@listID, $attr{$dev}{subDefB}) if ($attr{$dev}{subDefB});
  13513. push(@listID, $attr{$dev}{subDefC}) if ($attr{$dev}{subDefC});
  13514. push(@listID, $attr{$dev}{subDefD}) if ($attr{$dev}{subDefD});
  13515. push(@listID, $attr{$dev}{subDefI}) if ($attr{$dev}{subDefI});
  13516. push(@listID, $attr{$dev}{subDefH}) if ($attr{$dev}{subDefH});
  13517. push(@listID, $attr{$dev}{subDefW}) if ($attr{$dev}{subDefW});
  13518. push(@listID, $attr{$dev}{subDef0}) if ($attr{$dev}{subDef0});
  13519. }
  13520. $senderID = join(" ", sort grep(!$listID{$_}++, @listID));
  13521. } elsif ($ctrl eq "getFreeID") {
  13522. # find and sort free SenderIDs
  13523. my (@freeID, @listID, %listID, @intersection, @difference, %count, $element);
  13524. for (my $IDCntr = $IDCntr1; $IDCntr <= $IDCntr2; $IDCntr++) {
  13525. push(@freeID, sprintf "%08X", $IDCntr);
  13526. }
  13527. foreach my $dev (keys %defs) {
  13528. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13529. push(@listID, grep(hex($_) >= $IDCntr1 && hex($_) <= $IDCntr2, $defs{$dev}{DEF}));
  13530. push(@listID, $attr{$dev}{subDef}) if ($attr{$dev}{subDef} && $attr{$dev}{subDef} ne "00000000");
  13531. push(@listID, $attr{$dev}{subDefA}) if ($attr{$dev}{subDefA} && $attr{$dev}{subDefA} ne "00000000");
  13532. push(@listID, $attr{$dev}{subDefB}) if ($attr{$dev}{subDefB} && $attr{$dev}{subDefB} ne "00000000");
  13533. push(@listID, $attr{$dev}{subDefC}) if ($attr{$dev}{subDefC} && $attr{$dev}{subDefC} ne "00000000");
  13534. push(@listID, $attr{$dev}{subDefD}) if ($attr{$dev}{subDefD} && $attr{$dev}{subDefD} ne "00000000");
  13535. push(@listID, $attr{$dev}{subDefI}) if ($attr{$dev}{subDefI} && $attr{$dev}{subDefI} ne "00000000");
  13536. push(@listID, $attr{$dev}{subDefH}) if ($attr{$dev}{subDefH} && $attr{$dev}{subDefH} ne "00000000");
  13537. push(@listID, $attr{$dev}{subDefW}) if ($attr{$dev}{subDefW} && $attr{$dev}{subDefW} ne "00000000");
  13538. push(@listID, $attr{$dev}{subDef0}) if ($attr{$dev}{subDef0} && $attr{$dev}{subDef0} ne "00000000");
  13539. }
  13540. @listID = sort grep(!$listID{$_}++, @listID);
  13541. foreach $element (@listID, @freeID) {
  13542. $count{$element}++
  13543. }
  13544. foreach $element (keys %count) {
  13545. push @{$count{$element} > 1 ? \@intersection : \@difference }, $element;
  13546. }
  13547. $senderID = ':' . join(" ", sort @difference);
  13548. } elsif ($ctrl eq "getNextID") {
  13549. # get next free SenderID
  13550. my (@freeID, @listID, %listID, @intersection, @difference, %count, $element);
  13551. for (my $IDCntr = $IDCntr1; $IDCntr <= $IDCntr2; $IDCntr++) {
  13552. push(@freeID, sprintf "%08X", $IDCntr);
  13553. }
  13554. foreach my $dev (keys %defs) {
  13555. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13556. push(@listID, grep(hex($_) >= $IDCntr1 && hex($_) <= $IDCntr2, $defs{$dev}{DEF}));
  13557. push(@listID, $attr{$dev}{subDef}) if ($attr{$dev}{subDef} && $attr{$dev}{subDef} ne "00000000");
  13558. push(@listID, $attr{$dev}{subDefA}) if ($attr{$dev}{subDefA} && $attr{$dev}{subDefA} ne "00000000");
  13559. push(@listID, $attr{$dev}{subDefB}) if ($attr{$dev}{subDefB} && $attr{$dev}{subDefB} ne "00000000");
  13560. push(@listID, $attr{$dev}{subDefC}) if ($attr{$dev}{subDefC} && $attr{$dev}{subDefC} ne "00000000");
  13561. push(@listID, $attr{$dev}{subDefD}) if ($attr{$dev}{subDefD} && $attr{$dev}{subDefD} ne "00000000");
  13562. push(@listID, $attr{$dev}{subDefI}) if ($attr{$dev}{subDefI} && $attr{$dev}{subDefI} ne "00000000");
  13563. push(@listID, $attr{$dev}{subDefH}) if ($attr{$dev}{subDefH} && $attr{$dev}{subDefH} ne "00000000");
  13564. push(@listID, $attr{$dev}{subDefW}) if ($attr{$dev}{subDefW} && $attr{$dev}{subDefW} ne "00000000");
  13565. push(@listID, $attr{$dev}{subDef0}) if ($attr{$dev}{subDef0} && $attr{$dev}{subDef0} ne "00000000");
  13566. }
  13567. @listID = sort grep(!$listID{$_}++, @listID);
  13568. foreach $element (@listID, @freeID) {
  13569. $count{$element}++
  13570. }
  13571. foreach $element (keys %count) {
  13572. push @{$count{$element} > 1 ? \@intersection : \@difference }, $element;
  13573. }
  13574. @difference = sort @difference;
  13575. if (defined $difference[0]) {
  13576. $senderID = $difference[0];
  13577. } else {
  13578. $senderID = "0" x 8;
  13579. Log3 $IODev, 2, "EnOcean $IODev no free senderIDs available";
  13580. }
  13581. } else {
  13582. }
  13583. return $senderID;
  13584. }
  13585. # assign next free SenderID
  13586. sub EnOcean_AssignSenderID($$$$)
  13587. {
  13588. my ($ctrl, $hash, $attrName, $comMode) = @_;
  13589. my $def = $hash->{DEF};
  13590. my $err;
  13591. my $name = $hash->{NAME};
  13592. my $IODev = $hash->{IODev}{NAME};
  13593. my $senderID = AttrVal($name, $attrName, "");
  13594. # SenderID valid
  13595. return ($err, $senderID) if ($senderID =~ m/^[\dA-Fa-f]{8}$/);
  13596. return ("no IODev", $def) if (!defined $IODev);
  13597. # DEF is SenderID
  13598. if (hex($def) >= hex($defs{$IODev}{BaseID}) && hex($def) <= hex($defs{$IODev}{BaseID}) + 127) {
  13599. if ($comMode eq "biDir") {
  13600. $attr{$name}{comMode} = $comMode;
  13601. } else {
  13602. $attr{$name}{comMode} = "uniDir";
  13603. }
  13604. return ($err, $def);
  13605. } else {
  13606. if ($comMode eq "biDir") {
  13607. $attr{$name}{comMode} = $comMode;
  13608. } else {
  13609. $attr{$name}{comMode} = "confirm";
  13610. }
  13611. $senderID = EnOcean_CheckSenderID("getNextID", $IODev, "00000000");
  13612. }
  13613. #Log3 $name, 2, "EnOcean $name SenderID: $senderID assigned";
  13614. #CommandAttr(undef, "$name $attrName $senderID");
  13615. $attr{$name}{$attrName} = $senderID;
  13616. return ($err, $senderID);
  13617. }
  13618. # split chained data message
  13619. sub EnOcean_SndCdm($$$$$$$$)
  13620. {
  13621. my ($ctrl, $hash, $packetType, $rorg, $data, $senderID, $status, $destinationID) = @_;
  13622. if (!defined $data) {
  13623. Log3 $hash->{NAME}, 5, "EnOcean $hash->{NAME} EnOcean_SndCDM SenderID: $senderID DestinationID: $destinationID " .
  13624. "PacketType: $packetType RORG: $rorg DATA: undef STATUS: $status";
  13625. return;
  13626. }
  13627. my ($seq, $idx, $len, $dataPart, $dataPartLen) = (0, 0, length($data) / 2, undef, 14);
  13628. # split telelegram with optional data
  13629. $dataPartLen = 9 if ($destinationID ne "FFFFFFFF");
  13630. if ($packetType == 1 && $len > $dataPartLen) {
  13631. # first CDM telegram
  13632. if ($dataPartLen == 14) {
  13633. $data =~ m/^(....................)(.*)$/;
  13634. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . (sprintf "%04X", $len) . $rorg . $1;
  13635. $data = $2;
  13636. } else {
  13637. $data =~ m/^(..........)(.*)$/;
  13638. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . (sprintf "%04X", $len) . $rorg . $1;
  13639. $data = $2;
  13640. }
  13641. $idx ++;
  13642. $len -= $dataPartLen - 5;
  13643. EnOcean_SndRadio($ctrl, $hash, $packetType, "40", $dataPart, $senderID, $status, $destinationID);
  13644. while ($len > 0) {
  13645. if ($len > $dataPartLen - 2) {
  13646. if ($dataPartLen == 14) {
  13647. $data =~ m/^(..........................)(.*)$/;
  13648. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . $1;
  13649. $data = $2;
  13650. } else {
  13651. $data =~ m/^(................)(.*)$/;
  13652. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . $1;
  13653. $data = $2;
  13654. }
  13655. $idx ++;
  13656. $len -= $dataPartLen - 2;
  13657. } else {
  13658. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . $data;
  13659. $len = 0;
  13660. }
  13661. EnOcean_SndRadio($ctrl, $hash, $packetType, "40", $dataPart, $senderID, $status, $destinationID);
  13662. }
  13663. } else {
  13664. # not necessary to split
  13665. EnOcean_SndRadio($ctrl, $hash, $packetType, $rorg, $data, $senderID, $status, $destinationID);
  13666. }
  13667. return;
  13668. }
  13669. # send ESP3 Packet Type Radio
  13670. sub EnOcean_SndRadio($$$$$$$$)
  13671. {
  13672. my ($ctrl, $hash, $packetType, $rorg, $data, $senderID, $status, $destinationID) = @_;
  13673. if (!defined $data) {
  13674. Log3 $hash->{NAME}, 5, "EnOcean $hash->{NAME} EnOcean_SndRadio SenderID: $senderID DestinationID: $destinationID " .
  13675. "PacketType: $packetType RORG: $rorg DATA: undef STATUS: $status";
  13676. return;
  13677. }
  13678. my ($err, $response, $loglevel);
  13679. my $header;
  13680. my $odata = "";
  13681. my $odataLength = 0;
  13682. if ($packetType == 1) {
  13683. ($err, $rorg, $data, $response, $loglevel) = EnOcean_sec_convertToSecure($hash, $packetType, $rorg, $data);
  13684. if (defined $err) {
  13685. Log3 $hash->{NAME}, $loglevel, "EnOcean $hash->{NAME} Error: $err";
  13686. return "";
  13687. }
  13688. if (AttrVal($hash->{NAME}, "repeatingAllowed", "yes") eq "no") {
  13689. $status = substr($status, 0, 1) . "F";
  13690. }
  13691. if ($rorg eq "A6") {
  13692. # ADT telegram
  13693. $data .= $destinationID;
  13694. } elsif ($destinationID ne "FFFFFFFF") {
  13695. # SubTelNum = 03, DestinationID:8, RSSI = FF, secLevel = 00
  13696. $odata = sprintf "03%sFF00", $destinationID;
  13697. $odataLength = 7;
  13698. }
  13699. # Data Length:4 Optional Length:2 Packet Type:2
  13700. $header = sprintf "%04X%02X%02X", (length($data) / 2 + 6), $odataLength, $packetType;
  13701. Log3 $hash->{NAME}, 4, "EnOcean $hash->{NAME} sent PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status ODATA: $odata";
  13702. $data = $rorg . $data . $senderID . $status . $odata;
  13703. } elsif ($packetType == 2 || $packetType == 6) {
  13704. # smart ack commands
  13705. # Data Length:4 Optional Length:2 Packet Type:2
  13706. $header = sprintf "%04X%02X%02X", length($data) / 2, 0, $packetType;
  13707. Log3 $hash->{NAME}, 4, "EnOcean $hash->{NAME} sent PacketType: $packetType DATA: $data";
  13708. } elsif ($packetType == 7) {
  13709. my $delay = 0;
  13710. $delay = 1 if ($destinationID eq "FFFFFFFF");
  13711. $senderID = "00000000";
  13712. #$senderID = "00000000" if ($destinationID eq "FFFFFFFF");
  13713. $odata = sprintf "%s%sFF%02X", $destinationID, $senderID, $delay;
  13714. $odataLength = 10;
  13715. # Data Length:4 Optional Length:2 Packet Type:2
  13716. $header = sprintf "%04X%02X%02X", (length($data) / 2), $odataLength, $packetType;
  13717. Log3 $hash->{NAME}, 4, "EnOcean $hash->{NAME} sent PacketType: $packetType DATA: $data ODATA: $odata";
  13718. $data .= $odata;
  13719. }
  13720. if (defined $ctrl) {
  13721. # sent telegram delayed
  13722. my @param = ($hash, $header, $data);
  13723. InternalTimer(gettimeofday() + $ctrl, 'EnOcean_IOWriteTimer', \@param, 0);
  13724. } else {
  13725. IOWrite($hash, $header, $data);
  13726. }
  13727. return;
  13728. }
  13729. #
  13730. sub EnOcean_IOWriteTimer($)
  13731. {
  13732. my ($ioParam) = @_;
  13733. my ($hash, $header, $data) = @$ioParam;
  13734. IOWrite($hash, $header, $data);
  13735. return;
  13736. }
  13737. # Scale Readings
  13738. sub EnOcean_ReadingScaled($$$$)
  13739. {
  13740. my ($hash, $readingVal, $readingMin, $readingMax) = @_;
  13741. my $name = $hash->{NAME};
  13742. my $valScaled;
  13743. my $scaleDecimals = AttrVal($name, "scaleDecimals", undef);
  13744. my $scaleMin = AttrVal($name, "scaleMin", undef);
  13745. my $scaleMax = AttrVal($name, "scaleMax", undef);
  13746. if (defined $scaleMax && defined $scaleMin &&
  13747. $scaleMax =~ m/^[+-]?\d+(\.\d+)?$/ && $scaleMin =~ m/^[+-]?\d+(\.\d+)?$/) {
  13748. $valScaled = ($readingMin*$scaleMax-$scaleMin*$readingMax)/
  13749. ($readingMin-$readingMax)+
  13750. ($scaleMin-$scaleMax)/($readingMin-$readingMax)*$readingVal;
  13751. }
  13752. if (defined $scaleDecimals && $scaleDecimals =~ m/^[0-9]?$/) {
  13753. $scaleDecimals = "%0." . $scaleDecimals . "f";
  13754. $valScaled = sprintf "$scaleDecimals", $valScaled;
  13755. }
  13756. return $valScaled;
  13757. }
  13758. # Reorganize Strings
  13759. sub EnOcean_ReorgList($)
  13760. {
  13761. my ($list) = @_;
  13762. my @list = split("[ \t][ \t]*", $list);
  13763. my %list;
  13764. @list = sort grep(!$list{$_}++, @list);
  13765. $list = join(" ", @list) . " ";
  13766. return $list;
  13767. }
  13768. # EnOcean_Set called from sub InternalTimer()
  13769. sub EnOcean_TimerSet($)
  13770. {
  13771. my ($par) = @_;
  13772. EnOcean_Set($par->{hash}, @{$par->{timerCmd}});
  13773. }
  13774. #
  13775. sub EnOcean_InternalTimer($$$$$)
  13776. {
  13777. my ($modifier, $tim, $callback, $hash, $waitIfInitNotDone) = @_;
  13778. my $mHash = {};
  13779. my $timerName = "$hash->{NAME}_$modifier";
  13780. if ($modifier eq "") {
  13781. $mHash = $hash;
  13782. } else {
  13783. if (exists ($hash->{helper}{TIMER}{$timerName})) {
  13784. $mHash = $hash->{helper}{TIMER}{$timerName};
  13785. Log3 $hash->{NAME}, 5, "EnOcean_InternalTimer setting mHash with stored $timerName";
  13786. } else {
  13787. $mHash = {HASH => $hash, NAME => $timerName, MODIFIER => $modifier};
  13788. $hash->{helper}{TIMER}{$timerName} = $mHash;
  13789. Log3 $hash->{NAME}, 5, "EnOcean_InternalTimer setting mHash with $timerName";
  13790. }
  13791. }
  13792. InternalTimer($tim, $callback, $mHash, $waitIfInitNotDone);
  13793. Log3 $hash->{NAME}, 5, "EnOcean setting timer $timerName at " . strftime("%Y-%m-%d %H:%M:%S", localtime($tim));
  13794. return;
  13795. }
  13796. #
  13797. sub EnOcean_RemoveInternalTimer($$)
  13798. {
  13799. my ($modifier, $hash) = @_;
  13800. my $mHash = {};
  13801. my $timerName = "$hash->{NAME}_$modifier";
  13802. if ($modifier eq "") {
  13803. RemoveInternalTimer($hash);
  13804. } else {
  13805. $mHash = $hash->{helper}{TIMER}{$timerName};
  13806. if (defined($mHash)) {
  13807. delete $hash->{helper}{TIMER}{$timerName};
  13808. RemoveInternalTimer($mHash);
  13809. }
  13810. }
  13811. Log3 $hash->{NAME}, 5, "EnOcean removing timer $timerName";
  13812. return;
  13813. }
  13814. #
  13815. sub EnOcean_observeInit($$@)
  13816. {
  13817. #init observe
  13818. my ($ctrl, $hash, @cmdValue) = @_;
  13819. my ($err, $name) = (undef, $hash->{NAME});
  13820. return (undef, $ctrl) if (lc(AttrVal($name, "observe", "off")) eq "off");
  13821. return (undef, $ctrl) if (defined($hash->{helper}{observeCntr}) && $hash->{helper}{observeCntr} > 0);
  13822. $hash->{helper}{observeCntr} = 1;
  13823. #my @observeExeptions = split("[ \t][ \t]*", AttrVal($name, "observeExeptions", ""));
  13824. my @observeRefDev = split("[ \t][ \t]*", AttrVal($name, "observeRefDev", $name));
  13825. $hash->{helper}{observeRefDev} = \@observeRefDev;
  13826. Log3 $name, 4, "EnOcean $name < observeRefDev " . join(" ", @{$hash->{helper}{observeRefDev}}) . " (init)";
  13827. $hash->{helper}{lastCmdFunction} = "set";
  13828. # @cmdValue = (<name>, <cmd>, <param1>, <param2>, ...)
  13829. $hash->{helper}{lastCmdValue} = \@cmdValue;
  13830. my $observeCmds = AttrVal($name, "observeCmds", undef);
  13831. my @observeCmds;
  13832. #my %observeCmds;
  13833. my ($cmdPair, $cmdSent, $cmdReceived);
  13834. if (defined $observeCmds) {
  13835. @observeCmds = split("[ \t][ \t]*", $observeCmds);
  13836. foreach my $cmdPair (@observeCmds) {
  13837. ($cmdSent, $cmdReceived) = split(':', $cmdPair);
  13838. $hash->{helper}{observeCmds}{$cmdSent} = $cmdReceived;
  13839. }
  13840. } else {
  13841. $hash->{helper}{observeCmds}{$cmdValue[1]} = $cmdValue[1];
  13842. }
  13843. $hash->{helper}{observeCntr} = 1;
  13844. #CommandDeleteReading(undef, "$name observeFailedDev");
  13845. readingsSingleUpdate($hash, "observeFailedDev", "", 0);
  13846. my %functionHash = (hash => $hash, function => "observe");
  13847. RemoveInternalTimer(\%functionHash);
  13848. InternalTimer(gettimeofday() + AttrVal($name, "observeInterval", 1), "EnOcean_observeRepeat", \%functionHash, 0);
  13849. Log3 $name, 4, "EnOcean set " . join(" ", @cmdValue) . " observing started";
  13850. return ($err, $ctrl);
  13851. }
  13852. #
  13853. sub EnOcean_observeParse($$@)
  13854. {
  13855. # observe acknowledge
  13856. my ($ctrl, $hash, @cmdValue) = @_;
  13857. my ($err, $name) = (undef, $hash->{NAME});
  13858. return (undef, $ctrl) if (lc(AttrVal($name, "observe", "off")) eq "off");
  13859. # observing disabled or ignore second and following acknowledgment telegrams
  13860. return (undef, $ctrl) if (!exists($hash->{helper}{observeRefDev}) || @{$hash->{helper}{observeRefDev}} == 0);
  13861. my $devName = shift @cmdValue;
  13862. my $cmd = shift @cmdValue;
  13863. $cmd = shift @cmdValue if ($cmd eq "state");
  13864. my ($observeRefDevIdx) = grep{$hash->{helper}{observeRefDev}[$_] eq $devName} 0..$#{$hash->{helper}{observeRefDev}};
  13865. # device not observed
  13866. return (undef, $ctrl) if (!defined $observeRefDevIdx);
  13867. Log3 $name, 4, "EnOcean $name < observeRefDev " . join(" ", @{$hash->{helper}{observeRefDev}}) . " parsed";
  13868. Log3 $name, 4, "EnOcean $name < $devName $cmd " . join(" ", @cmdValue) . " received";
  13869. if (@{$hash->{helper}{observeRefDev}} == 1) {
  13870. # last acknowledgment telegram stops observing
  13871. delete $hash->{helper}{observeCmds};
  13872. delete $hash->{helper}{observeCntr};
  13873. delete $hash->{helper}{observeRefDev};
  13874. delete $hash->{helper}{lastCmdFunction};
  13875. delete $hash->{helper}{lastCmdValue};
  13876. my %functionHash = (hash => $hash, function => "observe");
  13877. RemoveInternalTimer(\%functionHash);
  13878. Log3 $name, 4, "EnOcean $name < $devName $cmd " . join(" ", @cmdValue) . " observing stopped";
  13879. } else {
  13880. # remove the device that has sent a telegram
  13881. Log3 $name, 4, "EnOcean $name < observeRefDev " . $hash->{helper}{observeRefDev}[$observeRefDevIdx] . " removed";
  13882. splice(@{$hash->{helper}{observeRefDev}}, $observeRefDevIdx, 1);
  13883. if (lc(AttrVal($name, "observeLogic", "or")) eq "and") {
  13884. # AND logic: remove the device that has sent a telegram and await further telegrams
  13885. Log3 $name, 4, "EnOcean $name < observeRefDev " . join(" ", @{$hash->{helper}{observeRefDev}}) . " observing continued";
  13886. } else {
  13887. # OR logic: last acknowledgment telegram stops observing
  13888. #shift @{$hash->{helper}{observeRefDev}};
  13889. delete $hash->{helper}{observeCmds};
  13890. delete $hash->{helper}{observeCntr};
  13891. delete $hash->{helper}{observeRefDev};
  13892. delete $hash->{helper}{lastCmdFunction};
  13893. delete $hash->{helper}{lastCmdValue};
  13894. my %functionHash = (hash => $hash, function => "observe");
  13895. RemoveInternalTimer(\%functionHash);
  13896. Log3 $name, 4, "EnOcean $name < $devName $cmd " . join(" ", @cmdValue) . " observing stopped";
  13897. }
  13898. }
  13899. # if (defined($hash->{helper}{lastCmdValue}[1]) && $hash->{helper}{lastCmdValue}[1] eq $cmd) {
  13900. # acknowledgment telegram ok, cancel the repetition of the command
  13901. # } else {
  13902. # acknowledgment telegram does not match the telegram sent, cancel the repetition of the command
  13903. # }
  13904. return ($err, $ctrl);
  13905. }
  13906. #
  13907. sub EnOcean_observeRepeat($)
  13908. {
  13909. #timer expires without acknowledgment telegram, repeat command
  13910. my ($functionHash) = @_;
  13911. my $hash = $functionHash->{hash};
  13912. my $name = $hash->{NAME};
  13913. return if (AttrVal($name, "observe", "off") eq "off" || !defined($hash->{helper}{observeCntr}));
  13914. #my @observeExeptions = split("[ \t][ \t]*", AttrVal($name, "observeExeptions", ""));
  13915. if ($hash->{helper}{observeCntr} <= AttrVal($name, "observeCmdRepetition", 2)) {
  13916. #repeat last command
  13917. $hash->{helper}{observeCntr} += 1;
  13918. Log3 $name, 4, "EnOcean set " . join(" ", @{$hash->{helper}{lastCmdValue}}) . " repeated";
  13919. EnOcean_Set($hash, @{$hash->{helper}{lastCmdValue}});
  13920. RemoveInternalTimer($functionHash);
  13921. InternalTimer(gettimeofday() + AttrVal($name, "observeInterval", 1), "EnOcean_observeRepeat", $functionHash, 0);
  13922. } else {
  13923. # reached the maximum number of retries, clear last command
  13924. Log3 $name, 2, "EnOcean set " . join(" ", @{$hash->{helper}{lastCmdValue}}) .
  13925. " observing " . join(" ", @{$hash->{helper}{observeRefDev}}) . " failed";
  13926. #splice(@{$hash->{helper}{observeRefDev}}, 0);
  13927. my $actionCmd = AttrVal($name, "observeErrorAction", undef);
  13928. if (defined $actionCmd) {
  13929. # error action exec
  13930. my %specials = ("%NAME" => shift(@{$hash->{helper}{lastCmdValue}}),
  13931. "%FAILEDDEV" => join(" ", @{$hash->{helper}{observeRefDev}}),
  13932. "%TYPE" => $hash->{TYPE},
  13933. "%EVENT" => ReplaceEventMap($name, join(" ", @{$hash->{helper}{lastCmdValue}}), 1)
  13934. );
  13935. $actionCmd = EvalSpecials($actionCmd, %specials);
  13936. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  13937. Log3 $name, 2, "EnOcean $name observeErrorAction ERROR: $ret" if($ret);
  13938. }
  13939. readingsSingleUpdate($hash, "observeFailedDev", join(" ", @{$hash->{helper}{observeRefDev}}), 1);
  13940. delete $hash->{helper}{observeCmds};
  13941. delete $hash->{helper}{observeCntr};
  13942. delete $hash->{helper}{observeRefDev};
  13943. delete $hash->{helper}{lastCmdFunction};
  13944. delete $hash->{helper}{lastCmdValue};
  13945. RemoveInternalTimer($functionHash);
  13946. }
  13947. return;
  13948. }
  13949. sub EnOcean_RLT($) {
  13950. # Radio Link Test
  13951. my ($rltParam) = @_;
  13952. my ($ctrl, $hash, $dataRx, $subDef, $rltMode, $rssiMaster) = @$rltParam;
  13953. my $name = $hash->{NAME};
  13954. my $def = $hash->{DEF};
  13955. my ($err, $logLevel, $response, $dataTx, $rorg, $msgID) = (undef, 5, undef, undef, undef, 0);
  13956. my $rltCntrMax = AttrVal($name, 'rltRepeat', 16);
  13957. my $rltType = AttrVal($name, 'rltType', '4BS');
  13958. if ($rltType eq '1BS') {
  13959. $msgID = $hash->{helper}{rlt}{cntr} & 0x3F if (exists($hash->{helper}{rlt}{cntr}));
  13960. $dataTx = sprintf("%02X", ($msgID & 0x3C) << 2 | 8 | ($msgID & 3) << 1);
  13961. $rorg = 'D5';
  13962. } else {
  13963. $dataTx = '0000000C';
  13964. $rorg = 'A5';
  13965. }
  13966. if ($ctrl eq 'start') {
  13967. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13968. $hash->{helper}{rlt}{cntr} = 0;
  13969. $hash->{helper}{rlt}{param}[0] = 'periodic';
  13970. readingsSingleUpdate($hash, 'state', 'active', 1);
  13971. EnOcean_SndRadio(undef, $hash, 1, $rorg, $dataTx, $subDef, "00", $def);
  13972. InternalTimer(gettimeofday() + 0.15, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  13973. } elsif ($ctrl eq 'parse') {
  13974. $hash->{helper}{rlt}{param}[0] = 'periodic';
  13975. if ($hash->{helper}{rlt}{cntr} < $rltCntrMax) {
  13976. # store received RLT data from slave
  13977. $hash->{helper}{rlt}{dataRx}[$hash->{helper}{rlt}{cntr}] = $dataRx;
  13978. $hash->{helper}{rlt}{rssiMaster}[$hash->{helper}{rlt}{cntr}] = $rssiMaster;
  13979. if ($hash->{helper}{rlt}{cntr} < $rltCntrMax - 1) {
  13980. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13981. $hash->{helper}{rlt}{cntr} ++;
  13982. EnOcean_SndRadio(undef, $hash, 1, $rorg, $dataTx, $subDef, "00", $def);
  13983. InternalTimer(gettimeofday() + 0.15, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  13984. }
  13985. } else {
  13986. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13987. readingsSingleUpdate($hash, 'state', 'stopped', 1);
  13988. EnOcean_RLTResult(undef, $hash, $rltType, $rltCntrMax);
  13989. if (exists $hash->{helper}{rlt}{oldDev}) {
  13990. # activate old device subType
  13991. my $oldHash = $hash->{helper}{rlt}{oldDev}[0];
  13992. my $oldName = $hash->{helper}{rlt}{oldDev}[1];
  13993. my $oldDef = $hash->{helper}{rlt}{oldDev}[2];
  13994. CommandModify(undef, "$oldName $oldDef");
  13995. $modules{EnOcean}{defptr}{$oldDef} = $oldHash;
  13996. }
  13997. delete $hash->{helper}{rlt};
  13998. # delete deviceID
  13999. CommandModify(undef, "$name 00000000");
  14000. delete $modules{EnOcean}{defptr}{$def};
  14001. }
  14002. } elsif ($ctrl eq 'periodic') {
  14003. RemoveInternalTimer($hash->{helper}{rlt}{param});
  14004. if ($hash->{helper}{rlt}{cntr} < $rltCntrMax - 1) {
  14005. # no RLT_SlaveTest telegram received from slave
  14006. $hash->{helper}{rlt}{param}[0] = 'periodic';
  14007. $hash->{helper}{rlt}{cntr} ++;
  14008. EnOcean_SndRadio(undef, $hash, 1, $rorg, $dataTx, $subDef, "00", $def);
  14009. InternalTimer(gettimeofday() + 0.11, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  14010. } else {
  14011. # waiting for last RLT_SlaveTest telegram
  14012. $hash->{helper}{rlt}{param}[0] = 'waiting';
  14013. InternalTimer(gettimeofday() + 0.15, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  14014. }
  14015. } elsif ($ctrl eq 'waiting') {
  14016. readingsSingleUpdate($hash, 'state', 'stopped', 1);
  14017. EnOcean_RLTResult(undef, $hash, $rltType, $rltCntrMax);
  14018. if (exists $hash->{helper}{rlt}{oldDev}) {
  14019. # activate old device subType
  14020. my $oldHash = $hash->{helper}{rlt}{oldDev}[0];
  14021. my $oldName = $hash->{helper}{rlt}{oldDev}[1];
  14022. my $oldDef = $hash->{helper}{rlt}{oldDev}[2];
  14023. CommandModify(undef, "$oldName $oldDef");
  14024. $modules{EnOcean}{defptr}{$oldDef} = $oldHash;
  14025. }
  14026. delete $hash->{helper}{rlt};
  14027. # delete deviceID
  14028. CommandModify(undef, "$name 00000000");
  14029. delete $modules{EnOcean}{defptr}{$def};
  14030. } elsif ($ctrl eq 'standby') {
  14031. RemoveInternalTimer($hash->{helper}{rlt}{param});
  14032. delete $hash->{helper}{rlt};
  14033. readingsSingleUpdate($hash, 'state', 'standby', 1);
  14034. # delete deviceID
  14035. CommandModify(undef, "$name 00000000");
  14036. delete $modules{EnOcean}{defptr}{$def};
  14037. } elsif ($ctrl eq 'stop') {
  14038. RemoveInternalTimer($hash->{helper}{rlt}{param});
  14039. if (exists $hash->{helper}{rlt}{oldDev}) {
  14040. # activate old device subType
  14041. my $oldHash = $hash->{helper}{rlt}{oldDev}[0];
  14042. my $oldName = $hash->{helper}{rlt}{oldDev}[1];
  14043. my $oldDef = $hash->{helper}{rlt}{oldDev}[2];
  14044. CommandModify(undef, "$oldName $oldDef");
  14045. $modules{EnOcean}{defptr}{$oldDef} = $oldHash;
  14046. }
  14047. delete $hash->{helper}{rlt};
  14048. readingsSingleUpdate($hash, 'state', 'stopped', 1);
  14049. # delete deviceID
  14050. CommandModify(undef, "$name 00000000");
  14051. delete $modules{EnOcean}{defptr}{$def};
  14052. }
  14053. return ($err, $logLevel, $response);
  14054. }
  14055. sub EnOcean_RLTResult($$$$) {
  14056. # show RLT results
  14057. my ($ctrl, $hash, $rltType, $rltCntrMax) = @_;
  14058. my $name = $hash->{NAME};
  14059. my ($err, $logLevel, $response, $data, $msgCntr, $msgID, $subTelNum, $rssiMaster, $rssiMasterAvg, $rssiSlave, $rssiLevel1, $rssiLevel2, $rssiNonEnOcean) =
  14060. (undef, 5, undef, undef, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  14061. my %rssi = (0 => '-', 1 => '>= -31', 2 => '-32', 0x3F => '<= -93');
  14062. my %rssiNonEnOcean =
  14063. (0 => '-',
  14064. 1 => '>= -31',
  14065. 2 => '-32 ... -37',
  14066. 3 => '-38 ... -43',
  14067. 4 => '-44 ... -49',
  14068. 5 => '-50 ... -55',
  14069. 6 => '-56 ... -61',
  14070. 7 => '-62 ... -67',
  14071. 8 => '-68 ... -73',
  14072. 9 => '-74 ... -79',
  14073. 10 => '-80 ... -85',
  14074. 11 => '<= -92');
  14075. for (my $cntr = 0; $cntr < $rltCntrMax; $cntr++) {
  14076. $data = $hash->{helper}{rlt}{dataRx}[$cntr];
  14077. if (defined $data) {
  14078. $msgCntr ++;
  14079. $rssiMaster = -$hash->{helper}{rlt}{rssiMaster}[$cntr];
  14080. $rssiMasterAvg += $rssiMaster;
  14081. if ($rltType eq '1BS') {
  14082. $msgID = (hex($data) & 0xF0) >> 6 | (hex($data) & 6) >> 1;
  14083. Log3 $name, 2, "EnOcean RLT DeviceID: " . $hash->{DEF} . " msgCntr: ". ($cntr + 1) . " msgID: $msgID RSSI Master: $rssiMaster response received";
  14084. } else {
  14085. $subTelNum = (hex(substr($data, 0, 2)) & 0xC0) >> 6;
  14086. $rssiLevel2 = hex(substr($data, 0, 2)) & 0x3F;
  14087. $rssiLevel2 = $rssi{$rssiLevel2} if (exists $rssi{$rssiLevel2});
  14088. $rssiLevel1 = hex(substr($data, 2, 2));
  14089. $rssiLevel1 = $rssi{$rssiLevel1} if (exists $rssi{$rssiLevel1});
  14090. $rssiSlave = hex(substr($data, 4, 2));
  14091. $rssiSlave = $rssi{$rssiSlave} if (exists $rssi{$rssiSlave});
  14092. $rssiNonEnOcean = (hex(substr($data, 6, 2)) & 0xF0) >> 4;
  14093. $rssiNonEnOcean = $rssiNonEnOcean{$rssiNonEnOcean} if (exists $rssiNonEnOcean{$rssiNonEnOcean});
  14094. $msgID = (hex(substr($data, 6, 2)) & 6) >> 1;
  14095. Log3 $name, 2, "EnOcean RLT DeviceID: " . $hash->{DEF} . " msgCntr: ". ($cntr + 1) . " subTelNum: $subTelNum " .
  14096. "RSSI Master: $rssiMaster RSSI Slave: $rssiSlave RSSI Level 1: $rssiLevel1 RSSI Level 2: $rssiLevel2 " .
  14097. "RSSI non EnOcean: $rssiNonEnOcean";
  14098. }
  14099. } else {
  14100. Log3 $name, 2, "EnOcean RLT DeviceID: " . $hash->{DEF} . " msgCntr: ". ($cntr + 1) . " no answer";
  14101. }
  14102. }
  14103. if ($msgCntr > 0) {
  14104. readingsBeginUpdate($hash);
  14105. readingsBulkUpdate($hash, 'msgLost', (sprintf "%0.1f", ($rltCntrMax - $msgCntr) / $rltCntrMax * 100));
  14106. readingsBulkUpdate($hash, 'rssiMasterAvg', (sprintf "%0.1f", $rssiMasterAvg / $msgCntr));
  14107. readingsEndUpdate($hash, 1);
  14108. } else {
  14109. CommandDeleteReading(undef, "$name msgLost");
  14110. CommandDeleteReading(undef, "$name rssiMasterAvg");
  14111. }
  14112. return ($err, $logLevel, $response);
  14113. }
  14114. #
  14115. sub EnOcean_energyManagement_01Parse($@)
  14116. {
  14117. my ($hash, @db) = @_;
  14118. my $name = $hash->{NAME};
  14119. # [drLevel] = 15 : no requests for reduction in power consumptions
  14120. my $drLevel = ($db[0] & 0xF0) >> 4;
  14121. my $powerUsage = $db[2] & 0x7F;
  14122. my $powerUsageLevel = $db[0] & 1 ? "max" : "min";
  14123. my $powerUsageScale = $db[2] & 0x80 ? "rel" : "max";
  14124. my $randomStart = $db[0] & 4 ? "yes" : "no";
  14125. my $randomEnd = $db[0] & 2 ? "yes" : "no";
  14126. my $randomTime = rand(AttrVal($name, "demandRespRandomTime", 1));
  14127. my $setpoint = $db[3];
  14128. my $timeout = $db[1] * 15 * 60;
  14129. $randomTime = $randomTime > $timeout && $timeout > 0 ? rand($timeout) : rand($randomTime);
  14130. readingsBeginUpdate($hash);
  14131. readingsBulkUpdate($hash, "randomEnd", $randomEnd);
  14132. readingsBulkUpdate($hash, "randomStart", $randomStart);
  14133. my %timeoutHash = (hash => $hash, function => "demandResponseTimeout");
  14134. my %functionHash = (hash => $hash,
  14135. function => "demandResponseExec",
  14136. drLevel => $drLevel,
  14137. powerUsage => $powerUsage,
  14138. powerUsageLevel => $powerUsageLevel,
  14139. powerUsageScale => $powerUsageScale,
  14140. setpoint => $setpoint
  14141. );
  14142. RemoveInternalTimer(\%timeoutHash);
  14143. RemoveInternalTimer(\%functionHash);
  14144. if ($timeout > 0 && $drLevel < 15) {
  14145. # timeout timer
  14146. InternalTimer(gettimeofday() + $timeout, "EnOcean_demandResponseTimeout", \%timeoutHash, 0);
  14147. my ($sec, $min, $hour, $day, $month, $year) = localtime(time + $timeout);
  14148. $month += 1;
  14149. $year += 1900;
  14150. $min = $min < 10 ? $min = "0" . $min : $min;
  14151. $hour = $hour < 10 ? $hour = "0" . $hour : $hour;
  14152. $day = $day < 10 ? $day = "0" . $day : $day;
  14153. $month = $month < 10 ? $ month = "0". $month : $month;
  14154. readingsBulkUpdate($hash, "timeout", "$year-$month-$day $hour:$min:$sec");
  14155. } else {
  14156. CommandDeleteReading(undef, "$name timeout");
  14157. }
  14158. if ($randomStart eq "yes" && ReadingsVal($name, "level", 15) == 15) {
  14159. readingsBulkUpdate($hash, "state", "waiting_for_start");
  14160. Log3 $name, 3, "EnOcean set $name demand response waiting for start";
  14161. InternalTimer(gettimeofday() + $randomTime, "EnOcean_demandResponseExec", \%functionHash, 0);
  14162. } elsif ($randomEnd eq "yes" && ReadingsVal($name, "level", 15) < 15) {
  14163. readingsBulkUpdate($hash, "state", "waiting_for_stop");
  14164. Log3 $name, 3, "EnOcean set $name demand response waiting for stop";
  14165. InternalTimer(gettimeofday() + $randomTime, "EnOcean_demandResponseExec", \%functionHash, 0);
  14166. } else {
  14167. EnOcean_demandResponseExec(\%functionHash);
  14168. }
  14169. readingsEndUpdate($hash, 1);
  14170. return;
  14171. }
  14172. #
  14173. sub EnOcean_demandResponseExec($)
  14174. {
  14175. my ($functionHash) = @_;
  14176. my $function = $functionHash->{function};
  14177. my $hash = $functionHash->{hash};
  14178. my $drLevel = $functionHash->{drLevel};
  14179. my $powerUsage = $functionHash->{powerUsage};
  14180. my $powerUsageLevel = $functionHash->{powerUsageLevel};
  14181. my $powerUsageScale = $functionHash->{powerUsageScale};
  14182. my $setpoint = $functionHash->{setpoint};
  14183. my $name = $hash->{NAME};
  14184. my $actionCmd = AttrVal($name, "demandRespAction", undef);
  14185. # save old values
  14186. $hash->{helper}{drLevel} = ReadingsVal($name, "level", 15);
  14187. $hash->{helper}{powerUsage} = ReadingsVal($name, "powerUsage", 100);
  14188. $hash->{helper}{powerUsageLevel} = ReadingsVal($name, "powerUsageLevel", "max");
  14189. $hash->{helper}{powerUsageScale} = ReadingsVal($name, "powerUsageScale", "max");
  14190. $hash->{helper}{setpoint} = ReadingsVal($name, "setpoint", 255);
  14191. readingsBeginUpdate($hash);
  14192. readingsBulkUpdate($hash, "level", $drLevel);
  14193. readingsBulkUpdate($hash, "powerUsage", $powerUsage);
  14194. readingsBulkUpdate($hash, "powerUsageLevel", $powerUsageLevel);
  14195. readingsBulkUpdate($hash, "powerUsageScale", $powerUsageScale);
  14196. readingsBulkUpdate($hash, "setpoint", $setpoint);
  14197. if ($drLevel == 15) {
  14198. readingsBulkUpdate($hash, "state", "off");
  14199. Log3 $name, 3, "EnOcean set $name demand response off";
  14200. } else {
  14201. readingsBulkUpdate($hash, "state", "on");
  14202. Log3 $name, 3, "EnOcean set $name demand response on";
  14203. }
  14204. readingsEndUpdate($hash, 1);
  14205. if (defined $actionCmd) {
  14206. # action exec
  14207. my %specials= ("%NAME" => $name,
  14208. "%TYPE" => $hash->{TYPE},
  14209. "%LEVEL" => $drLevel,
  14210. "%SETPOINT" => $setpoint,
  14211. "%POWERUSAGE" => $powerUsage,
  14212. "%POWERUSAGESCALE" => $powerUsageScale,
  14213. "%POWERUSAGELEVEL" => $powerUsageLevel,
  14214. "%STATE" => ReadingsVal($name, "state", "off")
  14215. );
  14216. $actionCmd = EvalSpecials($actionCmd, %specials);
  14217. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  14218. Log3 $name, 2, "EnOcean $name demandRespAction ERROR: $ret" if($ret);
  14219. }
  14220. return;
  14221. }
  14222. #
  14223. sub EnOcean_demandResponseTimeout($)
  14224. {
  14225. my ($functionHash) = @_;
  14226. my $function = $functionHash->{function};
  14227. my $hash = $functionHash->{hash};
  14228. my $name = $hash->{NAME};
  14229. my $actionCmd = AttrVal($name, "demandRespAction", undef);
  14230. my $data;
  14231. my $timeoutLevel = AttrVal($name, "demandRespTimeoutLevel", "max");
  14232. RemoveInternalTimer($functionHash);
  14233. CommandDeleteReading(undef, "$name timeout");
  14234. my $drLevel = 15;
  14235. my $powerUsage = 100;
  14236. my $powerUsageLevel = "max";
  14237. my $powerUsageScale = "max";
  14238. my $setpoint = 255;
  14239. my $timeout = 0;
  14240. if ($timeoutLevel eq "last" && defined($hash->{helper}{drLevel})) {
  14241. # restore old values
  14242. $drLevel = $hash->{helper}{drLevel};
  14243. $powerUsage = $hash->{helper}{powerUsage};
  14244. $powerUsageScale = $hash->{helper}{powerUsageLevel};
  14245. $powerUsageLevel = $hash->{helper}{powerUsageScale};
  14246. $setpoint = $hash->{helper}{setpoint};
  14247. }
  14248. readingsBeginUpdate($hash);
  14249. readingsBulkUpdate($hash, "level", $drLevel);
  14250. readingsBulkUpdate($hash, "powerUsage", $powerUsage);
  14251. readingsBulkUpdate($hash, "powerUsageLevel", $powerUsageLevel);
  14252. readingsBulkUpdate($hash, "powerUsageScale", $powerUsageScale);
  14253. readingsBulkUpdate($hash, "setpoint", $setpoint);
  14254. if ($drLevel == 15) {
  14255. readingsBulkUpdate($hash, "state", "off");
  14256. Log3 $name, 3, "EnOcean set $name demand response off";
  14257. } else {
  14258. readingsBulkUpdate($hash, "state", "on");
  14259. Log3 $name, 3, "EnOcean set $name demand response on";
  14260. }
  14261. readingsEndUpdate($hash, 1);
  14262. my %specials= ("%NAME" => $name,
  14263. "%TYPE" => $hash->{TYPE},
  14264. "%LEVEL" => $drLevel,
  14265. "%SETPOINT" => $setpoint,
  14266. "%POWERUSAGE" => $powerUsage,
  14267. "%POWERUSAGESCALE" => $powerUsageScale,
  14268. "%POWERUSAGELEVEL" => $powerUsageLevel,
  14269. "%STATE" => ReadingsVal($name, "state", "off")
  14270. );
  14271. $powerUsageLevel = $powerUsageLevel eq "max" ? 1 : 0;
  14272. $powerUsageScale = $powerUsageScale eq "rel" ? 0x80 : 0;
  14273. my $randomStart = ReadingsVal($name, "randomStart", "no") eq "yes" ? 4 : 0;
  14274. my $randomEnd = ReadingsVal($name, "randomEnd", "no") eq "yes" ? 2 : 0;
  14275. $data = sprintf "%02X%02X%02X%02X", $setpoint, $powerUsageScale | $powerUsage, $timeout,
  14276. $drLevel << 4 | $randomStart | $randomEnd | $powerUsageLevel | 8;
  14277. EnOcean_SndRadio(undef, $hash, 1, "A5", $data, AttrVal($name, "subDef", $hash->{DEF}), "00", "FFFFFFFF");
  14278. if (defined $actionCmd) {
  14279. # action exec
  14280. $actionCmd = EvalSpecials($actionCmd, %specials);
  14281. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  14282. Log3 $name, 2, "EnOcean $name demandRespAction ERROR: $ret" if($ret);
  14283. }
  14284. return;
  14285. }
  14286. # Send UTE Teach-In Telegrams
  14287. sub EnOcean_sndUTE($$$$$$$) {
  14288. my ($ctrl, $hash, $comMode, $responseRequest, $teachInReq, $devChannel, $eep) = @_;
  14289. my $name = $hash->{NAME};
  14290. my ($err, $data) = (undef, "");
  14291. my $IODev = $hash->{IODev}{NAME};
  14292. my $IOHash = $defs{$IODev};
  14293. my @db = (undef, undef, undef, "07", "FF", $devChannel);
  14294. if ($eep =~ m/^(..)-(..)-(..)$/) {
  14295. ($db[0], $db[1], $db[2]) = ($1, $2, $3);
  14296. } else {
  14297. return (1, undef, undef);
  14298. }
  14299. # set unidir/bidir operation
  14300. $db[6] = $comMode eq "biDir" ? 0x80 : 0;
  14301. $attr{$name}{comMode} = $comMode;
  14302. # set teach mode
  14303. if ($teachInReq eq "out") {
  14304. $db[6] |= 0x10;
  14305. } elsif ($teachInReq eq "inout") {
  14306. $db[6] |= 0x20;
  14307. }
  14308. # set response message mode
  14309. if ($responseRequest eq "no") {
  14310. $db[6] |= 0x40;
  14311. readingsSingleUpdate($hash, "teach", "EEP $eep UTE query sent", 1);
  14312. } else {
  14313. # set flag for response request,
  14314. if ($teachInReq eq "in") {
  14315. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{teachInReq} = $teachInReq;
  14316. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{hash} = $hash;
  14317. } elsif ($teachInReq eq "out") {
  14318. $hash->{IODev}{helper}{UTERespWait}{AttrVal($name, "subDef", $hash->{DEF})}{teachInReq} = $teachInReq;
  14319. $hash->{IODev}{helper}{UTERespWait}{AttrVal($name, "subDef", $hash->{DEF})}{hash} = $hash;
  14320. } elsif ($teachInReq eq "inout") {
  14321. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{teachInReq} = $teachInReq;
  14322. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{hash} = $hash;
  14323. }
  14324. readingsSingleUpdate($hash, "teach", "EEP $eep UTE query sent, response requested", 1);
  14325. if (!exists($hash->{IODev}{Teach})) {
  14326. # enable teach-in receiving for 3 sec
  14327. $hash->{IODev}{Teach} = 1;
  14328. my %timeoutHash = (hash => $IOHash, function => "UTERespTimeout", helper => "UTERespWait");
  14329. RemoveInternalTimer(\%timeoutHash);
  14330. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  14331. }
  14332. }
  14333. $attr{$name}{devChannel} = $devChannel;
  14334. $attr{$name}{eep} = $eep;
  14335. $attr{$name}{manufID} = "7FF";
  14336. $data = sprintf "%02X%02X%s%s%s%s%s", $db[6], $db[5], $db[4], $db[3], $db[2], $db[1], $db[0];
  14337. return ($err, "D4", $data);
  14338. }
  14339. #
  14340. sub EnOcean_RespTimeout($) {
  14341. my ($functionHash) = @_;
  14342. my $function = $functionHash->{function};
  14343. my $hash = $functionHash->{hash};
  14344. my $helper = $functionHash->{helper};
  14345. my $name = $hash->{NAME};
  14346. delete $hash->{helper}{$helper};
  14347. delete $hash->{Teach};
  14348. return;
  14349. }
  14350. #
  14351. sub EnOcean_setTeachConfirmWaitHash($) {
  14352. my ($ctrl, $hash) = @_;
  14353. if (AttrVal($hash->{NAME}, "teachMethod", "") eq 'confirm') {
  14354. $hash->{IODev}{helper}{teachConfirmWaitHash} = $hash;
  14355. my %functionHash = (hash => $hash->{IODev}, function => "teachConfirmWaitHash");
  14356. RemoveInternalTimer(\%functionHash);
  14357. InternalTimer(gettimeofday() + 5, "EnOcean_helperClear", \%functionHash, 0);
  14358. }
  14359. return;
  14360. }
  14361. #
  14362. sub EnOcean_ReadDevDesc($$) {
  14363. # read xml device description to $hash->{helper}
  14364. my ($ctrl, $hash) = @_;
  14365. my $name = $hash->{NAME};
  14366. if ($xmlFunc == 0) {
  14367. Log3 $name, 2, "EnOcean $name XML functions are not available";
  14368. return;
  14369. }
  14370. if (exists($hash->{TYPE}) && $hash->{TYPE} eq 'EnOcean' && exists($attr{$name}{model})) {
  14371. if (exists $EnO_models{$attr{$name}{model}}) {
  14372. if (exists $EnO_models{$attr{$name}{model}}{xml}{xmlDescrLocation}) {
  14373. my $xmlFile = $attr{global}{modpath} . $EnO_models{$attr{$name}{model}}{xml}{xmlDescrLocation};
  14374. if (-e -f -r $xmlFile) {
  14375. my $xmlData = $xml->XMLin($xmlFile);
  14376. $hash->{helper} = $xmlData;
  14377. if (exists $xmlData->{Device}) {
  14378. Log3 $name, 5, "EnOcean $name Beginn Device Description";
  14379. Log3 $name, 5, "###";
  14380. Log3 $name, 5, Dumper($xmlData);
  14381. Log3 $name, 5, "###";
  14382. Log3 $name, 5, "EnOcean $name End Device Description";
  14383. } else {
  14384. Log3 $name, 2, "EnOcean $name Device Description not defined";
  14385. }
  14386. } else {
  14387. Log3 $name, 2, "EnOcean $name Device Description file $xmlFile not exists";
  14388. }
  14389. }
  14390. }
  14391. }
  14392. return;
  14393. }
  14394. #
  14395. sub EnOcean_helperClear($) {
  14396. my ($functionHash) = @_;
  14397. my $function = $functionHash->{function};
  14398. my $hash = $functionHash->{hash};
  14399. delete $hash->{helper}{$function};
  14400. return;
  14401. }
  14402. #
  14403. sub EnOcean_cdmClearRemoteWait($) {
  14404. my ($functionHash) = @_;
  14405. my $hash = $functionHash->{hash};
  14406. my $param = $functionHash->{param};
  14407. delete $hash->{IODev}{helper}{remoteAnswerWait}{$param}{hash};
  14408. #Log3 $hash->{NAME}, 3, "EnOcean $hash->{NAME} EnOcean_cdmClearRemoteWait executed.";
  14409. return;
  14410. }
  14411. #
  14412. sub EnOcean_cdmClearHashVal($) {
  14413. my ($functionHash) = @_;
  14414. my $hash = $functionHash->{hash};
  14415. my $param = $functionHash->{param};
  14416. delete $hash->{$param};
  14417. #Log3 $hash->{NAME}, 3, "EnOcean $hash->{NAME} EnOcean_cdmClearHashVal executed.";
  14418. return;
  14419. }
  14420. #
  14421. sub EnOcean_CommandDelete($) {
  14422. my ($functionHash) = @_;
  14423. my $deleteDevice = $functionHash->{deleteDevice};
  14424. my $function = $functionHash->{function};
  14425. my $hash = $functionHash->{hash};
  14426. my $name = $hash->{NAME};
  14427. my $oldDevice = $functionHash->{oldDevice};
  14428. CommandDelete(undef, $deleteDevice);
  14429. if (defined $oldDevice) {
  14430. Log3 $name, 2, "EnOcean $name: $oldDevice renamed to $deleteDevice";
  14431. CommandRename(undef, "$oldDevice $deleteDevice");
  14432. CommandSave(undef, undef);
  14433. } else {
  14434. Log3 $name, 2, "EnOcean $name: $deleteDevice deleted";
  14435. CommandSave(undef, undef);
  14436. }
  14437. return;
  14438. }
  14439. #
  14440. sub EnOcean_convBitToHex($) {
  14441. # convert bit string to hex string
  14442. my ($bitStr) = @_;
  14443. my $hexStr = '';
  14444. while(length($bitStr) > 0) {
  14445. $bitStr =~ m/^(.*)(.{8})$/;
  14446. $bitStr = $1;
  14447. $hexStr = unpack('H2', pack('B8', $2)) . $hexStr;
  14448. }
  14449. return uc($hexStr);
  14450. }
  14451. #
  14452. sub EnOcean_convHexToBit($) {
  14453. # convert unsign hex string to bit string
  14454. my ($hexstr) = @_;
  14455. my $bitstr = '';
  14456. while (length($hexstr) > 0) {
  14457. $hexstr =~ m/^(.*)(..)$/;
  14458. $hexstr = $1;
  14459. $bitstr = unpack('B8', pack('H2', $2)) . $bitstr;
  14460. }
  14461. return $bitstr;
  14462. }
  14463. #
  14464. sub EnOcean_convIntToBit($$) {
  14465. # convert unsign number to bitstring
  14466. my ($data, $resolution) = @_;
  14467. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr input: $data";
  14468. if ($data > 0xFFFF) {
  14469. # unsigned long (32 bit)
  14470. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack L: " . pack('L', $data);
  14471. #$data = unpack('B32', pack('L', $data));
  14472. $data = unpack('B32', $data);
  14473. } elsif ($data > 0xFF) {
  14474. # unsigned short (16 bit)
  14475. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack S: " . pack('S', $data);
  14476. #$data = '0' x 16 . unpack('B16', pack('S', $data));
  14477. $data = '0' x 16 . unpack('B16', $data);
  14478. } else {
  14479. # unsigned char (8 bit)
  14480. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack C: " . pack('C', $data);
  14481. $data = '0' x 24 . unpack('B8', pack('C', $data));
  14482. }
  14483. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack B32: " . $data;
  14484. $data = substr($data, 32 - $resolution);
  14485. return $data;
  14486. }
  14487. sub EnOcean_gpConvSelDataToSndData($$$$) {
  14488. # Generic Profiles, make selective data in hex
  14489. my ($header, $channel, $resolution, $data) = @_;
  14490. my $resolutionPattern = '%04B%06B%0' . $resolution . 'B';
  14491. $data = sprintf "$resolutionPattern", $header, $channel, $data;
  14492. if (($resolution + 10) % 8) {
  14493. # fill with trailing zeroes to x bytes
  14494. $data = $data . '0' x (8 - (10 + $resolution) % 8);
  14495. }
  14496. #Log3 undef, 3, "EnOcean EnOcean_gpConvSelDataToSndData header: $header channel: $channel data: $data";
  14497. $data = EnOcean_convBitToHex($data);
  14498. #Log3 undef, 3, "EnOcean EnOcean_gpConvSelDataToSndData header: $header channel: $channel data: $data";
  14499. return $data;
  14500. }
  14501. #
  14502. sub EnOcean_gpConvDataToValue($$$$$) {
  14503. # Generic Profiles, convert data to value
  14504. my ($ctrl, $hash, $channel, $data, $dataDescr) = @_;
  14505. my $name = $hash->{NAME};
  14506. my ($err, $logLevel, $msg, $readingFormat, $readingType, $readingUnit, $readingValue, $valueType) =
  14507. (undef, 5, 'ok', '%d', 'data', 'N/A', $data, 'value');
  14508. my @channelTypeList = ("teachIn", "data", "flag", "enum");
  14509. my @signalTypeList;
  14510. my @valueTypeList = ("res", "value", "setpointAbs", "setpointRel");
  14511. # extract channel definition
  14512. my ($channelName, $channelDir, $channelType, $signalType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax);
  14513. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  14514. split(':', $dataDescr);
  14515. my $readingName = sprintf('%02d', $channel) . '-' . $channelName;
  14516. $readingType = $channelTypeList[$channelType];
  14517. $valueType = $valueTypeList[$valueType];
  14518. if ($channelType == 3) {
  14519. # enumeration
  14520. if (defined $EnO_gpValueEnum{$signalType}{enum}{$data}) {
  14521. $readingValue = $EnO_gpValueEnum{$signalType}{enum}{$data};
  14522. $readingFormat = '%s';
  14523. }
  14524. } elsif ($channelType == 2) {
  14525. # flag
  14526. if (defined $EnO_gpValueFlag{$signalType}{flag}{$data}) {
  14527. $readingValue = $EnO_gpValueFlag{$signalType}{flag}{$data};
  14528. $readingFormat = '%s';
  14529. }
  14530. } elsif ($channelType == 1) {
  14531. # data
  14532. if (defined $EnO_gpValueData{$signalType}{unit}) {
  14533. $readingUnit = $EnO_gpValueData{$signalType}{unit};
  14534. }
  14535. my @decimalDigits = (0, 1, 1, 2, 2, 2, 3, 4 , 4, 5, 7, 8, 10);
  14536. $readingValue = $data / 2**$EnO_resolution[$resolution] *
  14537. ($engMax * $EnO_scaling[$scalingMax] - $engMin * $EnO_scaling[$scalingMin]) + $engMin * $EnO_scaling[$scalingMin];
  14538. if ($readingValue =~ m/^[+-]?\d+$/) {
  14539. } elsif ($readingValue < 1000) {
  14540. $readingFormat = '%0.' . ($decimalDigits[$resolution] - 1) . 'f';
  14541. } else {
  14542. $readingFormat = '%.' . ($decimalDigits[$resolution] - 1) . 'g';
  14543. }
  14544. } else {
  14545. # teach-in info ... not used
  14546. my @valueList = ("res", "channelsDescription", "productID");
  14547. if (defined $valueList[$signalType]) {
  14548. $readingValue = $valueList[$signalType];
  14549. $readingFormat = '%s';
  14550. }
  14551. }
  14552. return ($err, $logLevel, $msg, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType);
  14553. }
  14554. # Parse Secure Teach-In Telegrams
  14555. sub EnOcean_sec_parseTeachIn($$$$) {
  14556. my ($hash, $telegram, $subDef, $destinationID) = @_;
  14557. my $name = $hash->{NAME};
  14558. my ($err, $response, $logLevel);
  14559. my $rlc; # Rolling code
  14560. my $key1; # First part of private key
  14561. my $key2; # Second part of private key
  14562. # Extract byte fields from telegram
  14563. # TEACH_IN_INFO, SLF, RLC/KEY/variable
  14564. $telegram =~ /^(..)(..)(.*)/; # TODO Parse error handling?
  14565. my $teach_bin = unpack('B8',pack('H2', $1)); # Parse as ASCII HEX, unpack to bitstring
  14566. my $slf_bin = unpack('B8',pack('H2', $2)); # Parse as ASCII HEX, unpack to bitstring
  14567. my $crypt = $3;
  14568. # Extract bit fields from teach-in info field
  14569. # IDX, CNT, PSK, TYPE, INFO
  14570. $teach_bin =~ /(..)(..)(.)(.)(..)/; # TODO Parse error handling?
  14571. my $idx = unpack('C',pack('B8', '000000'.$1)); # Padd to byte, parse as unsigned char
  14572. my $cnt = unpack('C',pack('B8', '000000'.$2)); # Padd to byte, parse as unsigned char
  14573. my $psk = $3;
  14574. my $type = $4;
  14575. my $info = unpack('C',pack('B8', '000000'.$5)); # Padd to byte, parse as unsigned char
  14576. # Extract bit fields from SLF field
  14577. # RLC_ALGO, RLC_TX, MAC_ALGO, DATA_ENC
  14578. $slf_bin =~ /(..)(.)(..)(...)/; # TODO Parse error handling?
  14579. my $rlc_algo = unpack('C',pack('B8', '000000'.$1)); # Padd to byte, parse as unsigned char
  14580. my $rlc_tx = $2;
  14581. my $mac_algo = unpack('C',pack('B8', '000000'.$3)); # Padd to byte, parse as unsigned char
  14582. my $data_enc = unpack('C',pack('B8', '00000'.$4)); # Padd to byte, parse as unsigned char
  14583. # The teach-in information is split in two telegrams due to the ERP1 limitations on telegram length
  14584. # So we should get a telegram with index 0 and count 2 with the first half of the infos needed
  14585. if ($idx == 0 && $cnt == 2) {
  14586. # First part of the teach in message
  14587. # Decode teach in type
  14588. if ($type == 0) {
  14589. # 1BS, 4BS, UTE or GP teach-in expected
  14590. if ($info == 0) {
  14591. $attr{$name}{comMode} = "uniDir";
  14592. $attr{$name}{secMode} = "rcv";
  14593. } else {
  14594. $attr{$name}{comMode} = "biDir";
  14595. $attr{$name}{secMode} = "biDir";
  14596. }
  14597. $hash->{helper}{teachInWait} = "STE";
  14598. } else {
  14599. # switch teach-in
  14600. $attr{$name}{teachMethod} = 'STE';
  14601. if ($info == 0) {
  14602. $attr{$name}{comMode} = "uniDir";
  14603. $attr{$name}{eep} = "D2-03-00";
  14604. $attr{$name}{manufID} = "7FF";
  14605. $attr{$name}{secMode} = "rcv";
  14606. foreach my $attrCntr (keys %{$EnO_eepConfig{"D2.03.00"}{attr}}) {
  14607. $attr{$name}{$attrCntr} = $EnO_eepConfig{"D2.03.00"}{attr}{$attrCntr};
  14608. }
  14609. readingsSingleUpdate($hash, "teach", "STE teach-in accepted EEP D2-03-00 Manufacturer: " . $EnO_manuf{"7FF"}, 1);
  14610. Log3 $name, 2, "EnOcean $name STE teach-in accepted EEP D2-03-00 Rocker A Manufacturer: " . $EnO_manuf{"7FF"};
  14611. } else {
  14612. $attr{$name}{comMode} = "uniDir";
  14613. $attr{$name}{eep} = "D2-03-00";
  14614. $attr{$name}{manufID} = "7FF";
  14615. $attr{$name}{secMode} = "rcv";
  14616. foreach my $attrCntr (keys %{$EnO_eepConfig{"D2.03.00"}{attr}}) {
  14617. $attr{$name}{$attrCntr} = $EnO_eepConfig{"D2.03.00"}{attr}{$attrCntr};
  14618. }
  14619. readingsSingleUpdate($hash, "teach", "STE teach-in accepted EEP D2-03-00 Manufacturer: " . $EnO_manuf{"7FF"}, 1);
  14620. Log3 $name, 2, "EnOcean $name STE teach-in accepted EEP D2-03-00 Rocker B Manufacturer: " . $EnO_manuf{"7FF"};
  14621. }
  14622. }
  14623. # Decode RLC algorithm and extract RLC and private key (only first part most likely)
  14624. if ($rlc_algo == 0) {
  14625. # No RLC used in telegram or internally in memory, use case untested
  14626. return ("Secure modes without RLC not tested or supported", undef);
  14627. } elsif ($rlc_algo == 1) {
  14628. # "RLC= 2-byte long. RLC algorithm consists on incrementing in +1 the previous RLC value
  14629. # Extract RLC and KEY fields from data trailing SLF field
  14630. # RLC, KEY, ID, STATUS
  14631. $crypt =~ /^(....)(.*)$/;
  14632. $rlc = $1;
  14633. $key1 = $2;
  14634. #print "RLC: $rlc\n";
  14635. #print "Part 1 of KEY: $key1\n";
  14636. # Store in device hash
  14637. $attr{$name}{rlcAlgo} = '2++';
  14638. readingsSingleUpdate($hash, ".rlcRcv", $rlc, 0);
  14639. # storing backup copy
  14640. $attr{$name}{rlcRcv} = $rlc;
  14641. $attr{$name}{keyRcv} = $key1;
  14642. } elsif ($rlc_algo == 2) {
  14643. # RLC= 3-byte long. RLC algorithm consists on incrementing in +1 the previous RLC value
  14644. # Extract RLC and KEY fields from data trailing SLF field
  14645. # RLC, KEY, ID, STATUS
  14646. $crypt =~ /^(......)(.*)$/;
  14647. $rlc = $1;
  14648. $key1 = $2;
  14649. #print "RLC: $rlc\n";
  14650. #print "Part 1 of KEY: $key1\n";
  14651. # Store in device hash
  14652. $attr{$name}{rlcAlgo} = '3++';
  14653. readingsSingleUpdate($hash, ".rlcRcv", $rlc, 0);
  14654. # storing backup copy
  14655. $attr{$name}{rlcRcv} = $rlc;
  14656. $attr{$name}{keyRcv} = $key1;
  14657. } else {
  14658. # Undefined RLC algorithm
  14659. return ("Undefined RLC algorithm $rlc_algo", undef);
  14660. }
  14661. # RLC Transmission
  14662. if ($rlc_tx == 0 ) {
  14663. # Secure operation mode telegrams do not contain RLC, we store and track it ourself
  14664. $attr{$name}{rlcTX} = 'false';
  14665. } else {
  14666. # Secure operation mode messages contain RLC, CAUTION untested
  14667. $attr{$name}{rlcTX} = 'true';
  14668. }
  14669. # Decode MAC Algorithm
  14670. if ($mac_algo == 0) {
  14671. # No MAC included in the secure telegram
  14672. # Doesn't make sense for RLC senders like the PTM215, as we can't verify the RLC then...
  14673. #$attr{$name}{macAlgo} = 'no';
  14674. return ("Secure mode without MAC algorithm unsupported", undef);
  14675. } elsif ($mac_algo == 1) {
  14676. # CMAC is a 3-byte-long code
  14677. $attr{$name}{macAlgo} = '3';
  14678. } elsif ($mac_algo == 2) {
  14679. # MAC is a 4-byte-long code
  14680. $attr{$name}{macAlgo} = '4';
  14681. } else {
  14682. # Undefined MAC algorith;
  14683. # Nothing we can do either...
  14684. #$attr{$name}{macAlgo} = 'no';
  14685. return ("Undefined MAC algorithm $mac_algo", undef);
  14686. }
  14687. # Decode data encryption algorithm
  14688. if ($data_enc == 0) {
  14689. # Data not encrypted? Right now we will handle this like an error, concrete use case untested
  14690. #$attr{$name}{secLevel} = 'encapsulation';
  14691. return ("Secure mode message without data encryption unsupported", undef);
  14692. } elsif ($data_enc == 1) {
  14693. # Unspecified
  14694. return ("Undefined data encryption algorithm $data_enc", undef);
  14695. } elsif ($data_enc == 2) {
  14696. # Unspecified
  14697. return ("Undefined data encryption algorithm $data_enc", undef);
  14698. } elsif ($data_enc == 3) {
  14699. # Data will be encrypted/decrypted XORing with a string obtained from a AES128 encryption
  14700. $attr{$name}{dataEnc} = 'VAES';
  14701. $attr{$name}{secLevel} = 'encryption';
  14702. } elsif ($data_enc == 4) {
  14703. # Data will be encrypted/decrypted using the AES128 algorithm in CBC mode
  14704. # Might be used in the future right now untested
  14705. #$attr{$name}{dataEnc} = 'AES-CBC';
  14706. #$attr{$name}{secLevel} = 'encryption';
  14707. return ("Secure mode message with AES-CBC data encryption unsupported", undef);
  14708. } else {
  14709. # Something went horribly wrong
  14710. return ("Could not parse data encryption information, $data_enc", undef);
  14711. }
  14712. $hash->{helper}{teachInSTE} = $cnt - 1;
  14713. # Ok we got a lots of infos and the first part of the private key
  14714. return (undef, "part1: $name");
  14715. } elsif ($idx == 1 && exists($hash->{helper}{teachInSTE})) {
  14716. # Second part of the teach-in telegrams
  14717. # Extract byte fields from telegram
  14718. # Don't care about info fields, KEY, ID, don't care about status
  14719. $telegram =~ /^..(.*)$/; # TODO Parse error handling?
  14720. $key2 = $1;
  14721. # We already should have gathered the infos from the first teach-in telegram
  14722. if (!defined($attr{$name}{keyRcv})) {
  14723. # We have missed the first telegram
  14724. return ("Missing first teach-in telegram", undef);
  14725. }
  14726. # Append second part of private key to first part of private key
  14727. $attr{$name}{keyRcv} .= $key2;
  14728. if ($attr{$name}{secMode} eq "biDir") {
  14729. # bidirectional secure teach-in
  14730. if (!defined $subDef) {
  14731. $subDef = EnOcean_CheckSenderID("getNextID", $defs{$name}{IODev}{NAME}, "00000000");
  14732. $attr{$name}{subDef} = $subDef;
  14733. }
  14734. ($err, $response, $logLevel) = EnOcean_sec_createTeachIn(undef, $hash, $attr{$name}{comMode},
  14735. $attr{$name}{dataEnc}, $attr{$name}{eep},
  14736. $attr{$name}{macAlgo}, $attr{$name}{rlcAlgo},
  14737. $attr{$name}{rlcTX}, $attr{$name}{secLevel},
  14738. $subDef, $destinationID);
  14739. if ($err) {
  14740. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  14741. return $err;
  14742. } else {
  14743. Log3 $name, $logLevel, "EnOcean $name $response";
  14744. }
  14745. }
  14746. delete $hash->{helper}{teachInSTE};
  14747. return (undef, "part2: $name");
  14748. }
  14749. # Sequence error?
  14750. return ("teach-in sequence error IDC: $idx CNT: $cnt", undef);
  14751. }
  14752. # Do VAES decyrption
  14753. # All parameters need to be passed as byte strings
  14754. #
  14755. # Parameter 1: Current rolling code, 16 bytes
  14756. # Parameter 2: Private key, 16bytes
  14757. # Paremeter 3: Encrypted data, 16bytes
  14758. #
  14759. # Returns: Decrypted data, 16 bytes
  14760. #
  14761. # Decryption of more than 16bytes of data is currently unsupported
  14762. #
  14763. sub EnOcean_sec_decodeVAES($$$) {
  14764. my $rlc = $_[0];
  14765. my $private_key = $_[1];
  14766. my $data_enc = $_[2];
  14767. # Public key according to EnOcean Security specification
  14768. my $public_key = pack('H32', '3410de8f1aba3eff9f5a117172eacabd');
  14769. # Input for VAES
  14770. my $aes_in = $public_key ^ $rlc;
  14771. #print "--\n";
  14772. #print "Public Key ".unpack('H32', $public_key)."\n";
  14773. #print "RLC ".unpack('H32', $rlc)."\n";
  14774. #print "AES input ".unpack('H32', $aes_in)."\n";
  14775. #print "--\n";
  14776. #print "Private Key ".unpack('H32', $private_key)."\n";
  14777. my $cipher = Crypt::Rijndael->new( $private_key );
  14778. my $aes_out = $cipher->encrypt($aes_in);
  14779. #print "AES output ".unpack('H32', $aes_out)."\n";
  14780. #print "Data_enc: ".unpack('H32', $data_enc)."\n";
  14781. my $data_dec = $data_enc ^ $aes_out;
  14782. #print "Data_dec: ".unpack('H32', $data_dec)."\n";
  14783. return $data_dec;
  14784. }
  14785. # Returns current RLC in hex format and increments the stored RLC
  14786. # Checks the boundaries of the RLC for roll-over
  14787. #
  14788. # Parameter 1: Sender ID in hexadecimal format for lookup in receivers hash
  14789. #
  14790. # Affects: receivers hash
  14791. #
  14792. # Returns: RLC in hexadecimal format
  14793. #
  14794. sub EnOcean_sec_getRLC($$) {
  14795. my $hash = $_[0];
  14796. my $rlcVar = $_[1];
  14797. my $name = $hash->{NAME};
  14798. # Fetch newest RLC from receiver hash
  14799. my $old_rlc = ReadingsVal($name, "." . $rlcVar, $attr{$name}{$rlcVar});
  14800. if (hex($old_rlc) < hex($attr{$name}{$rlcVar})) {
  14801. $old_rlc = $attr{$name}{$rlcVar};
  14802. }
  14803. #print "RLC old: $old_rlc\n";
  14804. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC old: $old_rlc";
  14805. # Advance RLC by one
  14806. my $new_rlc = hex($old_rlc) + 1;
  14807. # Boundary check
  14808. if ($attr{$name}{rlcAlgo} eq '2++') {
  14809. if ($new_rlc > 65535) {
  14810. #print "RLC rollover\n";
  14811. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC rollover";
  14812. $new_rlc = 0;
  14813. $attr{$name}{$rlcVar} = "0000";
  14814. EnOcean_CommandSave(undef, undef);
  14815. }
  14816. readingsSingleUpdate($hash, "." . $rlcVar, uc(unpack('H4',pack('n', $new_rlc))), 0);
  14817. $attr{$name}{$rlcVar} = uc(unpack('H4',pack('n', $new_rlc)));
  14818. } elsif ($attr{$name}{rlcAlgo} eq '3++') {
  14819. if ($new_rlc > 16777215) {
  14820. #print "RLC rollover\n";
  14821. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC rollover";
  14822. $new_rlc = 0;
  14823. $attr{$name}{$rlcVar} = "000000";
  14824. EnOcean_CommandSave(undef, undef);
  14825. }
  14826. readingsSingleUpdate($hash, "." . $rlcVar, uc(unpack('H6',pack('N', $new_rlc))), 0);
  14827. $attr{$name}{$rlcVar} = uc(unpack('H6',pack('N', $new_rlc)));
  14828. }
  14829. #print "RLC new: ".$attr{$name}{rlc}."\n";
  14830. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC new: ". $attr{$name}{$rlcVar};
  14831. return $old_rlc;
  14832. }
  14833. # Generate MAC of data
  14834. #
  14835. # Parameter 1: private key as byte string, 16bytes
  14836. # Parameter 2: data fro which mac should be calculated in hexadecimal format, len variable
  14837. # Parameter 3: length of MAC to be generated in bytes
  14838. #
  14839. # Returns: MAC in hexadecimal format
  14840. #
  14841. # This function currently supports data with lentgh of less then 16bytes,
  14842. # MAC for longer data is untested but specified
  14843. #
  14844. sub EnOcean_sec_generateMAC($$$) {
  14845. my $private_key = $_[0];
  14846. my $data = $_[1];
  14847. my $cmac_len = $_[2];
  14848. #print "Calculating MAC for data $data\n";
  14849. Log3 undef, 5, "EnOcean_sec_generateMAC Calculating MAC for data $data";
  14850. Log3 undef, 5, "EnOcean_sec_generateMAC private key ".unpack('H32', $private_key);
  14851. # Pack data to 16byte byte string, padd with 10..0 binary
  14852. my $data_expanded = pack('H32', $data.'80');
  14853. #print "Exp. data ".unpack('H32', $data_expanded)."\n";
  14854. # Constants according to specification
  14855. my $const_zero = pack('H32','00');
  14856. my $const_rb = pack('H32', '00000000000000000000000000000087');
  14857. # Encrypt zero data with private key to get L
  14858. my $cipher = Crypt::Rijndael->new($private_key);
  14859. my $l = $cipher->encrypt($const_zero);
  14860. #print "L ".unpack('H32', $l)."\n";
  14861. #print "L ".unpack('B128', $l)."\n";
  14862. # Expand L to 128bit string
  14863. my $l_bit = unpack('B128', $l);
  14864. # K1 and K2 stored as 128bit string
  14865. my $k1_bit;
  14866. my $k2_bit;
  14867. # K1 and K2 as binary
  14868. my $k1;
  14869. my $k2;
  14870. # Store L << 1 in K1
  14871. $l_bit =~ /^.(.{127})/;
  14872. $k1_bit = $1.'0';
  14873. $k1 = pack('B128', $k1_bit);
  14874. # If MSB of L == 1, K1 = K1 XOR const_Rb
  14875. if($l_bit =~ m/^1/) {
  14876. #print "MSB of L is set\n";
  14877. $k1 = $k1 ^ $const_rb;
  14878. $k1_bit = unpack('B128', $k1);
  14879. } else {
  14880. #print "MSB of L is unset\n";
  14881. }
  14882. # Store K1 << 1 in K2
  14883. $k1_bit =~ /^.(.{127})/;
  14884. $k2_bit = $1.'0';
  14885. $k2 = pack('B128', $k2_bit);
  14886. # If MSB of K1 == 1, K2 = K2 XOR const_Rb
  14887. if($k1_bit =~ m/^1/) {
  14888. #print "MSB of K1 is set\n";
  14889. $k2 = $k2 ^ $const_rb;
  14890. } else {
  14891. #print "MSB of K1 is unset\n";
  14892. }
  14893. # XOR data with K2
  14894. $data_expanded ^= $k2;
  14895. # Encrypt data
  14896. my $cmac = $cipher->encrypt($data_expanded);
  14897. #print "CMAC ".unpack('H32', $cmac)."\n";
  14898. Log3 undef, 5, "EnOcean_sec_generateMAC CMAC ".unpack('H32', $cmac);
  14899. # Extract specified len of MAC
  14900. my $cmac_pattern = '^(.{'.($cmac_len * 2).'})';
  14901. unpack('H32', $cmac) =~ /$cmac_pattern/;
  14902. Log3 undef, 5, "EnOcean_sec_generateMAC cutted CMAC ".unpack('H32', $1);
  14903. # Return MAC in hexadecimal format
  14904. return uc($1);
  14905. }
  14906. # Verify (MAC) and decode/decrypt secure mode message
  14907. #
  14908. # Parameter 1: content of radio telegram in hexadecimal format
  14909. #
  14910. # Returns: "ERROR-" + error description, "OK-" + EEP D2-03-00 telegram in hexadecimal format
  14911. #
  14912. # Right now we only decode PTM215 telegrams which are transmitted as RORG 30 and without
  14913. # encapsulation. Encapsulation of other telegrams is possible and specified but untested due to the
  14914. # lack of hardware suporting this.
  14915. #
  14916. sub EnOcean_sec_convertToNonsecure($$$) {
  14917. my ($hash, $rorg, $crypt_data) = @_;
  14918. my $name = $hash->{NAME};
  14919. if ($cryptFunc == 0) {
  14920. return ("Cryptographic functions are not available", undef, undef);
  14921. }
  14922. my $private_key;
  14923. # Prefix of pattern to extract the different cryptographic infos
  14924. my $crypt_pattern = "^(.*)";;
  14925. # Flags and infos for fields to expect
  14926. my $expect_rlc = 0;
  14927. my $expect_mac = 0;
  14928. my $mac_len;
  14929. my $expect_enc = 0;
  14930. # Check if RLC is transmitted and when, which length to expect
  14931. if($attr{$name}{rlcTX} eq 'true') {
  14932. # Message should contain RLC
  14933. if ($attr{$name}{rlcAlgo} eq '2++') {
  14934. $crypt_pattern .= "(....)";
  14935. $expect_rlc = 1;
  14936. } elsif ($attr{$name}{rlcAlgo} eq '3++') {
  14937. $crypt_pattern .= "(......)";
  14938. $expect_rlc = 1;
  14939. } else {
  14940. # RLC_TX but no info on RLC length
  14941. return ("RLC_TX and RLC_ALGO inconsistent", undef, undef);
  14942. }
  14943. }
  14944. # Check what length of MAC to expect
  14945. if($attr{$name}{macAlgo} eq '3') {
  14946. $crypt_pattern .= "(......)";
  14947. $mac_len = 3;
  14948. $expect_mac = 1;
  14949. } elsif ($attr{$name}{macAlgo} eq '4') {
  14950. $crypt_pattern .= "(........)";
  14951. $mac_len = 4;
  14952. $expect_mac = 1;
  14953. } else {
  14954. # According to the specification it's possible to transmit no MAC, bt we don't implement this for now
  14955. return ("Secure mode messages without MAC unsupported", undef, undef);
  14956. }
  14957. # Suffix for crypt pattern
  14958. $crypt_pattern .= '$';
  14959. # Extract byte fields from message payload
  14960. $crypt_data =~ /$crypt_pattern/;
  14961. my $data_enc = $1;
  14962. my $dataLength = length($data_enc);
  14963. return ("Telegrams with a length of more than 16 bytes are not supported", undef, undef) if ($dataLength > 32);
  14964. my $rlc;
  14965. my $mac;
  14966. if ($expect_rlc == 1 && $expect_mac == 1) {
  14967. $rlc = $2;
  14968. $mac = $3;
  14969. } elsif ($expect_rlc == 0 && $expect_mac == 1) {
  14970. $mac = $2;
  14971. }
  14972. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure RORG: $rorg DATA_ENC: $data_enc";
  14973. if ($expect_rlc == 1) {
  14974. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure RLC: $rlc";
  14975. };
  14976. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure MAC: $mac";
  14977. # TODO RLC could be transmitted with data, could not test this
  14978. #if(!defined($rlc)) {
  14979. # print "No RLC in message, using stored value\n";
  14980. # $rlc = getRLC($senderID);
  14981. #}
  14982. # Maximum RLC search window is 128
  14983. foreach my $rlc_window (0..128) {
  14984. #print "Trying RLC offset $rlc_window\n";
  14985. # Fetch stored RLC
  14986. $rlc = EnOcean_sec_getRLC($hash, "rlcRcv");
  14987. # Fetch private Key for VAES
  14988. if ($attr{$name}{keyRcv} =~ /[\dA-F]{32}/) {
  14989. $private_key = pack('H32',$attr{$name}{keyRcv});
  14990. } else {
  14991. return ("private key wrong, please teach-in the device new", undef, undef);
  14992. }
  14993. # Generate and check MAC over RORG+DATA+RLC fields
  14994. if ($mac eq EnOcean_sec_generateMAC($private_key, $rorg.$data_enc.$rlc, $mac_len)) {
  14995. #print "RLC verfified\n";
  14996. # Expand RLC to 16byte
  14997. my $rlc_expanded = pack('H32',$rlc);
  14998. # Expand data to 16byte
  14999. my $data_expanded = pack('H32',$data_enc);
  15000. # Decode data using VAES
  15001. my $data_dec = EnOcean_sec_decodeVAES($rlc_expanded, $private_key, $data_expanded);
  15002. my $data_end = unpack('H32', $data_dec);
  15003. if ($rorg eq '30') {
  15004. # Extract one nibble of data
  15005. $data_end =~ /^.(.)/;
  15006. return (undef, '32', "0" . uc($1));
  15007. } else {
  15008. $dataLength -= 2;
  15009. $data_end =~ /^(..)(.{$dataLength})/;
  15010. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure RORG: " . uc($1) . " DATA: " . uc($2);
  15011. return (undef, uc($1), uc($2));
  15012. }
  15013. }
  15014. }
  15015. # Couldn't verify or decrypt message in RLC window
  15016. return ("Can't verify or decrypt telegram", undef, undef);
  15017. }
  15018. #
  15019. sub EnOcean_sec_createTeachIn($$$$$$$$$$$)
  15020. {
  15021. my ($ctrl, $hash, $comMode, $dataEnc, $eep, $macAlgo, $rlcAlgo, $rlcTX, $secLevel, $subDef, $destinationID) = @_;
  15022. my $name = $hash->{NAME};
  15023. my ($data, $err, $response, $loglevel);
  15024. # THIS IS A BASIC IMPLEMENTATION WITH HARDCODED VALUES FOR
  15025. # THE SECURITY PARAMETERS, WILL BE CUSTOMIZABLE IN FUTURE
  15026. if ($cryptFunc == 0) {
  15027. return ("Cryptographic functions are not available", undef, 2);
  15028. }
  15029. # generate random private key
  15030. my $pKey;
  15031. for (my $i = 1; $i < 5; $i++) {
  15032. $pKey .= uc(unpack('H8', pack('L', makerandom(Size => 32, Strength => 1))));
  15033. }
  15034. $attr{$name}{keySnd} = AttrVal($name, "keySnd", $pKey);
  15035. #generate random rlc, save to fhem.cfg and update readings
  15036. my $rlc = ReadingsVal($name, ".rlcSnd", uc(unpack('H4', pack('n', makerandom(Size => 16, Strength => 1)))));
  15037. readingsSingleUpdate($hash, ".rlcSnd", $rlc, 0);
  15038. $attr{$name}{rlcSnd} = $rlc;
  15039. $attr{$name}{comMode} = AttrVal($name, "comMode", $comMode);
  15040. $attr{$name}{dataEnc} = AttrVal($name, "dataEnc", $dataEnc);
  15041. $attr{$name}{eep} = $eep;
  15042. $attr{$name}{macAlgo} = AttrVal($name, "macAlgo", $macAlgo);
  15043. $attr{$name}{manufID} = "7FF";
  15044. $attr{$name}{rlcAlgo} = AttrVal($name, "rlcAlgo", $rlcAlgo);
  15045. $attr{$name}{rlcTX} = AttrVal($name, "rlcTX", $rlcTX);
  15046. $attr{$name}{secLevel} = AttrVal($name, "secLevel", $secLevel);
  15047. if (AttrVal($name, "secMode", "") =~ m/^rcv|bidir$/) {
  15048. $attr{$name}{secMode} = "biDir";
  15049. } else {
  15050. $attr{$name}{secMode} = "snd";
  15051. }
  15052. # prepare 1st telegram
  15053. #RORG = 35, TEACH_IN_INFO_0, SLF, RLC, KEY, ID, STATUS as defined in Security_of_EnOcean_Radio_Networks.pdf page 17
  15054. #set TEACH_IN_INFO = 25 -> 0001.0101 -> IDX =0, CNT = 2, PSK = 0, TYPE = 1, INFO = 1
  15055. #set SLF = 4B -> 0100.1011 -> RLC_ALGO=16bit, RLC-TX=0, MAC-ALGO = AES3BYTE, DATA_ENC = VAES128
  15056. #save the fixed security parameters to fhem.cfg
  15057. #get first 5 bytes of private key
  15058. #data 1: 25 4B r1 r2 k1 k2 k3 k4 k5
  15059. $data = "254B" . $rlc . substr($attr{$name}{keySnd}, 0, 5*2);
  15060. EnOcean_SndRadio(undef, $hash, 1, "35", $data, $subDef, "00", $destinationID);
  15061. # prepare 2nd telegram
  15062. #RORG = 35, TEACH_IN_INFO_1, KEY, ID, STATUS as defined in Security_of_EnOcean_Radio_Networks.pdf page 17
  15063. #set TEACH_IN_INFO = 40 -> 0100.0000 -> IDX =1, CNT = 0, PSK = 0, TYPE = 0, INFO = 0
  15064. #get 2nd 11 bytes of private key
  15065. #data 2: 40 k6 k7 k8 k9 k10 k11 k12 k13 k14 k15 k16
  15066. $data = "40" . substr($attr{$name}{keySnd}, 10, 11*2);
  15067. EnOcean_SndRadio(undef, $hash, 1, "35", $data, $subDef, "00", $destinationID);
  15068. return (undef, "secure teach-in", 2);
  15069. }
  15070. #
  15071. sub EnOcean_sec_convertToSecure($$$$)
  15072. {
  15073. my ($hash, $packetType, $rorg, $data) = @_;
  15074. my ($err, $response, $loglevel);
  15075. my $name = $hash->{NAME};
  15076. my $secLevel = AttrVal($name, "secLevel", "off");
  15077. # encryption needed?
  15078. return ($err, $rorg, $data, $response, 5) if ($rorg =~ m/^F6|35$/ || $secLevel !~ m/^encapsulation|encryption$/);
  15079. return ("Cryptographic functions are not available", undef, undef, $response, 2) if ($cryptFunc == 0);
  15080. my $dataEnc = AttrVal($name, "dataEnc", undef);
  15081. my $subType = AttrVal($name, "subType", "");
  15082. # subType specific actions
  15083. if ($subType eq "switch.00" || $subType eq "windowHandle.10") {
  15084. # securemode for D2-03-00 and D2-03-10
  15085. if (hex($data) > 15) {
  15086. return("wrong data byte", $rorg, $data, $response, 2);
  15087. }
  15088. # set rorg to secure telegram
  15089. $rorg = "30";
  15090. } else {
  15091. return("Cryptographic functions for $subType not available", $rorg, $data, $response, 2);
  15092. }
  15093. #Get and update RLC
  15094. my $rlc = EnOcean_sec_getRLC($hash, "rlcSnd");
  15095. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: Got actual RLC: $rlc";
  15096. #Get key of device
  15097. my $pKey = AttrVal($name, "keySnd", undef);
  15098. return("private key not defined", $rorg, $data, $response, 2) if (!defined $pKey);
  15099. $pKey = pack('H32', $pKey);
  15100. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: key: " . AttrVal($name, "keySnd", "");
  15101. #prepare data
  15102. my $rlc_expanded = pack('H32', $rlc);
  15103. my $data_expanded = pack('H32', $data);
  15104. my $data_dec;
  15105. if ($dataEnc eq "VAES") {
  15106. $data_dec = EnOcean_sec_decodeVAES($rlc_expanded, $pKey, $data_expanded);
  15107. } else {
  15108. return("Cryptographic functions not available", $rorg, $data, $response, 2);
  15109. }
  15110. my $data_end = unpack('H32', $data_dec);
  15111. #get the correct nibble
  15112. $data_end =~ /^.(.)/;
  15113. $data_end = uc("0$1");
  15114. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: Crypted Data: $data_end";
  15115. # calc MAC
  15116. my $macAlgo = AttrVal($name, "macAlgo", undef);
  15117. return("MAC Algorithm not defined", $rorg, $data, $response, 2) if (!defined $macAlgo);
  15118. my $mac = EnOcean_sec_generateMAC($pKey, $rorg . $data_end . $rlc, $macAlgo);
  15119. # combine message
  15120. $data = $data_end . uc($mac);
  15121. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: Crypted Payload: $data";
  15122. return(undef, $rorg, $data, $response, 5);
  15123. }
  15124. #
  15125. sub
  15126. EnOcean_NumericSort
  15127. {
  15128. if ($a < $b) {
  15129. return -1;
  15130. } elsif ($a == $b) {
  15131. return 0;
  15132. } else {
  15133. return 1;
  15134. }
  15135. }
  15136. sub EnOcean_TimeDiff($)
  15137. {
  15138. my ($strTS) = @_;
  15139. if (defined $strTS) {
  15140. my $timeDiff = gettimeofday() - ($strTS eq "" ? gettimeofday() : time_str2num($strTS));
  15141. $timeDiff = 0 if ($timeDiff < 0);
  15142. return $timeDiff;
  15143. } else {
  15144. return 0;
  15145. }
  15146. }
  15147. # Undef
  15148. sub
  15149. EnOcean_Undef($$)
  15150. {
  15151. my ($hash, $name) = @_;
  15152. delete $hash->{helper};
  15153. delete $modules{EnOcean}{defptr}{uc($hash->{DEF})};
  15154. delete $modules{EnOcean}{defptr}{uc($attr{$name}{remoteID})} if (exists $attr{$name}{remoteID});
  15155. if (AttrVal($name, "remoteManagement", "off") eq "client") {
  15156. delete $hash->{RemoteClientUnlock};
  15157. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  15158. RemoveInternalTimer(\%functionHash);
  15159. }
  15160. return undef;
  15161. }
  15162. # Delete
  15163. sub
  15164. EnOcean_Delete($$)
  15165. {
  15166. my ($hash, $name) = @_;
  15167. my $logName = "FileLog_$name";
  15168. my ($count, $gplotFile, $logFile, $weblinkName, $weblinkHash);
  15169. Log3 $name, 2, "EnOcean $name deleted";
  15170. # delete FileLog device and log files
  15171. if (exists $defs{$logName}) {
  15172. $logFile = $defs{$logName}{logfile};
  15173. $logFile =~ /^(.*)($name).*\.(.*)$/;
  15174. $logFile = $1 . $2 . "*." . $3;
  15175. CommandDelete(undef, "FileLog_$name");
  15176. Log3 $name, 2, "EnOcean FileLog_$name deleted";
  15177. $count = unlink glob $logFile;
  15178. Log3 $name, 2, "EnOcean $logFile >> $count files deleted";
  15179. }
  15180. # delete SVG devices and gplot files
  15181. while (($weblinkName, $weblinkHash) = each(%defs)) {
  15182. if ($weblinkName =~ /^SVG_$name.*/) {
  15183. $gplotFile = "./www/gplot/" . $defs{$weblinkName}{GPLOTFILE} . "*.gplot";
  15184. CommandDelete(undef, $weblinkName);
  15185. Log3 $name, 2, "EnOcean $weblinkName deleted";
  15186. $count = unlink glob $gplotFile;
  15187. Log3 $name, 2, "EnOcean $gplotFile >> $count files deleted";
  15188. }
  15189. }
  15190. return undef;
  15191. }
  15192. 1;
  15193. =pod
  15194. =item device
  15195. =item summary EnOcean Gateway and Actor
  15196. =item summary_DE EnOcean Gateway und Aktor
  15197. =begin html
  15198. <a name="EnOcean"></a>
  15199. <h3>EnOcean</h3>
  15200. <ul><br>
  15201. <b>Quick Links</b>
  15202. <ul>
  15203. <li><a href="#EnOceanget">Get Commands</a></li>
  15204. <li><a href="#EnOceanset">Set Commands</a></li>
  15205. <li><a href="#EnOceanattr">Attributes</a></li>
  15206. <li><a href="#EnOceanevents">Generated Events</a></li>
  15207. </ul><br><br>
  15208. EnOcean devices are sold by numerous hardware vendors (e.g. Eltako, Peha, etc),
  15209. using the RF Protocol provided by the EnOcean Alliance.<br><br>
  15210. Depending on the function of the device an specific device profile is used, called
  15211. EnOcean Equipment Profile (EEP). The specific definition of a device is referenced by
  15212. the EEP (RORG-FUNC-TYPE). Basically four groups (RORG) will be differed, e. g.
  15213. RPS (switches), 1BS (contacts), 4BS, VLD (sensors and controller). Some manufacturers use
  15214. additional proprietary extensions. RORG MSC is not supported except for few exceptions.
  15215. Further technical information can be found at the
  15216. <a href="http://www.enocean-alliance.org/de/enocean_standard/">EnOcean Alliance</a>,
  15217. see in particular the
  15218. <a href="http://www.enocean-alliance.org/eep/">EnOcean Equipment Profiles (EEP)</a>
  15219. <br><br>
  15220. The supplementary Generic Profiles approach instead defines a language to communicate the
  15221. transmitted data types and ranges. The devices becomes self describing on their data
  15222. structures in communication. The Generic Profiles include a language definition with
  15223. a parameter selection that covers every possible measured value to be transmitted.
  15224. Therefore, the approach does not only define parameters for the value recalculation algorithm
  15225. but also includes specific signal definition. (e.g. physical units). Further technical
  15226. information can be found at the
  15227. <a href="https://www.enocean-alliance.org/fileadmin/redaktion/enocean_alliance/pdf/GenericProfiles_V1_Extract.pdf">Generic Profiles 1.0 Abstract</a>
  15228. <br><br>
  15229. Smart Acknowledge (Smart Ack) enables a special bidirectional communication. The communication is managed by a
  15230. Controller that responds to the devices telegrams with acknowledges. Smart Ack is a bidirectional communication
  15231. protocol between two actors. At least one actor must be an energy autarkic Sensor, and at least one must be a line
  15232. powered Controller (Fhem). A sensor sends its data and expects the answer telegram in a predefined very short
  15233. time slot. In this time Sensors receiver is active. For this purpose we declare a Post Master with Mail Boxes.
  15234. A Mail Box is like a letter box for a Sensor and it specific to a single sender. Telegrams from Fhem are collected
  15235. into the Mail Box. A Sensor can reclaim telegrams that are in his Mail Box.
  15236. <br><br>
  15237. Fhem recognizes a number of devices automatically. In order to teach-in, for
  15238. some devices the sending of confirmation telegrams has to be turned on.
  15239. Some equipment types and/or device models must be manually specified.
  15240. Do so using the <a href="#EnOceanattr">attributes</a>
  15241. <a href="#subType">subType</a> and <a href="#model">model</a>, see chapter
  15242. <a href="#EnOceanset">Set</a> and
  15243. <a href="#EnOceanevents">Generated events</a>. With the help of additional
  15244. <a href="#EnOceanattr">attributes</a>, the behavior of the devices can be
  15245. changed separately.
  15246. <br><br>
  15247. Fhem and the EnOcean devices must be trained with each other. To this, Fhem
  15248. must be in the learning mode, see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>,
  15249. <a href="#EnOcean_smartAck">Smart Ack Learning</a> and <a href="#TCM_learningMode">learningMode</a>.
  15250. The teach-in procedure depends on the type of the devices.
  15251. <br><br>
  15252. Switches (EEP RPS) and contacts (EEP 1BS) are recognized when receiving the first message.
  15253. Contacts can also send a teach-in telegram. Fhem not need this telegram.
  15254. Sensors (EEP 4BS) has to send a teach-in telegram. The profile-less
  15255. 4BS teach-in procedure transfers no EEP profile identifier and no manufacturer
  15256. ID. In this case Fhem does not recognize the device automatically. The proper
  15257. device type must be set manually, use the <a href="#EnOceanattr">attributes</a>
  15258. <a href="#subType">subType</a>, <a href="#manufID">manufID</a> and/or
  15259. <a href="#model">model</a>. If the EEP profile identifier and the manufacturer
  15260. ID are sent the device is clearly identifiable. Fhem automatically assigns
  15261. these devices to the correct profile.
  15262. <br><br>
  15263. 4BS devices can also be taught in special cases by using of confirmation telegrams. This method
  15264. is used for the EnOcean Tipp-Funk devices. The function is activated via the attribute [<a href="#EnOcean_teachMethod">teachMethod</a>] = confirm.<br>
  15265. For example the remote device Eltako TF100D can be learned as follows
  15266. <ul><br>
  15267. <code>define &lt;name&gt; EnOcean H5-38-08</code><br>
  15268. set TF100D in learning mode<br>
  15269. <code>set &lt;name&gt; teach</code>
  15270. </ul>
  15271. <br>
  15272. Some 4BS, VLD or MSC devices must be paired bidirectional,
  15273. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.
  15274. <br><br>
  15275. Devices that communicate encrypted, has to taught-in through specific procedures.
  15276. <br><br>
  15277. Smart Ack Learning is a futher process where devices exchange information about each
  15278. other in order to create the logical links in the EnOcean network and a Post Master Mail Box.
  15279. It can result in Learn In or Learn Out, see <a href="#EnOcean_smartAck">Smart Ack Learning</a>.
  15280. <br><br>
  15281. Fhem supports many of most common EnOcean profiles and manufacturer-specific
  15282. devices. Additional profiles and devices can be added if required.
  15283. <br><br>
  15284. In order to enable communication with EnOcean remote stations a
  15285. <a href="#TCM">TCM</a> module is necessary.
  15286. <br><br>
  15287. Please note that EnOcean repeaters also send Fhem data telegrams again.
  15288. Use the TCM <code>attr &lt;name&gt; <a href="#blockSenderID">blockSenderID</a> own</code>
  15289. to block receiving telegrams with a TCM SenderIDs.
  15290. <br><br>
  15291. <b>Observing Functions</b><br>
  15292. <ul>
  15293. Interference or overloading of the radio transmission can prevent the reception of Fhem
  15294. commands at the receiver. With the help of the observing function Fhem checks the reception
  15295. of the acknowledgment telegrams of the actuator. If within one second no acknowledgment
  15296. telegram is received, the last set command is sent again.
  15297. The set command is repeated a maximum of 5 times. The maximum number can be specified in the attribute
  15298. <a href="#EnOcean_observeCmdRepetition">observeCmdRepetition</a>.<br>
  15299. The function can only be used if the actuator immediately after the reception of
  15300. the set command sends an acknowledgment message.<br>
  15301. The observing function is turned on by the Attribute <a href="#EnOcean_observe">observe.</a>
  15302. In addition, further devices can be monitored. The names of this devices can be entered in the
  15303. <a href="#EnOcean_observeRefDev">observeRefDev</a> attribute. If additional device are specified,
  15304. the monitoring is stopped as soon as the first acknowledgment telegram of one of the devices was received (OR logic).
  15305. If the <a href="#EnOcean_observeLogic">observeLogic</a> attribute is set to "and", the monitoring is stopped when a telegram
  15306. was received by all devices (AND logic). Please note that the name of the own device has also to be entered in the
  15307. <a href="#EnOcean_observeRefDev">observeRefDev</a> if required.<br>
  15308. If the maximum number of retries is reached and still no all acknowledgment telegrams has been received, the reading
  15309. "observeFailedDev" shows the faulty devices and the command can be executed, that is stored in the
  15310. <a href="#EnOcean_observeErrorAction">observeErrorAction</a> attribute.
  15311. <br><br>
  15312. </ul>
  15313. <b>Energy Management</b><br>
  15314. <ul>
  15315. <li><a href="#demand_response">Demand Response</a> (EEP A5-37-01)</li>
  15316. Demand Response (DR) is a standard to allow utility companies to send requests for reduction in power
  15317. consumption during peak usage times. It is also used as a means to allow users to reduce overall power
  15318. comsumption as energy prices increase. The EEP was designed with a very flexible setting for the level
  15319. (0...15) as well as a default level whereby the transmitter can specify a specific level for all
  15320. controllers to use (0...100 % of either maximum or current power output, depending on the load type).
  15321. The profile also includes a timeout setting to indicate how long the DR event should last if the
  15322. DR transmitting device does not send heartbeats or subsequent new DR levels.<br>
  15323. The DR actor controls the target actuators such as switches, dimmers etc. The DR actor
  15324. is linked to the FHEM target actors via the attribute <a href="#EnOcean_demandRespRefDev">demandRespRefDev</a>.<br>
  15325. <ul>
  15326. <li>Standard actions are available for the following profiles:</li>
  15327. <ul>
  15328. <li>switch (setting the switching command for min, max by the attribute <a href="#EnOcean_demandRespMin">demandRespMin</a>,
  15329. <a href="#EnOcean_demandRespMax">demandRespMax</a>)</li>
  15330. <li>gateway/switching (on, off)</li>
  15331. <li>gateway/dimming (dim 0...100, relative to the max or current set value)</li>
  15332. <li>lightCtrl.01 (dim 0...255)</li>
  15333. <li>actuator.01 (dim 0...100)</li>
  15334. <li>roomSensorControl.01 (setpoint 0...255)</li>
  15335. <li>roomSensorControl.05 (setpoint 0...255 or nightReduction 0...5 for Eltako devices)</li>
  15336. <li>roomCtrlPanel.00 (roomCtrlMode comfort|economy)</li>
  15337. </ul>
  15338. <li>On the target actuator can be specified alternatively a freely definable command.
  15339. The command sequence is stored in the attribute <a href="#EnOcean_demandRespAction">demandRespAction</a>.
  15340. The command sequence can be designed similar to "notify". For the command sequence predefined variables can be used,
  15341. eg. $LEVEL. This actions can be executed very flexible depending on the given energy
  15342. reduction levels.
  15343. </li>
  15344. <li>Alternatively or additionally, a custom command sequence in the DR profile itself
  15345. can be stored.
  15346. </li>
  15347. </ul>
  15348. The profile has a master and slave mode.
  15349. <ul>
  15350. <li>In slave mode, demand response data telegrams received eg a control unit of the power utility,
  15351. evaluated and the corresponding commands triggered on the linked target actuators. The behavior in
  15352. slave mode can be changed by multiple attributes.
  15353. </li>
  15354. <li>In master mode, the demand response level is set by set commands and thus sends a corresponding
  15355. data telegram and the associated target actuators are controlled. The demand response control
  15356. value are specified by "level", "power", "setpoint" "max" or "min". Each other settings are
  15357. calculated proportionally. In normal operation, ie without power reduction, the control value (level)
  15358. is 15. Through the optional parameters "powerUsageScale", "randomStart", "randomEnd" and "timeout"
  15359. the control behavior can be customized. The threshold at which the reading "powerUsageLevel"
  15360. between "min" and "max" switch is specified with the attribute
  15361. <a href="#EnOcean_demandRespThreshold">demandRespThreshold</a>.
  15362. </li>
  15363. </ul>
  15364. Additional information about the profile itself can be found in the EnOcean EEP documentation.
  15365. <br><br>
  15366. </ul>
  15367. <b>Remote Management</b><br>
  15368. <ul>
  15369. Remote Management allows EnOcean devices to be configured and maintained over the air.
  15370. Thanks to Remote Management, sensors or switches IDs, for instance, can be stored or deleted from
  15371. already installed actuators or gateways which are hard to access. Remote Management also allows querying
  15372. debug information from the Remote Device and calling some manufacturer implemented functions.<br>
  15373. Remote Management is performed by the Remote Manager, operated by the actor, on the
  15374. managed Remote Device (Sensor, Gateway). The management is done through a series of
  15375. commands and responding answers. Actor sends the commands to the Remote Device. Remote
  15376. Device sends answers to the actor. The commands indicate the Remote Device what to do.
  15377. Remote Device answers if requested by the command. The commands belong to one of the
  15378. main use case categories, which are:
  15379. <ul>
  15380. <li>Security</li>
  15381. <li>Locate / indentify remote device</li>
  15382. <li>Get status</li>
  15383. <li>Extended function</li>
  15384. </ul>
  15385. The management is often done with a group of Remote Devices. Commands are sent as
  15386. addressed unicast telegrams, usually. In special cases broadcast transmission is also available.
  15387. To avoid telegram collisions the Remote Devices respond to broadcast commands with a
  15388. random delay.<br>
  15389. The Security, Locate, and Get Status options provide to the actor basic operability of Remote
  15390. management. Their purpose is to ensure the proper work of Remote Management when
  15391. operating with several Remote Devices. These functions behave in the same way on every
  15392. Remote Device. Every product that supports Remote Management provides these options.<br>
  15393. Extended functions provide the real benefit of Remote Management. They vary from Remote
  15394. Device to Remote Device. They depend on how and where the Remote Device is used.
  15395. Therefore, not every Remote Device provides every extended function. It depends on the
  15396. programmer / customer what extended functions he wants to add. There is a list of specified
  15397. commands, but the manufacturer can also add manufacturer specific extended functions. These
  15398. functions are identified by the manufacturer ID.<br>
  15399. More information can be found on the <a href="http://www.enocean.com">EnOcean websites</a>.<br><ber>
  15400. Fhem operates primarily as a remote manager. For tests but also a client device can be created.
  15401. <br><br>
  15402. The remote manager function must be activated for the desired device by
  15403. <ul><br>
  15404. <code>attr &lt;remote device name&gt; remote manager</code><br>
  15405. </ul>
  15406. <br><br>
  15407. The remote client device must be defined as follows<br>
  15408. <ul><br>
  15409. <code>define &lt;client name&gt; EnOcean C5-00-00</code><br>
  15410. </ul><br>
  15411. and has to by unlocked for t seconds
  15412. <ul><br>
  15413. <code>set &lt;client name&gt; unlock &lt;t/s&gt;</code><br>
  15414. </ul><br>
  15415. Only one remote management client device should be defined.<br><br>
  15416. For security reasons the remote management commands can only be accessed in the unlock
  15417. period. The period can be entered in two cases:
  15418. <ul>
  15419. <li>Within 30min after device power-up if no CODE is set</li>
  15420. <li>Within 30min after an unlock command with a correct 32bit security code is received</li>
  15421. </ul>
  15422. The unlock/lock period can be accessed only with the security code. The security code can be
  15423. set whenever the Remote Device accepts remote management commands.<br>
  15424. When the Remote Device is locked it does not respond to any command, but unlock and ping.
  15425. When a wrong security code is received the Remote Device does not process unlock commands
  15426. for a security period of 30 seconds.<br>
  15427. Security code=0x000000 is the default value and has to be interpreted as: no CODE has been
  15428. set. The actor can also set the security code to 0x000000 from a previously set value. If no
  15429. security code is set, unlock after the unlock period is not processed. Only ping will be
  15430. processed. Remote Management is not available until next power up. 0xFFFFFFFF is reserved
  15431. and can not be used as security code.<br><br>
  15432. To administrate a remote device whose Remote ID must be known. The Remote ID can be determined
  15433. as follows:
  15434. <ul><br>
  15435. <code>attr &lt;name&gt; remote manager</code><br>
  15436. power-up the remote device<br>
  15437. <code>get &lt;name&gt; remoteID</code><br><br>
  15438. </ul>
  15439. All commands are described in the remote management chapters of the <a href="#EnOcean_remoteSet">set</a>-
  15440. and <a href="#EnOcean_remoteGet">get</a>-commands.<br><br>
  15441. The Remote Management Function is configured using the following attributes:<br>
  15442. <ul>
  15443. <li><a href="#EnOcean_remoteCode">remoteCode</a></li>
  15444. <li><a href="#EnOcean_remoteEEP">remoteEEP</a></li>
  15445. <li><a href="#EnOcean_remoteID">remoteID</a></li>
  15446. <li><a href="#EnOcean_remoteManagement">remoteManagement</a></li>
  15447. <li><a href="#EnOcean_remoteManufID">remoteManufID</a></li>
  15448. </ul><br>
  15449. The content of events is described in the chapter <a href="#EnOcean_remoteEvents">Remote Management Events</a><br><br>.
  15450. The following extended functions are supported:
  15451. <ul>
  15452. <li>210:remoteLinkTableInfo</li>
  15453. <li>211:remoteLinkTable</li>
  15454. <li>212:remoteLinkTable</li>
  15455. <li>213:remoteLinkTableGP</li>
  15456. <li>214:remoteLinkTableGP</li>
  15457. <li>220:remoteLearnMode</li>
  15458. <li>221:remoteTeach</li>
  15459. <li>224:remoteReset</li>
  15460. <li>225:remoteRLT</li>
  15461. <li>226:remoteApplyChanges</li>
  15462. <li>227:remoteProductID</li>
  15463. <li>230:remoteDevCfg</li>
  15464. <li>231:remoteDevCfg</li>
  15465. <li>232:remoteLinkCfg</li>
  15466. <li>233:remoteLinkCfg</li>
  15467. <li>240:remoteAck</li>
  15468. <li>250:remoteRepeater</li>
  15469. <li>251:remoteRepeater</li>
  15470. <li>252:remoteRepeaterFilter</li>
  15471. </ul>
  15472. <br><br>
  15473. </ul>
  15474. <b>Radio Link Test</b><br>
  15475. <ul>
  15476. Units supporting the Radio Link Test (RLT) shall offer a functionality that allows for radio link testing between them
  15477. (Position A to Position B, point-to-point only). Fhem support at least 1BS and 4BS test messages. When two units
  15478. perform radio link testing one unit needs to act in a mode called RLT Master and the other unit needs to act in
  15479. a mode called RLT Slave. Fhem acts as RLT Master (subType radioLinkTest).<br>
  15480. The Radio Link Test device must be defined as follows<br>
  15481. <ul><br>
  15482. <code>define &lt;name&gt; EnOcean A5-3F-00</code><br>
  15483. </ul><br>
  15484. and has to by activated
  15485. <ul><br>
  15486. <code>set &lt;name&gt; standby</code><br>
  15487. </ul><br>
  15488. Alternatively, the device can also be created automatically by autocreate. Only one RLT device may be defined in FHEM.<br>
  15489. After activation the RLT Master listens for RLT Query messages. On reception of at least one RLT Query messsage the
  15490. RLT Master responds and starts transmission of RLT MasterTest messages. After that the RLT Master awaits the response
  15491. from the RLT Slave.<br>
  15492. A radio link test communication consits of a minimum of 16 and a maximum of 256 RLT MasterTest messages. When the
  15493. radio link test communication is completed the RLT Master gets deactivated automatically. The test results can be
  15494. found in the log file.
  15495. <br><br>
  15496. </ul>
  15497. <b>Security features</b><br>
  15498. <ul>
  15499. The receiving and sending of encrypted messages is supported. This module currently allows the secure operating mode of PTM 215
  15500. based switches.<br>
  15501. To receive secured telegrams, you first have to start the teach in mode via<br><br>
  15502. <code>set &lt;IODev&gt; teach &lt;t/s&gt;</code><br><br>
  15503. and then doing the following on the PTM 215 module:<br>
  15504. <ul>
  15505. <li>Remove the switch cover of the module</li>
  15506. <li>Press both buttons of one rocker side (A0 & A1 or B0 & B1)</li>
  15507. <li>While keeping the buttons pressed actuate the energy bow twice.</li><br>
  15508. </ul>
  15509. This generates two teach-in telegrams which create a Fhem device with the subType "switch.00" and synchronize the Fhem with
  15510. the PTM 215. Both the Fhem and the PTM 215 now maintain a counter which is used to generate a rolling code encryption scheme.
  15511. Also during teach-in, a private key is transmitted to the Fhem. The counter value is allowed to desynchronize for a maximum of
  15512. 128 counts, to allow compensating for missed telegrams, if this value is crossed you need to teach-in the PTM 215 again. Also
  15513. if your Fhem installation gets erased including the state information, you need to teach in the PTM 215 modules again (which
  15514. you would need to do anyway).<br><br>
  15515. To send secured telegrams, you first have send a secure teach-in to the remode device<br><br>
  15516. <ul>
  15517. <code>set &lt;name&gt; teachInSec</code><br><br>
  15518. </ul>
  15519. As for the security of this solution, if someone manages to capture the teach-in telegrams, he can extract the private key,
  15520. so the added security isn't perfect but relies on the fact, that none listens to you setting up your installation.
  15521. <br><br>
  15522. The cryptographic functions need the additional Perl modules Crypt/Rijndael and Crypt/Random. The module must be installed manually.
  15523. With the help of CPAN at the operating system level, for example,<br><br>
  15524. <ul>
  15525. <code>/usr/bin/perl -MCPAN -e 'install Crypt::Rijndael'</code><br>
  15526. <code>/usr/bin/perl -MCPAN -e 'install Crypt::Random'</code>
  15527. </ul>
  15528. <br><br>
  15529. </ul>
  15530. <a name="EnOceandefine"></a>
  15531. <b>Define</b>
  15532. <ul>
  15533. <code>define &lt;name&gt; EnOcean &lt;DEF&gt; [&lt;EEP&gt;]|getNextID|&lt;EEP&gt;</code>
  15534. <br><br>
  15535. Define an EnOcean device, connected via a <a href="#TCM">TCM</a> modul. The
  15536. &lt;DEF&gt; is the SenderID/DestinationID of the device (8 digit hex number), for example
  15537. <ul><br>
  15538. <code>define switch1 EnOcean FFC54500</code><br>
  15539. </ul><br>
  15540. In order to control devices, you cannot reuse the SenderIDs/
  15541. DestinationID of other devices (like remotes), instead you have to create
  15542. your own, which must be in the allowed SenderID range of the underlying Fhem
  15543. IO device, see <a href="#TCM">TCM</a> BaseID, LastID. For this first query the
  15544. <a href="#TCM">TCM</a> with the <code>get &lt;tcm&gt; baseID</code> command
  15545. for the BaseID. You can use up to 128 IDs starting with the BaseID shown there.
  15546. If you are using an Fhem SenderID outside of the allowed range, you will see an
  15547. ERR_ID_RANGE message in the Fhem log.<br>
  15548. FHEM can assign a free SenderID alternatively, for example
  15549. <ul><br>
  15550. <code>define switch1 EnOcean getNextID</code><br>
  15551. </ul><br>
  15552. If the EEP is known, the appropriate device can be created with the basic parameters, for example
  15553. <ul><br>
  15554. <code>define sensor1 EnOcean FFC54500 A5-02-05</code><br>
  15555. </ul><br>
  15556. or
  15557. <ul><br>
  15558. <code>define sensor1 EnOcean A5-02-05</code><br>
  15559. </ul><br>
  15560. Inofficial EEP for special devices
  15561. <ul>
  15562. <li>G5-07-01 PioTek-Tracker<br></li>
  15563. <li>G5-10-12 Room Sensor and Control Unit [Eltako FUTH65D]<br></li>
  15564. <li>G5-38-08 Gateway, Dimming [Eltako FSG, FUD]<br></li>
  15565. <li>H5-38-08 Gateway, Dimming [Eltako TF61D, TF100D]<br></li>
  15566. <li>M5-38-08 Gateway, Switching [Eltako FSR14]<br></li>
  15567. <li>N5-38-08 Gateway, Switching [Eltako TF61L, TF61R, TF100A, TF100L]<br></li>
  15568. <li>G5-3F-7F Shutter [Eltako FSB]<br></li>
  15569. <li>H5-3F-7F Shutter [Eltako TF61J]<br></li>
  15570. <li>L6-02-01 Smoke Detector [Eltako FRW]<br></li>
  15571. <li>G5-ZZ-ZZ Light and Presence Sensor [Omnio Ratio eagle-PM101]<br></li>
  15572. <li>ZZ-ZZ-ZZ EnOcean RAW profile<br></li>
  15573. <br><br>
  15574. </ul>
  15575. The <a href="#autocreate">autocreate</a> module may help you if the actor or sensor send
  15576. acknowledge messages or teach-in telegrams. In order to control this devices e. g. switches with
  15577. additional SenderIDs you can use the attributes <a href="#subDef">subDef</a>,
  15578. <a href="#subDef0">subDef0</a> and <a href="#subDefI">subDefI</a>.<br>
  15579. Fhem communicates unicast, if bidirectional 4BS or UTE teach-in is used, see
  15580. <a href="#EnOcean_teach-in"> Bidirectional Teach-In / Teach-Out</a>. In this case
  15581. Fhem send unicast telegrams with its SenderID and the DestinationID of the device.
  15582. <br><br>
  15583. </ul>
  15584. <a name="EnOceaninternals"></a>
  15585. <b>Internals</b>
  15586. <ul>
  15587. <li>DEF: 0000000 ... FFFFFFFF|&lt;EEP&gt;<br>
  15588. EnOcean DestinationID or SenderID<br>
  15589. If the attributes subDef* are set, this values are used as EnOcean SenderID.<br>
  15590. For an existing device, the device can be re-parameterized by entering the EEP.<br>
  15591. </li>
  15592. <li>&lt;IODev&gt;_DestinationID: 0000000 ... FFFFFFFF<br>
  15593. Received destination address, Broadcast radio: FFFFFFFF<br>
  15594. </li>
  15595. <li>&lt;IODev&gt;_RSSI: LP/dBm<br>
  15596. Received signal strength indication (best value of all received subtelegrams)<br>
  15597. </li>
  15598. <li>&lt;IODev&gt;_ReceivingQuality: excellent|good|bad<br>
  15599. excellent: RSSI >= -76 dBm (internal standard antenna sufficiently)<br>
  15600. good: RSSI < -76 dBm and RSSI >= -87 dBm (good antenna necessary)<br>
  15601. bad: RSSI < -87 dBm (repeater required)<br>
  15602. </li>
  15603. <li>&lt;IODev&gt;_RepeatingCounter: 0...2<br>
  15604. Number of forwardings by repeaters<br>
  15605. </li>
  15606. <br><br>
  15607. </ul>
  15608. <a name="EnOceanset"></a>
  15609. <b>Set</b>
  15610. <ul>
  15611. <li><a name="EnOcean_teach-in">Teach-In / Teach-Out</a>
  15612. <ul>
  15613. <li>Teach-in remote devices</li>
  15614. <br>
  15615. <code>set &lt;IODev&gt; teach &lt;t/s&gt;</code>
  15616. <br><br>
  15617. Set Fhem in the learning mode.<br>
  15618. A device, which is then also put in this state is to paired with
  15619. Fhem. Bidirectional Teach-In / Teach-Out is used for some 4BS, VLD and MSC devices,
  15620. e. g. EEP 4BS, RORG A5-20-01 (Battery Powered Actuator).<br>
  15621. Bidirectional Teach-In for 4BS, UTE and Generic Profiles are supported.<br>
  15622. <code>IODev</code> is the name of the TCM Module.<br>
  15623. <code>t/s</code> is the time for the learning period.
  15624. <br><br>
  15625. Types of learning modes see <a href="#TCM_learningMode">learningMode</a>
  15626. <br><br>
  15627. Example:
  15628. <ul><code>set TCM_0 teach 600</code></ul>
  15629. <br>
  15630. <li>RPS profiles Teach-In (switches)</li>
  15631. <br>
  15632. <code>set &lt;name&gt; A0|AI|B0|BI|C0|CI|D0|DI</code>
  15633. <br><br>
  15634. Send teach-in telegram to remote device.
  15635. <br><br>
  15636. <li>1BS profiles Teach-In (contact)</li>
  15637. <br>
  15638. <code>set &lt;name&gt; teach</code>
  15639. <br><br>
  15640. Send teach-in telegram to remote device.
  15641. <br><br>
  15642. <li>4BS profiles Teach-In (sensors, dimmer, room controller etc.)</li>
  15643. <br>
  15644. <code>set &lt;name&gt; teach</code>
  15645. <br><br>
  15646. Send teach-in telegram to remote device.<br>
  15647. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15648. is assigned automatically.
  15649. <br><br>
  15650. <li>UTE - Universal Uni- and Bidirectional Teach-In</li>
  15651. <br>
  15652. <code>set &lt;name&gt; teachIn|teachOut</code>
  15653. <br><br>
  15654. Send teach-in telegram to remote device.<br>
  15655. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15656. is assigned automatically.
  15657. <br><br>
  15658. <li>Generic Profiles Teach-In</li>
  15659. <br>
  15660. <code>set &lt;name&gt; teachIn|teachOut</code>
  15661. <br><br>
  15662. Send teach-in telegram to remote device.<br>
  15663. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15664. is assigned automatically.
  15665. <br><br>
  15666. <li>Secure Devices Teach-In</li>
  15667. <br>
  15668. <code>set &lt;name&gt; teachInSec</code>
  15669. <br><br>
  15670. Secure teach-in to the remode device.<br>
  15671. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15672. is assigned automatically.
  15673. <br><br>
  15674. </ul>
  15675. </li>
  15676. <li><a name="EnOcean_smartAck">Smart Ack Learning</a>
  15677. <ul>
  15678. <li>Teach-in remote Smart Ack devices</li>
  15679. <br>
  15680. <code>set &lt;IODev&gt; smartAckLearn &lt;t/s&gt;</code>
  15681. <br><br>
  15682. Set Fhem in the Smart Ack learning mode.<br>
  15683. The post master fuctionality must be activated using the command <code>smartAckMailboxMax</code> in advance.<br>
  15684. The simple learnmode is supported, see <a href="#TCM_smartAckLearnMode">smartAckLearnMode</a><br>
  15685. A device, which is then also put in this state is to paired with
  15686. Fhem. Bidirectional learn in for 4BS, UTE and Generic Profiles are supported.<br>
  15687. <code>IODev</code> is the name of the TCM Module.<br>
  15688. <code>t/s</code> is the time for the learning period.
  15689. <br><br>
  15690. Example:
  15691. <ul><code>set TCM_0 smartAckLearn 600</code></ul>
  15692. <br>
  15693. </ul>
  15694. </li>
  15695. <li><a name="EnOcean_remoteSet">Remote Management</a>
  15696. <ul>
  15697. <code>set &lt;name&gt; &lt;value&gt;</code>
  15698. <br><br>
  15699. where <code>value</code> is
  15700. <li>remoteAction<br>
  15701. sent action command to perfoms an action, depending on the functionality of the device</li>
  15702. <li>remoteApplyChanges devCfg|linkTable|no_change<br>
  15703. apply changes</li>
  15704. <li>remoteDevCfg &lt;index&gt; &lt;value&gt;<br>
  15705. set configuration</li>
  15706. <li>remoteLinkTable in|out &lt;index&gt; &lt;ID&gt; &lt;EEP&gt; &lt;channel&gt;<br>
  15707. set link table content</li>
  15708. <li>remoteLinkCfg in|out &lt;index&gt; &lt;data index&gt; &lt;value&gt;<br>
  15709. set link based configuration</li>
  15710. <li>remoteLinkTableGP in|out &lt;index&gt; &lt;GP channel description&gt;<br>
  15711. set link table content</li>
  15712. <li>remoteLock<br>
  15713. locks the remote device or local client</li>
  15714. <li>remoteLearnMode in|out|off &lt;index&gt;<br>
  15715. initiate remote learn-in or learn-out of inbound index</li>
  15716. <li>remoteReset devCfg|linkTableIn|linkTableOut|no_change<br>
  15717. reset to defaults</li>
  15718. <li>remoteRLT on|off &lt;number of RLT slaves&gt;<br>
  15719. reset to defaults</li>
  15720. <li>remoteRepeater on|off|filter &lt;level&gt; &lt;filter structure&gt;<br>
  15721. set repeater functions</li>
  15722. <li>remoteRepeaterFilter apply|block|delete|deleteAll destinationID|sourceID|rorg|rssi &lt;filter value&gt;<br>
  15723. set repeater functions</li>
  15724. <li>remoteSetCode<br>
  15725. set the remote security code</li>
  15726. <li>remoteTeach &lt;channel&gt;<br>
  15727. request teach-in telegram from channel 00..FF</li>
  15728. <li>remoteUnlock [1...1800]<br>
  15729. unlocks the remote device or local client<br>
  15730. The unlock period can be set in the client mode between 1s and 1800 s.</li>
  15731. <br>
  15732. [&lt;channel&gt;] = 00...FF<br>
  15733. [&lt;EEP&gt;] = &lt;RORG&gt;-&lt;function&gt;-&lt;type&gt;<br>
  15734. [&lt;filter structure&gt;] = AND|OR<br>
  15735. [&lt;filter value&gt;] = &lt;destinationID&gt;|&lt;sourceID&gt;|&lt;RORG&gt;|&lt;LP/dBm&gt;<br>
  15736. [&lt;GP channel description&gt;] = &lt;name of channel 00&gt;:&lt;O|I&gt;:&lt;channel type&gt;:&lt;signal type&gt;:&lt;value type&gt;[:&lt;resolution&gt;[:&lt;engineering min&gt;:&lt;scaling min&gt;:&lt;engineering max&gt;:&lt;scaling max&gt;]]<br>
  15737. [&lt;ID&gt;] = 00000001...FFFFFFFE<br>
  15738. [&lt;index&gt;] = 00...FF<br>
  15739. [&lt;number of RLT slaves&gt;] = 01..7F<br>
  15740. [&lt;level&gt;] = 1|2<br>
  15741. [&lt;data index&gt;] = 0000...FFFF<br>
  15742. [&lt;value&gt;] = n x 00...FF<br>
  15743. </ul><br>
  15744. </li><br>
  15745. <li>Switch, Pushbutton Switch (EEP F6-02-01 ... F6-03-02)<br>
  15746. RORG RPS [default subType]
  15747. <ul>
  15748. <code>set &lt;name&gt; &lt;value&gt;</code>
  15749. <br><br>
  15750. where <code>value</code> is one of A0, AI, B0, BI, C0, CI, D0, DI,
  15751. combinations of these and released. First and second action can be sent
  15752. simultaneously. Separate first and second action with a comma.<br>
  15753. In fact we are trying to emulate a PT200 type remote.<br>
  15754. If you define an <a href="#eventMap">eventMap</a> attribute with on/off,
  15755. then you will be able to easily set the device from the <a
  15756. href="#FHEMWEB">WEB</a> frontend.<br>
  15757. <a href="#setExtensions">set extensions</a> are supported, if the corresponding
  15758. <a href="#eventMap">eventMap</a> specifies the <code>on</code> and <code>off</code>
  15759. mappings, for example <code>attr <name> eventMap on-till:on-till AI:on A0:off</code>.<br>
  15760. With the help of additional <a href="#EnOceanattr">attributes</a>, the
  15761. behavior of the devices can be adapt.<br>
  15762. The attr subType must be switch. This is done if the device was created by autocreate.
  15763. <br><br>
  15764. Example:
  15765. <ul><code>
  15766. set switch1 BI<br>
  15767. set switch1 B0,CI<br>
  15768. attr eventMap BI:on B0:off<br>
  15769. set switch1 on<br>
  15770. </code></ul><br>
  15771. </ul>
  15772. </li>
  15773. <li>Staircase off-delay timer (EEP F6-02-01 ... F6-02-02)<br>
  15774. RORG RPS [Eltako FTN14, tested with Eltako FTN14 only]<br>
  15775. <ul>
  15776. <code>set &lt;name&gt; &lt;value&gt;</code>
  15777. <br><br>
  15778. where <code>value</code> is
  15779. <li>on<br>
  15780. issue switch on command</li>
  15781. <li>released<br>
  15782. start timer</li>
  15783. </ul><br>
  15784. Set attr eventMap to B0:on BI:off, attr subType to switch, attr
  15785. webCmd to on:released and if needed attr switchMode to pushbutton manually.<br>
  15786. The attr subType must be switch. This is done if the device was created by autocreate.<br>
  15787. Use the sensor type "Schalter" for Eltako devices. The Staircase
  15788. off-delay timer is switched on when pressing "on" and the time will be started
  15789. when pressing "released". "released" immediately after "on" is sent if
  15790. the attr switchMode is set to "pushbutton".
  15791. </li>
  15792. <br><br>
  15793. <li>Pushbutton Switch (EEP D2-03-00)<br>
  15794. RORG VLD [EnOcean PTM 215 Modul]
  15795. <ul>
  15796. <code>set &lt;name&gt; &lt;value&gt;</code>
  15797. <br><br>
  15798. where <code>value</code> is
  15799. <li>teachIn<br>
  15800. initiate UTE teach-in</li>
  15801. <li>teachInSec<br>
  15802. initiate secure teach-in</li>
  15803. <li>teachOut<br>
  15804. initiate UTE teach-out</li>
  15805. <li>A0|AI|B0|BI<br>
  15806. issue switch command</li>
  15807. <li>A0,B0|A0,AI|AI,B0|AI,BI<br>
  15808. issue switch command</li>
  15809. <li>pressed<br>
  15810. energy bow pressed</li>
  15811. <li>pressed34<br>
  15812. 3 or 4 buttons and energy bow pressed</li>
  15813. <li>released<br>
  15814. energy bow released</li><br>
  15815. </ul>
  15816. First and second action can be sent simultaneously. Separate first and second action with a comma.<br>
  15817. If you define an <a href="#eventMap">eventMap</a> attribute with on/off,
  15818. then you will be able to easily set the device from the <a href="#FHEMWEB">WEB</a> frontend.<br>
  15819. <a href="#setExtensions">set extensions</a> are supported, if the corresponding
  15820. <a href="#eventMap">eventMap</a> specifies the <code>on</code> and <code>off</code>
  15821. mappings, for example <code>attr <name> eventMap on-till:on-till AI:on A0:off</code>.<br>
  15822. If <a href="#EnOcean_comMode">comMode</a> is set to biDir the device can be controlled bidirectionally.<br>
  15823. With the help of additional <a href="#EnOceanattr">attributes</a>, the behavior of the devices can be adapt.<br>
  15824. The attr subType must be switch.00. This is done if the device was created by autocreate.
  15825. <br><br>
  15826. <ul>
  15827. Example:
  15828. <ul><code>
  15829. set switch1 BI<br>
  15830. set switch1 B0,CI<br>
  15831. attr eventMap BI:on B0:off<br>
  15832. set switch1 on<br>
  15833. </code></ul><br>
  15834. </ul>
  15835. </li>
  15836. <li>Single Input Contact, Door/Window Contact (EEP D5-00-01)<br>
  15837. RORG 1BS [tested with Eltako FSR14]
  15838. <ul>
  15839. <code>set &lt;name&gt; &lt;value&gt;</code>
  15840. <br><br>
  15841. where <code>value</code> is
  15842. <li>closed<br>
  15843. issue closed command</li>
  15844. <li>open<br>
  15845. issue open command</li>
  15846. <li>teach<br>
  15847. initiate teach-in</li>
  15848. </ul><br>
  15849. The attr subType must be contact. The attribute must be set manually.
  15850. </li><br><br>
  15851. <li>Room Sensor and Control Unit (EEP A5-10-02)<br>
  15852. [Thermokon SR04 PTS]<br>
  15853. <ul>
  15854. <code>set &lt;name&gt; &lt;value&gt;</code>
  15855. <br><br>
  15856. where <code>value</code> is
  15857. <li>teach<br>
  15858. initiate teach-in</li>
  15859. <li>setpoint [0 ... 255]<br>
  15860. Set the actuator to the specifed setpoint.</li>
  15861. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15862. Set the actuator to the scaled setpoint.</li>
  15863. <li>fanStage [auto|0|1|2|3]<br>
  15864. Set fan stage</li>
  15865. <li>switch [on|off]<br>
  15866. Set switch</li>
  15867. </ul><br>
  15868. The actual temperature will be taken from the temperature reported by
  15869. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15870. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15871. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15872. command is sent when the reference device is updated.<br>
  15873. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  15874. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  15875. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled setting
  15876. setpointScaled.<br>
  15877. The attr subType must be roomSensorControl.05. The attribute must be set manually.
  15878. </li>
  15879. <br><br>
  15880. <li>Room Sensor and Control Unit (EEP A5-10-03)<br>
  15881. [used for IntesisBox PA-AC-ENO-1i]<br>
  15882. <ul>
  15883. <code>set &lt;name&gt; &lt;value&gt;</code>
  15884. <br><br>
  15885. where <code>value</code> is
  15886. <li>teach<br>
  15887. initiate teach-in</li>
  15888. <li>setpoint [0 ... 255]<br>
  15889. Set the actuator to the specifed setpoint.</li>
  15890. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15891. Set the actuator to the scaled setpoint.</li>
  15892. <li>fanStage [auto|0|1|2|3]<br>
  15893. Set fan stage</li>
  15894. <li>switch [on|off]<br>
  15895. Set switch</li>
  15896. </ul><br>
  15897. The actual temperature will be taken from the temperature reported by
  15898. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15899. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15900. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15901. command is sent when the reference device is updated.<br>
  15902. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  15903. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  15904. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled setting
  15905. setpointScaled.<br>
  15906. The attr subType must be roomSensorControl.05 and attr manufID must be 019. The attribute must be set manually.
  15907. </li>
  15908. <br><br>
  15909. <li>Room Sensor and Control Unit (A5-10-06 plus night reduction)<br>
  15910. [Eltako FTR65DS, FTR65HS]<br>
  15911. <ul>
  15912. <code>set &lt;name&gt; &lt;value&gt;</code>
  15913. <br><br>
  15914. where <code>value</code> is
  15915. <li>teach<br>
  15916. initiate teach-in</li>
  15917. <li>desired-temp [t/&#176C [lock|unlock]]<br>
  15918. Set the desired temperature.</li>
  15919. <li>nightReduction [t/K [lock|unlock]]<br>
  15920. Set night reduction</li>
  15921. <li>setpointTemp [t/&#176C [lock|unlock]]<br>
  15922. Set the desired temperature</li>
  15923. </ul><br>
  15924. The actual temperature will be taken from the temperature reported by
  15925. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15926. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15927. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpointTemp
  15928. command is sent when the reference device is updated.<br>
  15929. This profil can be used with a further Room Sensor and Control Unit Eltako FTR55*
  15930. to control a heating/cooling relay FHK12, FHK14 or FHK61. If Fhem and FTR55*
  15931. is teached in, the temperature control of the FTR55* can be either blocked
  15932. or to a setpoint deviation of +/- 3 K be limited. For this use the optional parameter
  15933. [block] = lock|unlock, unlock is default.<br>
  15934. The attr subType must be roomSensorControl.05 and attr manufID must be 00D.
  15935. The attributes must be set manually.
  15936. </li>
  15937. <br><br>
  15938. <li>Room Sensor and Control Unit (EEP A5-10-10)<br>
  15939. [Thermokon SR04 * rH, Thanos SR *]<br>
  15940. <ul>
  15941. <code>set &lt;name&gt; &lt;value&gt;</code>
  15942. <br><br>
  15943. where <code>value</code> is
  15944. <li>teach<br>
  15945. initiate teach-in</li>
  15946. <li>setpoint [0 ... 255]<br>
  15947. Set the actuator to the specifed setpoint.</li>
  15948. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15949. Set the actuator to the scaled setpoint.</li>
  15950. <li>switch [on|off]<br>
  15951. Set switch</li>
  15952. </ul><br>
  15953. The actual temperature will be taken from the temperature reported by
  15954. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15955. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15956. The actual humidity will be taken from the humidity reported by
  15957. a humidity reference device <a href="#EnOcean_humidityRefDev">humidityRefDev</a>
  15958. primarily or from the attribute <a href="#EnOcean_humidity">humidity</a> if it is set.<br>
  15959. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15960. command is sent when the reference device is updated.<br>
  15961. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  15962. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  15963. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled setting
  15964. setpointScaled.<br>
  15965. The attr subType must be roomSensorControl.01. The attribute must be set manually.
  15966. </li>
  15967. <br><br>
  15968. <li>Room Sensor and Control Unit (EEP A5-10-12)<br>
  15969. [Eltako FUTH65D]<br>
  15970. <ul>
  15971. <code>set &lt;name&gt; &lt;value&gt;</code>
  15972. <br><br>
  15973. where <code>value</code> is
  15974. <li>teach<br>
  15975. initiate teach-in</li>
  15976. <li>setpoint [0 ... 255]<br>
  15977. Set the actuator to the specifed setpoint.</li>
  15978. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15979. Set the actuator to the scaled setpoint.</li>
  15980. <li>switch [on|off]<br>
  15981. Set switch</li>
  15982. </ul><br>
  15983. The actual temperature will be taken from the temperature reported by
  15984. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15985. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15986. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15987. command is sent when the reference device is updated.<br>
  15988. The attr subType must be roomSensorControl.01 and attr manufID must be 00D. The attribute must be set manually.
  15989. </li>
  15990. <br><br>
  15991. <li>Battery Powered Actuator (EEP A5-20-01)<br>
  15992. [Kieback&Peter MD15-FTL-xx]<br>
  15993. <ul>
  15994. <code>set &lt;name&gt; &lt;value&gt;</code>
  15995. <br><br>
  15996. where <code>value</code> is
  15997. <li>setpoint setpoint/%<br>
  15998. Set the actuator to the specifed setpoint (0...100). The setpoint can also be set by the
  15999. <a href="#EnOcean_setpointRefDev">setpointRefDev</a> device if it is set.</li>
  16000. <li>setpointTemp t/&#176C<br>
  16001. Set the actuator to the specifed temperature setpoint. The temperature setpoint can also be set by the
  16002. <a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a> device if it is set.<br>
  16003. The FHEM PID controller calculates the actuator setpoint based on the temperature setpoint. The controller's
  16004. operation can be set via the PID parameters <a href="#EnOcean_pidFactor_P">pidFactor_P</a>,
  16005. <a href="#EnOcean_pidFactor_I">pidFactor_I</a> and <a href="#EnOcean_pidFactor_D">pidFactor_D</a>.<br>
  16006. If the attribute pidCtrl is set to off, the PI controller of the actuator is used (selfCtrl mode). Please
  16007. read the instruction manual of the device, whether the device has an internal PI controller.<br></li>
  16008. <li>runInit<br>
  16009. Maintenance Mode: Run init sequence</li>
  16010. <li>valveOpens<br>
  16011. Maintenance Mode: Valve opens<br>
  16012. After the valveOpens command, the valve remains open permanently and can no longer be controlled by Fhem.
  16013. By pressing the button on the device itself, the actuator is returned to its normal operating state.</li>
  16014. <li>valveCloses<br>
  16015. Maintenance Mode: Valve closes</li>
  16016. </ul><br>
  16017. The Heating Radiator Actuating Drive is configured using the following attributes:<br>
  16018. <ul>
  16019. <li><a href="#EnOcean_pidActorCallBeforeSetting">pidActorCallBeforeSetting</a></li>
  16020. <li><a href="#EnOcean_pidActorErrorAction">pidActorErrorAction</a></li>
  16021. <li><a href="#EnOcean_pidActorErrorPos">pidActorErrorPos</a></li>
  16022. <li><a href="#EnOcean_pidActorLimitLower">pidActorLimitLower</a></li>
  16023. <li><a href="#EnOcean_pidActorLimitUpper">pidActorLimitUpper</a></li>
  16024. <li><a href="#EnOcean_pidCtrl">pidCtrl</a></li>
  16025. <li><a href="#EnOcean_pidDeltaTreshold">pidDeltaTreshold</a></li>
  16026. <li><a href="#EnOcean_pidFactor_P">pidFactor_P</a></li>
  16027. <li><a href="#EnOcean_pidFactor_I">pidFactor_I</a></li>
  16028. <li><a href="#EnOcean_pidFactor_D">pidFactor_D</a></li>
  16029. <li><a href="#EnOcean_pidIPortionCallBeforeSetting">pidIPortionCallBeforeSetting</a></li>
  16030. <li><a href="#EnOcean_pidSensorTimeout">pidSensorTimeout</a></li>
  16031. <li><a href="#EnOcean_rcvRespAction">rcvRespAction</a></li>
  16032. <li><a href="#EnOcean_setpointRefDev">setpointRefDev</a></li>
  16033. <li><a href="#EnOcean_setpointSummerMode">setpointSummerMode</a></li>
  16034. <li><a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a></li>
  16035. <li><a href="#temperatureRefDev">temperatureRefDev</a></li>
  16036. <li><a href="#EnOcean_summerMode">summerMode</a></li>
  16037. </ul>
  16038. The actual temperature will be reported by the Heating Radiator Actuating Drive or by the
  16039. <a href="#temperatureRefDev">temperatureRefDev</a> if it is set. The internal temperature sensor
  16040. of the Micropelt iTRV is not suitable as an actual temperature value for the PID controller.
  16041. An external room thermostat is required.<br>
  16042. The attr event-on-change-reading .* shut not by set. The PID controller expects periodic events.
  16043. If these are missing, a communication alarm is signaled.<br>
  16044. The attr subType must be hvac.01. This is done if the device was
  16045. created by autocreate. To control the device, it must be bidirectional paired,
  16046. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.<br>
  16047. The command is not sent until the device wakes up and sends a message, usually
  16048. every 10 minutes.
  16049. </li>
  16050. <br><br>
  16051. <li>Heating Radiator Actuating Drive (EEP A5-20-04)<br>
  16052. [Holter SmartDrive MX]<br>
  16053. <ul>
  16054. <code>set &lt;name&gt; &lt;value&gt;</code>
  16055. <br><br>
  16056. where <code>value</code> is
  16057. <li>setpoint setpoint/%<br>
  16058. Set the actuator to the specifed setpoint (0...100). The setpoint can also be set by the
  16059. <a href="#EnOcean_setpointRefDev">setpointRefDev</a> device if it is set.</li>
  16060. <li>setpointTemp t/&#176C<br>
  16061. Set the actuator to the specifed temperature setpoint. The temperature setpoint can also be set by the
  16062. <a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a> device if it is set.<br>
  16063. The FHEM PID controller calculates the actuator setpoint based on the temperature setpoint. The controller's
  16064. operation can be set via the PID parameters <a href="#EnOcean_pidFactor_P">pidFactor_P</a>,
  16065. <a href="#EnOcean_pidFactor_I">pidFactor_I</a> and <a href="#EnOcean_pidFactor_D">pidFactor_D</a>.</li>
  16066. <li>runInit<br>
  16067. Maintenance Mode: Run init sequence</li>
  16068. <li>valveOpens<br>
  16069. Maintenance Mode: Valve opens<br>
  16070. After the valveOpens command, the valve remains open permanently and can no longer be controlled by Fhem.
  16071. By pressing the button on the device itself, the actuator is returned to its normal operating state.</li>
  16072. <li>valveCloses<br>
  16073. Maintenance Mode: Valve closes</li>
  16074. </ul><br>
  16075. The Heating Radiator Actuating Drive is configured using the following attributes:<br>
  16076. <ul>
  16077. <li><a href="#EnOcean_blockKey">blockKey</a></li>
  16078. <li><a href="#EnOcean_displayOrientation">displayOrientation</a></li>
  16079. <li><a href="#EnOcean_measurementCtrl">measurementCtrl</a></li>
  16080. <li><a href="#model">model</a></li>
  16081. <li><a href="#EnOcean_pidActorCallBeforeSetting">pidActorCallBeforeSetting</a></li>
  16082. <li><a href="#EnOcean_pidActorErrorAction">pidActorErrorAction</a></li>
  16083. <li><a href="#EnOcean_pidActorErrorPos">pidActorErrorPos</a></li>
  16084. <li><a href="#EnOcean_pidActorLimitLower">pidActorLimitLower</a></li>
  16085. <li><a href="#EnOcean_pidActorLimitUpper">pidActorLimitUpper</a></li>
  16086. <li><a href="#EnOcean_pidCtrl">pidCtrl</a></li>
  16087. <li><a href="#EnOcean_pidDeltaTreshold">pidDeltaTreshold</a></li>
  16088. <li><a href="#EnOcean_pidFactor_P">pidFactor_P</a></li>
  16089. <li><a href="#EnOcean_pidFactor_I">pidFactor_I</a></li>
  16090. <li><a href="#EnOcean_pidFactor_D">pidFactor_D</a></li>
  16091. <li><a href="#EnOcean_pidIPortionCallBeforeSetting">pidIPortionCallBeforeSetting</a></li>
  16092. <li><a href="#EnOcean_pidSensorTimeout">pidSensorTimeout</a></li>
  16093. <li><a href="#EnOcean_setpointRefDev">setpointRefDev</a></li>
  16094. <li><a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a></li>
  16095. <li><a href="#temperatureRefDev">temperatureRefDev</a></li>
  16096. <li><a href="#EnOcean_summerMode">summerMode</a></li>
  16097. <li><a href="#EnOcean_wakeUpCycle">wakeUpCycle</a></li>
  16098. </ul>
  16099. The actual temperature will be reported by the Heating Radiator Actuating Drive or by the
  16100. <a href="#temperatureRefDev">temperatureRefDev</a> if it is set.<br>
  16101. The attr event-on-change-reading .* shut not by set. The PID controller expects periodic events.
  16102. If these are missing, a communication alarm is signaled.<br>
  16103. The attr subType must be hvac.04. This is done if the device was
  16104. created by autocreate. To control the device, it must be bidirectional paired,
  16105. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.<br>
  16106. The OEM version of the Holter SmartDrive MX has an internal PID controller. This function is activated by
  16107. attr <device> model Holter_OEM and attr <device> pidCtrl off.<br>
  16108. The command is not sent until the device wakes up and sends a message, usually
  16109. every 5 minutes.
  16110. </li>
  16111. <br><br>
  16112. <li>Generic HVAC Interface (EEP A5-20-10)<br>
  16113. [IntesisBox PA-AC-ENO-1i]<br>
  16114. <ul>
  16115. <code>set &lt;name&gt; &lt;value&gt;</code>
  16116. <br><br>
  16117. where <code>value</code> is
  16118. <li>ctrl auto|0...100<br>
  16119. Set control variable</li>
  16120. <li>fanSpeed auto|1...14<br>
  16121. Set fan speed</li>
  16122. <li>occupancy occupied|off|standby|unoccupied<br>
  16123. Set room occupancy</li>
  16124. <li>on<br>
  16125. Set on</li>
  16126. <li>off<br>
  16127. Set off</li>
  16128. <li>mode auto|heat|morning_warmup|cool|night_purge|precool|off|test|emergency_heat|fan_only|free_cool|ice|max_heat|eco|dehumidification|calibration|emergency_cool|emergency_stream|max_cool|hvc_load|no_load|auto_heat|auto_cool<br>
  16129. Set mode</li>
  16130. <li>teach<br>
  16131. Teach-in</li>
  16132. <li>vanePosition auto|horizontal|position_2|position_3|position_4|vertical|swing|vertical_swing|horizontal_swing|hor_vert_swing|stop_swing<br>
  16133. Set vane position</li>
  16134. </ul><br>
  16135. The attr subType must be hvac.10. This is done if the device was
  16136. created by autocreate. To control the device, it must be bidirectional paired,
  16137. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.
  16138. </li>
  16139. <br><br>
  16140. <li>Generic HVAC Interface - Error Control (EEP A5-20-11)<br>
  16141. [IntesisBox PA-AC-ENO-1i]<br>
  16142. <ul>
  16143. <code>set &lt;name&gt; &lt;value&gt;</code>
  16144. <br><br>
  16145. where <code>value</code> is
  16146. <li>externalDisable disable|enable<br>
  16147. Set external disablement</li>
  16148. <li>remoteCtrl disable|enable<br>
  16149. Dieable/enable remote controller</li>
  16150. <li>teach<br>
  16151. Teach-in</li>
  16152. <li>window closed|opened<br>
  16153. Set window state</li>
  16154. </ul><br>
  16155. The attr subType must be hvac.11. This is done if the device was
  16156. created by autocreate. To control the device, it must be bidirectional paired,
  16157. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.
  16158. </li>
  16159. <br><br>
  16160. <li>Energy management, <a name="demand_response">demand response</a> (EEP A5-37-01)<br>
  16161. demand response master commands<br>
  16162. <ul>
  16163. <code>set &lt;name&gt; &lt;value&gt;</code>
  16164. <br><br>
  16165. where <code>value</code> is
  16166. <li>level 0...15 [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16167. set demand response level</li>
  16168. <li>max [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16169. set power usage level to max</li>
  16170. <li>min [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16171. set power usage level to min</li>
  16172. <li>power power/% [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16173. set power</li>
  16174. <li>setpoint 0...255 [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16175. set setpoint</li>
  16176. <li>teach<br>
  16177. initiate teach-in</li>
  16178. </ul><br>
  16179. [&lt;powerUsageScale&gt;] = max|rel, [&lt;powerUsageScale&gt;] = max is default<br>
  16180. [&lt;randomStart&gt;] = yes|no, [&lt;randomStart&gt;] = no is default<br>
  16181. [&lt;randomEnd&gt;] = yes|no, [&lt;randomEnd&gt;] = no is default<br>
  16182. [timeout] = 0/min | 15/min ... 3825/min, [timeout] = 0 is default<br>
  16183. The attr subType must be energyManagement.01.<br>
  16184. This is done if the device was created by autocreate.<br>
  16185. </li>
  16186. <br><br>
  16187. <li><a name="Gateway">Gateway</a> (EEP A5-38-08)<br>
  16188. The Gateway profile include 7 different commands (Switching, Dimming,
  16189. Setpoint Shift, Basic Setpoint, Control variable, Fan stage, Blind Central Command).
  16190. The commands can be selected by the attribute gwCmd or command line. The attribute
  16191. entry has priority.<br>
  16192. <ul>
  16193. <code>set &lt;name&gt; &lt;value&gt;</code>
  16194. <br><br>
  16195. where <code>value</code> is
  16196. <li>&lt;gwCmd&gt; &lt;cmd&gt; [subCmd]<br>
  16197. initiate Gateway commands by command line</li>
  16198. <li>&lt;cmd&gt; [subCmd]<br>
  16199. initiate Gateway commands if attribute gwCmd is set.</li>
  16200. </ul><br>
  16201. The attr subType must be gateway. Attribute gwCmd can also be set to
  16202. switching|dimming|setpointShift|setpointBasic|controlVar|fanStage|blindCmd.<br>
  16203. This is done if the device was created by autocreate.<br>
  16204. For Eltako devices attributes must be set manually.
  16205. </li>
  16206. <br><br>
  16207. <li>Gateway (EEP A5-38-08)<br>
  16208. Switching<br>
  16209. [Eltako FLC61, FSA12, FSR14]<br>
  16210. <ul>
  16211. <code>set &lt;name&gt; &lt;value&gt;</code>
  16212. <br><br>
  16213. where <code>value</code> is
  16214. <li>teach<br>
  16215. initiate teach-in mode</li>
  16216. <li>on [lock|unlock]<br>
  16217. issue switch on command</li>
  16218. <li>off [lock|unlock]<br>
  16219. issue switch off command</li>
  16220. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16221. </ul><br>
  16222. The attr subType must be gateway and gwCmd must be switching. This is done if the device was
  16223. created by autocreate.<br>
  16224. For Eltako devices attributes must be set manually. For Eltako FSA12 attribute model must be set
  16225. to Eltako_FSA12.
  16226. </li>
  16227. <br><br>
  16228. <li>Gateway (EEP A5-38-08)<br>
  16229. Dimming<br>
  16230. [Eltako FUD12, FUD14, FUD61, FUD70, FSG14, ...]<br>
  16231. <ul>
  16232. <code>set &lt;name&gt; &lt;value&gt;</code>
  16233. <br><br>
  16234. where <code>value</code> is
  16235. <li>dim/% [rampTime/s [lock|unlock]]<br>
  16236. issue dim command</li>
  16237. <li>teach<br>
  16238. initiate teach-in mode</li>
  16239. <li>on [lock|unlock]<br>
  16240. issue switch on command</li>
  16241. <li>off [lock|unlock]<br>
  16242. issue switch off command</li>
  16243. <li>dim dim/% [rampTime/s [lock|unlock]]<br>
  16244. issue dim command</li>
  16245. <li>dimup dim/% [rampTime/s [lock|unlock]]<br>
  16246. issue dim command</li>
  16247. <li>dimdown dim/% [rampTime/s [lock|unlock]]<br>
  16248. issue dim command</li>
  16249. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16250. </ul><br>
  16251. rampTime Range: t = 1 s ... 255 s or 0 if no time specified,
  16252. for Eltako: t = 1 = fast dimming ... 255 = slow dimming or 0 = dimming speed on the dimmer used<br>
  16253. The attr subType must be gateway and gwCmd must be dimming. This is done if the device was
  16254. created by autocreate.<br>
  16255. For Eltako devices attributes must be set manually. Use the sensor type "PC/FVS" for Eltako devices.
  16256. </li>
  16257. <br><br>
  16258. <li>Gateway (EEP A5-38-08)<br>
  16259. Dimming of fluorescent lamps<br>
  16260. [Eltako FSG70, tested with Eltako FSG70 only]<br>
  16261. <ul>
  16262. <code>set &lt;name&gt; &lt;value&gt;</code>
  16263. <br><br>
  16264. where <code>value</code> is
  16265. <li>on<br>
  16266. issue switch on command</li>
  16267. <li>off<br>
  16268. issue switch off command</li>
  16269. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16270. </ul><br>
  16271. The attr subType must be gateway and gwCmd must be dimming. Set attr eventMap to B0:on BI:off,
  16272. attr subTypeSet to switch and attr switchMode to pushbutton manually.<br>
  16273. Use the sensor type "Richtungstaster" for Eltako devices.
  16274. </li>
  16275. <br><br>
  16276. <li>Gateway (EEP A5-38-08)<br>
  16277. Setpoint shift<br>
  16278. [untested]<br>
  16279. <ul>
  16280. <code>set &lt;name&gt; &lt;value&gt;</code>
  16281. <br><br>
  16282. where <code>value</code> is
  16283. <li>teach<br>
  16284. initiate teach-in mode</li>
  16285. <li>shift 1/K <br>
  16286. issue Setpoint shift</li>
  16287. </ul><br>
  16288. Shift Range: T = -12.7 K ... 12.8 K<br>
  16289. The attr subType must be gateway and gwCmd must be setpointShift.
  16290. This is done if the device was created by autocreate.<br>
  16291. </li>
  16292. <br><br>
  16293. <li>Gateway (EEP A5-38-08)<br>
  16294. Basic Setpoint<br>
  16295. [untested]<br>
  16296. <ul>
  16297. <code>set &lt;name&gt; &lt;value&gt;</code>
  16298. <br><br>
  16299. where <code>value</code> is
  16300. <li>teach<br>
  16301. initiate teach-in mode</li>
  16302. <li>basic t/&#176C<br>
  16303. issue Basic Setpoint</li>
  16304. </ul><br>
  16305. Setpoint Range: t = 0 &#176C ... 51.2 &#176C<br>
  16306. The attr subType must be gateway and gwCmd must be setpointBasic.
  16307. This is done if the device was created by autocreate.<br>
  16308. </li>
  16309. <br><br>
  16310. <li>Gateway (EEP A5-38-08)<br>
  16311. Control variable<br>
  16312. [untested]<br>
  16313. <ul>
  16314. <code>set &lt;name&gt; &lt;value&gt;</code>
  16315. <br><br>
  16316. where <code>value</code> is
  16317. <li>teach<br>
  16318. initiate teach-in mode</li>
  16319. <li>presence present|absent|standby<br>
  16320. issue Room occupancy</li>
  16321. <li>energyHoldOff normal|holdoff<br>
  16322. issue Energy hold off</li>
  16323. <li>controllerMode auto|heating|cooling|off<br>
  16324. issue Controller mode</li>
  16325. <li>controllerState auto|override <0 ... 100> <br>
  16326. issue Control variable override</li>
  16327. </ul><br>
  16328. Override Range: cvov = 0 % ... 100 %<br>
  16329. The attr subType must be gateway and gwCmd must be controlVar.
  16330. This is done if the device was created by autocreate.<br>
  16331. </li>
  16332. <br><br>
  16333. <li>Gateway (EEP A5-38-08)<br>
  16334. Fan stage<br>
  16335. [untested]<br>
  16336. <ul>
  16337. <code>set &lt;name&gt; &lt;value&gt;</code>
  16338. <br><br>
  16339. where <code>value</code> is
  16340. <li>teach<br>
  16341. initiate teach-in mode</li>
  16342. <li>stage 0 ... 3|auto<br>
  16343. issue Fan Stage override</li>
  16344. </ul><br>
  16345. The attr subType must be gateway and gwCmd must be fanStage.
  16346. This is done if the device was created by autocreate.<br>
  16347. </li>
  16348. <br><br>
  16349. <li>Gateway (EEP A5-38-08)<br>
  16350. <a name="Blind Command Central">Blind Command Central</a><br>
  16351. [not fully tested]<br>
  16352. <ul>
  16353. <code>set &lt;name&gt; &lt;value&gt;</code>
  16354. <br><br>
  16355. where <code>value</code> is
  16356. <li>position/% [&alpha;/&#176]<br>
  16357. drive blinds to position with angle value</li>
  16358. <li>teach<br>
  16359. initiate teach-in mode</li>
  16360. <li>status<br>
  16361. Status request</li>
  16362. <li>opens<br>
  16363. issue blinds opens command</li>
  16364. <li>up tu/s ta/s<br>
  16365. issue roll up command</li>
  16366. <li>closes<br>
  16367. issue blinds closes command</li>
  16368. <li>down td/s ta/s<br>
  16369. issue roll down command</li>
  16370. <li>position position/% [&alpha;/&#176]<br>
  16371. drive blinds to position with angle value</li>
  16372. <li>stop<br>
  16373. issue blinds stops command</li>
  16374. <li>runtimeSet tu/s td/s<br>
  16375. set runtime parameter</li>
  16376. <li>angleSet ta/s<br>
  16377. set angle configuration</li>
  16378. <li>positionMinMax positionMin/% positionMax/%<br>
  16379. set min, max values for position</li>
  16380. <li>angleMinMax &alpha;o/&#176 &alpha;s/&#176<br>
  16381. set slat angle for open and shut position</li>
  16382. <li>positionLogic normal|inverse<br>
  16383. set position logic</li>
  16384. </ul><br>
  16385. Runtime Range: tu|td = 0 s ... 255 s<br>
  16386. Select a runtime up and a runtime down that is at least as long as the
  16387. shading element or roller shutter needs to move from its end position to
  16388. the other position.<br>
  16389. Position Range: position = 0 % ... 100 %<br>
  16390. Angle Time Range: ta = 0 s ... 25.5 s<br>
  16391. Runtime value for the sunblind reversion time. Select the time to revolve
  16392. the sunblind from one slat angle end position to the other end position.<br>
  16393. Slat Angle: &alpha;|&alpha;o|&alpha;s = -180 &#176 ... 180 &#176<br>
  16394. Position Logic, normal: Blinds fully opens corresponds to Position = 0 %<br>
  16395. Position Logic, inverse: Blinds fully opens corresponds to Position = 100 %<br>
  16396. The attr subType must be gateway and gwCmd must be blindCmd.<br>
  16397. See also attributes <a href="#EnOcean_sendDevStatus">sendDevStatus and <a href="#EnOcean_serviceOn">serviceOn</a></a><br>
  16398. The profile is linked with controller profile, see <a href="#Blind Status">Blind Status</a>.<br>
  16399. </li>
  16400. <br><br>
  16401. <li>Extended Lighting Control (EEP A5-38-09)<br>
  16402. [untested]<br>
  16403. <ul>
  16404. <code>set &lt;name&gt; &lt;value&gt;</code>
  16405. <br><br>
  16406. where <code>value</code> is
  16407. <li>teach<br>
  16408. initiate remote teach-in</li>
  16409. <li>on<br>
  16410. issue switch on command</li>
  16411. <li>off<br>
  16412. issue switch off command</li>
  16413. <li>dim dim [rampTime/s]<br>
  16414. issue dim command</li>
  16415. <li>dimup rampTime/s<br>
  16416. issue dim command</li>
  16417. <li>dimdown rampTime/s<br>
  16418. issue dim command</li>
  16419. <li>stop<br>
  16420. stop dimming</li>
  16421. <li>rgb &lt;red color value&gt&lt;green color value&gt&lt;blue color value&gt<br>
  16422. issue color value command</li>
  16423. <li>scene drive|store 0..15<br>
  16424. store actual value in the scene or drive to scene value</li>
  16425. <li>dimMinMax &lt;min value&gt &lt;max value&gt<br>
  16426. set minimal and maximal dimmer value</li>
  16427. <li>lampOpHours 0..65535<br>
  16428. set the operation hours of the lamp</li>
  16429. <li>block unlock|on|off|local<br>
  16430. locking local operations</li>
  16431. <li>meteringValues 0..65535 mW|W|kW|MW|Wh|kWh|MWh|GWh|mA|mV<br>
  16432. set a new value for the energy metering (overwrite the actual value with the selected unit)</li>
  16433. <li>meteringValues 0..6553.5 A|V<br>
  16434. set a new value for the energy metering (overwrite the actual value with the selected unit)</li>
  16435. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16436. </ul><br>
  16437. color values: 00 ... FF hexadecimal<br>
  16438. rampTime Range: t = 1 s ... 65535 s or 1 if no time specified, ramping time can be set by attribute
  16439. <a href="#EnOcean_rampTime">rampTime</a><br>
  16440. The attr subType or subTypSet must be lightCtrl.01. This is done if the device was created by autocreate.<br>
  16441. The subType is associated with the subtype lightCtrlState.02.
  16442. </li>
  16443. <br><br>
  16444. <li><a name="Manufacturer Specific Applications">Manufacturer Specific Applications</a> (EEP A5-3F-7F)<br>
  16445. Shutter<br>
  16446. [Eltako FSB12, FSB14, FSB61, FSB70, tested with Eltako devices only]<br>
  16447. <ul>
  16448. <code>set &lt;name&gt; &lt;value&gt;</code>
  16449. <br><br>
  16450. where <code>value</code> is
  16451. <li>position/% [&alpha;/&#176]<br>
  16452. drive blinds to position with angle value</li>
  16453. <li>anglePos &alpha;/&#176<br>
  16454. drive blinds to angle value</li>
  16455. <li>closes<br>
  16456. issue blinds closes command</li>
  16457. <li>down td/s<br>
  16458. issue roll down command</li>
  16459. <li>opens<br>
  16460. issue blinds opens command</li>
  16461. <li>position position/% [&alpha;/&#176]<br>
  16462. drive blinds to position with angle value</li>
  16463. <li>stop<br>
  16464. issue stop command</li>
  16465. <li>teach<br>
  16466. initiate teach-in mode</li>
  16467. <li>up tu/s<br>
  16468. issue roll up command</li>
  16469. </ul><br>
  16470. Run-time Range: tu|td = 1 s ... 255 s<br>
  16471. Position Range: position = 0 % ... 100 %<br>
  16472. Slat Angle Range: &alpha; = -180 &#176 ... 180 &#176<br>
  16473. Angle Time Range: ta = 0 s ... 6 s<br>
  16474. The devive can only fully controlled if the attributes <a href="#angleMax">angleMax</a>,
  16475. <a href="#angleMin">angleMin</a>, <a href="#angleTime">angleTime</a>,
  16476. <a href="#shutTime">shutTime</a> and <a href="#shutTimeCloses">shutTimeCloses</a>,
  16477. are set correctly.
  16478. If <a href="#EnOcean_settingAccuracy">settingAccuracy</a> is set to high, the run-time is sent in 1/10 increments.<br>
  16479. Set attr subType to manufProfile, manufID to 00D and attr model to Eltako_FSB14|FSB61|FSB70|TF manually.<br>
  16480. Use the sensor type "Szenentaster/PC" for Eltako devices.
  16481. </li>
  16482. <br><br>
  16483. <li>Electronic switches and dimmers with Energy Measurement and Local Control (D2-01-00 - D2-01-12)<br>
  16484. [Telefunken Funktionsstecker, PEHA Easyclick, AWAG Elektrotechnik AG Omnio UPS 230/xx,UPD 230/xx, NodOn in-wall module, smart plug]<br>
  16485. <ul>
  16486. <code>set &lt;name&gt; &lt;value&gt;</code>
  16487. <br><br>
  16488. where <code>value</code> is
  16489. <li>autoOffTime t/s [&lt;channel&gt;]<br>
  16490. set auto Off timer</li>
  16491. <li>delayOffTime t/s [&lt;channel&gt;]<br>
  16492. set delay Off timer</li>
  16493. <li>dim/% [&lt;channel&gt; [&lt;rampTime&gt;]]<br>
  16494. issue dimming command</li>
  16495. <li>extSwitchMode unavailable|switch|pushbutton|auto [&lt;channel&gt;]<br>
  16496. set external interface mode</li>
  16497. <li>extSwitchType toggle|direction [&lt;channel&gt;]<br>
  16498. set external interface type</li>
  16499. <li>on [&lt;channel&gt;]<br>
  16500. issue switch on command</li>
  16501. <li>off [&lt;channel&gt;]<br>
  16502. issue switch off command</li>
  16503. <li>dim dim/% [&lt;channel&gt; [&lt;rampTime&gt;]]<br>
  16504. issue dimming command</li>
  16505. <li>local dayNight day|night, day is default<br>
  16506. set the user interface indication</li>
  16507. <li>local defaultState on|off|last, off is default<br>
  16508. set the default setting of the output channels when switch on</li>
  16509. <li>local localControl enabled|disabled, disabled is default<br>
  16510. enable the local control of the device</li>
  16511. <li>local overCurrentShutdown off|restart, off is default<br>
  16512. set the behavior after a shutdown due to an overcurrent</li>
  16513. <li>local overCurrentShutdownReset not_active|trigger, not_active is default<br>
  16514. trigger a reset after an overcurrent</li>
  16515. <li>local rampTime&lt;1...3&gt; 0/s, 0.5/s ... 7/s, 7.5/s, 0 is default<br>
  16516. set the dimming time of timer 1 ... 3</li>
  16517. <li>local teachInDev enabled|disabled, disabled is default<br>
  16518. enable the taught-in devices with different EEP</li>
  16519. <li>measurement delta 0/s ... 4095/s, 0 is default<br>
  16520. define the difference between two displayed measurements </li>
  16521. <li>measurement mode energy|power, energy is default<br>
  16522. define the measurand</li>
  16523. <li>measurement report query|auto, query is default<br>
  16524. specify the measurement method</li>
  16525. <li>measurement reset not_active|trigger, not_active is default<br>
  16526. resetting the measured values</li>
  16527. <li>measurement responseTimeMax 10/s ... 2550/s, 10 is default<br>
  16528. set the maximum time between two outputs of measured values</li>
  16529. <li>measurement responseTimeMin 1/s ... 255/s, 1 is default<br>
  16530. set the minimum time between two outputs of measured values</li>
  16531. <li>measurement unit Ws|Wh|KWh|W|KW, Ws is default<br>
  16532. specify the measurement unit</li>
  16533. <li>roomCtrlMode off|comfort|comfort-1|comfort-2|economy|buildingProtection<br>
  16534. set pilot wire mode</li>
  16535. <li>special repeater off|1|2<br>
  16536. set repeater level of device (additional NodOn command)
  16537. </li>
  16538. </ul><br>
  16539. [autoOffTime] = 0 s ... 0.1 s ... 6553.4 s<br>
  16540. [delayOffTime] = 0 s ... 0.1 s ... 6553.4 s<br>
  16541. [channel] = 0...29|all|input, all is default<br>
  16542. The default channel can be specified with the attr <a href="#EnOcean_defaultChannel">defaultChannel</a>.<br>
  16543. [rampTime] = 1..3|switch|stop, switch is default<br>
  16544. The attr subType must be actuator.01. This is done if the device was
  16545. created by autocreate. To control the device, it must be bidirectional paired,
  16546. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16547. </li>
  16548. <br><br>
  16549. <li>Blind Control for Position and Angle (D2-05-00 - D2-05-01)<br>
  16550. [AWAG Elektrotechnik AG OMNIO UPJ 230/12, REGJ12/04M ]<br>
  16551. <ul>
  16552. <code>set &lt;name&gt; &lt;value&gt;</code>
  16553. <br><br>
  16554. where <code>value</code> is
  16555. <li>opens [&lt;channel&gt;]<br>
  16556. issue blinds opens command</li>
  16557. <li>closes [&lt;channel&gt;]<br>
  16558. issue blinds closes command</li>
  16559. <li>position position/% [[&alpha;/%] [[&lt;channel&gt;] [directly|opens|closes]]]<br>
  16560. drive blinds to position with angle value</li>
  16561. <li>anglePos &alpha;/% [&lt;channel&gt;]<br>
  16562. drive blinds to angle value</li>
  16563. <li>stop [&lt;channel&gt;]<br>
  16564. issue stop command</li>
  16565. <li>alarm [&lt;channel&gt;]<br>
  16566. set actuator to the "alarm" mode. When the actuator ist set to the "alarm" mode neither local
  16567. nor central positioning and configuration commands will be executed. Before entering the "alarm"
  16568. mode, the actuator will execute the "alarm action" as configured by the attribute <a href="#EnOcean_alarmAction">alarmAction</a>
  16569. </li>
  16570. <li>lock [&lt;channel&gt;]<br>
  16571. set actuator to the "blockade" mode. When the actuator ist set to the "blockade" mode neither local
  16572. nor central positioning and configuration commands will be executed.
  16573. </li>
  16574. <li>unlock [&lt;channel&gt;]<br>
  16575. issue unlock command</li>
  16576. </ul><br>
  16577. Channel Range: 1 ... 4|all, default is all<br>
  16578. Position Range: position = 0 % ... 100 %<br>
  16579. Slat Angle Range: &alpha; = 0 % ... 100 %<br>
  16580. The devive can only fully controlled if the attributes <a href="#EnOcean_alarmAction">alarmAction</a>,
  16581. <a href="#angleTime">angleTime</a>, <a href="#EnOcean_reposition">reposition</a> and <a href="#shutTime">shutTime</a>
  16582. are set correctly.<br>
  16583. With the attribute <a name="EnOcean_defaultChannel">defaultChannel</a> the default channel can be specified.<br>
  16584. The attr subType must be blindsCtrl.00 or blindsCtrl.01. This is done if the device was
  16585. created by autocreate. To control the device, it must be bidirectional paired,
  16586. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16587. </li>
  16588. <br><br>
  16589. <li>Multisensor Windows Handle (D2-06-01)<br>
  16590. [Soda GmbH]<br>
  16591. <ul>
  16592. <code>set &lt;name&gt; &lt;value&gt;</code>
  16593. <br><br>
  16594. where <code>value</code> is
  16595. <li>presence absent|present<br>
  16596. set vacation mode</li>
  16597. <li>handleClosedClick disable|enable<br>
  16598. set handle closed click feature</li>
  16599. <li>batteryLowClick disable|enable<br>
  16600. set battery low click feature</li>
  16601. <li>teachSlave contact|windowHandleClosed|windowHandleOpen|windowHandleTilted<br>
  16602. sent teach-in to the slave devices (contact: EEP: D5-00-01, windowHandle: EEP F6-10-00)<br>
  16603. The events window or handle will get forwarded once a slave-device contact or windowHandle is taught in.
  16604. </li>
  16605. <li>updateInterval t/s<br>
  16606. set sensor update interval</li>
  16607. <li>blinkInterval t/s<br>
  16608. set vacation blink interval</li>
  16609. </ul><br>
  16610. sensor update interval Range: updateInterval = 5 ... 65535<br>
  16611. vacation blick interval Range: blinkInterval = 3 ... 255<br>
  16612. The multisensor window handle is configured using the following attributes:<br>
  16613. <ul>
  16614. <li><a href="#EnOcean_subDefH">subDefH</a></li>
  16615. <li><a href="#EnOcean_subDefW">subDefW</a></li>
  16616. </ul>
  16617. The attr subType must be multisensor.01. This is done if the device was
  16618. created by autocreate.
  16619. </li>
  16620. <br><br>
  16621. <li>Room Control Panels (D2-10-00 - D2-10-02)<br>
  16622. [Kieback & Peter RBW322-FTL]<br>
  16623. <ul>
  16624. <code>set &lt;name&gt; &lt;value&gt;</code>
  16625. <br><br>
  16626. where <code>value</code> is
  16627. <li>buildingProtectionTemp t/&#176C<br>
  16628. set building protection temperature</li>
  16629. <li>clearCmds [&lt;channel&gt;]<br>
  16630. clear waiting commands</li>
  16631. <li>comfortTemp t/&#176C<br>
  16632. set comfort temperature</li>
  16633. <li>config<br>
  16634. Setting the configuration of the room controller, the configuration parameters are set using attributes.</li>
  16635. <li>cooling auto|off|on|no_change<br>
  16636. switch cooling</li>
  16637. <li>deleteTimeProgram<br>
  16638. delete time programs of the room controller</li>
  16639. <li>desired-temp t/&#176C<br>
  16640. set setpoint temperature</li>
  16641. <li>economyTemp t/&#176C<br>
  16642. set economy temperature</li>
  16643. <li>fanSpeed fanspeed/%<br>
  16644. set fan speed</li>
  16645. <li>fanSpeedMode central|local<br>
  16646. set fan speed mode</li>
  16647. <li>heating auto|off|on|no_change<br>
  16648. switch heating</li>
  16649. <li>preComfortTemp t/&#176C<br>
  16650. set pre comfort temperature</li>
  16651. <li>roomCtrlMode buildingProtectionTemp|comfortTemp|economyTemp|preComfortTemp<br>
  16652. select setpoint temperature</li>
  16653. <li>setpointTemp t/&#176C<br>
  16654. set current setpoint temperature</li>
  16655. <li>time<br>
  16656. set time and date of the room controller </li>
  16657. <li>timeProgram<br>
  16658. set time programms of the room contoller</li>
  16659. <li>window closed|open<br>
  16660. put the window state</li>
  16661. </ul><br>
  16662. Setpoint Range: t = 0 &#176C ... 40 &#176C<br>
  16663. The room controller is configured using the following attributes:<br>
  16664. <ul>
  16665. <li><a href="#EnOcean_blockDateTime">blockDateTime</a></li>
  16666. <li><a href="#EnOcean_blockDisplay">blockDisplay</a></li>
  16667. <li><a href="#EnOcean_blockFanSpeed">blockFanSpeed</a></li>
  16668. <li><a href="#EnOcean_blockMotion">blockMotion</a></li>
  16669. <li><a href="#EnOcean_blockProgram">blockProgram</a></li>
  16670. <li><a href="#EnOcean_blockOccupany">blockOccupancy</a></li>
  16671. <li><a href="#EnOcean_blockTemp">blockTemp</a></li>
  16672. <li><a href="#EnOcean_blockTimeProgram">blockTimeProgram</a></li>
  16673. <li><a href="#EnOcean_blockSetpointTemp">blockSetpointTemp</a></li>
  16674. <li><a href="#EnOcean_daylightSavingTime">daylightSavingTime</a></li>
  16675. <li><a href="#EnOcean_displayContent">displayContent</a></li>
  16676. <li><a href="#EnOcean_pollInterval">pollInterval</a></li>
  16677. <li><a href="#EnOcean_temperatureScale">temperatureScale</a></li>
  16678. <li><a href="#EnOcean_timeNotation">timeNotation</a></li>
  16679. <li><a href="#EnOcean_timeProgram[1-4]">timeProgram[1-4]</a></li>
  16680. </ul>
  16681. The attr subType must be roomCtrlPanel.00. This is done if the device was
  16682. created by autocreate. To control the device, it must be bidirectional paired,
  16683. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16684. </li>
  16685. <br><br>
  16686. <li>Room Control Panels (D2-11-01 - D2-11-08)<br>
  16687. [Thermokon EasySens SR06 LCD-2T/-2T rh -4T/-4T rh]<br>
  16688. <ul>
  16689. <code>set &lt;name&gt; &lt;value&gt;</code>
  16690. <br><br>
  16691. where <code>value</code> is
  16692. <li>cooling on|off, default [colling] = off<br>
  16693. set cooling symbol at the display</li>
  16694. <li>desired-temp t/&#176C<br>
  16695. set setpoint temperature</li>
  16696. <li>fanSpeed auto|off|1|2|3<br>
  16697. set fan speed</li>
  16698. <li>heating on|off, default [heating] = off<br>
  16699. set heating symbol at the display</li>
  16700. <li>occupancy occupied|unoccupied<br>
  16701. set occupancy state</li>
  16702. <li>setpointTemp t/&#176C<br>
  16703. set current setpoint temperature</li>
  16704. <li>setpointShiftMax t/K<br>
  16705. set setpoint shift max</li>
  16706. <li>setpointType setpointTemp|setpointShift<br>
  16707. set setpoint type</li>
  16708. <li>window closed|open, default [window] = closed<br>
  16709. set window open symbol at the display</li>
  16710. </ul><br>
  16711. Setpoint Range: t = 5 &#176C ... 40 &#176C<br>
  16712. Setpoint Shift Max Range: t = 0 K ... 10 K<br>
  16713. The attr subType must be roomCtrlPanel.01. This is done if the device was
  16714. created by autocreate. To control the device, it must be bidirectional paired by Smart Ack,
  16715. see <a href="#EnOcean_smartAck">SmartAck Learning</a>.
  16716. </li>
  16717. <br><br>
  16718. <li>Fan Control (D2-20-00 - D2-20-02)<br>
  16719. [Maico ECA x RC/RCH, ER 100 RC, untested]<br>
  16720. <ul>
  16721. <code>set &lt;name&gt; &lt;value&gt;</code>
  16722. <br><br>
  16723. where <code>value</code> is
  16724. <li>on<br>
  16725. fan on</li>
  16726. <li>off<br>
  16727. fan off</li>
  16728. <li>desired-temp [t/&#176C]<br>
  16729. set setpoint temperature</li>
  16730. <li>fanSpeed fanspeed/%|auto|default<br>
  16731. set fan speed</li>
  16732. <li>humidityThreshold rH/%<br>
  16733. set humidity threshold</li>
  16734. <li>roomSize 0...350/m<sup>2</sup>|default|not_used<br>
  16735. set room size</li>
  16736. <li>setpointTemp [t/&#176C]<br>
  16737. set current setpoint temperature</li>
  16738. </ul><br>
  16739. Setpoint Range: t = 0 &#176C ... 40 &#176C<br>
  16740. The fan controller is configured using the following attributes:<br>
  16741. <ul>
  16742. <li><a href="#EnOcean_setCmdTrigger">setCmdTrigger</a></li>
  16743. <li><a href="#EnOcean_switchHysteresis">switchHysteresis</a></li>
  16744. <li><a href="#temperatureRefDev">temperatureRefDev</a></li>
  16745. </ul>
  16746. The attr subType must be fanCtrl.00. This is done if the device was
  16747. created by autocreate. To control the device, it must be bidirectional paired,
  16748. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>. The profile
  16749. behaves like a master. Only one fan can be taught as a slave.
  16750. </li>
  16751. <br><br>
  16752. <li>Heat Recovery Ventilation (D2-50-00 - D2-50-11)<br>
  16753. [untested]<br>
  16754. <ul>
  16755. <code>set &lt;name&gt; &lt;value&gt;</code>
  16756. <br><br>
  16757. where <code>value</code> is
  16758. <li>ventilation off|1...4|auto|demand|supplyAir|exhaustAir<br>
  16759. select ventilation mode/level</li>
  16760. <li>heatExchangerBypass opens|closes<br>
  16761. override of automatic heat exchanger bypass control</li>
  16762. <li>startTimerMode<br>
  16763. enable timer operation mode</li>
  16764. <li>CO2Threshold default|1/%<br>
  16765. override CO2 threshold for CO2 control in automatic mode</li>
  16766. <li>humidityThreshold default|rH/%<br>
  16767. override humidity threshold for humidity control in automatic mode</li>
  16768. <li>airQuatityThreshold default|1/%<br>
  16769. override air qualidity threshold for air qualidity control in automatic mode</li>
  16770. <li>roomTemp default|t/&#176C<br>
  16771. override room temperature threshold for room temperature control mode</li>
  16772. </ul><br>
  16773. roomTemp Range: t = -63 &#176C ... 63 &#176C<br>
  16774. xThreshold Range: 0 % ... 100 %<br>
  16775. The attr subType must be heatRecovery.00. This is done if the device was
  16776. created by autocreate. To control the device, it must be bidirectional paired,
  16777. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16778. </li>
  16779. <br><br>
  16780. <li>Valve Control (EEP D2-A0-01)<br>
  16781. <ul>
  16782. <code>set &lt;name&gt; &lt;value&gt;</code>
  16783. <br><br>
  16784. where <code>value</code> is
  16785. <li>closes<br>
  16786. issue closes command (master)</li>
  16787. <li>opens<br>
  16788. issue opens command (master)</li>
  16789. <li>closed<br>
  16790. issue closed command (slave)</li>
  16791. <li>open<br>
  16792. issue open command (slave)</li>
  16793. <li>teachIn<br>
  16794. initiate UTE teach-in (slave)</li>
  16795. <li>teachOut<br>
  16796. initiate UTE teach-out (slave)</li>
  16797. </ul><br>
  16798. The valve controller is configured using the following attributes:<br>
  16799. <ul>
  16800. <li><a href="#EnOcean_devMode">devMode</a></li>
  16801. </ul>
  16802. The attr subType must be valveCtrl.00. This is done if the device was
  16803. created by autocreate. To control the device, it must be bidirectional paired,
  16804. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>. The profile
  16805. behaves like a master or slave, see <a href="#EnOcean_devMode">devMode</a>.
  16806. </li>
  16807. <br><br>
  16808. <li>Generic Profiles<br>
  16809. <ul>
  16810. <code>set &lt;name&gt; &lt;value&gt;</code>
  16811. <br><br>
  16812. where <code>value</code> is
  16813. <li>&lt;00 ... 64&gt;-&lt;channel name&gt; &lt;value&gt;<br>
  16814. set channel value</li>
  16815. <li>channelName &lt;channel number&gt;-&lt;channel name&gt;<br>
  16816. rename channel</li>
  16817. <li>teachIn<br>
  16818. sent teach-in telegram</li>
  16819. <li>teachOut<br>
  16820. sent teach-out telegram</li>
  16821. </ul><br>
  16822. The generic profile device is configured using the following attributes:<br>
  16823. <ul>
  16824. <li><a href="#EnOcean_comMode">comMode</a></li>
  16825. <li><a href="#EnOcean_devMode">devMode</a></li>
  16826. <li><a href="#EnOcean_gpDef">gpDef</a></li>
  16827. <li><a href="#EnOcean_manufID">manufID</a></li>
  16828. </ul>
  16829. The attr subType must be genericProfile. This is done if the device was
  16830. created by autocreate. If the profile in slave mode is operated, especially the channel
  16831. definition in the gpDef attributes must be entered manually.
  16832. </li>
  16833. <br><br>
  16834. <li>RAW Command<br>
  16835. <ul>
  16836. <code>set &lt;name&gt; &lt;value&gt;</code>
  16837. <br><br>
  16838. where <code>value</code> is
  16839. <li>1BS|4BS|GPCD|GPSD|GPTI|GPTR|MSC|RPS|UTE|VLD data [status]<br>
  16840. sent data telegram</li>
  16841. </ul><br>
  16842. [data] = &lt;1-byte hex ... 512-byte hex&gt;<br>
  16843. [status] = 0x00 ... 0xFF<br>
  16844. With the help of this command data messages in hexadecimal format can be sent.
  16845. Telegram types (RORG) 1BS, 4BS, RPS, MSC, UTE, VLD, GPCD, GPSD, GPTI and GPTR are supported.
  16846. For further information, see <a href="http://www.enocean-alliance.org/eep/">EnOcean Equipment Profiles (EEP)</a> and
  16847. Generic Profiles.
  16848. </li>
  16849. <br><br>
  16850. <li>Radio Link Test<br>
  16851. <ul>
  16852. <code>set &lt;name&gt; &lt;value&gt;</code>
  16853. <br><br>
  16854. where <code>value</code> is
  16855. <li>standby|stop<br>
  16856. set RLT Master state
  16857. </li>
  16858. </ul><br>
  16859. The Radio Link Test device is configured using the following attributes:<br>
  16860. <ul>
  16861. <li><a href="#EnOcean_rltRepeat">rltRepeat</a></li>
  16862. <li><a href="#EnOcean_rltType">rltType</a></li>
  16863. </ul>
  16864. The attr subType must be readioLinkTest. This is done if the device was
  16865. created by autocreate or manually by <code>define &lt;name&gt; EnOcean A5-3F-00</code><br>.
  16866. </li>
  16867. <br><br>
  16868. </ul></ul>
  16869. <a name="EnOceanget"></a>
  16870. <b>Get</b>
  16871. <ul>
  16872. <li><a name="EnOcean_remoteGet">Remote Management</a>
  16873. <ul>
  16874. <code>get &lt;name&gt; &lt;value&gt;</code>
  16875. <br><br>
  16876. where <code>value</code> is
  16877. <li>remoteDevCfg &lt;start data index&gt; &lt;end data index&gt;<br>
  16878. get device configuration between start index and end index</li>
  16879. <li>remoteFunctions<br>
  16880. get a list of the supported extended functions</li>
  16881. <li>remoteID<br>
  16882. get the remote device ID</li>
  16883. <li>remoteLinkTableInfo<br>
  16884. query supported link table info</li>
  16885. <li>remoteLinkCfg in|out &lt;index&gt; &lt;start data index&gt; &lt;end data index&gt; &lt;length&gt;<br>
  16886. get link table between start index and end index</li>
  16887. <li>remoteLinkTable in|out &lt;start index&gt; &lt;end index&gt;<br>
  16888. get link table between start index and end index</li>
  16889. <li>remoteLinkTableGP in|out &lt;index&gt;<br>
  16890. get link table GP entry with index</li>
  16891. <li>remotePing<br>
  16892. get a ping response from the remote device</li>
  16893. <li>remoteProductID<br>
  16894. query product ID</li>
  16895. <li>remoteRepeater<br>
  16896. asks for the repeater status of the remote device</li>
  16897. <li>remoteStatus<br>
  16898. asks for the status info of the remote device</li>
  16899. <br>
  16900. [&lt;data index&gt;] = 0000...FFFF<br>
  16901. [&lt;index&gt;] = 00...FF<br>
  16902. [&lt;length&gt;] = n x 00...FF<br>
  16903. </ul>
  16904. </li><br><br>
  16905. <li>Dual Channel Switch Actuator (EEP A5-11-059)<br>
  16906. [untested]<br>
  16907. <ul>
  16908. <code>get &lt;name&gt; &lt;value&gt;</code>
  16909. <br><br>
  16910. where <code>value</code> is
  16911. <li>state<br>
  16912. status request</li>
  16913. </ul><br>
  16914. The attr subType or subTypSet must be switch.05. This is done if the device was created by autocreate.
  16915. </li>
  16916. <br><br>
  16917. <li>Extended Lighting Control (EEP A5-38-09)<br>
  16918. [untested]<br>
  16919. <ul>
  16920. <code>get &lt;name&gt; &lt;value&gt;</code>
  16921. <br><br>
  16922. where <code>value</code> is
  16923. <li>state<br>
  16924. status request</li>
  16925. </ul><br>
  16926. The attr subType or subTypSet must be lightCtrl.01. This is done if the device was created by autocreate.<br>
  16927. The subType is associated with the subtype lightCtrlState.02.
  16928. </li>
  16929. <br><br>
  16930. <li>Electronic switches and dimmers with Energy Measurement and Local Control (D2-01-00 - D2-01-12)<br>
  16931. [Telefunken Funktionsstecker, PEHA Easyclick, AWAG Elektrotechnik AG Omnio UPS 230/xx,UPD 230/xx, NodOn in-wall module, smart plug]<br>
  16932. <ul>
  16933. <code>get &lt;name&gt; &lt;value&gt;</code>
  16934. <br><br>
  16935. where <code>value</code> is
  16936. <li>roomCtrlMode<br>
  16937. get pilot wire mode</li>
  16938. <li>settings [&lt;channel&gt;]<br>
  16939. get external interface settings</li>
  16940. <li>state [&lt;channel&gt;]<br>
  16941. </li>
  16942. <li>measurement &lt;channel&gt; energy|power<br>
  16943. </li>
  16944. <li>special &lt;channel&gt; health|load|voltage|serialNumber<br>
  16945. additional Permondo SmartPlug PSC234 commands
  16946. </li>
  16947. <li>special &lt;channel&gt; firmwareVersion|reset|taughtInDevID|taughtInDevNum<br>
  16948. additional NodOn commands
  16949. </li>
  16950. </ul><br>
  16951. The default channel can be specified with the attr <a href="#EnOcean_defaultChannel">defaultChannel</a>.<br>
  16952. The attr subType must be actuator.01. This is done if the device was
  16953. created by autocreate. To control the device, it must be bidirectional paired,
  16954. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16955. </li>
  16956. <br><br>
  16957. <li>Blind Control for Position and Angle (D2-05-00)<br>
  16958. [AWAG Elektrotechnik AG OMNIO UPJ 230/12, REGJ12/04M]<br>
  16959. <ul>
  16960. <code>get &lt;name&gt; &lt;value&gt;</code>
  16961. <br><br>
  16962. where <code>value</code> is
  16963. <li>position [&lt;channel&gt;]<br>
  16964. query position and angle value</li>
  16965. </ul><br>
  16966. Channel Range: 1 ... 4|all, default is all<br>
  16967. The devive can only fully controlled if the attributes <a href="#EnOcean_alarmAction">alarmAction</a>,
  16968. <a href="#angleTime">angleTime</a>, <a href="#EnOcean_reposition">reposition</a> and <a href="#shutTime">shutTime</a>
  16969. are set correctly.<br>
  16970. With the attribute <a name="EnOcean_defaultChannel">defaultChannel</a> the default channel can be specified.<br>
  16971. The attr subType must be blindsCtrl.00 or blindsCrtl.01. This is done if the device was
  16972. created by autocreate. To control the device, it must be bidirectional paired,
  16973. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16974. </li>
  16975. <br><br>
  16976. <li>Multisensor Windows Handle (D2-06-01)<br>
  16977. [Soda GmbH]<br>
  16978. <ul>
  16979. <code>get &lt;name&gt; &lt;value&gt;</code>
  16980. <br><br>
  16981. where <code>value</code> is
  16982. <li>config<br>
  16983. get configuration settings</li>
  16984. <li>log<br>
  16985. get log data</li>
  16986. </ul><br>
  16987. The multisensor window handle is configured using the following attributes:<br>
  16988. <ul>
  16989. <li><a href="#EnOcean_subDefH">subDefH</a></li>
  16990. <li><a href="#EnOcean_subDefW">subDefW</a></li>
  16991. </ul>
  16992. The attr subType must be multisensor.01. This is done if the device was
  16993. created by autocreate.
  16994. </li>
  16995. <br><br>
  16996. <li>Room Control Panels (D2-10-00 - D2-10-02)<br>
  16997. [Kieback & Peter RBW322-FTL]<br>
  16998. <ul>
  16999. <code>get &lt;name&gt; &lt;value&gt;</code>
  17000. <br><br>
  17001. where <code>value</code> is
  17002. <li>config<br>
  17003. get the configuration of the room controler</li>
  17004. <li>data<br>
  17005. get data</li>
  17006. <li>roomCtrl<br>
  17007. get the parameter of the room controler</li>
  17008. <li>timeProgram<br>
  17009. get the time program</li>
  17010. </ul><br>
  17011. The attr subType must be roomCtrlPanel.00. This is done if the device was
  17012. created by autocreate. To control the device, it must be bidirectional paired,
  17013. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  17014. </li>
  17015. <br><br>
  17016. <li>Fan Control (D2-20-00 - D2-20-02)<br>
  17017. [Maico ECA x RC/RCH, ER 100 RC, untested]<br>
  17018. <ul>
  17019. <code>get &lt;name&gt; &lt;value&gt;</code>
  17020. <br><br>
  17021. where <code>value</code> is
  17022. <li>state<br>
  17023. get the state of the room controler</li>
  17024. </ul><br>
  17025. The attr subType must be fanCtrl.00. This is done if the device was
  17026. created by autocreate. To control the device, it must be bidirectional paired,
  17027. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  17028. </li>
  17029. <br><br>
  17030. <li>Heat Recovery Ventilation (D2-50-00 - D2-50-11)<br>
  17031. [untested]<br>
  17032. <ul>
  17033. <code>get &lt;name&gt; &lt;value&gt;</code>
  17034. <br><br>
  17035. where <code>value</code> is
  17036. <li>basicState<br>
  17037. get the basic state</li>
  17038. <li>extendedState<br>
  17039. get the extended state</li>
  17040. </ul><br>
  17041. The attr subType must be heatRecovery.00. This is done if the device was
  17042. created by autocreate. To control the device, it must be bidirectional paired,
  17043. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  17044. </li>
  17045. <br><br>
  17046. <li>Valve Control (EEP D2-A0-01)<br>
  17047. <ul>
  17048. <code>get &lt;name&gt; &lt;value&gt;</code>
  17049. <br><br>
  17050. where <code>value</code> is
  17051. <li>state<br>
  17052. get the state of the valve controler (master)</li>
  17053. </ul><br>
  17054. The attr subType must be valveCtrl.00. This is done if the device was
  17055. created by autocreate. To control the device, it must be bidirectional paired,
  17056. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>. The profile
  17057. behaves like a master or slave, see <a href="#EnOcean_devMode">devMode</a>.
  17058. </li>
  17059. <br><br>
  17060. </ul><br>
  17061. <a name="EnOceanattr"></a>
  17062. <b>Attributes</b>
  17063. <ul>
  17064. <ul>
  17065. <li><a name="actualTemp">actualTemp</a> t/&#176C<br>
  17066. The value of the actual temperature, used by a Room Sensor and Control Unit
  17067. or when controlling HVAC components e. g. Battery Powered Actuators (MD15 devices). Should by
  17068. filled via a notify from a distinct temperature sensor.<br>
  17069. If absent, the reported temperature from the HVAC components is used.
  17070. </li>
  17071. <li><a name="EnOcean_alarmAction">alarmAction</a> &lt;channel1&gt;[:&lt;channel2&gt;[:&lt;channel3&gt;[:&lt;channel4&gt;]]]<br>
  17072. [alarmAction] = no|stop|opens|closes, default is no<br>
  17073. Action that is executed before the actuator is entering the "alarm" mode.<br>
  17074. Notice subType blindsCrtl.00, blindsCrtl.01: The attribute can only be set while the actuator is online.
  17075. </li>
  17076. <li><a name="angleMax">angleMax</a> &alpha;s/&#176, [&alpha;s] = -180 ... 180, 90 is default.<br>
  17077. Slat angle end position maximum.<br>
  17078. angleMax is supported for shutter.
  17079. </li>
  17080. <li><a name="angleMin">angleMin</a> &alpha;o/&#176, [&alpha;o] = -180 ... 180, -90 is default.<br>
  17081. Slat angle end position minimum.<br>
  17082. angleMin is supported for shutter.
  17083. </li>
  17084. <li><a name="angleTime">angleTime</a> &lt;channel1&gt;[:&lt;channel2&gt;[:&lt;channel3&gt;[:&lt;channel4&gt;]]]<br>
  17085. subType blindsCtrl.00, blindsCtrl.01: [angleTime] = 0|0.01 .. 2.54, 0 is default.<br>
  17086. subType manufProfile: [angleTime] = 0 ... 6, 0 is default.<br>
  17087. Runtime value for the sunblind reversion time. Select the time to revolve
  17088. the sunblind from one slat angle end position to the other end position.<br>
  17089. Notice subType blindsCrtl.00: The attribute can only be set while the actuator is online.
  17090. </li>
  17091. <li><a name="EnOcean_blockDateTime">blockDateTime</a> yes|no, [blockDateTime] = no is default.<br>
  17092. blockDateTime is supported for roomCtrlPanel.00.
  17093. </li>
  17094. <li><a name="EnOcean_blockDisplay">blockDisplay</a> yes|no, [blockDisplay] = no is default.<br>
  17095. blockDisplay is supported for roomCtrlPanel.00.
  17096. </li>
  17097. <li><a name="EnOcean_blockFanSpeed">blockFanSpeed</a> yes|no, [blockFanSpeed] = no is default.<br>
  17098. blockFanSpeed is supported for roomCtrlPanel.00.
  17099. </li>
  17100. <li><a name="EnOcean_blockKey">blockKey</a> yes|no, [blockKey] = no is default.<br>
  17101. blockKey is supported for roomCtrlPanel.00 and hvac.04.
  17102. </li>
  17103. <li><a name="EnOcean_blockMotion">blockMotion</a> yes|no, [blockMotion] = no is default.<br>
  17104. blockMotion is supported for roomCtrlPanel.00.
  17105. </li>
  17106. <li><a name="EnOcean_blockOccupany">blockOccupancy</a> yes|no, [blockOccupancy] = no is default.<br>
  17107. blockOccupancy is supported for roomCtrlPanel.00.
  17108. </li>
  17109. <li><a name="EnOcean_blockTemp">blockTemp</a> yes|no, [blockTemp] = no is default.<br>
  17110. blockTemp is supported for roomCtrlPanel.00.
  17111. </li>
  17112. <li><a name="EnOcean_blockTimeProgram">blockTimeProgram</a> yes|no, [blockTimeProgram] = no is default.<br>
  17113. blockTimeProgram is supported for roomCtrlPanel.00.
  17114. </li>
  17115. <li><a name="EnOcean_blockSetpointTemp">blockSetpointTemp</a> yes|no, [blockSetpointTemp] = no is default.<br>
  17116. blockSetPointTemp is supported for roomCtrlPanel.00.
  17117. </li>
  17118. <li><a name="EnOcean_blockUnknownMSC">blockUnknownMSC</a> yes|no,
  17119. [blockUnknownMSC] = no is default.<br>
  17120. If the structure of the MSC telegrams can not interpret the raw data to be output. Setting this attribute to yes,
  17121. the output can be suppressed.
  17122. </li>
  17123. <li><a name="EnOcean_comMode">comMode</a> biDir|confirm|uniDir, [comMode] = uniDir is default.<br>
  17124. Communication Mode between an enabled EnOcean device and Fhem.<br>
  17125. Unidirectional communication means a point-to-multipoint communication
  17126. relationship. The EnOcean device e. g. sensors does not know the unique
  17127. Fhem SenderID.<br>
  17128. If the attribute is set to confirm Fhem awaits confirmation telegrams from the remote device.<br>
  17129. Bidirectional communication means a point-to-point communication
  17130. relationship between an enabled EnOcean device and Fhem. It requires all parties
  17131. involved to know the unique Sender ID of their partners. Bidirectional communication
  17132. needs a teach-in / teach-out process, see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  17133. </li>
  17134. <li><a name="EnOcean_dataEnc">dataEnc</a> VAES|AES-CBC, [dataEnc] = VAES is default<br>
  17135. Data encryption algorithm
  17136. </li>
  17137. <li><a name="EnOcean_defaultChannel">defaultChannel</a> &lt;channel&gt;
  17138. subType actuator.01: [defaultChannel] = all|input|0 ... 29, all is default.<br>
  17139. subType blindsCtrl.00, blindsCtrl.01: [defaultChannel] = all|1 ... 4, all is default.<br>
  17140. Default device channel
  17141. </li>
  17142. <li><a name="EnOcean_daylightSavingTime">daylightSavingTime</a> supported|not_supported, [daylightSavingTime] = supported is default.<br>
  17143. daylightSavingTime is supported for roomCtrlPanel.00.
  17144. </li>
  17145. <li><a name="EnOcean_demandRespAction">demandRespAction</a> &lt;command&gt;<br>
  17146. Command being executed after an demand response command is set. If &lt;command&gt; is enclosed in {},
  17147. then it is a perl expression, if it is enclosed in "", then it is a shell command,
  17148. else it is a "plain" fhem.pl command (chain). In the &lt;command&gt; you can access the demand response
  17149. readings $TYPE, $NAME, $LEVEL, $SETPOINT, $POWERUSAGE, $POWERUSAGESCALE, $POWERUSAGELEVEL, $STATE. In addition,
  17150. the variables $TARGETNAME, $TARGETTYPE, $TARGETSTATE can be used if the action is executed
  17151. on the target device. This data is available as a local variable in perl, as environment variable for shell
  17152. scripts, and will be textually replaced for Fhem commands.
  17153. </li>
  17154. <li><a name="EnOcean_demandRespMax">demandRespMax</a> A0|AI|B0|BI|C0|CI|D0|DI, [demandRespMax] = B0 is default<br>
  17155. Switch command which is executed if the demand response switches to a maximum.
  17156. </li>
  17157. <li><a name="EnOcean_demandRespMin">demandRespMin</a> A0|AI|B0|BI|C0|CI|D0|DI, [demandRespMax] = BI is default<br>
  17158. Switch command which is executed if the demand response switches to a minimum.
  17159. </li>
  17160. <li><a name="EnOcean_demandRespRefDev">demandRespRefDev</a> &lt;name&gt;<br>
  17161. </li>
  17162. <li><a name="EnOcean_demandRespRandomTime">demandRespRandomTime</a> t/s [demandRespRandomTime] = 1 is default<br>
  17163. Maximum length of the random delay at the start or end of a demand respose event in slave mode.
  17164. </li>
  17165. <li><a name="EnOcean_demandRespThreshold">demandRespThreshold</a> 0...15 [demandRespTheshold] = 8 is default<br>
  17166. Threshold for switching the power usage level between minimum and maximum in the master mode.
  17167. </li>
  17168. <li><a name="EnOcean_demandRespTimeoutLevel">demandRespTimeoutLevel</a> max|last [demandRespTimeoutLevel] = max is default<br>
  17169. Demand response timeout level in slave mode.
  17170. </li>
  17171. <li><a name="devChannel">devChannel</a> 00 ... FF, [devChannel] = FF is default<br>
  17172. Number of the individual device channel, FF = all channels supported by the device
  17173. </li>
  17174. <li><a name="destinationID">destinationID</a> multicast|unicast|00000001 ... FFFFFFFF,
  17175. [destinationID] = multicast is default<br>
  17176. Destination ID, special values: multicast = FFFFFFFF, unicast = [DEF]
  17177. </li>
  17178. <li><a name="EnOcean_devMode">devMode</a> master|slave, [devMode] = master is default.<br>
  17179. device operation mode.
  17180. </li>
  17181. <li><a href="#devStateIcon">devStateIcon</a></li>
  17182. <li><a name="EnOcean_dimMax">dimMax</a> dim/%|off, [dimMax] = 255 is default.<br>
  17183. maximum brightness value<br>
  17184. dimMax is supported for the profile gateway/dimming.
  17185. </li>
  17186. <li><a name="EnOcean_dimMin">dimMin</a> dim/%|off, [dimMax] = off is default.<br>
  17187. minimum brightness value<br>
  17188. If [dimMax] = off, then the actuator takes down the ramp time set there.
  17189. dimMin is supported for the profile gateway/dimming.
  17190. </li>
  17191. <li><a name="dimValueOn">dimValueOn</a> dim/%|last|stored,
  17192. [dimValueOn] = 100 is default.<br>
  17193. Dim value for the command "on".<br>
  17194. The dimmer switched on with the value 1 % ... 100 % if [dimValueOn] =
  17195. 1 ... 100.<br>
  17196. The dimmer switched to the last dim value received from the
  17197. bidirectional dimmer if [dimValueOn] = last.<br>
  17198. The dimmer switched to the last Fhem dim value if [dimValueOn] =
  17199. stored.<br>
  17200. dimValueOn is supported for the profile gateway/dimming.
  17201. </li>
  17202. <li><a href="#EnOcean_disable">disable</a> 0|1<br>
  17203. If applied set commands will not be executed.
  17204. </li>
  17205. <li><a href="#EnOcean_disabledForIntervals">disabledForIntervals</a> HH:MM-HH:MM HH:MM-HH-MM...<br>
  17206. Space separated list of HH:MM tupels. If the current time is between
  17207. the two time specifications, set commands will not be executed. Instead of
  17208. HH:MM you can also specify HH or HH:MM:SS. To specify an interval
  17209. spawning midnight, you have to specify two intervals, e.g.:
  17210. <ul>
  17211. 23:00-24:00 00:00-01:00
  17212. </ul>
  17213. </li>
  17214. <li><a name="EnOcean_displayContent">displayContent</a>
  17215. humidity|off|setpointTemp|temperatureExtern|temperatureIntern|time|default|no_change, [displayContent] = no_change is default.<br>
  17216. displayContent is supported for roomCtrlPanel.00.
  17217. </li>
  17218. <li><a name="EnOcean_displayOrientation">displayOrientation</a> rad/&#176, [displayOrientation] = 0|90|180|270, 0 is default.<br>
  17219. Display orientation of the actuator
  17220. </li>
  17221. <li><a href="#do_not_notify">do_not_notify</a></li>
  17222. <li><a name="EnOcean_eep">eep</a> &lt;00...FF&gt;-&lt;00...3F&gt;-&lt;00...7F&gt;<br>
  17223. EnOcean Equipment Profile (EEP)
  17224. <li><a href="#eventMap">eventMap</a></li>
  17225. </li>
  17226. <li><a name="EnOcean_gpDef">gpDef</a> &lt;name of channel 00&gt;:&lt;O|I&gt;:&lt;channel type&gt;:&lt;signal type&gt;:&lt;value type&gt;[:&lt;resolution&gt;[:&lt;engineering min&gt;:&lt;scaling min&gt;:&lt;engineering max&gt;:&lt;scaling max&gt;]] ...
  17227. &lt;name of channel 64&gt;:&lt;O|I&gt;:&lt;channel type&gt;:&lt;signal type&gt;:&lt;value type&gt;[:&lt;resolution&gt;[:&lt;engineering min&gt;:&lt;scaling min&gt;:&lt;engineering max&gt;:&lt;scaling max&gt;]]
  17228. <br>
  17229. Generic Profiles channel definitions are set automatically in master mode. If the profile in slave mode is operated, the channel
  17230. definition must be entered manually. For each channel, the channel definitions are to be given in ascending order. The channel
  17231. parameters to be specified in decimal. First, the outgoing channels (direction = O) are to be defined, then the incoming channels
  17232. (direction = I) should be described. The channel numbers are assigned automatically starting with 00th.
  17233. </li>
  17234. <li><a name="gwCmd">gwCmd</a> switching|dimming|setpointShift|setpointBasic|controlVar|fanStage|blindCmd<br>
  17235. Gateway Command Type, see <a href="#Gateway">Gateway</a> profile
  17236. </li>
  17237. <li><a name="EnOcean_humidity">humidity</a> rH/%<br>
  17238. The value of the actual humidity, used by a Room Sensor and Control Unit. Should by
  17239. filled via a notify from a distinct humidity sensor.
  17240. </li>
  17241. <li><a name="EnOcean_humidityRefDev">humidityRefDev</a> &lt;name&gt;<br>
  17242. Name of the device whose reference value is read. The reference values is
  17243. the reading humidity.
  17244. </li>
  17245. <li><a href="#ignore">ignore</a></li>
  17246. <li><a href="#IODev">IODev</a></li>
  17247. <li><a name="EnOcean_keyRcv">keyRcv</a> &lt;private key 16 byte hex&gt;<br>
  17248. Private Key for receive direction
  17249. </li>
  17250. <li><a name="EnOcean_keySnd">keySnd</a> &lt;private key 16 byte hex&gt;<br>
  17251. Private Key for send direction
  17252. </li>
  17253. <li><a name="EnOcean_macAlgo">macAlgo</a> no|3|4<br>
  17254. MAC Algorithm
  17255. </li>
  17256. <li><a name="EnOcean_manufID">manufID</a> &lt;000 ... 7FF&gt;<br>
  17257. Manufacturer ID number
  17258. </li>
  17259. <li><a name="EnOcean_measurementCtrl">measurementCtrl</a> enable|disable<br>
  17260. Enable or disable the temperature measurements (room and feed temperature) of the actuator. If the temperature
  17261. measurements are turned off, an external temperature sensor must be exists, see attribute
  17262. <a href="#temperatureRefDev">temperatureRefDev</a>.
  17263. </li>
  17264. <li><a href="#model">model</a></li>
  17265. <li><a name="EnOcean_observe">observe</a> off|on, [observe] = off is default.<br>
  17266. Observing and repeating the execution of set commands
  17267. </li>
  17268. <li><a name="EnOcean_observeCmdRepetition">observeCmdRepetition</a> 1..5, [observeCmdRepetition] = 2 is default.<br>
  17269. Maximum number of command retries
  17270. </li>
  17271. <li><a name="EnOcean_observeErrorAction">observeErrorAction</a> &lt;command&gt;<br>
  17272. Command being executed after an error. If &lt;command&gt; is enclosed in {},
  17273. then it is a perl expression, if it is enclosed in "", then it is a shell command,
  17274. else it is a "plain" fhem.pl command (chain). In the &lt;command&gt; you can access the set
  17275. command. $TYPE, $NAME, $FAILEDDEV, $EVENT, $EVTPART0, $EVTPART1, $EVTPART2, etc. contains the space separated
  17276. set parts. The <a href="#eventMap">eventMap</a> replacements are taken into account. This data
  17277. is available as a local variable in perl, as environment variable for shell
  17278. scripts, and will be textually replaced for Fhem commands.
  17279. </li>
  17280. <li><a name="EnOcean_observeInterval">observeInterval</a> 1/s ... 255/s, [observeInterval] = 1 is default.<br>
  17281. Interval between two observations
  17282. </li>
  17283. <li><a name="EnOcean_observeLogic">observeLogic</a> and|or, [observeLogic] = or is default.<br>
  17284. Observe logic
  17285. </li>
  17286. <li><a name="EnOcean_observeRefDev">observeRefDev</a> &lt;name&gt; [&lt;name&gt; [&lt;name&gt;]],
  17287. [observeRefDev] = &lt;name of the own device&gt; is default<br>
  17288. Names of the devices to be observed. The list must be separated by spaces.
  17289. </li>
  17290. <li><a name="EnOcean_pidActorCallBeforeSetting">pidActorCallBeforeSetting</a>,
  17291. [pidActorCallBeforeSetting] = not defined is default<br>
  17292. Callback-function, which can manipulate the actorValue. Further information see modul PID20.
  17293. </li>
  17294. <li><a name="EnOcean_pidActorErrorAction">pidActorErrorAction</a> freeze|errorPos,
  17295. [pidActorErrorAction] = freeze is default<br>
  17296. required action on error
  17297. </li>
  17298. <li><a name="EnOcean_pidActorErrorPos">pidActorErrorPos</a> valvePos/%,
  17299. [pidActorErrorPos] = 0...100, 0 is default<br>
  17300. actor's position to be used in case of error
  17301. </li>
  17302. <li><a name="EnOcean_pidActorLimitLower">pidActorLimitLower</a> valvePos/%,
  17303. [pidActorLimitLower] = 0...100, 0 is default<br>
  17304. lower limit for actor
  17305. </li>
  17306. <li><a name="EnOcean_pidActorLimitUpper">pidActorLimitUpper</a> valvePos/%,
  17307. [pidActorLimitUpper] = 0...100, 100 is default<br>
  17308. upper limit for actor
  17309. </li>
  17310. <li><a name="EnOcean_pidCtrl">pidCtrl</a> on|off,
  17311. [pidCtrl] = on is default<br>
  17312. Activate the Fhem PID regulator
  17313. </li>
  17314. <li><a name="EnOcean_pidDeltaTreshold">pidDeltaTreshold</a> &lt;floating-point number&gt;,
  17315. [pidDeltaTreshold] = 0 is default<br>
  17316. if delta < delta-threshold the pid will enter idle state
  17317. </li>
  17318. <li><a name="EnOcean_pidFactor_P">pidFactor_P</a> &lt;floating-point number&gt;,
  17319. [pidFactor_P] = 25 is default<br>
  17320. P value for PID
  17321. </li>
  17322. <li><a name="EnOcean_pidFactor_I">pidFactor_I</a> &lt;floating-point number&gt;,
  17323. [pidFactor_I] = 0.25 is default<br>
  17324. I value for PID
  17325. </li>
  17326. <li><a name="EnOcean_pidFactor_D">pidFactor_D</a> &lt;floating-point number&gt;,
  17327. [pidFactor_D] = 0 is default<br>
  17328. D value for PID
  17329. </li>
  17330. <li><a name="EnOcean_pidIPortionCallBeforeSetting">pidIPortionCallBeforeSetting</a>
  17331. [pidIPortionCallBeforeSetting] = not defined is default<br>
  17332. Callback-function, which can manipulate the value of I-Portion. Further information see modul PID20.
  17333. </li>
  17334. <li><a name="EnOcean_pidSensorTimeout">pidSensorTimeout t/s</a>
  17335. [pidSensorTimeout] = 3600 is default<br>
  17336. number of seconds to wait before sensor <a href="#temperatureRefDev">temperatureRefDev</a> will be recognized n/a
  17337. </li>
  17338. <li><a name="EnOcean_pollInterval">pollInterval</a> t/s, [pollInterval] = 10 is default.<br>
  17339. [pollInterval] = 1 ... 1440.<br>
  17340. pollInterval is supported for roomCtrlPanel.00.
  17341. </li>
  17342. <li><a name="EnOcean_rampTime">rampTime</a> t/s or relative, [rampTime] = 1 is default.<br>
  17343. No ramping or for Eltako dimming speed set on the dimmer if [rampTime] = 0.<br>
  17344. Gateway/dimmung: Ramping time 1 s to 255 s or relative fast to low dimming speed if [rampTime] = 1 ... 255.<br>
  17345. lightCtrl.01: Ramping time 1 s to 65535 s<br>
  17346. rampTime is supported for gateway, command dimming and lightCtrl.01.
  17347. </li>
  17348. <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
  17349. <li><a name="EnOcean_rcvRespAction">rcvRespAction</a> &lt;command&gt;<br>
  17350. Command being executed after an message from the aktor is received and before an response message is sent.
  17351. If &lt;command&gt; is enclosed in {}, then it is a perl expression, if it is enclosed in "", then it is a shell command,
  17352. else it is a "plain" fhem.pl command (chain). In the &lt;command&gt; you can access the name of the device by using $NAME
  17353. and the current readings $ACTUATORSTATE, $BATTERY, $COVER, $ENERGYINPUT, $ENERGYSTORAGE, $MAINTENANCEMODE, $OPERATIONMODE,
  17354. $ROOMTEMP, $SELFCTRL, $SETPOINT, $SETPOINTTEMP, $SUMMERMODE, $TEMPERATURE, $WINDOW for the subType hvac.01 and $NAME,
  17355. $BATTERY, $FEEDTEMP, $MAINTENANCEMODE, $OPERATIONMODE, $ROOMTEMP, $SETPOINT, $SETPOINTTEMP, $SUMMERMODE, $TEMPERATURE
  17356. for the subType hvac.04.
  17357. This data is available as a local variable in perl, as environment variable for shell
  17358. scripts, and will be textually replaced for Fhem commands.
  17359. </li>
  17360. <li><a name="EnOcean_remoteCode">remoteCode</a> &lt;00000000...FFFFFFFE&gt;<br>
  17361. Remote Management Security Code, 00000000 is interpreted as on code has been set.
  17362. </li>
  17363. <li><a name="EnOcean_remoteEEP">remoteEEP</a> &lt;00...FF&gt;-&lt;00...3F&gt;-&lt;00...7F&gt;<br>
  17364. Remote Management EnOcean Equipment Profile (EEP)
  17365. </li>
  17366. <li><a name="EnOcean_remoteID">remoteID</a> &lt;00000001...FFFFFFFE&gt;<br>
  17367. Remote Management Remote Device ID
  17368. </li>
  17369. <li><a name="EnOcean_remoteManagement">remoteManagement</a> client|manager|off,
  17370. [remoteManagement] = off is default.<br>
  17371. Enable Remote Management for the device.
  17372. </li>
  17373. <li><a name="EnOcean_remoteManufID">remoteManufID</a> &lt;000...7FF&gt;<br>
  17374. Remote Management Manufacturer ID
  17375. </li>
  17376. <li><a name="repeatingAllowed">repeatingAllowed</a> yes|no,
  17377. [repeatingAllowed] = yes is default.<br>
  17378. EnOcean Repeater in the transmission range of Fhem may forward data messages
  17379. of the device, if the attribute is set to yes.
  17380. </li>
  17381. <li><a name="EnOcean_releasedChannel">releasedChannel</a> A|B|C|D|I|0|auto, [releasedChannel] = auto is default.<br>
  17382. Attribute releasedChannel determines via which SenderID (subDefA ... subDef0) the command released is sent.
  17383. If [releasedChannel] = auto, the SenderID the last command A0, AI, B0, BI, C0, CI, D0 or DI is used.
  17384. Attribute releasedChannel is supported for attr switchType = central and attr switchType = channel.
  17385. </li>
  17386. <li><a name="EnOcean_reposition">reposition</a> directly|opens|closes, [reposition] = directly is default.<br>
  17387. Attribute reposition specifies how to adjust the internal positioning tracker before going to the new position.
  17388. </li>
  17389. <li><a name="EnOcean_rlcAlgo">rlcAlgo</a> 2++|3++<br>
  17390. RLC Algorithm
  17391. </li>
  17392. <li><a name="EnOcean_rlcRcv">rlcRcv</a> &lt;rolling code 2 or 3 byte hex&gt;<br>
  17393. Rolling Code for receive direction
  17394. </li>
  17395. <li><a name="EnOcean_rlcSnd">rlcSnd</a> &lt;rolling code 2 or 3 byte hex&gt;<br>
  17396. Rolling Code for send direction
  17397. </li>
  17398. <li><a name="EnOcean_rlcTX">rlcTX</a> false|true<br>
  17399. Rolling Code is expected in the received telegram
  17400. </li>
  17401. <li><a name="EnOcean_rltRepeat">rltRepeat</a> 16|32|64|128|256,
  17402. [rltRepeat] = 16 is default.<br>
  17403. Number of RLT MasterTest messages sent
  17404. </li>
  17405. <li><a name="EnOcean_rltType">rltType</a> 1BS|4BS,
  17406. [rltType] = 4BS is default.<br>
  17407. Type of RLT MasterTest message
  17408. </li>
  17409. <li><a name="scaleDecimals">scaleDecimals</a> 0 ... 9<br>
  17410. Decimal rounding with x digits of the scaled reading setpoint
  17411. </li>
  17412. <li><a name="EnOcean_teachMethod">teachMethod</a> 1BS|4B|confirm|GP|RPS|smartAck|STE|UTE<br>
  17413. teach-in method
  17414. </li>
  17415. <li><a name="scaleMax">scaleMax</a> &lt;floating-point number&gt;<br>
  17416. Scaled maximum value of the reading setpoint
  17417. </li>
  17418. <li><a name="scaleMin">scaleMin</a> &lt;floating-point number&gt;<br>
  17419. Scaled minimum value of the reading setpoint
  17420. </li>
  17421. <li><a name="EnOcean_secLevel">secLevel</a> encapsulation|encryption|off, [secLevel] = off is default<br>
  17422. Security level of the data
  17423. </li>
  17424. <li><a name="EnOcean_secMode">secMode</a> rcv|snd|bidir<br>
  17425. Telegram direction, which is secured
  17426. </li>
  17427. <li><a name="EnOcean_sendDevStatus">sendDevStatus</a> no|yes, [sendDevStatus] = no is default.<br>
  17428. Send new status of the device.
  17429. </li>
  17430. <li><a name="sensorMode">sensorMode</a> switch|pushbutton,
  17431. [sensorMode] = switch is default.<br>
  17432. The status "released" will be shown in the reading state if the
  17433. attribute is set to "pushbutton".
  17434. </li>
  17435. <li><a name="EnOcean_serviceOn">serviceOn</a> no|yes,
  17436. [serviceOn] = no is default.<br>
  17437. Device in Service Mode.
  17438. </li>
  17439. <li><a name="EnOcean_setCmdTrigger">setCmdTrigger</a> man|refDev, [setCmdTrigger] = man is default.<br>
  17440. Operation mode to send set commands<br>
  17441. If the attribute is set to "refDev", a device-specific set command is sent when the reference device is updated.
  17442. For the subType "roomSensorControl.05" and "fanCrtl.00" the reference "temperatureRefDev" is supported.<br>
  17443. For the subType "roomSensorControl.01" the references "humidityRefDev" and "temperatureRefDev" are supported.<br>
  17444. </li>
  17445. <li><a name="EnOcean_setpointRefDev">setpointRefDev</a> &lt;name&gt;<br>
  17446. Name of the device whose reference value is read. The reference values is
  17447. the reading setpoint.
  17448. </li>
  17449. <li><a name="EnOcean_setpointSummerMode">setpointSummerMode</a> valvePos/%,
  17450. [setpointSummerMode] = 0...100, 0 is default<br>
  17451. Valve position in summer operation
  17452. </li>
  17453. <li><a name="EnOcean_setpointTempRefDev">setpointTempRefDev</a> &lt;name&gt;<br>
  17454. Name of the device whose reference value is read. The reference values is
  17455. the reading setpointTemp.
  17456. </li>
  17457. <li><a name="EnOcean_settingAccuracy">settingAccuracy</a> high|low,
  17458. [settingAccuracy] = low is default.<br>
  17459. set setting accurancy.
  17460. </li>
  17461. <li><a href="#showtime">showtime</a></li>
  17462. <li><a name="shutTime">shutTime</a> &lt;channel1&gt;[:&lt;channel2&gt;[:&lt;channel3&gt;[:&lt;channel4&gt;]]]<br>
  17463. subType blindsCtrl.00, blindsCtrl.01: [shutTime] = 5 ... 300, 300 is default.<br>
  17464. subType manufProfile: [shutTime] = 1 ... 255, 255 is default.<br>
  17465. Use the attr shutTime to set the time delay to the position "Halt" in
  17466. seconds. Select a delay time that is at least as long as the shading element
  17467. or roller shutter needs to move from its end position to the other position.<br>
  17468. Notice subType blindsCrtl.00: The attribute can only be set while the actuator is online.
  17469. </li>
  17470. <li><a name="shutTimeCloses">shutTimeCloses</a> t/s, [shutTimeCloses] = 1 ... 255,
  17471. [shutTimeCloses] = [shutTime] is default.<br>
  17472. Set the attr shutTimeCloses to define the runtime used by the commands opens and closes.
  17473. Select a runtime that is at least as long as the value set by the delay switch of the actuator.
  17474. <br>
  17475. shutTimeCloses is supported for shutter.
  17476. </li>
  17477. <li><a name="subDef">subDef</a> &lt;EnOcean SenderID&gt;,
  17478. [subDef] = [DEF] is default.<br>
  17479. SenderID (<a href="#TCM">TCM</a> BaseID + offset) to control a bidirectional switch or actor.<br>
  17480. In order to control devices that send acknowledge telegrams, you cannot reuse the ID of this
  17481. devices, instead you have to create your own, which must be in the
  17482. allowed ID-Range of the underlying IO device. For this first query the
  17483. <a href="#TCM">TCM</a> with the "<code>get &lt;tcm&gt; idbase</code>" command. You can use
  17484. up to 128 IDs starting with the base shown there.<br>
  17485. If [subDef] = getNextID FHEM can assign a free SenderID alternatively. The system configuration
  17486. needs to be reloaded. The assigned SenderID will only displayed after the system configuration
  17487. has been reloaded, e.g. Fhem command rereadcfg.
  17488. </li>
  17489. <li><a name="subDefA">subDefA</a> &lt;EnOcean SenderID&gt;,
  17490. [subDefA] = [subDef] is default.<br>
  17491. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = A0|AI|released<br>
  17492. Used with switch type "channel". Set attr switchType to channel.<br>
  17493. subDefA is supported for switches.<br>
  17494. Second action is not sent.<br>
  17495. If [subDefA] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17496. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17497. </li>
  17498. <li><a name="subDefB">subDefB</a> &lt;EnOcean SenderID&gt;,
  17499. [subDefB] = [subDef] is default.<br>
  17500. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = B0|BI|released<br>
  17501. Used with switch type "channel". Set attr switchType to channel.<br>
  17502. subDefB is supported for switches.<br>
  17503. Second action is not sent.<br>
  17504. If [subDefB] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17505. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17506. </li>
  17507. <li><a name="subDefC">subDefC</a> &lt;EnOcean SenderID&gt;,
  17508. [subDefC] = [subDef] is default.<br>
  17509. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = C0|CI|released<br>
  17510. Used with switch type "channel". Set attr switchType to channel.<br>
  17511. subDefC is supported for switches.<br>
  17512. Second action is not sent.<br>
  17513. If [subDefC] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17514. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17515. </li>
  17516. <li><a name="subDefD">subDefD</a> &lt;EnOcean SenderID&gt;,
  17517. [subDefD] = [subDef] is default.<br>
  17518. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = D0|DI|released<br>
  17519. Used with switch type "channel". Set attr switchType to channel.<br>
  17520. subDefD is supported for switches.<br>
  17521. Second action is not sent.<br>
  17522. If [subDefD] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17523. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17524. </li>
  17525. <li><a name="subDef0">subDef0</a> &lt;EnOcean SenderID&gt;,
  17526. [subDef0] = [subDef] is default.<br>
  17527. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = A0|B0|C0|D0|released<br>
  17528. Used with switch type "central". Set attr switchType to central.<br>
  17529. Use the sensor type "zentral aus/ein" for Eltako devices.<br>
  17530. subDef0 is supported for switches.<br>
  17531. Second action is not sent.<br>
  17532. If [subDef0] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17533. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17534. </li>
  17535. <li><a name="subDefI">subDefI</a> &lt;EnOcean SenderID&gt;,
  17536. [subDefI] = [subDef] is default.<br>
  17537. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = AI|BI|CI|DI<br>
  17538. Used with switch type "central". Set attr switchType to central.<br>
  17539. Use the sensor type "zentral aus/ein" for Eltako devices.<br>
  17540. subDefI is supported for switches.<br>
  17541. Second action is not sent.<br>
  17542. If [subDefI] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17543. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17544. </li>
  17545. <li><a name="EnOcean_subDefH">subDefH</a> &lt;EnOcean SenderID&gt;,
  17546. [subDefH] = undef is default.<br>
  17547. SenderID (<a href="#TCM">TCM</a> BaseID + offset)<br>
  17548. Used with subType "multisensor.00". If the attribute subDefH is set, the position of the window handle as EEP F6-10-00
  17549. (windowHandle) telegram is forwarded.<br>
  17550. If [subDefH] = getNextID FHEM can assign a free SenderID alternatively.
  17551. </li>
  17552. <li><a name="EnOcean_subDefW">subDefW</a> &lt;EnOcean SenderID&gt;,
  17553. [subDefW] = undef is default.<br>
  17554. SenderID (<a href="#TCM">TCM</a> BaseID + offset)<br>
  17555. Used with subType "multisensor.00". If the attribute subDefW is set, the window state as EEP D5-00-01
  17556. (contact) telegram is forwarded.<br>
  17557. If [subDefW] = getNextID FHEM can assign a free SenderID alternatively.
  17558. </li>
  17559. <li><a href="#subType">subType</a></li>
  17560. <li><a name="subTypeSet">subTypeSet</a> &lt;type of device&gt;, [subTypeSet] = [subType] is default.<br>
  17561. Type of device (EEP Profile) used for sending commands. Set the Attribute manually.
  17562. The profile has to fit their basic profile. More information can be found in the basic profiles.
  17563. </li>
  17564. <li><a name="EnOcean_summerMode">summerMode</a> off|on,
  17565. [summerMode] = off is default.<br>
  17566. Put Battery Powered Actuator (hvac.01) or Heating Radiator Actuating Drive (hvac.04) in summer operation
  17567. to reduce energy consumption. If [summerMode] = on, the set commands are not executed.
  17568. </li>
  17569. <li><a name="EnOcean_switchHysteresis">switchHysteresis</a> &lt;value&gt;,
  17570. [switchHysteresis] = 1 is default.<br>
  17571. Switch Hysteresis
  17572. </li>
  17573. <li><a name="switchMode">switchMode</a> switch|pushbutton,
  17574. [switchMode] = switch is default.<br>
  17575. The set command "released" immediately after &lt;value&gt; is sent if the
  17576. attribute is set to "pushbutton".
  17577. </li>
  17578. <li><a name="switchType">switchType</a> direction|universal|central|channel,
  17579. [switchType] = direction is default.<br>
  17580. EnOcean Devices support different types of sensors, e. g. direction
  17581. switch, universal switch or pushbutton, central on/off.<br>
  17582. For Eltako devices these are the sensor types "Richtungstaster",
  17583. "Universalschalter" or "Universaltaster", "Zentral aus/ein".<br>
  17584. With the sensor type <code>direction</code> switch on/off commands are
  17585. accepted, e. g. B0, BI, released. Fhem can control an device with this
  17586. sensor type unique. This is the default function and should be
  17587. preferred.<br>
  17588. Some devices only support the <code>universal switch
  17589. </code> or <code>pushbutton</code>. With a Fhem command, for example,
  17590. B0 or BI is switched between two states. In this case Fhem cannot
  17591. control this device unique. But if the Attribute <code>switchType
  17592. </code> is set to <code>universal</code> Fhem synchronized with
  17593. a bidirectional device and normal on/off commands can be used.
  17594. If the bidirectional device response with the channel B
  17595. confirmation telegrams also B0 and BI commands are to be sent,
  17596. e g. channel A with A0 and AI. Also note that confirmation telegrams
  17597. needs to be sent.<br>
  17598. Partly for the switchType <code>central</code> two different SenderID
  17599. are required. In this case set the Attribute <code>switchType</code> to
  17600. <code>central</code> and define the Attributes
  17601. <a href="#subDef0">subDef0</a> and <a href="#subDefI">subDefI</a>.<br>
  17602. Furthermore, SenderIDs can be used depending on the channel A, B, C or D.
  17603. In this case set the Attribute switchType to <code>channel</code> and define
  17604. the Attributes <a href="#subDefA">subDefA</a>, <a href="#subDefB">subDefB</a>,
  17605. <a href="#subDefC">subDefC</a>, or <a href="#subDefD">subDefD</a>.
  17606. </li>
  17607. <li><a name="temperatureRefDev">temperatureRefDev</a> &lt;name&gt;<br>
  17608. Name of the device whose reference value is read. The reference values is
  17609. the reading temperature.
  17610. </li>
  17611. <li><a name="EnOcean_temperatureScale">temperatureScale</a> F|C|default|no_change, [temperatureScale] = no_change is default.<br>
  17612. temperatureScale is supported for roomCtrlPanel.00.
  17613. </li>
  17614. <li><a name="EnOcean_timeNotation">timeNotation</a> 12|24|default|no_change, [timeNotation] = no_change is default.<br>
  17615. timeNotation is supported for roomCtrlPanel.00.
  17616. </li>
  17617. <li><a name="EnOcean_timeProgram[1-4]">timeProgram[1-4]</a> &lt;period&gt; &lt;starttime&gt; &lt;endtime&gt; &lt;roomCtrlMode&gt;, [timeProgam[1-4]] = &lt;none&gt; is default.<br>
  17618. [period] = FrMo|FrSu|ThFr|WeFr|TuTh|MoWe|SaSu|MoFr|MoSu|Su|Sa|Fr|Th|We|Tu|Mo<br>
  17619. [starttime] = [00..23]:[00|15|30|45]<br>
  17620. [endtime] = [00..23]:[00|15|30|45]<br>
  17621. [roomCtrlMode] = buildingProtection|comfort|economy|preComfort<br>
  17622. The Room Control Panel Kieback & Peter RBW322-FTL supports only [roomCtrlMode] = comfort.<br>
  17623. timeProgram is supported for roomCtrlPanel.00.
  17624. </li>
  17625. <li><a name="EnOcean_trackerWakeUpCycle">trackerWakeUpCycle</a> t/s, [wakeUpCycle] =10 s, 20 s, 30 s, 40 s, 60 s, 120 s, 180 s, 240 s, 3600, 86400 s, 30 s is default.<br>
  17626. Transmission cycle of the tracker.
  17627. </li>
  17628. <li><a name="EnOcean_updateState">updateState</a> default|yes|no, [updateState] = default is default.<br>
  17629. update reading state after set commands
  17630. </li>
  17631. <li><a name="EnOcean_uteResponseRequest">uteResponseRequest</a> yes|no<br>
  17632. request UTE teach-in/teach-out response message, the standard value depends on the EEP profil
  17633. </li>
  17634. <li><a href="#verbose">verbose</a></li>
  17635. <li><a name="EnOcean_wakeUpCycle">wakeUpCycle</a> t/s, [wakeUpCycle] = 10 s ... 151200 s, 300 s is default.<br>
  17636. Transmission cycle of the actuator.
  17637. </li>
  17638. <li><a href="#webCmd">webCmd</a></li>
  17639. </ul>
  17640. </ul>
  17641. <br>
  17642. <a name="EnOceanevents"></a>
  17643. <b>Generated events</b>
  17644. <ul>
  17645. <ul>
  17646. <li><a name="EnOcean_remoteEvents">Remote Management</a><br>
  17647. <ul>
  17648. <li>remoteDevCfg&lt;0000...FFFF&gt;: &lt;device config&gt;</li>
  17649. <li>remoteFunction&lt;01...99&gt;: &lt;remote function number&gt;:&lt;remote manufacturer ID&gt;:&lt;explanation&gt;</li>
  17650. <li>remoteLastFunctionNumber: 001...FFF</li>
  17651. <li>remoteLastStatusReturnCode: 00...FF</li>
  17652. <li>remoteLearn: not_supported|supported</li>
  17653. <li>remoteLinkCfg&lt;in|out&gt;&lt;00...FF&gt;: &lt;data index&gt;:&lt;device config&gt;</li>
  17654. <li>remoteLinkTableDesc&lt;in|out&gt;&lt;00...FF&gt;: &lt;DeviceID&gt;:&lt;EEP&gt;:&lt;channel&gt;</li>
  17655. <li>remoteLinkTableGPDesc&lt;in|out&gt;&lt;00...FF&gt;: &lt;name of channel 00&gt;:&lt;O|I&gt;:&lt;channel type&gt;:&lt;signal type&gt;:&lt;value type&gt;[:&lt;resolution&gt;[:&lt;engineering min&gt;:&lt;scaling min&gt;:&lt;engineering max&gt;:&lt;scaling max&gt;]]</li>
  17656. <li>remoteProductID: 00000000...FFFFFFFF</li>
  17657. <li>remoteRepeaterFilter: AND|OR</li>
  17658. <li>remoteRepeaterFunction: on|off|filter</li>
  17659. <li>remoteRepeaterLevel: 1|2</li>
  17660. <li>remoteTeach: not_supported|supported</li>
  17661. <li>remoteRSSI: LP/dBm</li>
  17662. <li>teach: &lt;result of teach procedure&gt;</li>
  17663. </ul>
  17664. </li>
  17665. <br><br>
  17666. <li>Switch (EEP F6-02-01 ... F6-03-02)<br>
  17667. <ul>
  17668. <li>A0</li>
  17669. <li>AI</li>
  17670. <li>B0</li>
  17671. <li>BI</li>
  17672. <li>C0</li>
  17673. <li>CI</li>
  17674. <li>D0</li>
  17675. <li>DI</li>
  17676. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17677. one of the above, e.g. A0 BI or D0 CI</li>
  17678. <li>buttons: pressed|released</li>
  17679. <li>state: &lt;BtnX&gt;[,&lt;BtnY&gt;]</li>
  17680. </ul><br>
  17681. Switches (remote controls) or actors with more than one
  17682. (pair) keys may have multiple channels e. g. B0/BI, A0/AI with one
  17683. SenderID or with separate addresses.
  17684. </li>
  17685. <br><br>
  17686. <li>Pushbutton Switch, Pushbutton Input Module (EEP F6-02-01 ... F6-02-02, F6-01-01)<br>
  17687. [Eltako FT55, FSM12, FSM61, FTS12]<br>
  17688. <ul>
  17689. <li>A0</li>
  17690. <li>AI</li>
  17691. <li>B0</li>
  17692. <li>BI</li>
  17693. <li>C0</li>
  17694. <li>CI</li>
  17695. <li>D0</li>
  17696. <li>DI</li>
  17697. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17698. one of the above, e.g. A0,BI or D0,CI</li>
  17699. <li>released</li>
  17700. <li>buttons: pressed|released</li>
  17701. <li>state: &lt;BtnX&gt;[,&lt;BtnY&gt;] [released]</li>
  17702. </ul><br>
  17703. The status of the device may become "released", this is not the case for a normal switch.<br>
  17704. Set attr model to Eltako_FT55|FSM12|FSM61|FTS12 or attr sensorMode to pushbutton manually.
  17705. </li>
  17706. <br><br>
  17707. <li>Pushbutton Switch (EEP F6-3F-7F)<br>
  17708. [Eltako FGW14/FAM14 with internal decryption and RS-485 communication]<br>
  17709. <ul>
  17710. <li>A0</li>
  17711. <li>AI</li>
  17712. <li>B0</li>
  17713. <li>BI</li>
  17714. <li>C0</li>
  17715. <li>CI</li>
  17716. <li>D0</li>
  17717. <li>DI</li>
  17718. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17719. one of the above, e.g. A0,BI or D0,CI</li>
  17720. <li>released</li>
  17721. <li>buttons: pressed|released</li>
  17722. <li>state: &lt;BtnX&gt;[,&lt;BtnY&gt;] [released]</li>
  17723. </ul><br>
  17724. Set attr subType to switch.7F and manufID to 00D.<br>
  17725. The status of the device may become "released", this is not the case for
  17726. a normal switch. Set attr sensorMode to pushbutton manually.
  17727. </li>
  17728. <br><br>
  17729. <li>Pushbutton Switch (EEP D2-03-00)<br>
  17730. [EnOcean PTM 215 Modul]<br>
  17731. <ul>
  17732. <li>A0</li>
  17733. <li>AI</li>
  17734. <li>B0</li>
  17735. <li>BI</li>
  17736. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17737. one of the above, e.g. A0,BI</li>
  17738. <li>pressed</li>
  17739. <li>released</li>
  17740. <li>teach: &lt;result of teach procedure&gt;</li>
  17741. <li>energyBow: pressed|released</li>
  17742. <li>state: &lt;BtnX&gt;|&lt;BtnX&gt;,&lt;BtnY&gt;|released|pressed|teachIn|teachOut</li>
  17743. </ul><br>
  17744. The attr subType must be switch.00. This is done if the device was
  17745. created by autocreate. Set attr sensorMode to pushbutton manually if needed.
  17746. </li>
  17747. <br><br>
  17748. <li>Heating/Cooling Relay (EEP F6-02-01 ... F6-02-02)<br>
  17749. [Eltako FAE14, FHK14, untested]<br>
  17750. <ul>
  17751. <li>controllerMode: auto|off</li>
  17752. <li>energyHoldOff: normal|holdoff</li>
  17753. <li>buttons: pressed|released</li>
  17754. </ul><br>
  17755. Set attr subType to switch and model to Eltako_FAE14|FHK14 manually. In addition
  17756. every telegram received from a teached-in temperature sensor (e.g. FTR55H)
  17757. is repeated as a confirmation telegram from the Heating/Cooling Relay
  17758. FAE14, FHK14. In this case set attr subType to e. g. roomSensorControl.05
  17759. and attr manufID to 00D.
  17760. </li>
  17761. <br><br>
  17762. <li>Key Card Activated Switch (EEP F6-04-01)<br>
  17763. [Eltako FKC, FKF, FZS, untested]<br>
  17764. <ul>
  17765. <li>keycard_inserted</li>
  17766. <li>keycard_removed</li>
  17767. <li>state: keycard_inserted|keycard_removed</li>
  17768. </ul><br>
  17769. Set attr subType to keycard manually.
  17770. </li>
  17771. <br><br>
  17772. <li>Wind Speed Threshold Detector (EEP F6-05-00)<br>
  17773. <ul>
  17774. <li>on</li>
  17775. <li>off</li>
  17776. <li>alarm: dead_sensor|off</li>
  17777. <li>windSpeed: dead_sensor|on|off</li>
  17778. <li>battery: low|ok</li>
  17779. <li>state: on|off</li>
  17780. </ul><br>
  17781. Set attr subType to windSpeed.00 manually.
  17782. </li>
  17783. <br><br>
  17784. <li>Liquid Leakage Sensor (EEP F6-05-01)<br>
  17785. [untested]<br>
  17786. <ul>
  17787. <li>dry</li>
  17788. <li>wet</li>
  17789. <li>state: dry|wet</li>
  17790. </ul><br>
  17791. Set attr subType to liquidLeakage manually.
  17792. </li>
  17793. <br><br>
  17794. <li>Smoke Detector (EEP F6-05-02)<br>
  17795. [Eltako FRW]<br>
  17796. <ul>
  17797. <li>smoke-alarm</li>
  17798. <li>off</li>
  17799. <li>alarm: dead_sensor|smoke-alarm|off</li>
  17800. <li>battery: low|ok</li>
  17801. <li>state: smoke-alarm|off</li>
  17802. </ul><br>
  17803. Set attr subType to smokeDetector.02 manually.
  17804. </li>
  17805. <br><br>
  17806. <li>Window Handle (EEP F6-10-00, D2-03-10)<br>
  17807. [HOPPE SecuSignal, Eltako FHF, Eltako FTKE]<br>
  17808. <ul>
  17809. <li>closed</li>
  17810. <li>open</li>
  17811. <li>tilted</li>
  17812. <li>open_from_tilted</li>
  17813. <li>state: closed|open|tilted|open_from_tilted</li>
  17814. </ul><br>
  17815. The device windowHandle or windowHandle.10 should be created by autocreate.
  17816. </li>
  17817. <br><br>
  17818. <li>Single Input Contact, Door/Window Contact<br>
  17819. 1BS Telegram (EEP D5-00-01)<br>
  17820. [EnOcean STM 320, STM 329, STM 250, Eltako FTK, Peha D 450 FU]
  17821. <ul>
  17822. <li>closed</li>
  17823. <li>open</li>
  17824. <li>teach: &lt;result of teach procedure&gt;</li>
  17825. <li>state: open|closed</li>
  17826. </ul></li>
  17827. The device should be created by autocreate.
  17828. <br><br>
  17829. <li>Temperature Sensors with with different ranges (EEP A5-02-01 ... A5-02-30)<br>
  17830. [EnOcean STM 330, Eltako FTF55, Thermokon SR65 ...]<br>
  17831. <ul>
  17832. <li>t/&#176C</li>
  17833. <li>temperature: t/&#176C (Sensor Range: t = &lt;t min&gt; &#176C ... &lt;t max&gt; &#176C)</li>
  17834. <li>state: t/&#176C</li>
  17835. </ul><br>
  17836. The attr subType must be tempSensor.01 ... tempSensor.30. This is done if the device was
  17837. created by autocreate.
  17838. </li>
  17839. <br><br>
  17840. <li>Temperatur and Humidity Sensor (EEP A5-04-02)<br>
  17841. [Eltako FAFT60, FIFT63AP]<br>
  17842. <ul>
  17843. <li>T: t/&#176C H: rH/% B: unknown|low|ok</li>
  17844. <li>battery: unknown|low|ok</li>
  17845. <li>energyStorage: unknown|empty|charged|full</li>
  17846. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  17847. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  17848. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 6.6 V)
  17849. <li>state: T: t/&#176C H: rH/% B: unknown|low|ok</li>
  17850. </ul><br>
  17851. The attr subType must be tempHumiSensor.02 and attr
  17852. manufID must be 00D for Eltako Devices. This is done if the device was
  17853. created by autocreate.
  17854. </li>
  17855. <br><br>
  17856. <li>Temperatur and Humidity Sensor (EEP A5-04-03)<br>
  17857. [untsted]<br>
  17858. <ul>
  17859. <li>T: t/&#176C H: rH/%</li>
  17860. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  17861. <li>telegramType: heartbeat|event</li>
  17862. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  17863. <li>state: T: t/&#176C H: rH/%</li>
  17864. </ul><br>
  17865. The attr subType must be tempHumiSensor.03. This is done if the device was
  17866. created by autocreate.
  17867. </li>
  17868. <br><br>
  17869. <li>Barometric Sensor (EEP A5-05-01)<br>
  17870. [untested]<br>
  17871. <ul>
  17872. <li>P/hPa</li>
  17873. <li>airPressure: P/hPa (Sensor Range: P = 500 hPa ... 1150 hPa</li>
  17874. <li>telegramType: heartbeat|event</li>
  17875. <li>state: P/hPa</li>
  17876. </ul><br>
  17877. The attr subType must be baroSensor.01. This is done if the device was
  17878. created by autocreate.
  17879. </li>
  17880. <br><br>
  17881. <li>Light Sensor (EEP A5-06-01)<br>
  17882. [Eltako FAH60, FAH63, FIH63, Thermokon SR65 LI]<br>
  17883. <ul>
  17884. <li>E/lx</li>
  17885. <li>brightness: E/lx (Sensor Range: 300 lx ... 30 klx, 600 lx ... 60 klx
  17886. , Sensor Range for Eltako: E = 0 lx ... 100 lx, 300 lx ... 30 klx)</li>
  17887. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 5.1 V)
  17888. <li>state: E/lx</li>
  17889. </ul><br>
  17890. Eltako devices only support Brightness.<br>
  17891. The attr subType must be lightSensor.01 and attr manufID must be 00D
  17892. for Eltako Devices. This is done if the device was created by
  17893. autocreate.
  17894. </li>
  17895. <br><br>
  17896. <li>Light Sensor (EEP A5-06-02)<br>
  17897. [untested]<br>
  17898. <ul>
  17899. <li>E/lx</li>
  17900. <li>brightness: E/lx (Sensor Range: 0 lx ... 1020 lx</li>
  17901. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.1 V)</li>
  17902. <li>state: E/lx</li>
  17903. </ul><br>
  17904. The attr subType must be lightSensor.02. This is done if the device was
  17905. created by autocreate.
  17906. </li>
  17907. <br><br>
  17908. <li>Light Sensor (EEP A5-06-03)<br>
  17909. [untested]<br>
  17910. <ul>
  17911. <li>E/lx</li>
  17912. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  17913. <li>errorCode: 251 ... 255</li>
  17914. <li>state: E/lx</li>
  17915. </ul><br>
  17916. The attr subType must be lightSensor.03. This is done if the device was
  17917. created by autocreate.
  17918. </li>
  17919. <br><br>
  17920. <li>Light Sensor (EEP A5-06-04)<br>
  17921. [untested]<br>
  17922. <ul>
  17923. <li>T: t/&#176C E: E/lx B: ok|low</li>
  17924. <li>battery: ok|low</li>
  17925. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 65535 lx)</li>
  17926. <li>energyStorage: 1/%</li>
  17927. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  17928. <li>state: T: t/&#176C E: E/lx B: ok|low</li>
  17929. </ul><br>
  17930. The attr subType must be lightSensor.04. This is done if the device was
  17931. created by autocreate.
  17932. </li>
  17933. <br><br>
  17934. <li>Light Sensor (EEP A5-06-05)<br>
  17935. [untested]<br>
  17936. <ul>
  17937. <li>E/lx</li>
  17938. <li>brightness: E/lx (Sensor Range: 0 lx ... 10200 lx</li>
  17939. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.1 V)</li>
  17940. <li>state: E/lx</li>
  17941. </ul><br>
  17942. The attr subType must be lightSensor.05. This is done if the device was created by autocreate.
  17943. </li>
  17944. <br><br>
  17945. <li>Occupancy Sensor (EEP A5-07-01, A5-07-02)<br>
  17946. [EnOcean EOSW]<br>
  17947. <ul>
  17948. <li>on|off</li>
  17949. <li>battery: ok|low</li>
  17950. <li>button: pressed|released</li>
  17951. <li>current: I/&#181;A (Sensor Range: I = 0 V ... 127.0 &#181;A)</li>
  17952. <li>errorCode: 251 ... 255</li>
  17953. <li>motion: on|off</li>
  17954. <li>sensorType: ceiling|wall</li>
  17955. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  17956. <li>state: on|off</li>
  17957. </ul><br>
  17958. The attr subType must be occupSensor.<01|02>. This is done if the device was
  17959. created by autocreate. Current is the solar panel current. Some values are
  17960. displayed only for certain types of devices.
  17961. </li>
  17962. <br><br>
  17963. <li>Eltako/PioTek-Tracker TF-TTB (EEP A5-07-01)<br>
  17964. <ul>
  17965. <li>on|off</li>
  17966. <li>battery: ok|low</li>
  17967. <li>button: pressed|released</li>
  17968. <li>motion: on|off</li>
  17969. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  17970. <li>state: on|off</li>
  17971. </ul><br>
  17972. The attr subType must be occupSensor.01. This is done if the device was
  17973. created by autocreate. The attr model has to be set manually to tracker.
  17974. Alternatively, the profile will be defined with inofficial EEP G5-07-01.<br>
  17975. The transmission cycle is set using the attribute <a href="#EnOcean_trackerWakeUpCycle">trackerWakeUpCycle</a>.
  17976. </li>
  17977. <br><br>
  17978. <li>Occupancy Sensor (EEP A5-07-03)<br>
  17979. [untested]<br>
  17980. <ul>
  17981. <li>M: on|off E: E/lx U: U/V</li>
  17982. <li>battery: ok|low</li>
  17983. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  17984. <li>errorCode: 251 ... 255</li>
  17985. <li>motion: on|off</li>
  17986. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  17987. <li>state: M: on|off E: E/lx U: U/V</li>
  17988. </ul><br>
  17989. The attr subType must be occupSensor.03. This is done if the device was
  17990. created by autocreate.
  17991. </li>
  17992. <br><br>
  17993. <li>Light, Temperatur and Occupancy Sensor (EEP A5-08-01 ... A5-08-03)<br>
  17994. [Eltako FABH63, FBH55, FBH63, FIBH63, Thermokon SR-MDS, PEHA 482 FU-BM DE]<br>
  17995. <ul>
  17996. <li>M: on|off E: E/lx P: absent|present T: t/&#176C U: U/V</li>
  17997. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 510, 1020, 1530 or 2048 lx)</li>
  17998. <li>motion: on|off</li>
  17999. <li>presence: absent|present</li>
  18000. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 51 &#176C or -30 &#176C ... 50 &#176C)</li>
  18001. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 5.1 V)
  18002. <li>state: M: on|off E: E/lx P: absent|present T: t/&#176C U: U/V</li>
  18003. </ul><br>
  18004. Eltako and PEHA devices only support Brightness and Motion.<br>
  18005. The attr subType must be lightTempOccupSensor.<01|02|03> and attr
  18006. manufID must be 00D for Eltako Devices. This is done if the device was
  18007. created by autocreate.
  18008. </li>
  18009. <br><br>
  18010. <li>Gas Sensor, CO Sensor (EEP A5-09-01)<br>
  18011. [untested]<br>
  18012. <ul>
  18013. <li>CO: c/ppm (Sensor Range: c = 0 ppm ... 255 ppm)</li>
  18014. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 255 &#176C)</li>
  18015. <li>state: c/ppm</li>
  18016. </ul><br>
  18017. The attr subType must be COSensor.01. This is done if the device was created by autocreate.
  18018. </li>
  18019. <br><br>
  18020. <li>Gas Sensor, CO Sensor (EEP A5-09-02)<br>
  18021. [untested]<br>
  18022. <ul>
  18023. <li>CO: c/ppm (Sensor Range: c = 0 ppm ... 1020 ppm)</li>
  18024. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 51.0 &#176C)</li>
  18025. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 5.1 V)
  18026. <li>state: c/ppm</li>
  18027. </ul><br>
  18028. The attr subType must be COSensor.02. This is done if the device was
  18029. created by autocreate.
  18030. </li>
  18031. <br><br>
  18032. <li>Gas Sensor, CO2 Sensor (EEP A5-09-04)<br>
  18033. [Thermokon SR04 CO2 *, Eltako FCOTF63, untested]<br>
  18034. <ul>
  18035. <li>airQuality: high|mean|moderate|low (Air Quality Classes DIN EN 13779)</li>
  18036. <li>CO2: c/ppm (Sensor Range: c = 0 ppm ... 2550 ppm)</li>
  18037. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18038. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 51 &#176C)</li>
  18039. <li>state: T: t/&#176C H: rH/% CO2: c/ppm AQ: high|mean|moderate|low</li>
  18040. </ul><br>
  18041. The attr subType must be tempHumiCO2Sensor.01. This is done if the device was
  18042. created by autocreate.
  18043. </li>
  18044. <br><br>
  18045. <li>Gas Sensor, Volatile organic compounds (VOC) Sensor (EEP A5-09-05, A5-09-0C)<br>
  18046. [untested]<br>
  18047. <ul>
  18048. <li>concentration: c/[unit] (Sensor Range: c = 0 ... 655350</li>
  18049. <li>concentrationUnit: ppb|&mu;/m3</li>
  18050. <li>vocName: Name of last measured VOC</li>
  18051. <li>state: c/[unit]</li>
  18052. </ul><br>
  18053. The attr subType must be vocSensor.01. This is done if the device was
  18054. created by autocreate.
  18055. </li>
  18056. <br><br>
  18057. <li>Gas Sensor, Radon Sensor (EEP A5-09-06)<br>
  18058. [untested]<br>
  18059. <ul>
  18060. <li>Rn: A m3/Bq (Sensor Range: A = 0 Bq/m3 ... 1023 Bq/m3)</li>
  18061. <li>state: A m3/Bq</li>
  18062. </ul><br>
  18063. The attr subType must be radonSensor.01. This is done if the device was
  18064. created by autocreate.
  18065. </li>
  18066. <br><br>
  18067. <li>Gas Sensor, Particles Sensor (EEP A5-09-07)<br>
  18068. [untested]<br>
  18069. Three channels with particle sizes of up to 10 &mu;m, 2.5 &mu;m and 1 &mu;m are supported<br>.
  18070. <ul>
  18071. <li>particles_10: p m3/&mu;g | inactive (Sensor Range: p = 0 &mu;g/m3 ... 511 &mu;g/m3)</li>
  18072. <li>particles_2_5: p m3/&mu;g | inactive (Sensor Range: p = 0 &mu;g/m3 ... 511 &mu;g/m3)</li>
  18073. <li>particles_1: p m3/&mu;g | inactive (Sensor Range: p = 0 &mu;g/m3 ... 511 &mu;g/m3)</li>
  18074. <li>state: PM10: p m3/&mu;g PM2_5: p m3/&mu;g PM1: p m3/&mu;g</li>
  18075. </ul><br>
  18076. The attr subType must be particlesSensor.01. This is done if the device was
  18077. created by autocreate.
  18078. </li>
  18079. <br><br>
  18080. <li>CO2 Sensor (EEP A5-09-08, A5-09-09)<br>
  18081. [untested]<br>
  18082. <ul>
  18083. <li>CO2: c/ppm (Sensor Range: c = 0 ppm ... 2000 ppm)</li>
  18084. <li>powerFailureDetection: detected|not_detected</li>
  18085. <li>state: c/ppm</li>
  18086. </ul><br>
  18087. The attr subType must be CO2Sensor.01. This is done if the device was
  18088. created by autocreate.
  18089. </li>
  18090. <br><br>
  18091. <li>H Sensor (EEP A5-09-0A)<br>
  18092. [untested]<br>
  18093. <ul>
  18094. <li>c/ppm</li>
  18095. <li>voltage: U/V (Sensor Range: U = 2 V ... 5 V)</li>
  18096. <li>H: c/ppm (Sensor Range: c = 0 ppm ... 2000 ppm)</li>
  18097. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  18098. <li>state: c/ppm</li>
  18099. </ul><br>
  18100. The attr subType must be HSensor.01. This is done if the device was
  18101. created by autocreate.
  18102. </li>
  18103. <br><br>
  18104. <li>Radiation Sensor (EEP A5-09-0B)<br>
  18105. [untested]<br>
  18106. <ul>
  18107. <li>1/[unit]</li>
  18108. <li>radioactivity: 1/[unit] (Sensor Range: c = 0 [unit] ... 65535 [unit])</li>
  18109. <li>unit: uSv/h|cpm|Bq/L|Bq/kg</li>
  18110. <li>voltage: U/V (Sensor Range: U = 2 V ... 5 V)</li>
  18111. <li>state: 1/[unit]</li>
  18112. </ul><br>
  18113. The attr subType must be radiationSensor.01. This is done if the device was
  18114. created by autocreate.
  18115. </li>
  18116. <br><br>
  18117. <li>Room Sensor and Control Unit (EEP A5-10-01 ... A5-10-0D)<br>
  18118. [Eltako FTR55*, Thermokon SR04 *, Thanos SR *]<br>
  18119. <ul>
  18120. <li>T: t/&#176C SP: 0 ... 255 F: 0|1|2|3|auto SW: 0|1</li>
  18121. <li>fanStage: 0|1|2|3|auto</li>
  18122. <li>switch: on|off</li>
  18123. <li>setpoint: 0 ... 255</li>
  18124. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18125. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18126. <li>state: T: t/&#176C SP: 0 ... 255 F: 0|1|2|3|auto SW: on|off</li><br>
  18127. Alternatively for Eltako devices
  18128. <li>T: t/&#176C SPT: t/&#176C NR: t/&#176C</li>
  18129. <li>block: lock|unlock</li>
  18130. <li>nightReduction: t/K</li>
  18131. <li>setpointTemp: t/&#176C</li>
  18132. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18133. <li>state: T: t/&#176C SPT: t/&#176C NR: t/K</li><br>
  18134. </ul><br>
  18135. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18136. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18137. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18138. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18139. adjust the scaling alternatively.<br>
  18140. The attr subType must be roomSensorControl.05 and attr
  18141. manufID must be 00D for Eltako Devices. This is done if the device was
  18142. created by autocreate.
  18143. </li>
  18144. <br><br>
  18145. <li>Room Sensor and Control Unit (EEP A5-04-01, A5-10-10 ... A5-10-14)<br>
  18146. [Eltako FUTH65D, Thermokon SR04 * rH, Thanos SR *]<br>
  18147. <ul>
  18148. <li>T: t/&#176C H: rH/% SP: 0 ... 255 SW: 0|1</li>
  18149. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18150. <li>switch: 0|1</li>
  18151. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18152. <li>setpoint: 0 ... 255</li>
  18153. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18154. <li>state: T: t/&#176C H: rH/% SP: 0 ... 255 SW: 0|1</li>
  18155. </ul><br>
  18156. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18157. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18158. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18159. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18160. adjust the scaling alternatively.<br>
  18161. The attr subType must be roomSensorControl.01 and attr
  18162. manufID must be 00D for Eltako Devices. This is
  18163. done if the device was created by autocreate.
  18164. </li>
  18165. <br><br>
  18166. <li>Room Sensor and Control Unit (EEP A5-10-15 ... A5-10-17)<br>
  18167. [untested]<br>
  18168. <ul>
  18169. <li>T: t/&#176C SP: 0 ... 63 P: absent|present</li>
  18170. <li>presence: absent|present</li>
  18171. <li>temperature: t/&#176C (Sensor Range: t = -10 &#176C ... 41.2 &#176C)</li>
  18172. <li>setpoint: 0 ... 63</li>
  18173. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18174. <li>state: T: t/&#176C SP: 0 ... 63 P: absent|present</li>
  18175. </ul><br>
  18176. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18177. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18178. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18179. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18180. adjust the scaling alternatively.<br>
  18181. The attr subType must be roomSensorControl.02. This is done if the device was
  18182. created by autocreate.
  18183. </li>
  18184. <br><br>
  18185. <li>Room Sensor and Control Unit (EEP A5-10-18)<br>
  18186. [untested]<br>
  18187. <ul>
  18188. <li>T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18189. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18190. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18191. <li>presence: absent|present|disabled</li>
  18192. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18193. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18194. <li>state: T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18195. </ul><br>
  18196. The attr subType must be roomSensorControl.18. This is done if the device was
  18197. created by autocreate.
  18198. </li>
  18199. <br><br>
  18200. <li>Room Sensor and Control Unit (EEP A5-10-19)<br>
  18201. [untested]<br>
  18202. <ul>
  18203. <li>T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18204. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18205. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18206. <li>presence: absent|present|disabled</li>
  18207. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18208. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18209. <li>state: T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18210. </ul><br>
  18211. The attr subType must be roomSensorControl.19. This is done if the device was
  18212. created by autocreate.
  18213. </li>
  18214. <br><br>
  18215. <li>Room Sensor and Control Unit (EEP A5-10-1A)<br>
  18216. [untested]<br>
  18217. <ul>
  18218. <li>T: t/&#176C F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled U: U/V</li>
  18219. <li>errorCode: 251 ... 255</li>
  18220. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18221. <li>presence: absent|present|disabled</li>
  18222. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18223. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18224. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18225. <li>state: T: t/&#176C F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled U: U/V</li>
  18226. </ul><br>
  18227. The attr subType must be roomSensorControl.1A. This is done if the device was
  18228. created by autocreate.
  18229. </li>
  18230. <br><br>
  18231. <li>Room Sensor and Control Unit (EEP A5-10-1B)<br>
  18232. [untested]<br>
  18233. <ul>
  18234. <li>T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off P: absent|present|disabled U: U/V</li>
  18235. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18236. <li>errorCode: 251 ... 255</li>
  18237. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18238. <li>presence: absent|present|disabled</li>
  18239. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18240. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18241. <li>state: T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off P: absent|present|disabled U: U/V</li>
  18242. </ul><br>
  18243. The attr subType must be roomSensorControl.1B. This is done if the device was
  18244. created by autocreate.
  18245. </li>
  18246. <br><br>
  18247. <li>Room Sensor and Control Unit (EEP A5-10-1C)<br>
  18248. [untested]<br>
  18249. <ul>
  18250. <li>T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off SP: E/lx P: absent|present|disabled</li>
  18251. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18252. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18253. <li>presence: absent|present|disabled</li>
  18254. <li>setpoint: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18255. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18256. <li>state: T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off SP: E/lx P: absent|present|disabled</li>
  18257. </ul><br>
  18258. The attr subType must be roomSensorControl.1C. This is done if the device was
  18259. created by autocreate.
  18260. </li>
  18261. <br><br>
  18262. <li>Room Sensor and Control Unit (EEP A5-10-1D)<br>
  18263. [untested]<br>
  18264. <ul>
  18265. <li>T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: rH/% P: absent|present|disabled</li>
  18266. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18267. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18268. <li>presence: absent|present|disabled</li>
  18269. <li>setpoint: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18270. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18271. <li>state: T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: rH/% P: absent|present|disabled</li>
  18272. </ul><br>
  18273. The attr subType must be roomSensorControl.1D. This is done if the device was
  18274. created by autocreate.
  18275. </li>
  18276. <br><br>
  18277. <li>Room Sensor and Control Unit (EEP A5-10-1F)<br>
  18278. [untested]<br>
  18279. <ul>
  18280. <li>T: t/&#176C F: 0|1|2|3|auto SP: 0 ... 255 P: absent|present|disabled</li>
  18281. <li>fan: 0|1|2|3|auto</li>
  18282. <li>presence: absent|present|disabled</li>
  18283. <li>setpoint: 0 ... 255</li>
  18284. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18285. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18286. <li>state: T: t/&#176C F: 0|1|2|3|auto SP: 0 ... 255 P: absent|present|disabled</li>
  18287. </ul><br>
  18288. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18289. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18290. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18291. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18292. adjust the scaling alternatively.<br>
  18293. The attr subType must be roomSensorControl.1F. This is done if the device was
  18294. created by autocreate.
  18295. </li>
  18296. <br><br>
  18297. <li>Room Operation Panel (EEP A5-10-20, A5-10-21)<br>
  18298. [untested]<br>
  18299. <ul>
  18300. <li>T: t/&#176C H: rH/% SP: 0 ... 255 B: ok|low</li>
  18301. <li>activity: yes|no</li>
  18302. <li>battery: ok|low</li>
  18303. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18304. <li>setpoint: 0 ... 255</li>
  18305. <li>setpointMode: auto|frostProtect|setpoint</li>
  18306. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18307. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18308. <li>state: t/&#176C H: rH/% SP: 0 ... 255 B: ok|low</li>
  18309. </ul><br>
  18310. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18311. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18312. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18313. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18314. adjust the scaling alternatively.<br>
  18315. The attr subType must be roomSensorControl.20. This is done if the device was created by autocreate.
  18316. </li>
  18317. <br><br>
  18318. <li>Room Operation Panel (EEP A5-10-22, A5-10-23)<br>
  18319. [untested]<br>
  18320. <ul>
  18321. <li>T: t/&#176C H: rH/% SP: 0 ... 255 F: auto|off|1|2|3 O: occupied|unoccupied</li>
  18322. <li>fanSpeed: auto|off|1|2|3</li>
  18323. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18324. <li>occupancy: occupied|unoccupied</li>
  18325. <li>setpoint: 0 ... 255</li>
  18326. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18327. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18328. <li>state: t/&#176C H: rH/% SP: 0 ... 255 F: auto|off|1|2|3 O: occupied|unoccupied</li>
  18329. </ul><br>
  18330. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18331. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18332. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18333. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18334. adjust the scaling alternatively.<br>
  18335. The attr subType must be roomSensorControl.22.
  18336. This is done if the device was created by autocreate.
  18337. </li>
  18338. <br><br>
  18339. <li>Lighting Controller State (EEP A5-11-01)<br>
  18340. [untested]<br>
  18341. <ul>
  18342. <li>on|off</li>
  18343. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 510 lx)</li>
  18344. <li>contact: open|closed</li>
  18345. <li>daylightHarvesting: enabled|disabled</li>
  18346. <li>dim: 0 ... 255</li>
  18347. <li>presence: absent|present</li>
  18348. <li>illum: 0 ... 255</li>
  18349. <li>mode: switching|dimming</li>
  18350. <li>powerRelayTimer: enabled|disabled</li>
  18351. <li>powerSwitch: on|off</li>
  18352. <li>repeater: enabled|disabled</li>
  18353. <li>state: on|off</li>
  18354. </ul><br>
  18355. The attr subType must be lightCtrlState.01 This is done if the device was
  18356. created by autocreate.
  18357. </li>
  18358. <br><br>
  18359. <li>Temperature Controller Output (EEP A5-11-02)<br>
  18360. [untested]<br>
  18361. <ul>
  18362. <li>t/&#176C</li>
  18363. <li>alarm: on|off</li>
  18364. <li>controlVar: cvar (Sensor Range: cvar = 0 % ... 100 %)</li>
  18365. <li>controllerMode: auto|heating|cooling|off</li>
  18366. <li>controllerState: auto|override</li>
  18367. <li>energyHoldOff: normal|holdoff</li>
  18368. <li>fan: 0 ... 3|auto</li>
  18369. <li>presence: present|absent|standby|frost</li>
  18370. <li>setpointTemp: t/&#176C (Sensor Range: t = 0 &#176C ... 51.2 &#176C)</li>
  18371. <li>state: t/&#176C</li>
  18372. </ul><br>
  18373. The attr subType must be tempCtrlState.01 This is done if the device was
  18374. created by autocreate.
  18375. </li>
  18376. <br><br>
  18377. <li><a name="Blind Status">Blind Status</a> (EEP A5-11-03)<br>
  18378. [untested, experimental status]<br>
  18379. <ul>
  18380. <li>open|closed|not_reached|not_available</li>
  18381. <li>alarm: on|off|no endpoints defined|not used</li>
  18382. <li>anglePos: &alpha;/&#176 (Sensor Range: &alpha; = -180 &#176 ... 180 &#176)</li>
  18383. <li>endPosition: open|closed|not_reached|not_available</li>
  18384. <li>position: pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  18385. <li>positionMode: normal|inverse</li>
  18386. <li>serviceOn: yes|no</li>
  18387. <li>shutterState: opens|closes|stopped|not_available</li>
  18388. <li>state: open|closed|not_reached|not_available</li>
  18389. </ul><br>
  18390. The attr subType must be shutterCtrlState.01 This is done if the device was
  18391. created by autocreate.<br>
  18392. The profile is linked with <a href="#Blind Command Central">Blind Command Central</a>.
  18393. The profile <a href="#Blind Command Central">Blind Command Central</a>
  18394. controls the devices centrally. For that the attributes subDef, subTypeSet
  18395. and gwCmd have to be set manually.
  18396. </li>
  18397. <br><br>
  18398. <li>Extended Lighting Status (EEP A5-11-04)<br>
  18399. [untested]<br>
  18400. <ul>
  18401. <li>on|off</li>
  18402. <li>alarm: off|lamp_failure|internal_failure|external_periphery_failure</li>
  18403. <li>blue: 0 ... 255</li>
  18404. <li>current: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18405. <li>currentUnit: mA|A</li>
  18406. <li>dim: 0 ... 255</li>
  18407. <li>energy: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18408. <li>energyUnit: Wh|kWh|MWh|GWh</li>
  18409. <li>green: 0 ... 255</li>
  18410. <li>measuredValue: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18411. <li>measureUnit: unknown</li>
  18412. <li>lampOpHours: t/h |unknown (Sensor range: t = 0 h ... 65535 h)</li>
  18413. <li>power: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18414. <li>powerSwitch: on|off</li>
  18415. <li>powerUnit: mW|W|kW|MW</li>
  18416. <li>red: 0 ... 255</li>
  18417. <li>rgb: RRGGBB (red (R), green (G) or blue (B) color component values: 00 ... FF)</li>
  18418. <li>serviceOn: yes|no</li>
  18419. <li>voltage: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18420. <li>voltageUnit: mV|V</li>
  18421. <li>state: on|off</li>
  18422. </ul><br>
  18423. The attr subType must be lightCtrlState.02 This is done if the device was
  18424. created by autocreate.
  18425. </li>
  18426. <br><br>
  18427. <li>Dual Channel Switch Actuator (EEP A5-11-05)<br>
  18428. [untested]<br>
  18429. <ul>
  18430. <li>1: on|off 2: on|off</li>
  18431. <li>channel1: on|off</li>
  18432. <li>channel2: on|off</li>
  18433. <li>workingMode: 1 ... 4</li>
  18434. <li>state: 1: on|off 2: on|off</li>
  18435. </ul><br>
  18436. The attr subType must be switch.05. This is done if the device was created by autocreate.
  18437. </li>
  18438. <br><br>
  18439. <li>Automated meter reading (AMR), Counter (EEP A5-12-00)<br>
  18440. [Thermokon SR-MI-HS, untested]<br>
  18441. <ul>
  18442. <li>1/s</li>
  18443. <li>currentValue<00 ... 15>: 1/s</li>
  18444. <li>counter<00 ... 15>: 0 ... 16777215</li>
  18445. <li>state: 1/s</li>
  18446. </ul><br>
  18447. The attr subType must be autoMeterReading.00. This is done if the device was
  18448. created by autocreate.
  18449. </li>
  18450. <br><br>
  18451. <li>Automated meter reading (AMR), Electricity (EEP A5-12-01)<br>
  18452. [Eltako FSS12, DSZ14DRS, DSZ14WDRS, Thermokon SR-MI-HS, untested]<br>
  18453. [Eltako FWZ12-16A tested]<br>
  18454. <ul>
  18455. <li>P/W</li>
  18456. <li>power: P/W</li>
  18457. <li>energy<0 ... 15>: E/kWh</li>
  18458. <li>currentTariff: 0 ... 15</li>
  18459. <li>serialNumber: S-&lt;nnnnnn&gt;</li>
  18460. <li>state: P/W</li>
  18461. </ul><br>
  18462. The attr subType must be autoMeterReading.01 and attr
  18463. manufID must be 00D for Eltako Devices. This is done if the device was
  18464. created by autocreate.
  18465. </li>
  18466. <br><br>
  18467. <li>Automated meter reading (AMR), Gas, Water (EEP A5-12-02, A5-12-03)<br>
  18468. [untested]<br>
  18469. <ul>
  18470. <li>Vs/l</li>
  18471. <li>flowrate: Vs/l</li>
  18472. <li>consumption<0 ... 15>: V/m3</li>
  18473. <li>currentTariff: 0 ... 15</li>
  18474. <li>state: Vs/l</li>
  18475. </ul><br>
  18476. The attr subType must be autoMeterReading.02|autoMeterReading.03.
  18477. This is done if the device was created by autocreate.
  18478. </li>
  18479. <br><br>
  18480. <li>Automated meter reading (AMR), Temperatur, Load (EEP A5-12-04)<br>
  18481. [untested]<br>
  18482. <ul>
  18483. <li>T: t/&#176C W: m/g B: full|ok|low|empty</li>
  18484. <li>battery: full|ok|low|empty</li>
  18485. <li>temperature: t/&#176C (Sensor Range: t = -40 &#176C ... 40 &#176C)</li>
  18486. <li>weight: m/g</li>
  18487. <li>state: T: t/&#176C W: m/g B: full|ok|low|empty</li>
  18488. </ul><br>
  18489. The attr subType must be autoMeterReading.04.
  18490. This is done if the device was created by autocreate.
  18491. </li>
  18492. <br><br>
  18493. <li>Automated meter reading (AMR), Temperatur, Container Sensor (EEP A5-12-05)<br>
  18494. [untested]<br>
  18495. <ul>
  18496. <li>T: t/&#176C L: <location0 ... location9> B: full|ok|low|empty</li>
  18497. <li>amount: 0 ... 10</li>
  18498. <li>battery: full|ok|low|empty</li>
  18499. <li>location<0 ... 9>: possessed|not_possessed</li>
  18500. <li>temperature: t/&#176C (Sensor Range: t = -40 &#176C ... 40 &#176C)</li>
  18501. <li>state: T: t/&#176C L: <location0 ... location9> B: full|ok|low|empty</li>
  18502. </ul><br>
  18503. The attr subType must be autoMeterReading.05.
  18504. This is done if the device was created by autocreate.
  18505. </li>
  18506. <br><br>
  18507. <li>Automated meter reading (AMR), Current Meter 16 Channels (EEP A5-12-10)<br>
  18508. [untested]<br>
  18509. <ul>
  18510. <li>I/mA</li>
  18511. <li>current<00 ... 15>: I/mA (Sensor Range: I = 0 mA ... 16777215 mA)</li>
  18512. <li>electricChange<00 ... 15>: Q/Ah (Sensor Range: Q = 0 Ah ... 16777215 Ah)</li>
  18513. <li>currentTariff: 00 ... 15</li>
  18514. <li>state: I/mA</li>
  18515. </ul><br>
  18516. The attr subType must be autoMeterReading.10. This is done if the device was created by autocreate.
  18517. </li>
  18518. <br><br>
  18519. <li>Environmental Applications<br>
  18520. Weather Station (EEP A5-13-01)<br>
  18521. Sun Intensity (EEP A5-13-02)<br>
  18522. [Eltako FWS61]<br>
  18523. <ul>
  18524. <li>T: t/&#176C B: E/lx W: Vs/m IR: yes|no</li>
  18525. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 999 lx)</li>
  18526. <li>dayNight: day|night</li>
  18527. <li>hemisphere: north|south</li>
  18528. <li>isRaining: yes|no</li>
  18529. <li>sunEast: E/lx (Sensor Range: E = 1 lx ... 150 klx)</li>
  18530. <li>sunSouth: E/lx (Sensor Range: E = 1 lx ... 150 klx)</li>
  18531. <li>sunWest: E/lx (Sensor Range: E = 1 lx ... 150 klx)</li>
  18532. <li>temperature: t/&#176C (Sensor Range: t = -40 &#176C ... 80 &#176C)</li>
  18533. <li>windSpeed: Vs/m (Sensor Range: V = 0 m/s ... 70 m/s)</li>
  18534. <li>state:T: t/&#176C B: E/lx W: Vs/m IR: yes|no</li>
  18535. </ul><br>
  18536. Brightness is the strength of the dawn light. SunEast,
  18537. sunSouth and sunWest are the solar radiation from the respective
  18538. compass direction. IsRaining is the rain indicator.<br>
  18539. The attr subType must be environmentApp and attr manufID must be 00D
  18540. for Eltako Devices. This is done if the device was created by
  18541. autocreate.<br>
  18542. The Eltako Weather Station FWS61 supports not the day/night indicator
  18543. (dayNight).<br>
  18544. </li>
  18545. <br><br>
  18546. <li>Environmental Applications<br>
  18547. Data Exchange (EEP A5-13-03)<br>
  18548. Time and Day Exchange (EEP A5-13-04)<br>
  18549. Direction Exchange (EEP A5-13-05)<br>
  18550. Geographic Exchange (EEP A5-13-06)<br>
  18551. <ul>
  18552. <li>azimuth: &alpha;/&deg; (Sensor Range: &alpha; = 0 &deg; ... 359 &deg;)</li>
  18553. <li>date: JJJJ-MM-DD</li>
  18554. <li>elevation: &beta;/&deg; (Sensor Range: &beta; = -90 &deg; ... 90 &deg;)</li>
  18555. <li>latitude: &phi;/&deg; (Sensor Range: &phi; = -90 &deg; ... 90 &deg;)</li>
  18556. <li>longitude: &lambda;/&deg; (Sensor Range: &lambda; = -180 &deg; ... 180 &deg;)</li>
  18557. <li>time: hh:mm:ss [AM|PM]</li>
  18558. <li>timeSource: GPS|RTC</li>
  18559. <li>weekday: Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday</li>
  18560. </ul><br>
  18561. The attr subType must be environmentApp. This is done if the device was created by
  18562. autocreate.
  18563. </li>
  18564. <br><br>
  18565. <li>Environmental Applications<br>
  18566. Sun Position and Radiation (EEP A5-13-10)<br>
  18567. [untested]<br>
  18568. <ul>
  18569. <li>SRA: E m2/W SNA: &alpha;/&deg; SNE: &beta;/&deg;</li>
  18570. <li>dayNight: day|night</li>
  18571. <li>solarRadiation: E m2/W (Sensor Range: E = 0 W/m2 ... 2000 W/m2)</li>
  18572. <li>sunAzimuth: &alpha;/&deg; (Sensor Range: &alpha; = -90 &deg; ... 90 &deg;)</li>
  18573. <li>sunElevation: &beta;/&deg; (Sensor Range: &beta; = 0 &deg; ... 90 &deg;)</li>
  18574. <li>state:SRA: E m2/W SNA: &alpha;/&deg; SNE: &beta;/&deg;</li>
  18575. </ul><br>
  18576. The attr subType must be environmentApp. This is done if the device was created by
  18577. autocreate.
  18578. </li>
  18579. <br><br>
  18580. <li>Wind Sensor (EEP A5-13-07)<br>
  18581. [Hideki, untested]<br>
  18582. <ul>
  18583. <li>Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18584. <li>battery: ok|low</li>
  18585. <li>windSpeedAverage: Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18586. <li>windSpeedDirection: NNE|NE|ENE|E|ESE|SE|SSE|S|SSW|SW|WSW|W|WNW|NW|NNW|N</li>
  18587. <li>windSpeedMax: Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18588. <li>state:Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18589. </ul><br>
  18590. The attr subType must be windSensor.01. This is done if the device was created by
  18591. autocreate.<br>
  18592. </li>
  18593. <br><br>
  18594. <li>Rain Sensor (EEP A5-13-08)<br>
  18595. [Hideki, untested]<br>
  18596. <ul>
  18597. <li>H/mm</li>
  18598. <li>battery: ok|low</li>
  18599. <li>rain: H/mm</li>
  18600. <li>state:H/mm</li>
  18601. </ul><br>
  18602. The amount of rainfall is calculated at intervals of 183 s.<br>
  18603. The attr subType must be rainSensor.01. This is done if the device was created by
  18604. autocreate.<br>
  18605. </li>
  18606. <br><br>
  18607. <li>Multi-Func Sensor (EEP A5-14-01 ... A5-14-06)<br>
  18608. [untested]<br>
  18609. <ul>
  18610. <li>C: open|closed V: on|off E: E/lx U: U/V</li>
  18611. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18612. <li>contact: open|closed</li>
  18613. <li>errorCode: 251 ... 255</li>
  18614. <li>vibration: on|off</li>
  18615. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18616. <li>state: C: open|closed V: on|off E: E/lx U: U/V</li>
  18617. </ul><br>
  18618. The attr subType must be multiFuncSensor. This is done if the device was
  18619. created by autocreate.
  18620. </li>
  18621. <br><br>
  18622. <li>Dual Door Contact (EEP A5-14-07, A5-14-08)<br>
  18623. [untested]<br>
  18624. <ul>
  18625. <li>C: open|closed B: unlocked|locked V: on|off U: U/V</li>
  18626. <li>alarm: dead_sensor</li>
  18627. <li>block: unlocked|locked</li>
  18628. <li>contact: open|closed</li>
  18629. <li>vibration: on|off</li>
  18630. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18631. <li>state: C: open|closed B: unlocked|locked V: on|off U: U/V</li>
  18632. </ul><br>
  18633. The attr subType must be doorContact. This is done if the device was
  18634. created by autocreate.
  18635. </li>
  18636. <br><br>
  18637. <li>Window/Door Contact (EEP A5-14-09, A5-14-0A)<br>
  18638. [untested]<br>
  18639. <ul>
  18640. <li>W: open|tilt|closed B: unlocked|locked V: on|off U: U/V</li>
  18641. <li>alarm: dead_sensor</li>
  18642. <li>vibration: on|off</li>
  18643. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18644. <li>window: open|tilt|closed</li>
  18645. <li>state: W: open|tilt|closed V: on|off U: U/V</li>
  18646. </ul><br>
  18647. The attr subType must be windowContact. This is done if the device was
  18648. created by autocreate.
  18649. </li>
  18650. <br><br>
  18651. <li>Battery Powered Actuator (EEP A5-20-01)<br>
  18652. [Kieback&Peter MD15-FTL-xx]<br>
  18653. <ul>
  18654. <li>T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18655. <li>actuatorState: obstructed|ok</li>
  18656. <li>alarm: no_response_from_actuator</li>
  18657. <li>battery: ok|low</li>
  18658. <li>cover: open|closed</li>
  18659. <li>delta: &lt;floating-point number&gt;</li>
  18660. <li>energyInput: enabled|disabled</li>
  18661. <li>energyStorage: charged|empty</li>
  18662. <li>maintenanceMode: off|runInit|valveClosed|valveOpend:runInit</li>
  18663. <li>operationMode: off|setpoint|setpointTemp</li>
  18664. <li>p_d: &lt;floating-point number&gt;</li>
  18665. <li>p_i: &lt;floating-point number&gt;</li>
  18666. <li>p_p: &lt;floating-point number&gt;</li>
  18667. <li>pidAlarm: actuator_in_errorPos|dead_sensor|no_temperature_value|setpoint_device_missing</li>
  18668. <li>pidState: alarm|idle|processing|start|stop|</li>
  18669. <li>roomTemp: t/&#176C</li>
  18670. <li>selfCtl: on|off</li>
  18671. <li>setpoint: setpoint/%</li>
  18672. <li>setpointSet: setpoint/%</li>
  18673. <li>setpointCalc: setpoint/%</li>
  18674. <li>setpointTemp: t/&#176C</li>
  18675. <li>setpointTempSet: t/&#176C</li>
  18676. <li>teach: &lt;result of teach procedure&gt;</li>
  18677. <li>temperature: t/&#176C</li>
  18678. <li>waitingCmds: no_change|runInit|setpoint|setpointTemp|valveCloses|valveOpens</li>
  18679. <li>wakeUpCycle: t/s</li>
  18680. <li>window: open|closed</li>
  18681. <li>state: T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18682. </ul><br>
  18683. The internal temperature sensor (roomTemp) of the Micropelt iTRV is not suitable as
  18684. a room thermostat.<br>
  18685. The attr subType must be hvac.01. This is done if the device was created by
  18686. autocreate.
  18687. </li>
  18688. <br><br>
  18689. <li>Heating Radiator Actuating Drive (EEP A5-20-04)<br>
  18690. [Holter SmartDrive MX]<br>
  18691. <ul>
  18692. <li>T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18693. <li>alarm: measurement_error|battery_empty|frost_protection|blocked_valve|end_point_detection_error|no_valve|not_taught_in|no_response_from_controller|teach-in_error</li>
  18694. <li>battery: ok|empty</li>
  18695. <li>blockKey: yes|no</li>
  18696. <li>delta: &lt;floating-point number&gt;</li>
  18697. <li>feedTemp: t/&#176C</li>
  18698. <li>maintenanceMode: off|runInit|valveClosed|valveOpend:runInit</li>
  18699. <li>measurementState: active|inactive</li>
  18700. <li>operationMode: off|setpoint|setpointTemp</li>
  18701. <li>p_d: &lt;floating-point number&gt;</li>
  18702. <li>p_i: &lt;floating-point number&gt;</li>
  18703. <li>p_p: &lt;floating-point number&gt;</li>
  18704. <li>pidAlarm: actuator_in_errorPos|dead_sensor|no_temperature_value|setpoint_device_missing</li>
  18705. <li>pidState: alarm|idle|processing|start|stop|</li>
  18706. <li>roomTemp: t/&#176C</li>
  18707. <li>setpoint: setpoint/%</li>
  18708. <li>setpointSet: setpoint/%</li>
  18709. <li>setpointCalc: setpoint/%</li>
  18710. <li>setpointTemp: t/&#176C</li>
  18711. <li>setpointTempSet: t/&#176C</li>
  18712. <li>teach: &lt;result of teach procedure&gt;</li>
  18713. <li>temperature: t/&#176C</li>
  18714. <li>waitingCmds: no_change|runInit|setpoint|setpointTemp|valveCloses|valveOpens</li>
  18715. <li>state: T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18716. </ul><br>
  18717. The attr subType must be hvac.04. This is done if the device was created by
  18718. autocreate.
  18719. </li>
  18720. <br><br>
  18721. <li>Generic HVAC Interface (EEP A5-20-10)<br>
  18722. [IntesisBox PA-AC-ENO-1i]<br>
  18723. <ul>
  18724. <li>on|off</li>
  18725. <li>ctrl: auto|0...100</li>
  18726. <li>fanSpeed: auto|1...14</li>
  18727. <li>occupancy: occupied|off|standby|unoccupied</li>
  18728. <li>mode: auto|heat|morning_warmup|cool|night_purge|precool|off|test|emergency_heat|fan_only|free_cool|ice|max_heat|eco|dehumidification|calibration|emergency_cool|emergency_stream|max_cool|hvc_load|no_load|auto_heat|auto_cool</li>
  18729. <li>vanePosition: auto|horizontal|position_2|position_3|position_4|vertical|swing|vertical_swing|horizontal_swing|hor_vert_swing|stop_swing</li>
  18730. <li>powerSwitch: on|off</li>
  18731. <li>teach: &lt;result of teach procedure&gt;</li>
  18732. <li>state: on|off</li>
  18733. </ul><br>
  18734. The attr subType must be hvac.10. This is done if the device was created by
  18735. autocreate.
  18736. </li>
  18737. <br><br>
  18738. <li>Generic HVAC Interface - Error Control (EEP A5-20-11)<br>
  18739. [IntesisBox PA-AC-ENO-1i]<br>
  18740. <ul>
  18741. <li>error|ok</li>
  18742. <li>alarm: error|ok</li>
  18743. <li>errorCode: 0...65535</li>
  18744. <li>externalDisable: disable|enable</li>
  18745. <li>keyCardDisable: disable|enable</li>
  18746. <li>otherDisable: disable|enable</li>
  18747. <li>powerSwitch: on|off</li>
  18748. <li>remoteCtrl: disable|enable</li>
  18749. <li>teach: &lt;result of teach procedure&gt;</li>
  18750. <li>window: closed|opened</li>
  18751. <li>windowDisable: disable|enable</li>
  18752. <li>state: error|ok</li>
  18753. </ul><br>
  18754. The attr subType must be hvac.11. This is done if the device was created by
  18755. autocreate.
  18756. </li>
  18757. <br><br>
  18758. <li>Digital Input (EEP A5-30-01, A5-30-02)<br>
  18759. [Thermokon SR65 DI, untested]<br>
  18760. <ul>
  18761. <li>open|closed</li>
  18762. <li>battery: ok|low (only EEP A5-30-01)</li>
  18763. <li>contact: open|closed</li>
  18764. <li>teach: &lt;result of teach procedure&gt;</li>
  18765. <li>state: open|closed</li>
  18766. </ul><br>
  18767. The attr subType must be digitalInput.01 or digitalInput.02. This is done if the device was
  18768. created by autocreate.
  18769. </li>
  18770. <br><br>
  18771. <li>Digital Input (EEP A5-30-03)<br>
  18772. 4 digital Inputs, Wake, Temperature [untested]<br>
  18773. <ul>
  18774. <li>T: t/&#176C I: 0|1 0|1 0|1 0|1 W: 0|1</li>
  18775. <li>in0: 0|1</li>
  18776. <li>in1: 0|1</li>
  18777. <li>in2: 0|1</li>
  18778. <li>in3: 0|1</li>
  18779. <li>teach: &lt;result of teach procedure&gt;</li>
  18780. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18781. <li>wake: high|low</li>
  18782. <li>state: T: t/&#176C I: 0|1 0|1 0|1 0|1 W: high|low</li>
  18783. </ul><br>
  18784. The attr subType must be digitalInput.03. This is done if the device was
  18785. created by autocreate.
  18786. </li>
  18787. <br><br>
  18788. <li>Digital Input (EEP A5-30-04)<br>
  18789. 3 digital Inputs, 1 digital Input 8 bits [untested]<br>
  18790. <ul>
  18791. <li>0|1 0|1 0|1 0...255</li>
  18792. <li>in0: 0|1</li>
  18793. <li>in1: 0|1</li>
  18794. <li>in2: 0|1</li>
  18795. <li>in3: 0...255</li>
  18796. <li>teach: &lt;result of teach procedure&gt;</li>
  18797. <li>state: 0|1 0|1 0|1 0...255</li>
  18798. </ul><br>
  18799. The attr subType must be digitalInput.04. This is done if the device was
  18800. created by autocreate.
  18801. </li>
  18802. <br><br>
  18803. <li>Digital Input, single input contact, retransmission, battery monitor (EEP A5-30-05)<br>
  18804. [untested]<br>
  18805. <ul>
  18806. <li>error|event|heartbeat</li>
  18807. <li>battery: U/V (Range: U = 0 V ... 3.3 V</li>
  18808. <li>signalIdx: 0 ... 127</li>
  18809. <li>teach: &lt;result of teach procedure&gt;</li>
  18810. <li>telegramType: event|heartbeat</li>
  18811. <li>state: error|event|heartbeat</li>
  18812. </ul><br>
  18813. The attr subType must be digitalInput.05. This is done if the device was
  18814. created by autocreate.
  18815. </li>
  18816. <li>Energy management, demand response (EEP A5-37-01)<br>
  18817. <br>
  18818. <ul>
  18819. <li>on|off|waiting_for_start|waiting_for_stop</li>
  18820. <li>level: 0...15</li>
  18821. <li>powerUsage: powerUsage/%</li>
  18822. <li>powerUsageLevel: max|min</li>
  18823. <li>powerUsageScale: rel|max</li>
  18824. <li>randomEnd: yes|no</li>
  18825. <li>randomStart: yes|no</li>
  18826. <li>setpoint: 0...255</li>
  18827. <li>teach: &lt;result of teach procedure&gt;</li>
  18828. <li>timeout: yyyy-mm-dd hh:mm:ss</li>
  18829. <li>state: on|off|waiting_for_start|waiting_for_stop</li>
  18830. </ul><br>
  18831. The attr subType must be energyManagement.01. This is done if the device was
  18832. created by autocreate.
  18833. </li>
  18834. <br><br>
  18835. <li>Gateway (EEP A5-38-08)<br>
  18836. Switching<br>
  18837. [Eltako FLC61, FSA12, FSR14]<br>
  18838. <ul>
  18839. <li>on</li>
  18840. <li>off</li>
  18841. <li>executeTime: t/s (Sensor Range: t = 0.1 s ... 6553.5 s or 0 if no time specified)</li>
  18842. <li>executeType: duration|delay</li>
  18843. <li>block: lock|unlock</li>
  18844. <li>teach: &lt;result of teach procedure&gt;</li>
  18845. <li>state: on|off</li>
  18846. </ul><br>
  18847. The attr subType must be gateway and gwCmd must be switching. This is done if the device was
  18848. created by autocreate.<br>
  18849. For Eltako devices attributes must be set manually. Eltako devices only send on/off.
  18850. </li>
  18851. <br><br>
  18852. <li>Gateway (EEP A5-38-08)<br>
  18853. Dimming<br>
  18854. [Eltako FUD14, FUD61, FUD70, FSG14, ...]<br>
  18855. <ul>
  18856. <li>on</li>
  18857. <li>off</li>
  18858. <li>block: lock|unlock</li>
  18859. <li>dim: dim/% (Sensor Range: dim = 0 % ... 100 %)</li>
  18860. <li>dimValueLast: dim/%<br>
  18861. Last value received from the bidirectional dimmer.</li>
  18862. <li>dimValueStored: dim/%<br>
  18863. Last value saved by <code>set &lt;name&gt; dim &lt;value&gt;</code>.</li>
  18864. <li>rampTime: t/s (Sensor Range: t = 1 s ... 255 s or 0 if no time specified,
  18865. for Eltako: t = 1 = fast dimming ... 255 = slow dimming or 0 = dimming speed on the dimmer used)</li>
  18866. <li>teach: &lt;result of teach procedure&gt;</li>
  18867. <li>state: on|off</li>
  18868. </ul><br>
  18869. The attr subType must be gateway, gwCmd must be dimming and attr manufID must be 00D
  18870. for Eltako Devices. This is done if the device was created by autocreate.<br>
  18871. For Eltako devices attributes must be set manually. Eltako devices only send on/off and dim.
  18872. </li>
  18873. <br><br>
  18874. <li>Gateway (EEP A5-38-08)<br>
  18875. Setpoint shift<br>
  18876. [untested]<br>
  18877. <ul>
  18878. <li>1/K</li>
  18879. <li>setpointShift: 1/K (Sensor Range: T = -12.7 K ... 12.8 K)</li>
  18880. <li>teach: &lt;result of teach procedure&gt;</li>
  18881. <li>state: 1/K</li>
  18882. </ul><br>
  18883. The attr subType must be gateway, gwCmd must be setpointShift.
  18884. This is done if the device was created by autocreate.
  18885. </li>
  18886. <br><br>
  18887. <li>Gateway (EEP A5-38-08)<br>
  18888. Basic Setpoint<br>
  18889. [untested]<br>
  18890. <ul>
  18891. <li>t/&#176C</li>
  18892. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 51.2 &#176C)</li>
  18893. <li>teach: &lt;result of teach procedure&gt;</li>
  18894. <li>state: t/&#176C</li>
  18895. </ul><br>
  18896. The attr subType must be gateway, gwCmd must be setpointBasic.
  18897. This is done if the device was created by autocreate.
  18898. </li>
  18899. <br><br>
  18900. <li>Gateway (EEP A5-38-08)<br>
  18901. Control variable<br>
  18902. [untested]<br>
  18903. <ul>
  18904. <li>auto|heating|cooling|off</li>
  18905. <li>controlVar: cvov (Sensor Range: cvov = 0 % ... 100 %)</li>
  18906. <li>controllerMode: auto|heating|cooling|off</li>
  18907. <li>controllerState: auto|override</li>
  18908. <li>energyHoldOff: normal|holdoff</li>
  18909. <li>presence: present|absent|standby</li>
  18910. <li>teach: &lt;result of teach procedure&gt;</li>
  18911. <li>state: auto|heating|cooling|off</li>
  18912. </ul><br>
  18913. The attr subType must be gateway, gwCmd must be controlVar.
  18914. This is done if the device was created by autocreate.
  18915. </li>
  18916. <br><br>
  18917. <li>Gateway (EEP A5-38-08)<br>
  18918. Fan stage<br>
  18919. [untested]<br>
  18920. <ul>
  18921. <li>0 ... 3|auto</li>
  18922. <li>teach: &lt;result of teach procedure&gt;</li>
  18923. <li>state: 0 ... 3|auto</li>
  18924. </ul><br>
  18925. The attr subType must be gateway, gwCmd must be fanStage.
  18926. This is done if the device was created by autocreate.
  18927. </li>
  18928. <br><br>
  18929. <li>Extended Lighting Control (EEP A5-38-09)<br>
  18930. [untested]<br>
  18931. <ul>
  18932. <li>on</li>
  18933. <li>off</li>
  18934. <li>block: unlock|on|off|local</li>
  18935. <li>blue: &lt;blue channel value&gt; (Range: blue = 0 ... 255)</li>
  18936. <li>dimMax: &lt;maximum dimming value&gt; (Range: dim = 0 ... 255)</li>
  18937. <li>dimMin: &lt;minimum dimming value&gt; (Range: dim = 0 ... 255)</li>
  18938. <li>green: &lt;green channel value&gt; (Range: green = 0 ... 255)</li>
  18939. <li>rampTime: t/s (Range: t = 0 s ... 65535 s)</li>
  18940. <li>red: &lt;red channel value&gt; (Range: red = 0 ... 255)</li>
  18941. <li>rgb: RRGGBB (red (R), green (G) or blue (B) color component values: 00 ... FF)</li>
  18942. <li>teach: &lt;result of teach procedure&gt;</li>
  18943. <li>state: on|off</li>
  18944. </ul><br>
  18945. Another readings, see subtype lightCtrlState.02.<br>
  18946. The attr subType or subTypSet must be lightCtrl.01. This is done if the device was created by autocreate.<br>
  18947. The subType is associated with the subtype lightCtrlState.02.
  18948. </li>
  18949. <br><br>
  18950. <li>Manufacturer Specific Applications (EEP A5-3F-7F)<br><br>
  18951. Wireless Analog Input Module<br>
  18952. [Thermokon SR65 3AI, untested]<br>
  18953. <ul>
  18954. <li>I1: U/V I2: U/V I3: U/V</li>
  18955. <li>input1: U/V (Sensor Range: U = 0 V ... 10 V)</li>
  18956. <li>input2: U/V (Sensor Range: U = 0 V ... 10 V)</li>
  18957. <li>input3: U/V (Sensor Range: U = 0 V ... 10 V)</li>
  18958. <li>teach: &lt;result of teach procedure&gt;</li>
  18959. <li>state: I1: U/V I2: U/V I3: U/V</li>
  18960. </ul><br>
  18961. The attr subType must be manufProfile and attr manufID must be 002
  18962. for Thermokon Devices. This is done if the device was
  18963. created by autocreate.
  18964. </li>
  18965. <br><br>
  18966. <li>Manufacturer Specific Applications (EEP A5-3F-7F)<br><br>
  18967. Thermostat Actuator<br>
  18968. [AWAG omnio UPH230/1x]<br>
  18969. <ul>
  18970. <li>on|off</li>
  18971. <li>emergencyMode&lt;channel&gt;: on|off</li>
  18972. <li>nightReduction&lt;channel&gt;: on|off</li>
  18973. <li>setpointTemp&lt;channel&gt;: t/&#176C</li>
  18974. <li>teach: &lt;result of teach procedure&gt;</li>
  18975. <li>temperature&lt;channel&gt;: t/&#176C</li>
  18976. <li>window&lt;channel&gt;: on|off</li>
  18977. <li>state: on|off</li>
  18978. </ul><br>
  18979. The attr subType must be manufProfile and attr manufID must be 005
  18980. for AWAG omnio Devices. This is done if the device was created by autocreate.
  18981. </li>
  18982. <br><br>
  18983. <li>Manufacturer Specific Applications (EEP A5-3F-7F)<br><br>
  18984. Shutter (EEP F6-02-01 ... F6-02-02)<br>
  18985. [Eltako FSB12, FSB14, FSB61, FSB70]<br>
  18986. <ul>
  18987. <li>open|open_ack<br>
  18988. The status of the device will become "open" after the TOP endpoint is
  18989. reached, or it has finished an "opens" or "position 0" command.</li>
  18990. <li>closed<br>
  18991. The status of the device will become "closed" if the BOTTOM endpoint is
  18992. reached</li>
  18993. <li>stop<br>
  18994. The status of the device become "stop" if stop command is sent.</li>
  18995. <li>not_reached<br>
  18996. The status of the device become "not_reached" between one of the endpoints.</li>
  18997. <li>anglePos: &alpha;/&#176 (Sensor Range: &alpha; = -180 &#176 ... 180 &#176)</li>
  18998. <li>endPosition: open|open_ack|closed|not_reached|not_available</li>
  18999. <li>position: pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  19000. <li>teach: &lt;result of teach procedure&gt;</li>
  19001. <li>state: open|open_ack|closed|not_reached|stop|teach</li>
  19002. </ul><br>
  19003. The values of the reading position and anglePos are updated automatically,
  19004. if the command position is sent or the reading state was changed
  19005. manually to open or closed.<br>
  19006. Set attr subType file, attr manufID to 00D and attr model to
  19007. Eltako_FSB14|FSB61|FSB70 manually.
  19008. </li>
  19009. <br><br>
  19010. <li>Electronic switches and dimmers with Energy Measurement and Local Control (D2-01-00 - D2-01-12)<br>
  19011. [Telefunken Funktionsstecker, PEHA Easyclick, AWAG Elektrotechnik AG Omnio UPS 230/xx,UPD 230/xx]<br>
  19012. <ul>
  19013. <li>on</li>
  19014. <li>off</li>
  19015. <li>autoOffTime&lt;1...29|All|Input&gt;: 1/s</li>
  19016. <li>channel&lt;0...29|All|Input&gt;: on|off</li>
  19017. <li>delayOffTime&lt;1...29|All|Input&gt;: 1/s</li>
  19018. <li>dayNight: day|night</li>
  19019. <li>defaultState: on|off|last</li>
  19020. <li>devTemp: t/&#176C|invalid</li>
  19021. <li>devTempState: ok|max|warning</li>
  19022. <li>dim&lt;0...29|Input&gt;: dim/% (Sensor Range: dim = 0 % ... 100 %)</li>
  19023. <li>energy&lt;channel&gt;: E/[Ws|Wh|KWh]</li>
  19024. <li>energyUnit&lt;channel&gt;: Ws|Wh|KWh</li>
  19025. <li>error&lt;channel&gt;: ok|warning|failure|not_supported</li>
  19026. <li>extSwitchMode&lt;1...29|All|Input&gt;: unavailable|switch|pushbutton|auto</li>
  19027. <li>extSwitchType&lt;1...29|All|Input&gt;: toggle|direction</li>
  19028. <li>firmwareVersion: [000000 ... FFFFFF]</li>
  19029. <li>loadClassification: no</li>
  19030. <li>localControl&lt;channel&gt;: enabled|disabled</li>
  19031. <li>loadLink: connected|disconnected</li>
  19032. <li>loadOperation: 3-wire</li>
  19033. <li>loadState: on|off</li>
  19034. <li>measurementMode: energy|power</li>
  19035. <li>measurementReport: auto|query</li>
  19036. <li>measurementReset: not_active|trigger</li>
  19037. <li>measurementDelta: E/[Ws|Wh|KWh|W|KW]</li>
  19038. <li>measurementUnit: Ws|Wh|KWh|W|KW</li>
  19039. <li>overCurrentOff&lt;channel&gt;: executed|ready</li>
  19040. <li>overCurrentShutdown&lt;channel&gt;: off|restart</li>
  19041. <li>overCurrentShutdownReset&lt;channel&gt;: not_active|trigger</li>
  19042. <li>power&lt;channel&gt;: P/[W|KW]</li>
  19043. <li>powerFailure&lt;channel&gt;: enabled|disabled</li>
  19044. <li>powerFailureDetection&lt;channel&gt;: detected|not_detected</li>
  19045. <li>powerUnit&lt;channel&gt;: W|KW</li>
  19046. <li>rampTime&lt;1...3l&gt;: 1/s</li>
  19047. <li>responseTimeMax: 1/s</li>
  19048. <li>responseTimeMin: 1/s</li>
  19049. <li>roomCtrlMode: off|comfort|comfort-1|comfort-2|economy|buildingProtection</li>
  19050. <li>serialNumber: [00000000 ... FFFFFFFF]</li>
  19051. <li>taughtInDevID&lt;00...23&gt;: [00000001 ... FFFFFFFE]</li>
  19052. <li>taughtInDevNum: [0 ... 23]</li>
  19053. <li>teach: &lt;result of teach procedure&gt;</li>
  19054. <li>teachInDev: enabled|disabled</li>
  19055. <li>state: on|off</li>
  19056. </ul>
  19057. <br>
  19058. The attr subType must be actuator.01. This is done if the device was
  19059. created by autocreate. To control the device, it must be bidirectional paired,
  19060. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19061. </li>
  19062. <br><br>
  19063. <li>Blind Control for Position and Angle (D2-05-00)<br>
  19064. [AWAG Elektrotechnik AG OMNIO UPJ 230/12]<br>
  19065. <ul>
  19066. <li>open<br>
  19067. The status of the device will become "open" after the TOP endpoint is
  19068. reached, or it has finished an "opens" or "position 0" command.</li>
  19069. <li>closed<br>
  19070. The status of the device will become "closed" if the BOTTOM endpoint is
  19071. reached</li>
  19072. <li>stop<br>
  19073. The status of the device become "stop" if stop command is sent.</li>
  19074. <li>not_reached<br>
  19075. The status of the device become "not_reached" between one of the endpoints.</li>
  19076. <li>pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  19077. <li>anglePos&lt;channel&gt;: &alpha;/% (Sensor Range: &alpha; = 0 % ... 100 %)</li>
  19078. <li>block&lt;channel&gt;: unlock|lock|alarm</li>
  19079. <li>endPosition&lt;channel&gt;: open|closed|not_reached|unknown</li>
  19080. <li>position&lt;channel&gt;: unknown|pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  19081. <li>teach: &lt;result of teach procedure&gt;</li>
  19082. <li>state: open|closed|in_motion|stopped|pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  19083. </ul>
  19084. <br>
  19085. The attr subType must be blindsCtrl.00 or blindsCtrl.01. This is done if the device was
  19086. created by autocreate. To control the device, it must be bidirectional paired,
  19087. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19088. </li>
  19089. <br><br>
  19090. <li>Multisensor Window Handle (D2-06-01)<br>
  19091. [Soda GmbH]<br>
  19092. <ul>
  19093. <li>T: t/&#176C H: -|rH/% E: -|E/lx M: off|on|invalid|not_supported|unknown</li>
  19094. <li>alarms: &lt;alarms&gt; (Range: alarms = 00000000 ... FFFFFFFF)</li>
  19095. <li>battery: ok|low</li>
  19096. <li>batteryLowClick: enabled|disabled</li>
  19097. <li>burglaryAlarm: off|on|invalid|not_supported|unknown</li>
  19098. <li>handle: up|down|left|right|invalid|not_supported|unknown</li>
  19099. <li>blinkInterval: t/s|unknown (Range: t = 3 s ... 255 s)</li>
  19100. <li>blinkIntervalSet: t/s|unknown (Range: t = 3 s ... 255 s)</li>
  19101. <li>brightness: E/lx|over_range|invalid|not_supported|unknown (Sensor Range: E = 0 lx ... 60000 lx)</li>
  19102. <li>buttonLeft: pressed|released|invalid|not_supported|unknown</li>
  19103. <li>buttonLeftPresses: &lt;buttonLeftPresses&gt; (Range: buttonLeftPresses = 00000000 ... FFFFFFFF)</li>
  19104. <li>buttonRight: pressed|released|invalid|not_supported|unknown</li>
  19105. <li>buttonRightPresses: &lt;buttonRightPresses&gt; (Range: buttonRightPresses = 00000000 ... FFFFFFFF)</li>
  19106. <li>energyStorage: 1/%|unknown</li>
  19107. <li>handleClosedClick: enabled|disabled</li>
  19108. <li>handleMoveClosed: &lt;handleMoveClosed&gt; (Range: handleMoveClosed = 00000000 ... FFFFFFFF)</li>
  19109. <li>handleMoveOpend: &lt;handleMoveOpend&gt; (Range: handleMoveOpend = 00000000 ... FFFFFFFF)</li>
  19110. <li>handleMoveTilted: &lt;handleMoveTilted&gt; (Range: handleMoveTilted = 00000000 ... FFFFFFFF)</li>
  19111. <li>humidity: rH/%|invalid|not_supported|unknown</li>
  19112. <li>motion: off|on|invalid|not_supported|unknown</li>
  19113. <li>powerOns: &lt;powerOns&gt; (Range: powerOns = 00000000 ... FFFFFFFF)</li>
  19114. <li>presence: absent|present|invalid|not_supported|unknown</li>
  19115. <li>protectionAlarm: off|on|invalid|not_supported|unknown</li>
  19116. <li>temperature: t/&#176C|invalid|not_supported|unknown (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  19117. <li>updateInterval: t/s|unknown (Range: t = 5 s ... 65535 s)</li>
  19118. <li>updateIntervalSet: t/s|unknown (Range: t = 5 s ... 65535 s)</li>
  19119. <li>waitingCmds: &lt;integer number&gt;</li>
  19120. <li>window: undef|not_tilted|tilted|invalid|not_supported|unknown</li>
  19121. <li>windowTilts: &lt;windowTilts&gt; (Range: windowTilts = 00000000 ... FFFFFFFF)</li>
  19122. <li>state: T: t/&#176C H: -|rH/% E: -|E/lx M: off|on|invalid|not_supported|unknown</li>
  19123. </ul><br>
  19124. The attr subType must be multisensor.01. This is done if the device was
  19125. created by autocreate. To control the device, it must be bidirectional paired,
  19126. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19127. </li>
  19128. <br><br>
  19129. <li>Room Control Panels (D2-10-00 - D2-10-02)<br>
  19130. [Kieback & Peter RBW322-FTL]<br>
  19131. <ul>
  19132. <li>T: t/&#176C H: -|rH/% F: 0 ... 100/% SPT: t/&#176C O: -|absent|present M: -|on|off</li>
  19133. <li>battery: ok|low|empty|-</li>
  19134. <li>cooling: auto|on|off|-</li>
  19135. <li>customWarning[1|2]: on|off</li>
  19136. <li>fanSpeed: 0 ... 100/%</li>
  19137. <li>fanSpeedMode: central|local</li>
  19138. <li>heating: auto|on|off|-</li>
  19139. <li>humidity: -|rH/%</li>
  19140. <li>moldWarning: on|off</li>
  19141. <li>motion: on|off|-</li>
  19142. <li>occupancy: -|absent|present</li>
  19143. <li>roomCtrlMode: buildingProtection|comfort|economy|preComfort</li>
  19144. <li>setpointBuildingProtectionTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19145. <li>setpointComfortTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19146. <li>setpointEconomyTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19147. <li>setpointPreComfortTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19148. <li>setpointTemp: t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19149. <li>solarPowered: yes|no</li>
  19150. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  19151. <li>window: closed|open</li>
  19152. <li>state: T: t/&#176C H: -|rH/% F: 0 ... 100/% SPT: t/&#176C O: -|absent|present M: -|on|off</li>
  19153. </ul><br>
  19154. The attr subType must be roomCtrlPanel.00. This is done if the device was
  19155. created by autocreate. To control the device, it must be bidirectional paired,
  19156. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19157. </li>
  19158. <br><br>
  19159. <li>Room Control Panels (D2-11-01 - D2-11-08)<br>
  19160. [Thermokon EasySens SR06 LCD-2T/-2T rh -4T/-4T rh]<br>
  19161. <ul>
  19162. <li>T: t/&#176C H: rH/% SPT: t/&#176C F: auto|off|1|2|3</li>
  19163. <li>cooling: on|off</li>
  19164. <li>fanSpeed: auto|off|1|2|3</li>
  19165. <li>heating: on|off</li>
  19166. <li>humidity: rH/%</li>
  19167. <li>occupancy: occupied|unoccupied</li>
  19168. <li>setpointBase: t/&#176C (Range: t = 15 &#176C ... 30 &#176C)</li>
  19169. <li>setpointShift: t/K (Range: t = -10 K ... 10 K)</li>
  19170. <li>setpointShiftMax: t/K (Range: t = 0 K ... 10 K)</li>
  19171. <li>setpointTemp: t/&#176C (Range: t = 5 &#176C ... 40 &#176C)</li>
  19172. <li>setpointType: setpointTemp|setpointShift</li>
  19173. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  19174. <li>trigger: heartbeat|sensor|input</li>
  19175. <li>window: closed|open</li>
  19176. <li>state: T: t/&#176C H: rH/% SPT: t/&#176C F: auto|off|1|2|3</li>
  19177. </ul><br>
  19178. The attr subType must be roomCtrlPanel.01. This is done if the device was
  19179. created by autocreate. To control the device, it must be bidirectional paired by Smart Ack,
  19180. see <a href="#EnOcean_smartAck">SmartAck Learning</a>.
  19181. </li>
  19182. <br><br>
  19183. <li>Fan Control (D2-20-00 - D2-20-02)<br>
  19184. [Maico ECA x RC/RCH, ER 100 RC, untested]<br>
  19185. <ul>
  19186. <li>on|off|not_supported</li>
  19187. <li>fanSpeed: 0 ... 100/%</li>
  19188. <li>error: ok|air_filter|hardware|not_supported</li>
  19189. <li>humidity: rH/%|not_supported</li>
  19190. <li>humidityCtrl: disabled|enabled|not_supported</li>
  19191. <li>roomSize: 0...350/m<sup>2</sup>|max</li>
  19192. <li>roomSizeRef: unsed|not_used|not_supported</li>
  19193. <li>setpointTemp: t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19194. <li>teach: &lt;result of teach procedure&gt;</li>
  19195. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  19196. <li>state: on|off|not_supported</li>
  19197. </ul><br>
  19198. The attr subType must be fanCtrl.00. This is done if the device was
  19199. created by autocreate. To control the device, it must be bidirectional paired,
  19200. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19201. </li>
  19202. <br><br>
  19203. <li>AC Current Clamp (D2-32-00 - D2-32-02)<br>
  19204. [untested]<br>
  19205. <ul>
  19206. <li>I1: I/A I2: I/A I3: I/A</li>
  19207. <li>current1: I/A (Range: I = 0 A ... 4095 A)</li>
  19208. <li>current2: I/A (Range: I = 0 A ... 4095 A)</li>
  19209. <li>current3: I/A (Range: I = 0 A ... 4095 A)</li>
  19210. <li>teach: &lt;result of teach procedure&gt;</li>
  19211. <li>state: I1: I/A I2: I/A I3: I/A</li>
  19212. </ul><br>
  19213. The attr subType must be currentClamp.00|currentClamp.01|currentClamp.02. This is done if the device was
  19214. created by autocreate.
  19215. </li>
  19216. <br><br>
  19217. <li>LED Controller Status (EEP D2-40-00 - D2-40-01)<br>
  19218. [untested]<br>
  19219. <ul>
  19220. <li>on|off</li>
  19221. <li>blue: 0 % ... 100 %</li>
  19222. <li>daylightHarvesting: on|off</li>
  19223. <li>demandResp: on|off</li>
  19224. <li>dim: 0 % ... 100 %</li>
  19225. <li>green: 0 % ... 100 %</li>
  19226. <li>occupany: unoccupied|occupied|unknown</li>
  19227. <li>powerSwitch: on|off</li>
  19228. <li>red: 0 % ... 100 %</li>
  19229. <li>rgb: RRGGBB (red (R), green (G) or blue (B) color component values: 00 ... FF)</li>
  19230. <li>teach: &lt;result of teach procedure&gt;</li>
  19231. <li>telegramType: event|heartbeat</li>
  19232. <li>state: on|off</li>
  19233. </ul><br>
  19234. The attr subType must be ledCtrlState.00|ledCtrlState.01 This is done if the device was
  19235. created by autocreate.
  19236. </li>
  19237. <br><br>
  19238. <li>Heat Recovery Ventilation (D2-50-00 - D2-50-11)<br>
  19239. [untested]<br>
  19240. <ul>
  19241. <li>off|1...4|auto|demand|supplyAir|exhaustAir</li>
  19242. <li>airQualidity1: 1/%</li>
  19243. <li>airQualidity2: 1/%</li>
  19244. <li>airQualidityThreshold: default|1/%</li>
  19245. <li>CO2Threshold: default|1/%</li>
  19246. <li>coolingProtection: on|off</li>
  19247. <li>defrost: on|off</li>
  19248. <li>deviceMode: master|slave</li>
  19249. <li>drainHeater: on|off</li>
  19250. <li>exhaustAirFlap: closed|opend</li>
  19251. <li>exhaustAirFlow: h/m3 (Sensor Range: Q = 0 m3/h ... 1023 m3/h)</li>
  19252. <li>exhaustFanSpeed: min (Sensor Range: n = 0 / min ... 4095 / min)</li>
  19253. <li>exhaustTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19254. <li>fault: bbbbbbbb bbbbbbbb bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19255. <li>filterMaintenance: required|not_required</li>
  19256. <li>fireplaceSafetyMode: disabled|enabled</li>
  19257. <li>heatExchangerBypass: closed|opend</li>
  19258. <li>humidityThreshold: default|rH/%</li>
  19259. <li>info: bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19260. <li>input: bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19261. <li>operationHours: [0 ... 589815]</li>
  19262. <li>output: bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19263. <li>outdoorAirHeater: on|off</li>
  19264. <li>outdoorTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19265. <li>roomTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19266. <li>roomTempCtrl: on|off</li>
  19267. <li>roomTempSet: default|t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19268. <li>supplyAirFlow: h/m3 (Sensor Range: Q = 0 m3/h ... 1023 m3/h)</li>
  19269. <li>supplyAirFlap: closed|opend</li>
  19270. <li>supplyAirHeater: on|off</li>
  19271. <li>supplyFanSpeed: min (Sensor Range: n = 0 / min ... 4095 / min)</li>
  19272. <li>supplyTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19273. <li>SWVersion: [0 ... 4095]</li>
  19274. <li>timerMode: on|off</li>
  19275. <li>weeklyTimer: on|off</li>
  19276. <li>state: off|1...4|auto|demand|supplyAir|exhaustAir</li>
  19277. </ul><br>
  19278. The attr subType must be heatRecovery.00. This is done if the device was
  19279. created by autocreate. To control the device, it must be bidirectional paired,
  19280. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19281. </li>
  19282. <br><br>
  19283. <li>Valve Control (EEP D2-A0-01)<br>
  19284. <ul>
  19285. <li>opens</li>
  19286. <li>open</li>
  19287. <li>closes</li>
  19288. <li>closed</li>
  19289. <li>teach: &lt;result of teach procedure&gt;</li>
  19290. <li>state: opens|open|closes|closed|teachIn|teachOut</li>
  19291. </ul><br>
  19292. The attr subType must be valveCtrl.00. This is done if the device was
  19293. created by autocreate. To control the device, it must be bidirectional paired,
  19294. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19295. </li>
  19296. <br><br>
  19297. <li>Liquid Leakage Sensor (EEP D2-B0-51)<br>
  19298. [untested]<br>
  19299. <ul>
  19300. <li>dry</li>
  19301. <li>wet</li>
  19302. <li>state: dry|wet</li>
  19303. </ul><br>
  19304. The attr subType must be liquidLeakage.51. This is done if the device was
  19305. created by autocreate.
  19306. </li>
  19307. <br><br>
  19308. <li>Generic Profiles<br>
  19309. <ul>
  19310. <li>&lt;00...64&gt;-&lt;channel name&gt;: &lt;value&gt;</li>
  19311. <li>&lt;00...64&gt;-&lt;channel name&gt;Unit: &lt;value&gt;</li>
  19312. <li>&lt;00...64&gt;-&lt;channel name&gt;ValueType: value|setpointAbs|setpointRel</li>
  19313. <li>&lt;00...64&gt;-&lt;channel name&gt;ChannelType: teachIn|data|flag|enum</li>
  19314. <li>teach: &lt;result of teach procedure&gt;</li>
  19315. </ul><br>
  19316. The attr subType must be genericProfile. This is done if the device was
  19317. created by autocreate. If the profile in slave mode is operated, especially the channel
  19318. definition in the gpDef attributes must be entered manually.
  19319. </li>
  19320. <br><br>
  19321. <li>RAW Command<br>
  19322. <ul>
  19323. <li>RORG: 1BS|4BS|ENC|MCS|RPS|SEC|STE|UTE|VLD</li>
  19324. <li>dataSent: data (Range: 1 Byte hex ... 512 Byte hex)</li>
  19325. <li>statusSent: status (Range: 0x00 ... 0xFF)</li>
  19326. <li>state: RORG: rorg DATA: data STATUS: status ODATA: odata</li>
  19327. </ul><br>
  19328. With the help of this command data messages in hexadecimal format can be sent and received.
  19329. The telegram types (RORG) 1BS and RPS are always received protocol-specific.
  19330. For further information, see
  19331. <a href="http://www.enocean-alliance.org/eep/">EnOcean Equipment Profiles (EEP)</a>.
  19332. <br>
  19333. Set attr subType to raw manually.
  19334. </li>
  19335. <br><br>
  19336. <li>Light and Presence Sensor<br>
  19337. [Omnio Ratio eagle-PM101]<br>
  19338. <ul>
  19339. <li>on</li>
  19340. <li>off</li>
  19341. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx)</li>
  19342. <li>channel1: on|off<br>
  19343. Motion message in depending on the brightness threshold</li>
  19344. <li>channel2: on|off<br>
  19345. Motion message</li>
  19346. <li>motion: on|off<br>
  19347. Channel 2</li>
  19348. <li>state: on|off<br>
  19349. Channel 2</li>
  19350. </ul><br>
  19351. The sensor also sends switching commands (RORG F6) with the SenderID-1.<br>
  19352. Set attr subType to PM101 manually. Automatic teach-in is not possible,
  19353. since no EEP and manufacturer ID are sent.
  19354. </li>
  19355. <br><br>
  19356. <li>Radio Link Test<br>
  19357. <ul>
  19358. <li>standby|active|stopped</li>
  19359. <li>msgLost: msgLost/%</li>
  19360. <li>rssiMasterAvg: LP/dBm</li>
  19361. <li>state: standby|active|stopped<br></li>
  19362. </ul><br>
  19363. The attr subType must be readioLinkTest. This is done if the device was
  19364. created by autocreate or manually by <code>define &lt;name&gt; EnOcean A5-3F-00</code><br>.
  19365. </li>
  19366. </ul>
  19367. </ul>
  19368. =end html
  19369. =cut